dotfiles/bin/power

37 lines
670 B
Plaintext
Raw Permalink Normal View History

2022-08-12 12:13:54 +02:00
#!/bin/bash
COMMANDS="Lock\nToggle Screensaver\nExit\nSuspend\nHibernate\nShutdown\nReboot"
[ "$(cat /proc/1/comm)" = "systemd" ] && logind=systemctl || logind=loginctl
COMMAND=`echo -e $COMMANDS | dmenu -fn 'Noto Sans Mono:size=15' -i -p "Power:" "$@"`
echo $COMMAND
case $COMMAND in
Lock)
exec xautolock -locknow
;;
"Toggle Screensaver")
exec xautolock -toggle
;;
Suspend)
xautolock -locknow
exec $logind suspend
;;
Hibernate)
xautolock -locknow
exec $logind hibernate
;;
Exit)
#exec i3-msg exit
#killall dwm
kill $PPID
;;
Shutdown)
#exec systemctl poweroff
exec poweroff
;;
Reboot)
#exec systemctl reboot
exec reboot
;;
esac