#!/bin/sh
# demo_menu module -- a self-contained script demonstrating every popup
# row type sxbar supports, all declared from this one script's `menu`
# subcommand (see README, "Module-declared menus"):
# popup_info -- plain text, not clickable
# popup_image -- a picture (album art, an icon, etc.)
# popup_item -- a full-width button
# popup_set -- a draggable slider
# popup_buttons -- a row of N equal-width button segments
#
# Wire it up as a custom module and hover over it to see them all:
#
# custom : demo_menu : "~/.config/sxbar/scripts/demo_menu.sh" : 999
#
# The button/slider rows fire a desktop notification via demo_popup.sh
# (needs notify-send) so you can see them actually run without wiring up
# anything real yet -- copy whichever row types you want into your own
# module's script and point them at real commands instead.
#
# demo_menu.sh -> bar text
# demo_menu.sh image -> path to a local image file for the image row --
# picks whatever icon it can find on this system,
# empty if none (same "no output" convention as
# media.sh's `art` subcommand)
# demo_menu.sh menu -> popup definition, read once at startup
mode="${1:-text}"
self="$0"
dir=$(dirname "$self")
popup="$dir/demo_popup.sh"
case "$mode" in
menu)
echo 'popup : hover : buttons'
echo 'popup_info : "Just text -- click me, nothing happens"'
echo "popup_image : \"$self image\""
echo "popup_item : \"Say hello\" : \"$popup 'Hello!'\""
echo "popup_set : \"$popup\""
echo "popup_buttons : \"One\" : \"$popup 'One!'\" : \"Two\" : \"$popup 'Two!'\" : \"Three\" : \"$popup 'Three!'\""
;;
image)
for f in /usr/share/pixmaps/*.png /usr/share/icons/hicolor/48x48/apps/*.png; do
[ -f "$f" ] && { printf '%s' "$f"; break; }
done
;;
*)
echo "Demo"
;;
esac