From b319fb07f017e172b3ce8f13965f410debe6e5e4 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Mon, 28 Jul 2025 10:45:44 +0100 Subject: [PATCH] Add toggle keyboard script --- .config/i3/config | 5 +---- scripts/system/toggle-keyboard.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) create mode 100755 scripts/system/toggle-keyboard.sh diff --git a/.config/i3/config b/.config/i3/config index 02ed682..f93e916 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -74,6 +74,7 @@ bindsym $mod+u exec --no-startup-id autorandr -c bindsym $mod+Shift+f exec --no-startup-id firefox --private-window bindsym $mod+Shift+z exec --no-startup-id i3lock --color 000000 bindsym $mod+F12 exec --no-startup-id dunstctl history-pop +bindsym $mod+F1 exec --no-startup-id "sh /home/vylpes/scripts/system/toggle-keyboard.sh" # ===== # start a terminal @@ -187,10 +188,6 @@ bindsym $mod+Shift+8 move container to workspace number $ws8 bindsym $mod+Shift+9 move container to workspace number $ws9 bindsym $mod+Shift+0 move container to workspace number $ws10 -# keyboard layouts -bindsym $mod+F1 exec --no-startup-id setxkbmap -layout us -bindsym $mod+F2 exec --no-startup-id setxkbmap -layout gb - # reload the configuration file bindsym $mod+Mod1+r reload # restart i3 inplace (preserves your layout/session, can be used to upgrade i3) diff --git a/scripts/system/toggle-keyboard.sh b/scripts/system/toggle-keyboard.sh new file mode 100755 index 0000000..6856ade --- /dev/null +++ b/scripts/system/toggle-keyboard.sh @@ -0,0 +1,13 @@ +layout=$(setxkbmap -query | awk '/layout/{print $2}') +new=$layout + +if [ $layout = "us" ]; +then + setxkbmap -layout gb; + new="gb"; +else + setxkbmap -layout us; + new="us"; +fi + +echo "Keyboard layout changed from $layout to $new"