Here's a small script I wrote for this purpose:
Code: Select all
#!/bin/bash
function fluxbox() {
local menu="$HOME/.fluxbox/menu"
echo -e "\t[exec] ("$1") {"$2"}" >> $menu
vim + $menu
}
function xfce() {
local menu="$HOME/.xfce4/menu.xml"
echo -e "\t<app name="\"""$1""\"" cmd="\"""$2""\""/>" >> $menu
vim + $menu
}
function openbox() {
local menu="$HOME/.config/openbox/menu.xml"
local w1=" "
local w2=" "
echo -e "$w1<item label="\"""$1""\"">\n$w2<action name=""\""Execute""\""><execute>"$2"</execute></action>\n$w1</item>" >> $menu
vim + $menu
}
[ "$#" = "3" ] || exit
case "$1" in
"fluxbox" ) fluxbox "$2" "$3";;
"xfce" ) xfce "$2" "$3";;
"openbox" ) openbox "$2" "$3";;
* ) exit;;
esac
The echo -e line in openbox() got wrapped, so remember to fix that if you're going to try the script.
Here's how to use it:
addentry.sh <wm> <name> <exec>
i.e. addentry.sh openbox epiphany epiphany
The script just echoes the entry to the end of the menufile, because I'm not able to figure out how to to echo it to the right place. (Is it even possible?) Instead, the script launches vim. Here's how to move the entry to the right place:
Place the cursor at the beginning of the new entry. press esc, and then type dd for flux/xfce, or 3dd for openbox. Move up to where you want the entry, and press p. If openbox, make sure the cursor is at a </item> tag. Then press Esc, and ZZ to save and exit. Alternatively, change the script so it reads gvim + etc instead of vim. This works great for me at least
Edit: Never mind about the line getting wrapped, it only happened in the preview.