Date and Clock pipe menus for Openbox

Write tutorials for Linux Mint here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post read forum rules
Post Reply
revmacian
Level 5
Level 5
Posts: 548
Joined: Wed May 27, 2020 1:50 pm
Location: United States

Date and Clock pipe menus for Openbox

Post by revmacian »

I am running Openbox as my window manager inside the Mate desktop environment (Mint 20.2 Mate edition). Today I learned how to make a couple pipe menus; one for the date and another for the time. Below is my tutorial if anyone else is interested in doing this.

Step 1
Code for the Openbox root menu, add this code somewhere in your root menu:

Code: Select all

...menu stuff here...
  <separator label="Calendar and Clock"/>
  <menu id="date" label="Today's date" icon="/path/to/desired/icon" execute="sh /path/to/date-menu.sh" />
  <menu id="time" label="Current time" icon="/path/to/desired/icon" execute="sh /path/to/time-menu.sh" />
...menu stuff here...
You can find many nice icons in /usr/share/icons/Mint-Y

Step 2a
The date script. Save this code as a bash script named date-menu.sh and make it executable - I saved mine in ~/bin:

Code: Select all

#!/bin/sh
#
vardate=$(date +'%B %d, %Y')

cat << EOFMENU
<openbox_pipe_menu>
  <item label="$vardate" />
</openbox_pipe_menu>
EOFMENU

See man date for more output formats for the date.

Step 2b
The time script. Save this code as a bash script named time-menu.sh and make it executable - I saved mine in ~/bin:

Code: Select all

#!/bin/sh
#
vartime=$(date +'%l:%M %p')

cat << EOFMENU
<openbox_pipe_menu>
  <item label="$vartime" />
</openbox_pipe_menu>
EOFMENU

See man date for more output formats for the date.

Step 3
Restart, or Reconfigure, Openbox to see the new menu items. Now you have the date and time in the root menu - the scripts will run each time you hover the mouse cursor over the parent menu items (Today's date and Current time), respectively.

Documentation
If needed, the official Openbox menu documentation can be found here: http://openbox.org/wiki/Help:Menus

Screenshot
And, finally, a screenshot:
Attachments
cal-pipe-menu2.jpg
Give a man a fish and you'll feed him for a day. Teach a man to fish and you'll feed him for a lifetime.
US Navy, NEC HM8404
Post Reply

Return to “Tutorials”