configfiles/scripts/cmenu.sh

88 lines
2 KiB
Bash
Raw Normal View History

2015-05-29 21:08:06 +02:00
#!/bin/bash
DMENU="$(dirname $0)/dmenu.sh"
menu() {
echo $@ | tr ' ' '\n' | $DMENU
}
screenshot() {
cd ~/Screenshots
exec scrot $@ -e 'firefox $f'
}
sysctl() {
action=$1
service=$2
gksu -S -m "$action $service" systemctl $action $service
}
require-service() {
service=$1
systemctl is-active --quiet $service || sysctl start $service
}
case "$(menu timer screenshot wallpaper wicd ncmpcpp zomnet power)" in
timer)
exec urxvt -geometry 50x3 -e ~/.config/scripts/teatimer.sh
;;
screenshot)
case "$(menu all selective)" in
all)
screenshot
;;
selective)
screenshot -s
;;
esac
;;
wallpaper)
exec nitrogen ~/wallpapers
;;
wicd)
exec wicd-gtk
;;
ncmpcpp)
exec urxvt -e ncmpcpp
;;
zomnet)
case "$(menu start-stop uservm ncmpcpp deluge)" in
start-stop)
systemctl is-active zomnet > /dev/null
if [ "$?" -eq 0 ]; then
sysctl stop zomnet
else
sysctl start zomnet
fi
;;
uservm)
require-service zomnet
exec urxvt -e ssh user.vm.zom.bi
;;
ncmpcpp)
require-service zomnet
exec urxvt -e ncmpcpp -h user.vm.zom.bi
;;
deluge)
require-service zomnet
exec deluge-gtk
esac
;;
power)
case "$(menu hibernate suspend reboot poweroff)" in
hibernate)
systemctl hibernate
;;
suspend)
systemctl suspend
;;
reboot)
systemctl reboot
;;
poweroff)
systemctl poweroff
;;
esac
;;
esac