Work on desktop setup some more
This commit is contained in:
@ -1,11 +1,8 @@
|
||||
#!/usr/bin/zsh
|
||||
|
||||
let monitor_count="$(wlr-randr --json | jq 'length')"
|
||||
(( monitor_count <= 1 )) && exit
|
||||
|
||||
# Wait for the socket
|
||||
if ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; then
|
||||
printf 'Waiting for socket ' 1>&2
|
||||
printf 'Waiting for socket .' 1>&2
|
||||
let i=0
|
||||
while ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; do
|
||||
if (( i >= 20 )); then
|
||||
@ -13,25 +10,34 @@ if ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
i+=1
|
||||
printf '.' 1>&2
|
||||
sleep 0.1
|
||||
printf '.' 1>&2
|
||||
done
|
||||
printf '\n' 1>&2
|
||||
fi
|
||||
|
||||
get_current_profile() {
|
||||
kanshictl status | jq -er '.current_profile'
|
||||
local profile
|
||||
profile="$(kanshictl status | jq -er '.current_profile')"
|
||||
(( $? )) && return 1
|
||||
: ${(P)1::="${profile}"}
|
||||
}
|
||||
|
||||
local current_profile
|
||||
let i=0
|
||||
while ! get_current_profile >/dev/null; do
|
||||
while ! get_current_profile current_profile >/dev/null; do
|
||||
if (( i >= 5 )); then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
local current_profile="$(get_current_profile)"
|
||||
local monitor_count_str="$(wlr-randr --json | jq 'length')"
|
||||
[[ "${monitor_count_str}" =~ '[0-9]+' ]] || exit
|
||||
let monitor_count="${monitor_count_str}"
|
||||
(( monitor_count <= 1 )) && [[ "${current_profile}" != 'default' ]] \
|
||||
&& kanshictl switch default
|
||||
|
||||
local current_state="$(</proc/acpi/button/lid/LID0/state)"
|
||||
|
||||
if [[ "${current_profile}" = *open* ]] &&
|
||||
|
||||
Reference in New Issue
Block a user