4

I want to deploy a "Did you know..." or "Tip of the day" application at the office. It should:

  • Show a dialog at login time with a random tip.
  • Obviously, provide some way to store my own tips.
  • Be easy to disable and reenable by the user itself.

I'm using puppet, so I'm covered with the deployment. The tips don't even need to be gathered from a server, since I can deploy the newest tips file/database with no costs.

Sure, I could hack a quick solution by using zenity and bash, but I'd like to know if there's any application out there specifically targeted at this.

I don't like the zenity approach very much because it's very limited on the contents that can be displayed. No text alongside screenshots, for example. Zenity is aimed towards displaying simple dialogs.

5
  • 1
    You could use yelp to display your tips if you're willing to write them in xml or html.
    – user55822
    Dec 9, 2012 at 10:16
  • I like this approach. I can write this script, but I how can I put my custom xml or html into yelp? Jan 10, 2013 at 23:26
  • 1
    Check out yad, a fork of Zenity with many improvements.
    – dixoncx
    Jan 16, 2013 at 7:57
  • You can pass a file as an argument to yelp. Jan 20, 2013 at 22:51
  • As for yad, thanks, it has more options than zenity, but it's still very limited on hwo to position the images, and only displays pango markup text. As for yelp, what kind of files does it take? I tried passing some HTML files, and it just open them on a Chromium browser. Jan 21, 2013 at 0:38

2 Answers 2

6

This sounds a lot like a graphical interface to fortune with a custom fortunes database.

Creating the Custom Fortunes Database

  1. Create a text file containing all of the tips you want to display. Each tip should be on its own line, and there should be line containing only the % character after every tip.
  2. Run strfile -c % tips tips.dat to produce a file suitable for use with fortune

Installing fortune and the Tips

  1. Run sudo apt-get install fortune-mod to get the fortune program.
  2. Now place tips and tips.dat in /usr/share/games/fortunes. If there are other files already there, those fortunes will display intermixed with your tips; you may wish to remove them.

Graphical Interface

There are unfortunately not many options for graphically displaying fortunes. You can either install xcowsay, which is in the normal repositories, or install the Wanda the Fish indicator applet from its PPA: https://launchpad.net/~dylanmccall/+archive/indicator-fish. Both of these can be configured to start when a user logs in. I believe only xcowsay can display images, however.

Neither of these programs are particularly professional looking, as xcowsay has a talking cow and indicator-fish a cartoon fish accompanying each fortune. If that is a concern for you, you'll likely be better off writing your own graphical wrapper for fortune.

1
  • Thanks, but the graphical interface part turns me down completely :( Jan 10, 2013 at 23:24
0

I ended up hacking a quick solution with Python using Python-webkit. This solution displays HTML files

#!/usr/bin/env python

import gtk,webkit,os
from random import choice

win = gtk.Window()
win.connect("destroy", lambda w: gtk.main_quit())

scroller = gtk.ScrolledWindow()
win.add(scroller)

web = webkit.WebView()
scroller.add(web)

banners = ["banner1","banner2","banner3"]
banner = choice(banners)

web.load_uri("file:///usr/local/lib/tips/"+banner+".html")

win.resize(640,400)
win.show_all()
gtk.main()

Place the corresponding banners on /usr/local/lib/tips/, for example, the banner1.html is a simple image:

<html><head><style>*,html,body{margin:0;padding:0;}</style></head><body></body><img src='banner1.png' /></html>

If you reference resources (images, css, js...), place them also in /usr/local/lib/tips/.

Then, run this python script at session start, by creating a desktop file on /etc/xdg/autostart.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .