sway-man-inhibit/README.md -rw-r--r-- 1.6 KiB
c398ff4a — Pierre-Albéric TROUPLIN init: add LICENSE, README and script 7 months ago

#Sway manual inhibit

  • Author: palb91
  • License: MIT
  • Description: Hacky script to inhibit idle manually, with a timeout
  • Dependancy: swayidle


I wanted a simple way to prevent manually the automatic session lock, but for a limited period, without having to rely on the current window or screen. Just don't lock for a period please, whatever I do. This lets me the time to prepare a tea, then watch my cats doing cat things… and going back to my laptop without having to unlock it.

#How to use this script?


usage: sway-man-inhibit [command]

    create  Set up the inhibitor.
    remove  Remove the inhibitor.
    toggle  Toggle inhibitor state.
    status  Show the current inhibitor status [default]

#binding in sway

bindsym $mod+l       exec sway-man-inhibit remove && loginctl lock-session
bindsym $mod+Shift+l exec sway-man-inhibit toggle

#Configure swayidle (${XDG_CONFIG_HOME}/swayidle/config)

The following configuration won't lock the session if there is the manual inhibitor, but will remove this inhibitor after 1800s.

timeout  180  'sway-inhibit || loginctl lock-session'
timeout  172  'sway-inhibit || swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"'
timeout 1800  'sway-inhibit remove && notify-send "swayidle" "enabled!"'
before-sleep  'loginctl lock-session'
lock          'swaylock'

#Add a flag in the bar

Check if the file $XDG_RUNTIME_DIR/inhibit.lock exists, if yes print a red open lock.

Status bar