diff --git a/copy.sh b/copy.sh index 0384bde..21904a8 100644 --- a/copy.sh +++ b/copy.sh @@ -124,6 +124,21 @@ fi printf "\n%.0s" {1..1} +# Function to detect keyboard layout using localectl or setxkbmap +detect_layout() { + if command -v localectl >/dev/null 2>&1; then + layout=$(localectl status --no-pager | awk '/X11 Layout/ {print $3}') + if [ -n "$layout" ]; then + echo "$layout" + fi + elif command -v setxkbmap >/dev/null 2>&1; then + layout=$(setxkbmap -query | grep layout | awk '{print $2}') + if [ -n "$layout" ]; then + echo "$layout" + fi + fi +} + # detect the current keyboard layout layout=$(detect_layout)