date-menu.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. #!/usr/bin/env bash
  2. # The script base is taken from http://openbox.org/wiki/Openbox:Pipemenus
  3. # This is in the public domain. Honestly, how can you claim anything to something
  4. # this simple?
  5. #
  6. # Outputs a simple openbox pipe menu to display the date, time, and calendar.
  7. # You need 'date' and 'cal'. You should have these. Additionally, the calendar
  8. # only appears properly formated if you use a mono spaced font.
  9. # Outputs the selected row from the calender output.
  10. # If you don't use a mono spaced font, you would have to play with spacing here.
  11. # It would probably involve a very complicated mess. Is there a way to force a
  12. # different font per menu?
  13. function calRow() {
  14. cal | gawk -v row=$1 '{ if (NR==row) { print $0 } }'
  15. }
  16. # WRITING TO PIPEMENU
  17. cat << EOFMENU
  18. <openbox_pipe_menu>
  19. <separator label="`date +%A\ %I\:%M\ %p`" />
  20. <item label="`date +%B\ %d,\ %Y`" />
  21. <separator />
  22. <item label="`calRow 2`" />
  23. <item label="`calRow 3`" />
  24. <item label="`calRow 4`" />
  25. <item label="`calRow 5`" />
  26. <item label="`calRow 6`" />
  27. <item label="`calRow 7`" />
  28. </openbox_pipe_menu>
  29. EOFMENU