#!/usr/bin/env bash # ABOUTME: Rofi-based session menu with horizontal icon layout. # ABOUTME: Replaces wlogout — provides lock, logout, suspend, hibernate, reboot, shutdown. declare -A actions declare -a order order=("lock" "logout" "suspend" "hibernate" "reboot" "shutdown") actions[lock]="gtklock" actions[logout]="niri msg action quit" actions[suspend]="systemctl suspend" actions[hibernate]="systemctl hibernate" actions[reboot]="systemctl reboot" actions[shutdown]="systemctl poweroff" # GTK icon theme names declare -A icons icons[lock]="system-lock-screen" icons[logout]="system-log-out" icons[suspend]="system-suspend" icons[hibernate]="system-suspend-hibernate" icons[reboot]="system-reboot" icons[shutdown]="system-shutdown" # Build menu — use rofi icon protocol menu="" for key in "${order[@]}"; do [[ -n "$menu" ]] && menu+="\n" menu+="${key}\x00icon\x1f${icons[$key]}" done selected=$(echo -e "$menu" | rofi -dmenu \ -theme /etc/xdg/rofi/themes/session.rasi \ -show-icons \ -p "") [[ -z "$selected" ]] && exit 0 # Execute the selected action if [[ -n "${actions[$selected]+x}" ]]; then eval "${actions[$selected]}" fi