59 lines
1.5 KiB
Bash
Executable File
59 lines
1.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
lock() {
|
|
killall -SIGHUP gpg-agent
|
|
pactl set-sink-mute @DEFAULT_SINK@ true
|
|
playerctl --all-players pause
|
|
|
|
# needs i3lock-color
|
|
i3lock --ignore-empty-password --clock --indicator --show-failed-attempts \
|
|
--color=222222 \
|
|
--verif-color=eeeeeeee --wrong-color=eeeeeeee --modif-color=aaaaaa \
|
|
--time-color=eeeeeeee --date-color=cccccccc \
|
|
--ring-color=333333ff --line-uses-ring --inside-color=00000000 \
|
|
--insidewrong-color=00000000 --insidever-color=00000000 \
|
|
--date-str="%Y-%m-%d $(hostname)" \
|
|
--pass-media-keys $@
|
|
}
|
|
|
|
unsetDPMS() {
|
|
xset dpms 0 0 0
|
|
}
|
|
|
|
case "$1" in
|
|
lock)
|
|
trap "unsetDPMS" HUP INT TERM
|
|
# set dpms time to argument, or 0 if none given
|
|
xset +dpms dpms ${2-0} ${2-0} ${2-0}
|
|
lock ${2+"--nofork"}
|
|
unsetDPMS
|
|
;;
|
|
logout)
|
|
i3-msg exit
|
|
;;
|
|
suspend)
|
|
lock && systemctl suspend
|
|
;;
|
|
hibernate)
|
|
lock && systemctl hibernate
|
|
;;
|
|
reboot)
|
|
systemctl reboot
|
|
;;
|
|
"reboot to Windows")
|
|
sudo refind-next-boot 'Microsoft' && systemctl reboot
|
|
;;
|
|
shutdown)
|
|
systemctl poweroff
|
|
;;
|
|
pick)
|
|
$0 "$(echo -e 'lock\nlogout\nsuspend\nhibernate\nreboot\nreboot to Windows\nshutdown' | rofi -dmenu -i)"
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|reboot to Windows|shutdown|pick}"
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
exit 0
|