configfiles/scripts/cmenu.sh

106 lines
2.4 KiB
Bash
Raw Normal View History

2015-05-29 21:08:06 +02:00
#!/bin/bash
cd $(dirname $0)
DMENU="./dmenu.sh"
2015-05-29 21:08:06 +02:00
menu() {
echo $@ | tr ' ' '\n' | $DMENU
}
screenshot() {
cd ~/Screenshots
exec scrot $@ -e 'firefox $f'
}
sysctl() {
action=$1
service=$2
2015-07-22 15:18:04 +02:00
gksu -S -m "$action $service" systemctl $action $service
2015-05-29 21:08:06 +02:00
}
require-service() {
service=$1
systemctl is-active --quiet $service || sysctl start $service
}
2015-09-07 07:03:31 +02:00
case "$(menu update timer cpu screenshot wallpaper wicd ncmpcpp ssh zomnet power)" in
update)
exec urxvt -e bash -c "yaourt -Syua"
;;
2015-05-29 21:08:06 +02:00
timer)
exec urxvt -geometry 50x3 -e ~/.config/scripts/teatimer.sh
;;
2015-09-02 15:11:49 +02:00
cpu)
choice=$(menu performance powersave)
case $choice in
performance|powersave)
exec gksu -S -m "Setting cpu to $choice" "cpupower frequency-set -g $choice"
esac
;;
2015-05-29 21:08:06 +02:00
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
;;
2015-05-29 21:08:06 +02:00
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