-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmx-keys-fix.sh
executable file
·37 lines (26 loc) · 1.28 KB
/
mx-keys-fix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
file_path="/usr/share/X11/xkb/symbols/de"
temp_file="$file_path.temp"
patch_file="keyboard_layout.patch"
# Backup the original file
cp "$file_path" "$file_path.backup"
# Create a temporary modified copy of the original file
cp "$file_path" "$temp_file"
# Function to replace key definitions in the temporary file
replace_key_definitions() {
local key=$1
local original=$2
local replacement=$3
# Use sed to replace the original line with the replacement for the specific key
sed -i "/key <$key>/c $replacement" "$temp_file"
}
# Replace TLDE and LSGT key definitions
replace_key_definitions "TLDE" "key <TLDE> { [asciicircum, degree, notsign, notsign ] };" "key <TLDE> { [ less, greater, bar, dead_belowmacron ] };"
replace_key_definitions "LSGT" "key <LSGT> { [ less, greater, bar, dead_belowmacron ] };" "key <LSGT> { [asciicircum, degree, notsign, notsign ] };"
# Generate the patch file by diffing the original and modified files
diff -u "$file_path" "$temp_file" > "$patch_file"
# Apply the patch
patch "$file_path" < "$patch_file"
# Cleanup: Remove the temporary file
rm "$temp_file"
echo "Patch applied successfully. Original file backed up at $file_path.backup"