awesome: launch custom commands from menu

The menu in the awesome wiki is a good one, yet it has some drawbacks:

1) It’s written in bash. Not all systems have bash. Not all systems have bash in /bin/bash.
2) The menu is stored inside the script itself, which makes it hard to edit.

My solution: write a menu file with choices:

% pwd
/usr/home/cy/.config/awesome
% cat menu
firefox
thunderbird
transmission
linuxdcpp
sunbird
eclipse

Add a command to .awesomerc, like this one:

key
{
modkey = {"Mod4"} key = "F2" command = "spawn"
arg = "cat /usr/home/cy/.config/awesome/menu | awesome-menu -e 'sh ~/bin/awesome-exec ' 'Execute:' &"
}

Finally, write ~/bin/awesome-exec (or elsewhere, if you fancy):

#!/bin/sh

case $1 in
        sunbird)
                exec linux-sunbird & ;;
        *)
                exec $1 & ;;
esac

As you can see, this solution is a lot more simple than the one in the awesome Wiki. Also, you can edit the menu easily, like this:

echo mutt >> ~/.config/awesome/menu // add
cat ~/.config/awesome/menu | grep -v mutt > ~/.config/awesome/menu //remove

I’m saying “easily”, because you can add these commands as an alias.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: