LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > linux-related notes
User Name
Password

Notices


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:

Code:
 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:

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

[...]

</openbox_pipe_menu>
And the actual menu.xml looks like:

Code:
<?xml version="1.0" encoding="utf-8"?>
<openbox_menu xmlns="http://openbox.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://openbox.org/                 file:///usr/share/openbox/menu.xsd">
	<menu execute="some-pipe-menu.sh" id="somepipemenu" label="some pipe menu"/>
	<menu execute="some-other-pipe-menu.sh" id="otherpipemenu" label="other pipe menu"/>
	<menu execute="obclockmenu.sh" id="root-menu" label="Openbox 3.5">
</openbox_menu>

A subtly different alternative approach:

Code:
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 1850 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



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

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