Latest LQ Deal: Linux Power User Bundle
Go Back > Blogs > linux-related notes
User Name


Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
Rate this Entry

A clock as the header of Openbox' root menu

Posted 07-15-2014 at 04:15 PM by the dsc
Updated 07-16-2014 at 06:35 PM by the dsc (grammar?)

If you want a clock instead of the typical "openbox"-labeled separator at the top of the root menu. The way to do that isn't the most nice and convenient way imaginable, though. Essentially you have the root menu as a pipe menu.

The executed script is just a sed one liner:

 sed "s|INSERT-CLOCK-HERE|$(date +'%-H:%M')|" $HOME/.config/openbox/menu-sed.xml
This a "24 hour" clock format, without leading zeros, but can be changed "12 hour"format, or to some sort of display of time in time-yards and time-inches, if "date" does that.

Where this "menu-sed" would be essentially the "static" openbox root menu, a copy of menu.xml, only changed slightly to have the proper "headers" and "footers" or, more precisely, xml tags:

<?xml version="1.0" encoding="utf-8"?>
	  	  <separator label="INSERT-CLOCK-HERE"/>


And the actual menu.xml looks like:

<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="" xmlns:xsi="" xsi:schemaLocation="                 file:///usr/share/openbox/menu.xsd">
	<menu execute="" id="somepipemenu" label="some pipe menu"/>
	<menu execute="" id="otherpipemenu" label="other pipe menu"/>
	<menu execute="" id="root-menu" label="Openbox 3.5">

A subtly different alternative approach:

printf "<?xml version=\"1.0\" encoding=\"utf-8\"?><openbox_pipe_menu><separator label=\"$(date +'%-H:%M')\"/>" ; cat $HOME/.config/openbox/menu-body.xml
And the "body" file obviously hasn't the xml "header", neither the clock line. I think it gives obscenely humanly indistinguishably better results, specially if its a "#!/bin/sh" script.

That's all. I suggest to backup the original menu.xml if you're attempting to do that, and it's also handy to have a reachable/open-and-always-on-top terminal window, if something go wrong and suddenly you don't have any menu at all, so you can restore the backup or fix whatever and do "openbox --reconfigure" without logging out or rebooting, like only a log-outer or a rebooter would do.
Posted in Uncategorized
Views 1151 Comments 0
« Prev     Main     Next »
Total Comments 0




All times are GMT -5. The time now is 09:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration