Switch from way-displays to kanshi
This commit is contained in:
46
enable-displays-for-sleep
Executable file
46
enable-displays-for-sleep
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env zsh
|
||||
|
||||
let just_list=0
|
||||
local operation="--on"
|
||||
local jq_filter_neg="| not"
|
||||
local ignored=()
|
||||
|
||||
while getopts 'ldi:' name; do
|
||||
case "${name}" in
|
||||
h)
|
||||
echo 'enable-displays-for-sleep [-l] [-d] [-i]'
|
||||
echo '-d disable instead of enable'
|
||||
echo '-l print the list of display that would be changed'
|
||||
echo '-i ignore display'
|
||||
echo 'By default, enable displays.'
|
||||
;;
|
||||
l)
|
||||
just_list=1
|
||||
;;
|
||||
d)
|
||||
jq_filter_neg=""
|
||||
operation="--off"
|
||||
;;
|
||||
i)
|
||||
ignored+="${OPTARG}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
SCRIPT=".[] | select(.enabled${jq_filter_neg}) | .name"
|
||||
|
||||
set -e
|
||||
displays=("${(0)$(wlr-randr --json | jq --raw-output0 "${SCRIPT}")}")
|
||||
set +e
|
||||
|
||||
displays=(${displays:|ignored})
|
||||
|
||||
if ((just_list)); then
|
||||
printf '%s\0' ${displays}
|
||||
else
|
||||
flags=()
|
||||
for display in ${displays}; do
|
||||
flags+=(--output "${display}" "${operation}")
|
||||
done
|
||||
(( ${#flags} )) && wlr-randr ${flags}
|
||||
fi
|
Reference in New Issue
Block a user