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