moonarch/defaults/bin/moonarch-powermenu
nevaforget 5d2ce00455 Initial commit: Moonarch reproduzierbares Arch-Linux-Setup
Niri-basierter Wayland-Desktop mit greetd/regreet, Catppuccin Mocha
Theming, Rofi-Menus, Waybar und vollstaendiger Post-Install-Automatisierung.

Archinstall-Config klont das Repo automatisch via custom-commands,
danach genuegt ein einzelner Befehl fuer die komplette Einrichtung.
2026-03-23 17:42:26 +01:00

85 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# ABOUTME: Rofi-basiertes Power-Menü für Moonarch (Niri).
# ABOUTME: Bietet Shutdown, Reboot, Lock, Suspend und Logout.
# CMDs
uptime="`uptime -p | sed -e 's/up //g'`"
host="$USER@"`hostname`
# Options
shutdown='󰤆'
reboot=''
lock=''
suspend=''
logout='󰗽'
yes=''
no='󰆢'
# Rofi CMD
rofi_cmd() {
rofi -dmenu \
-p "$host uptime: $uptime" \
-mesg "$host uptime: $uptime" \
-theme /etc/xdg/rofi/powermenu/powermenu.rasi
}
# Confirmation CMD
confirm_cmd() {
rofi -dmenu \
-p 'Confirmation' \
-normal-window \
-mesg 'Confirm '${chosen} \
-theme /etc/xdg/rofi/powermenu/confirm.rasi
}
# Ask for confirmation
confirm_exit() {
echo -e "$yes\n$no" | confirm_cmd ${chosen}
}
# Pass variables to rofi dmenu
run_rofi() {
echo -e "$lock\n$suspend\n$logout\n$reboot\n$shutdown" | rofi_cmd
}
# Execute Command
run_cmd() {
selected="$(confirm_exit)"
if [[ "$selected" == "$yes" ]]; then
if [[ $1 == '--shutdown' ]]; then
systemctl poweroff
elif [[ $1 == '--reboot' ]]; then
systemctl reboot
elif [[ $1 == '--suspend' ]]; then
mpc -q pause
amixer set Master mute
systemctl suspend
elif [[ $1 == '--logout' ]]; then
niri msg action quit
fi
else
exit 0
fi
}
# Actions
chosen="$(run_rofi)"
case ${chosen} in
$shutdown)
run_cmd --shutdown
;;
$reboot)
run_cmd --reboot
;;
$lock)
killall rofi
wlogout -P 1 -s -r 10 -c 10
;;
$suspend)
run_cmd --suspend
;;
$logout)
run_cmd --logout
;;
esac