summaryrefslogtreecommitdiff
path: root/usr/local/bin/sway-power
blob: 82088ad8f3d7b03e7bbd3562dc6eeffc3579b4be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh

_have() {
  command -v "$1"
}

PWR_OPTS=$(printf '%b' 'Lock\nReboot\nShutdown\nSuspend\nHibernate' | bemenu -l 5 -i -p 'Power menu:')

case "$PWR_OPTS" in
  Hibernate)
    systemctl hibernate
    ;;
  Lock)
    _have swaylock && swaylock --daemonize && swaymsg 'output * power off'
    ;;
  Reboot)
    systemctl reboot
    ;;
  Shutdown)
    systemctl poweroff
    ;;
  Suspend)
    systemctl suspend
    ;;
esac