Is there any way to set a greeting message in ubuntu?

I love a quote. Now I want every time my computer starts, the quote to be on the screen, like a welcome note.Is there any way to do that in ubuntu 13.04?


Solution 1:

You could pop up a simple zenity dialog on login with the content of your quote.

Put the following code into a script then add that script to your "Startup Applications"

zenity --info --text=$quote --title="A Quote"

Using fortune

Install the fortune-mod package (sudo apt-get install fortune-mod) then you can integrate the fortune command into your script like this:

zenity --info --text="$(fortune literature)" --title="A Quote" --no-wrap

You can just add that command to your Startup Applications without putting it in a script.

The literature option is used to specify that you want a quote specifically, otherwise it will give you jokes, riddles and other 'fortunes'.

Note: some of the fortunes are quite long, use --text="$(fortune -s literature)" instead of --text="$(fortune literature)" in the command above to print short quotes only.

Screenshot below: Fortunes in a dialog

Fortune also has many different options to customize the type of quotes you'll get (literature, riddles, etc.) See the fortune man page for more information. To use those options, just change fortune in the command above to fortune SOME_OPTION.

Credits to FreudianSlip for the fortune command

Solution 2:

If you want to fancy things up (like show a transparent quote on your wallpaper, type in some reminders etc...):

  1. Open terminal by pressing Ctrl+Alt+T
  2. Go to "Edit > Profiles > New".
  3. Give it a name (eg, "quote_of_the_day") and click Create.
  4. Click Edit, go to the colors tab and uncheck "use colors from ...".
  5. Select a text color which will be visible on your desktop wallpaper.
  6. Go to background tab and select Transparent Background and set it to None.
  7. Under Scrolling tab choose "Scrollbar is: Disabled".
  8. You can change font and size from general tab.
  9. Here you may also change columns and rows to about 50 and 5 respectively.
  10. Go to Title and Command and choose keep initial title from the combo box.

Now you've made a terminal profile for the quotes display. enter image description here

Next we will make a compiz setting to put it in our desktop background and remove those shadows and decorations.

  • Open Compiz Config by typing in terminal ccsm (assuming you have it installed)
  • Click Window Rules and do the following: enter image description here

  • Click Place Windows and do the following: enter image description here
  • Note: the 600 x and 100 y positions should be changed according to your screen resolution. (this puts it somewhere in the top right corner)
  • Go to Window Decoration and do the following: enter image description here



Now copy and paste the below script in to gedit and save it as quote_script.py

import commands
from time import sleep
import random

quotefile = "/home/user/Documents/.../quotes.txt"
interval = 10

with open(quotefile,'rb') as data: quotes = data.readlines()
print "\x1b[?25l"+random.choice(quotes)[:-1]
sleep(interval)
exit()

Change quotefile and interval to suit your file location and quote display time.
Go to startup applications by typing in terminal : gnome-session-properties. Add a new one by clicking add and type in:

  • Name:

    Daily Quotes

  • Command:

    gnome-terminal --window-with-profile=quote_of_the_day -e "python /home/user/Documents/.../quote_script.py"
    
  • Comment:

    Show random quotes at login


That's it! You may try logging out and in again to see the result.

Final Result:

enter image description here
- Experiment with terminal column and row values; Position values, interval, font colors etc. Remember to put quotes in quotes.txt file line by line.

Solution 3:

Let say that you have all your quotes in one file called quotes.txt (each quote on one line) saved somewhere, let say in ~/Documents. Then, using terminal you can do:

  1. Create a new file/script greeting.sh in your ~/bin directory:

    mkdir -p ~/bin #this command will make a bin directory in your home folder if you don't already have it
    gedit ~/bin/greetings.sh
    
  2. If you want to get a desktop notification, put next 2 lines inside:

    #!/bin/bash
    
    quotes="$HOME/Documents/quotes.txt"
    random_line=$(shuf -i 1-$(wc -l < $quotes) -n 1)
    quote=$(sed -n -e "$random_line"p $quotes)
    notify-send "Quote of the day" "$quote"
    

    Alternatively, if you want a popup (message box) to show up, use zenity instead notify-send:

    zenity --info --title  "Quote of the day" --text "$quote"
    
  3. Save the file and close it.

  4. Make the file exacutable:

    chmod +x ~/bin/greetings.sh
    
  5. Search in Dash for Startup Applications, open it and click Add.

  6. Under name type "Show my name and date" or something you will recognise.
  7. Under command type: /home/$USER/bin/greetings.sh (change $USER with your user name).
  8. Under comment (if you want), type a brief description.

Related: How do I show a message with username and date at login?