Work on desktop setup

This commit is contained in:
2025-11-28 16:32:55 -08:00
parent 69654a19b9
commit ba65e597ec
2 changed files with 45 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#!/usr/bin/env zsh #!/usr/bin/env zsh
"${HOME}/scripts/set-initial-kanshi-state"
acpi_listen | while read event; do acpi_listen | while read event; do
let num_outputs="$(wlr-randr --json | jq 'length')" let num_outputs="$(wlr-randr --json | jq 'length')"
if ((num_outputs <= 1)); then if ((num_outputs <= 1)); then

43
set-initial-kanshi-state Executable file
View File

@ -0,0 +1,43 @@
#!/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
let i=0
while ! [[ -S /run/user/1000/fr.emersion.kanshi.wayland-1 ]]; do
if (( i >= 20 )); then
printf '\nFailed to connect to socket!\n' 1>&2
exit 1
fi
i+=1
printf '.' 1>&2
sleep 0.1
done
printf '\n' 1>&2
fi
get_current_profile() {
kanshictl status | jq -er '.current_profile'
}
let i=0
while ! get_current_profile >/dev/null; do
if (( i >= 5 )); then
break
fi
sleep 0.1
done
local current_profile="$(get_current_profile)"
local current_state="$(</proc/acpi/button/lid/LID0/state)"
if [[ "${current_profile}" = *open* ]] &&
[[ "${current_state}" != *open* ]]; then
kanshictl switch docked-closed
elif [[ "${current_profile}" = *closed* ]] &&
[[ "${current_state}" != *closed* ]]; then
kanshictl switch docked-open
fi