Unix3r

Build. Break. Learn. Repeat.

Starting0%
Skip to content

unix3r/dotfiles

Public
main
U Unix3r Initial commit: sway + waybar dotfiles (Catppuccin Mocha) eb290df
30 lines · 983 B Raw History
1#!/usr/bin/env bash
2# powermenu.sh — wofi power menu (wlogout is used instead if you pass --wlogout)
3source "$(dirname "$0")/_lib.sh"
4
5if [[ $1 == --wlogout ]] && has wlogout; then
6 exec wlogout -b 5 -T 400 -B 400
7fi
8
9lock=$' Lock'
10logout=$' Log out'
11suspend=$' Suspend'
12hibernate=$' Hibernate'
13reboot=$' Reboot'
14shutdown=$' Shut down'
15
16choice=$(printf '%s\n' "$lock" "$suspend" "$logout" "$reboot" "$shutdown" "$hibernate" \
17 | menu "Power" --width 260 --height 290 --lines 6) || exit 0
18
19confirm() {
20 [[ $(printf 'No\nYes\n' | menu "$1?" --width 200 --height 130 --lines 2) == Yes ]]
21}
22
23case $choice in
24 "$lock") swaylock -f ;;
25 "$suspend") systemctl suspend ;; # swayidle locks before sleep
26 "$hibernate") confirm Hibernate && systemctl hibernate ;;
27 "$logout") confirm "Log out" && swaymsg exit ;;
28 "$reboot") confirm Reboot && systemctl reboot ;;
29 "$shutdown") confirm "Shut down" && systemctl poweroff ;;
30esac