aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/sysact
blob: 5ea92face7b5af859f89d8d075f5d61be47568a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

export WM="Hyprland"
case "$(readlink -f /sbin/init)" in
    *systemd*) ctl='systemctl' ;;
    *) ctl='loginctl' ;;
esac

wmpid(){ # Get Hyprland process PID
    pgrep -o hyprland
}

case "$(printf " lock\n󰠚 leave $WM\n renew $WM\n󱣻 hibernate\n reboot\n shutdown\n sleep\n display off" | rofi -dmenu -i -l 15 -p 'Action: ')" in
    ' lock') hyprlock ;;
    "󰠚 leave $WM") kill -TERM "$(wmpid)" ;;
    " renew $WM") hyprctl reload ;;
    '󱣻 hibernate') $ctl hibernate -i ;;
    ' sleep') $ctl suspend -i ;;
    ' reboot') $ctl reboot -i ;;
    ' shutdown') $ctl poweroff -i ;;
    ' display off') hyprctl dispatch dpms off ;;
    *) exit 1 ;;
esac