New popup utility
March 09, 2014 —
BarryK
I have always wanted to write a "popup" text-message utility from scratch, in C or BaCon, that is very efficient and does all of the various things that I would like a popup utility to do.
In Puppy and Quirky we have some popups that use gtkdialog, but I have always considered this to be less-than-satisfactory -- for example, 'yaf-splash' (gtkdialog-splash) and 'pupmessage').
There are others of course, such as xmessage, gxmessage, Xdialog, yad, etc. (and of course gtkdialog), most of which can do a lot more than simple information-popup, but are not really optimal for simple message-popup.
So, I have written one, named 'popup', in BaCon. It is written with HUG, with some GTK function imports and some embedded C. It runs as a daemon, that is, as a separate process, and once started you can optionally send more controls (commands) and text to it -- not by stdin or whatever, but by writing to a file.
I had originally thought that 'popup' could watch the file for modifications using inotify, but soon decided that is not suitable, for various reasons. Now, the GTK timer function is used, called every 500 msec, which is also convenient as a "terminate=<number>" control can be sent to tell it to quit after so many seconds.
Anyway, showing how it works by example, here is an invocation:
# ./popup "name=bk1 background='#00ffff' placement=top-middle|This text allows Pango Text Attribute Markup Language, for example <b>bold</b>, <big>big</big>, <small>small</small>, <i>italic</i>, <tt>monospace</tt>"
Which looks like:
Then this:
# echo "background='#ff0000' level=top flash=on writemode=append-newline|Now the message is on top layer and flashing, to draw attention" >> /tmp/popup_bk1
The popup comes to top layer and background flashes:
Then to terminate it:
# echo "terminate=now|" >> /tmp/popup_bk1
To find out all that it can do, just type "./popup" and hit ENTER key, or "-h" or "--help" then ENTER.
I have uploaded the source code to the BaCon forum:
http://basic-converter.proboards.com/thread/641/popup-utility
I have placed popup into the Quirky build system, but it is a generic utility that will work in any Linux, including puppies.
Comments
queued messages"BarryK"Significant improvement, see post in BaCon forum:http://basic-converter.proboards.com/thread/641/popup-utility?page=1&scrollTo=5904
# ./popup "name=bk1 background='#ffff80' placement=top-middle width=-1 terminate=closebox|This text allows Pango Text Attribute Markup Language, for example <b>bold</b>, <big>big</big>, <small>small</small>, <i>italic</i>, <tt>monospace</tt>"
<
Which looks like this:
I have also added real-time count-up and count-down, in seconds or in "clock mode" (display minutes and seconds), by means of the "timecount" control. For example:
# ./popup "name=bk1 background='#ffff00' placement=top-middle width=-1|This text allows Pango Text Attribute Markup Language, for example <b>bold</b>, <big>big</big>, <small>small</small>, <i>italic</i>, <tt>monospace</tt>"
# echo "terminate=20 timecount=dn writemode=append-newline|Popup will terminate in <big><b><span color='#ff0000'>COUNT</span></b></big> seconds" >> /tmp/popup_bk1
<
Snapshot:
The latter works by substituting the text "COUNT" wherever it is in the message, into the time, and updates it every second.
I plan to add some more features, then I will post the source and binary. I will probably post the binary without needing that separate "hug.so" library, for the convenience of others who might want to use this utility.
# ./popup "name=bk1 background='#ffff00' placement=middle width=360 terminate=ok|This text allows Pango Text Attribute Markup Language, for example <b>bold</b>, <big>big</big>, <small>small</small>, <i>italic</i>, <tt>monospace</tt>"
<
When count-down finishes, count-up starts.
Also count-up and count-down should be able to have different colors.
That will allow me to see how long it has been since I missed the count-down.
http://bkhome.org/bacon/popup/
I added text-justification.
That's it, done, but might tweak a few things later.
This makes it Puppy specific! It would be nice if you could use a gtk widget.
I did try this once but it was bad, kept printing the label as well. A work around was to use the "X" char. Not pretty but worked.
Ok, the code now tests if the image exists, if not, uses an "X".
Also, there was a bug parsing the fontname.
Have re-uploaded code and binary.
Tags: linux