dotfiles/desktop/.local/bin/kanshiswitch
Marty Oehme d91bc46d75
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).
2025-06-09 14:38:15 +02:00

29 lines
561 B
Bash
Executable file

#!/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