From f0f10ab09b7bf8514c3653b21115457d6c76dac9 Mon Sep 17 00:00:00 2001 From: Martin Larsson Date: Tue, 7 Jan 2025 23:49:17 +0100 Subject: [PATCH] Add language toggle between SE and US in Sway, additionally, set Ghostty to the default terminal. --- linux_home/.config/sway/config | 6 +++++- linux_home/.config/sway/toggle_keyboard_layout.sh | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 linux_home/.config/sway/toggle_keyboard_layout.sh diff --git a/linux_home/.config/sway/config b/linux_home/.config/sway/config index 6f30ac4..ad16af8 100644 --- a/linux_home/.config/sway/config +++ b/linux_home/.config/sway/config @@ -3,6 +3,7 @@ include catppuccin_macchiato # Remap caps lock to escape input * { xkb_options "caps:escape" + xkb_layout us,se } input "type:touchpad" { @@ -23,7 +24,7 @@ input "type:touchpad" { # Logo key. Use Mod1 for Alt. set $mod Mod4 # Your preferred terminal emulator -set $term alacritty +set $term ghostty # Your preferred application launcher # Note: pass the final command to swaymsg so that the resulting window can be opened # on the original workspace that the command was run on. @@ -57,6 +58,9 @@ exec_always --no-startup-id ~/.config/sway/dim_inactive.windows.py # Exit sway (logs you out of your Wayland session) bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -B 'Yes, exit sway' 'swaymsg exit' + + # Switch the keyboard layout + bindsym $mod+Shift+l exec ~/.config/sway/toggle_keyboard_layout.sh # # Moving around: # diff --git a/linux_home/.config/sway/toggle_keyboard_layout.sh b/linux_home/.config/sway/toggle_keyboard_layout.sh new file mode 100755 index 0000000..58e79ac --- /dev/null +++ b/linux_home/.config/sway/toggle_keyboard_layout.sh @@ -0,0 +1,10 @@ +#!/bin/zsh + +# Toggle between US (0) and Swedish (1) layouts +current=$(swaymsg -t get_inputs | jq -r '.[] | select(.type=="keyboard") | .xkb_active_layout_index' | head -n 1) + +if [ "$current" -eq 0 ]; then + swaymsg input '*' xkb_switch_layout 1 +else + swaymsg input '*' xkb_switch_layout 0 +fi