Add language toggle between SE and US in Sway, additionally, set Ghostty to the default terminal.

This commit is contained in:
Martin Larsson 2025-01-07 23:49:17 +01:00
parent 060aa3fed8
commit f0f10ab09b
2 changed files with 15 additions and 1 deletions

View file

@ -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:
#

View file

@ -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