hdate for a GUI desktop

Boruch Baum

hdate for a desktop GUI

Here's a simple way to get your preferred hdate information quickly on your desktop in one keystroke, without opening a console terminal. This example is for the xfce desktop, but the technique is almost identical in gnome (v2 for sure), and the idea is the same for KDE and other environments:

  xfconf-query -c xfce4-keyboard-shortcuts -n -p /commands/custom/\<Super\>t -t string -s "notify-send \"$(hdate -q --hebrew)\" \"$(hdate -tq)\""

xfconf-query is the xfce tool to query and modify your personal xfce desktop configuration settings. The changes it makes are persistent, so there's no need to add the command to your .bashrc or other startup script. The above command asks xfce to create a key-binding for the "<Super>t" key (<Super> is that key, often to the left of the space bar, often with a MS windows logo on it). The command being bound to "<Super>t",

  notify-send \"$(hdate -q --hebrew)\" \"$(hdate -tq)\"

sends a pretty, GUI, themed notification containing hdate output to your GUI desktop whenever you press <Super>t.

If you want something a bit fancier, point xfconf-query to a custom script, containing something like:

notify-send \
  "$(hdate -q --hebrew | sed 's/.*,//')" \
  "$(hdate -tcq | awk -F, '\
                    NR==2 {print "        " $1 "\n" $2 "\n";FS=":"} \
                    /candle-lighting/ {print ""} \
                    NR>2  {print $2":"$3 "  " $1} \
                         ' )"

At this point, now that you've already written a script, you can further customize its output as you see fit.


1] notify-send takes two arguments. The first is for the notification title, and the second is for the notification text.
2] hcal output doesn't display properly using this method, because notify-send doesn't properly interpret the 'bold' and 'color' attributes that hcal sends to the terminal, and because notify-send usually isn't set up to display in a fixed with font, which hcal expects for column alignment.
3] backslashes in the notify-send arguments are necessary to prevent expansion by the shell.
4] the gnome version of xfconf-query is gconf-query.
5] GUI windows can be spawned usig commands such as zenity, yada, gtkdialog. See each's documentation for details.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks