river: Add output quick switch script

Invoked by `MOD+SHIFT+O` (for '[O]utput'), it greps the kanshi
configuration file for existing profiles and allows you to select one
which kanshi tries to apply. Can be a little buggy, though due to kanshi
and not the plugin (sometimes failing to re-activate turned off screens
etc).
This commit is contained in:
Marty Oehme 2025-06-09 14:19:57 +02:00
parent ff7863b011
commit d91bc46d75
Signed by: Marty
GPG key ID: 4E535BC19C61886E
3 changed files with 31 additions and 9 deletions

29
desktop/.local/bin/kanshiswitch Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env sh
if ! exist kanshictl; then
printf "Requires command 'kanshictl' on system."
exit 1
fi
picker=dmenu
if exist bemenu; then
picker=bemenu
elif exist wofi; then
picker=wofi
elif exist rofi; then
picker=rofi
fi
regex='s/profile \+\(.*\) \+{/\1/p'
list=$(sed -ne "$regex" "${XDG_CONFIG_HOME:-~/.config}/kanshi/config")
profile=$(printf "%s" "$list" | "$picker")
if [ -z "$profile" ]; then
return
else
kanshictl switch "$profile"
fi
if [ "$1" = '-v' ]; then
notify-send "Kanshi profile set" "Set to: $profile"
fi