(scripts) added sway-kb-layout-switcher using fuzzel to switch layout

This commit is contained in:
zegonix
2025-06-12 21:13:34 +02:00
parent 32540cd6f3
commit 3e29010433
2 changed files with 41 additions and 11 deletions

View File

@@ -0,0 +1,32 @@
#!/usr/bin/env bash
function switch_kb_layout {
layouts="$(echo -e "$(swaymsg -t get_config)" | grep -ioP "(?<=xkb_layout ).*$")"
layouts="${layouts//\"/}"
layouts="${layouts//\\/}"
IFS=","
layouts=(${layouts})
unset IFS
if [[ -z "${layouts[@]}" ]] || ((${#layouts[@]} <= 0)); then
return 1
fi
unset number
if ((${#layouts[@]} > 16)); then
number=16
else
number=${#layouts[@]}
fi
selection="$(printf "%s\n" "${layouts[@]}" | fuzzel --lines ${number} --dmenu)"
if [[ -z "${selection}" ]]; then
return 1
fi
swaymsg input type:keyboard xkb_layout "${selection}"
}
switch_kb_layout

View File

@@ -51,7 +51,7 @@ exec nm-applet
### configuring input ### configuring input
input type:keyboard { input type:keyboard {
xkb_layout "us,us(intl)" xkb_layout "us,us(intl),ch"
} }
input type:pointer accel_profile flat input type:pointer accel_profile flat
input type:pointer pointer_accel 0.53 input type:pointer pointer_accel 0.53
@@ -59,16 +59,13 @@ input type:pointer pointer_accel 0.53
### configuring keybindings ### configuring keybindings
# keymaps for i3 actions # reload the configuration file
## reload the i3 configuration file
bindsym $mod+Shift+c reload bindsym $mod+Shift+c reload
## restart i3 inplace (preserves your layout/session, can be used to upgrade i3) # restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart bindsym $mod+Shift+r restart
### exit i3 (logs you out of your X session) # lock screen
#bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
## lock screen
bindsym $mod+Escape exec systemctl suspend bindsym $mod+Escape exec systemctl suspend
## kill focused window # kill focused window
bindsym $mod+Shift+q kill bindsym $mod+Shift+q kill
# start programm launcher # start programm launcher
@@ -157,7 +154,8 @@ bindsym $mod+o move workspace to output up
bindsym $mod+p move workspace to output right bindsym $mod+p move workspace to output right
# switch keyboard layout # switch keyboard layout
bindsym $mod+Shift+n exec swaymsg input type:keyboard xkb_switch_layout next bindsym --locked $mod+Shift+n exec swaymsg input type:keyboard xkb_switch_layout next
bindsym --locked $mod+Shift+m exec bash sway-kb-layout-switcher.sh
## take screenshots ## take screenshots
#bindsym $mod+s exec maim -su | xclip -selection clipboard -t image/png #bindsym $mod+s exec maim -su | xclip -selection clipboard -t image/png
@@ -173,7 +171,7 @@ bindsym --locked XF86AudioPlay exec playerctl play-pause
bindsym --locked XF86AudioPrev exec playerctl previous bindsym --locked XF86AudioPrev exec playerctl previous
bindsym --locked XF86AudioNext exec playerctl next bindsym --locked XF86AudioNext exec playerctl next
bindsym --locked XF86AudioStop exec playerctl stop bindsym --locked XF86AudioStop exec playerctl stop
bindsym $mod+a exec bash select-audio-sink.sh bindsym $mod+a exec bash audio-sink-switcher.sh
### configuring behaviour ### configuring behaviour