configfiles/scripts/cmenu.sh

95 lines
2.1 KiB
Bash
Executable file

#!/bin/bash
cd $(dirname $0)
DMENU="./dmenu.sh"
menu() {
echo $@ | tr ' ' '\n' | $DMENU
}
screenshot() {
cd ~/Screenshots
exec scrot $@ -e 'firefox $f'
}
sysctl() {
action=$1
service=$2
gksu -w -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 ssh 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
;;
ssh)
host=$(menu `./ssh_hosts.sh`)
if [ -n "$host" ]; then
exec urxvt -e $HOME/.config/scripts/sshw.sh $host
fi
;;
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