@@ 1,21 @@
+MIT License
+
+Copyright (c) 2020 Pierre-Albéric TROUPLIN
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
@@ 1,59 @@
+# Sway manual inhibit
+
+- Author: **palb91**
+- License: **MIT**
+- Description: **Hacky script to inhibit idle manually, with a timeout**
+- Dependancy: [swayidle](https://github.com/swaywm/swayidle)
+
+---
+
+## Why?
+
+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
+
+```
+usage: sway-man-inhibit [command]
+
+commands:
+ create Set up the inhibitor.
+ remove Remove the inhibitor.
+ toggle Toggle inhibitor state.
+ status Show the current inhibitor status [default]
+```
+
+### binding in sway
+
+```sh
+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.
+
+```sh
+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.
+
+
@@ 1,15 @@
+#!/bin/sh
+#
+# Manage lock and manual inhibitor
+
+lock_file="${XDG_RUNTIME_DIR}/inhibit.lock"
+
+[ "${#}" -gt 0 ] || set -- status
+
+case "${1}" in
+ create) touch "${lock_file}" ;;
+ remove) rm -f "${lock_file}" ;;
+ toggle) rm "${lock_file}" 2>/dev/null || touch "${lock_file}" ;;
+ status) [ -e "${lock_file}" ] ;;
+ *) exit 33 ;;
+esac