Ubuntu / Linux news and application reviews.

WebUpd8 reader Reda El Khattabi has created a small tool that makes it very easy to create an Ubuntu AppIndicator for Zenity, YAD (a Zenity fork with many improvements) or basically any bash script or command.


Features:
  • supports submenus and separators
  • you can specify a custom icon
  • persistent mode or quit after executing command

For now the tool doesn't support specifying a timeout after which it should quit, but this feature might be added in the future.



Usage (examples)



The script takes input from stdin and when you select an entry, the whole path is printed to stdout. Here's working example that will create an AppIndicator for Y PPA Manager:

echo "Add
Advanced
List
Search
Settings" | ./cappind.py -p -i y-ppa-manager | while read s; do
case "$s" in
Add ) y-ppa-cmd add ;;
Advanced ) y-ppa-cmd advanced ;;
List ) y-ppa-cmd list ;;
Search ) y-ppa-cmd search ;;
Settings ) y-ppa-cmd settings ;;
esac
done

  • "-p" makes the indicator persistent and adds a quit menu item at the end - without it, the indicator quits after executing the select action.
  • "-i" specifies an icon from the current icon theme (don't use an exact path to an icon, it won't work. Just enter an icon name).

Here's another example, this time with submenus (just for the sake of this example) and a separator above the "Media" menu item that creates an AppIndicator for Nautilus (for opening Downloads, Music folders, etc.):

Bash appindicator

echo "Home Folder
Documents
Downloads
Pictures

Media:Music
Media:Videos" | ./cappind.py -p -i nautilus |  sed -u 's/Media://g' | while read s; do
case "$s" in
Home* ) nautilus ;;
Documents ) nautilus ~/Documents/ ;;
Downloads ) nautilus ~/Downloads/ ;;
Pictures ) nautilus ~/Pictures/ ;;
Music ) nautilus ~/Music/ ;;
Videos ) nautilus ~/Videos/ ;;
esac
done


More examples and download

Thanks to Réda for the tip!