Turns out, I'm kind of a Star Wars fan. My last vice are cartoons Star Wars: The Clone Wars, which I find very interesting and inspiring because they always include deep reflections. I especially like the phrases at the beginning of each chapter, and for that reason, it occurred to me that it might be a good idea for one of these phrases to appear when starting GNOME. That way, I would start my days with an inspiring phrase.
The thing is, that idea ended up in the following script, that all of you can use as I will teach next. The usefulness of this script far exceeds the reasons I wrote it. It can be used not only to display personalized "phrases of the day" but also to learn languages or anything else that requires the constancy involved in seeing a sign whenever you start the computer |
Installation
1.- Download the script.
2.- Unzip it in the folder you like the most, you HOME it may be a good place.
3.- The package consists of 4 files:
- quote.png: is the image to be shown together with the poster
- quote.txt: is the text file that contains the phrases from which the script will be fed. Keep in mind that each sentence must occupy one line. Each line has the same chances of being displayed.
- quote.py: is the python script that does all the "magic". Basically what it does is get lines randomly from the quote.txt file and display them in Notify OSD through DBus.
- quote.sh: is a bash script that waits a few seconds before executing the python script. The reasons for this script are explained later.
4.- In theory, everything should work perfectly adding the python script to the list of applications that run on startup. The problem is that, probably due to a bug in Notify OSD (and its compatibility with Compiz), if it is executed immediately when X starts, the poster appears with a horrible black background.
For this reason, you have to wait a few seconds after the system boots to run the script. I have tried to do it directly from the python script using time.sleep with very little success (who knows why… since when I run it alone -without restarting the X- it works perfectly).
The solution is that instead of adding the python script, let's add the bash script (quote.sh) to the list of applications that run on startup. To do this, I opened System> Preferences> Applications on startup.
Click the button Add and in Name i wrote Quote of the Day or whatever you prefer. Then in Medals, I wrote sh /path/where/is/el/script/quote.sh (in my case, it was sh /home/earendil/quote/quote.sh). In comment, add a comment that describes how the script works.
5.- Ready. Restart the X and see if everything works fine.
Some extra tweaks
1.- To change the time to wait before displaying the poster with the phrase, I opened the file quote.sh and modify the number of seconds after the command Sleep.
2.- To change how long the poster should be visible, I opened the file quote.py and look for the line that says set_timeout (10000). The number indicates the number of milliseconds; so, following the example, 10000 would be equal to 10 seconds.
I love the idea! 🙂 I would like to know how to make the notification go out with a certain periodicity with a new random item.
Too bad they are all in English. No "castle" has something interesting to say? 😉
The script already chooses random elements (they are lines taken from quote.txt). To make it run every X mins, you just have to add to the script as a cron job. On the blog, we published several articles on how to do it:
https://blog.desdelinux.net/cron-crontab-explicados/
http://usemoslinux.blogspot.com/2010/10/como-administrar-la-ejecucion-de-tareas.html
https://blog.desdelinux.net/como-administrar-las-tareas-programadas-en-gnome/
Cheers! Paul.
I personally would have used fortune to generate the phrases.
For not reinventing the wheel.
Yes ... when I wrote it I did not know that fortune existed. 🙂
Cheers! Paul.