working on copy script

This commit is contained in:
shynd 2025-02-20 21:03:20 +01:00
parent 4406c93ac2
commit a5973792c5
1 changed files with 15 additions and 0 deletions

15
copy.sh
View File

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