my dotfiles for arch
at main 1.3 kB view raw
1#!/bin/bash 2 3XKB_FILE="/usr/share/X11/xkb/symbols/us" 4BACKUP_FILE="${XKB_FILE}.backup.$(date +%s)" 5 6echo "Creating backup at $BACKUP_FILE..." 7sudo cp "$XKB_FILE" "$BACKUP_FILE" 8if [ $? -ne 0 ]; then 9 echo "Backup failed." 10 exit 1 11fi 12 13echo "Modifying intl section to map acute+c to cedilla..." 14 15# Create a temp file with the fix 16TEMP_FILE=$(mktemp) 17 18# Extract intl section, modify it, then rebuild the file 19sudo bash << 'SCRIPT' 20XKB_FILE="/usr/share/X11/xkb/symbols/us" 21TEMP_FILE=$(mktemp) 22 23# Replace acute+c mapping with cedilla in the intl section 24sed '/xkb_symbols "intl"/,/^}/ { 25 s/ccedil, Ccedil/ccedil, Ccedil/g 26 s/\[ acute,/[ dead_acute,/g 27}' "$XKB_FILE" > "$TEMP_FILE.new" 28 29# If sed found the pattern, use it; otherwise, manually add cedilla to acute deadkey 30if grep -q "dead_acute" "$TEMP_FILE.new"; then 31 mv "$TEMP_FILE.new" "$XKB_FILE" 32else 33 # Fallback: inject cedilla mapping after the intl section starts 34 sed '/xkb_symbols "intl"/a\ // Map apostrophe+c to cedilla\n key <AC02> { [ c, C, ccedil, Ccedil ] };' "$BACKUP_FILE" > "$XKB_FILE" 35fi 36 37rm -f "$TEMP_FILE" "$TEMP_FILE.new" 38SCRIPT 39 40echo "Clearing XKB cache..." 41rm -rf ~/.cache/xkb 2>/dev/null 42 43echo "Reloading Niri..." 44niri msg action quit 45 46echo "Done. Log back in."