···232232# Manual lock
233233bindsym Control+Mod4+l exec $lock
234234235235+# Power menu (Lock/Logout/Suspend/Hibernate/Reboot/Shutdown).
236236+# A compact wofi list pinned to the bottom-right, also reachable from the ⏻
237237+# button on the Waybar tray end. Its Lock entry runs `loginctl lock-session`,
238238+# which the swayidle `lock` handler below turns into our themed $lock.
239239+bindsym $mod+Escape exec ~/.config/sway/power-menu.sh
240240+235241# Auto-lock + display power management.
236242# - lock after 5 min idle
237243# - blank the outputs after 10 min (and restore on activity)
238244# - always lock right before the system suspends, so it's locked on resume
245245+# - `lock` fires on `loginctl lock-session` (e.g. from wlogout) -> themed $lock
239246exec swayidle -w \
240247 timeout 300 '$lock' \
241248 timeout 600 'swaymsg "output * power off"' resume 'swaymsg "output * power on"' \
242242- before-sleep '$lock'
249249+ before-sleep '$lock' \
250250+ lock '$lock'
243251244252# resize window (you can also use the mouse for that)
245253mode "resize" {
+31
sway/power-menu.sh
···11+#!/usr/bin/env sh
22+# Compact power menu via wofi, anchored to the bottom-right next to the Waybar
33+# ⏻ button. Entries are ordered so the most-used actions (Logout/Lock) sit at
44+# the BOTTOM of the list, closest to the button you just clicked.
55+#
66+# Invoked by $mod+Escape (sway/config) and the custom/power Waybar module
77+# (waybar/config). Lock goes through `loginctl lock-session`, which swayidle's
88+# `lock` handler turns into the themed $lock (see sway/config).
99+#
1010+# --cache-file /dev/null keeps wofi from reordering entries by usage frequency,
1111+# so the deliberate ordering below is preserved.
1212+1313+chosen=$(printf '%s\n' \
1414+ Shutdown \
1515+ Reboot \
1616+ Hibernate \
1717+ Suspend \
1818+ Logout \
1919+ Lock \
2020+ | wofi --dmenu --prompt Power \
2121+ --location bottom_right --width 200 --lines 7 \
2222+ --cache-file /dev/null)
2323+2424+case "$chosen" in
2525+ Lock) loginctl lock-session ;;
2626+ Logout) swaymsg exit ;;
2727+ Suspend) systemctl suspend ;;
2828+ Hibernate) systemctl hibernate ;;
2929+ Reboot) systemctl reboot ;;
3030+ Shutdown) systemctl poweroff ;;
3131+esac
+11-1
waybar/config
···2121 "clock#dc",
2222 "clock#madrid",
2323 "clock#melbourne",
2424- "tray"
2424+ "tray",
2525+ "custom/power"
2526 ],
26272728 "sway/workspaces": {
···100101 "tray": {
101102 "icon-size": 18,
102103 "spacing": 8
104104+ },
105105+106106+ // Power button -> compact wofi power menu pinned bottom-right (the script
107107+ // sets Lock/Logout/Suspend/...). Same menu is bound to $mod+Escape in
108108+ // sway/config.
109109+ "custom/power": {
110110+ "format": "⏻",
111111+ "tooltip": false,
112112+ "on-click": "~/.config/sway/power-menu.sh"
103113 }
104114}