#!/bin/bash # Get current state of Caps Lock and Escape key swap current_state=$(setxkbmap -query | grep options | grep "caps:escape" | wc -l) # If the swap is off, turn it on; otherwise, turn it off if [ $current_state -eq 0 ]; then echo "Swapping Caps Lock and Escape..." setxkbmap -option caps:escape else echo "Reverting to normal layout..." setxkbmap -option fi