Update stuff for screen lock
This commit is contained in:
@ -5,7 +5,7 @@ local operation="--on"
|
|||||||
local jq_filter_neg="| not"
|
local jq_filter_neg="| not"
|
||||||
local ignored=()
|
local ignored=()
|
||||||
|
|
||||||
while getopts 'ldi:' name; do
|
while getopts 'hldi:' name; do
|
||||||
case "${name}" in
|
case "${name}" in
|
||||||
h)
|
h)
|
||||||
echo 'enable-displays-for-sleep [-l] [-d] [-i]'
|
echo 'enable-displays-for-sleep [-l] [-d] [-i]'
|
||||||
|
|||||||
17
laptop-lid-daemon
Executable file
17
laptop-lid-daemon
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
acpi_listen | while read event; do
|
||||||
|
let num_outputs="$(wlr-randr --json | jq 'length')"
|
||||||
|
if ((num_outputs <= 1)); then
|
||||||
|
kanshictl switch default
|
||||||
|
else
|
||||||
|
case "${event}" in
|
||||||
|
'button/lid LID open')
|
||||||
|
kanshictl switch docked-open
|
||||||
|
;;
|
||||||
|
'button/lid LID close')
|
||||||
|
kanshictl switch docked-closed
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done
|
||||||
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
LOCKFILE="${HOME}/.cache/swayidle-lock-screen.lock"
|
LOCKFILE="${HOME}/.cache/swayidle-lock-screen.lock"
|
||||||
|
ENABLE_DISPLAYS="${HOME}/scripts/enable-displays-for-sleep"
|
||||||
|
|
||||||
function has-rootful-xwayland-p {
|
function has-rootful-xwayland-p {
|
||||||
for pid in $(pgrep Xwayland); do
|
for pid in $(pgrep Xwayland); do
|
||||||
@ -21,18 +22,23 @@ function run {
|
|||||||
if [[ "${XDG_CURRENT_DESKTOP}" == 'river' ]] && has-rootful-xwayland-p; then
|
if [[ "${XDG_CURRENT_DESKTOP}" == 'river' ]] && has-rootful-xwayland-p; then
|
||||||
swaylock ${empty_flag} --color '#000000'
|
swaylock ${empty_flag} --color '#000000'
|
||||||
else
|
else
|
||||||
|
local swayidle_pid
|
||||||
|
if ((dont_sleep)); then
|
||||||
# get the list of currently disabled monitors so we don't touch them
|
# get the list of currently disabled monitors so we don't touch them
|
||||||
local ignored=("${(0)$(enable-displays-for-sleep -l)}")
|
local ignored=("${(0)$("${ENABLE_DISPLAYS}" -l)}")
|
||||||
local ignored_args=()
|
local ignored_args=()
|
||||||
for name in ${ignored}; do
|
for name in ${ignored}; do
|
||||||
# quote so it can be safely passed to swayidle
|
# quote so it can be safely passed to swayidle
|
||||||
ignored_args+=(-i "${(q)name}")
|
ignored_args+=(-i "${(q)name}")
|
||||||
done
|
done
|
||||||
|
|
||||||
swayidle -w -C /dev/null \
|
swayidle -w -C /dev/null \
|
||||||
timeout 15 "enable-displays-for-sleep -d ${ignored}" \
|
timeout 15 "${(q)ENABLE_DISPLAYS} -d ${ignored_args}" \
|
||||||
resume "enable-displays-for-sleep {$ignored}" &
|
resume "${(q)ENABLE_DISPLAYS} {$ignored_args}" &
|
||||||
local swayidle_pid="${!}"
|
swayidle_pid="${!}"
|
||||||
|
else
|
||||||
|
swayidle -w -C /dev/null timeout 15 "systemctl sleep" &
|
||||||
|
swayidle_pid="${!}"
|
||||||
|
fi
|
||||||
swaylock ${empty_flag} ${img_flags}
|
swaylock ${empty_flag} ${img_flags}
|
||||||
kill "${swayidle_pid}"
|
kill "${swayidle_pid}"
|
||||||
fi
|
fi
|
||||||
@ -52,6 +58,7 @@ local suspend_command=''
|
|||||||
local wake_command=''
|
local wake_command=''
|
||||||
local empty_flag=''
|
local empty_flag=''
|
||||||
local fix_eww=()
|
local fix_eww=()
|
||||||
|
let dont_sleep=0
|
||||||
while [[ "${1}" =~ '^-' ]]; do
|
while [[ "${1}" =~ '^-' ]]; do
|
||||||
case "${1}" in
|
case "${1}" in
|
||||||
--)
|
--)
|
||||||
@ -68,6 +75,9 @@ while [[ "${1}" =~ '^-' ]]; do
|
|||||||
-e)
|
-e)
|
||||||
empty_flag='-e'
|
empty_flag='-e'
|
||||||
;;
|
;;
|
||||||
|
-d)
|
||||||
|
dont_sleep=1
|
||||||
|
;;
|
||||||
-*)
|
-*)
|
||||||
printf "error: unknown flag '%s'\n" "${1}" >&2
|
printf "error: unknown flag '%s'\n" "${1}" >&2
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user