Here's a lightweight .sh script for Arch Linux with i3WM, designed to work with Rofi to let you choose between:
- Shutdown
- Reboot (Restart)
- Suspend (Sleep)
- Logout
📄 Script: powermenu.sh
Save this as:
~/.config/i3/scripts/powermenu.sh
#!/bin/sh
# Options
shutdown="Shutdown"
reboot="Reboot"
suspend="Suspend"
logout="Logout"
# Rofi prompt
chosen=$(echo "$shutdown\n$reboot\n$suspend\n$logout" | rofi -dmenu -i -p "Power")
# Handle choice
case $chosen in
$shutdown)
systemctl poweroff
;;
$reboot)
systemctl reboot
;;
$suspend)
mlock && systemctl suspend
;;
$logout)
i3-msg exit
;;
esac
✅ Replace mlock with your screen locker command if needed (e.g. betterlockscreen -l, slock, etc.) before suspend.
🔧 Make It Executable
Run this once:
chmod +x ~/.config/i3/scripts/powermenu.sh
⌨️ Bind It to a Key in i3
Add this to your i3 config (~/.config/i3/config or ~/.i3/config):
bindsym $mod+Shift+x exec ~/.config/i3/scripts/powermenu.sh
Now press Mod + Shift + x to open the power menu.
💡 Mod is typically the Windows key.
🧩 Optional: Use With drun or Launch Menu
If you prefer launching it from a launcher like Rofi's app launcher, just add an entry or run:
~/.config/i3/scripts/powermenu.sh
Let me know if you want:
- Icons in Rofi
- Confirmation dialog
- Hybernate option
- Custom styling for Rofi
✅ This setup is fast, minimal, and works great on Arch Linux with i3 and Rofi.