summaryrefslogtreecommitdiff
path: root/polybar/scripts/power-menu.sh
blob: ab5935279d3dbc6e39cfb08e7c3805207dd73f67 (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
26
27
28
29
30
31
32
33
#!/usr/bin/env bash
set -euo pipefail

export DISPLAY="${DISPLAY:-:0}"
if [ -z "${XAUTHORITY:-}" ] && [ -r "$HOME/.Xauthority" ]; then
  export XAUTHORITY="$HOME/.Xauthority"
fi

choice="$(
  printf '%s\n' lock logout suspend reboot shutdown |
    dmenu -i -p power \
      -fn "FiraCode Nerd Font-14" \
      -nb "#282828" -nf "#ebdbb2" \
      -sb "#d79921" -sf "#282828"
)"

case "$choice" in
  lock)
    i3lock
    ;;
  logout)
    i3-msg exit
    ;;
  suspend)
    loginctl suspend
    ;;
  reboot)
    loginctl reboot
    ;;
  shutdown)
    loginctl poweroff
    ;;
esac