configfiles/bspwm/.config/scripts/cmenu.sh
2015-10-08 10:31:53 +02:00

106 lines
2.4 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 -S -m "$action $service" systemctl $action $service
}
require-service() {
service=$1
systemctl is-active --quiet $service || sysctl start $service
}
case "$(menu update timer cpu screenshot wallpaper wicd ncmpcpp ssh zomnet power)" in
update)
exec urxvt -e bash -c "yaourt -Syua"
;;
timer)
exec urxvt -geometry 50x3 -e ~/.config/scripts/teatimer.sh
;;
cpu)
choice=$(menu performance powersave)
case $choice in
performance|powersave)
exec gksu -S -m "Setting cpu to $choice" "cpupower frequency-set -g $choice"
esac
;;
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