-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·60 lines (50 loc) · 1.96 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·60 lines (50 loc) · 1.96 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
# The path to the X keyboard configuration directory
xkb_path="/usr/share/X11/xkb"
# Check if the directory exists
if [[ ! -d ${xkb_path} ]] ; then
echo "Directory ${xkb_path} is not there, aborting. Check your xkeyboard-config installation."
exit
fi
# Check if the symbols/ce file already exists before copying
if [[ ! -f ${xkb_path}/symbols/ce ]] ; then
echo "Copying symbols/ce to ${xkb_path}/symbols/..."
cp symbols/ce ${xkb_path}/symbols/
echo "Copy complete."
else
echo "File ${xkb_path}/symbols/ce already exists. Skipping copy."
fi
# Function to check and insert content into XML files
insert_if_not_exists_xml() {
local file=$1
local content=$2
local marker=$3
if ! grep -q "${marker}" "${file}"; then
sed -i -e "/^.*<\/layoutList>/ {r ${content}" -e 'N}' "${file}"
echo "Updated ${file} with new layout."
else
echo "Marker ${marker} found in ${file}. Skipping update."
fi
}
# Function to check and insert content into LST files
insert_if_not_exists_lst() {
local file=$1
local content=$2
local marker=$3
if ! grep -q "${marker}" "${file}"; then
sed -i -e "/^.*A user-defined custom Layout/ {r ${content}" -e 'N}' "${file}"
echo "Updated ${file} with new entry."
else
echo "Marker ${marker} found in ${file}. Skipping update."
fi
}
# Define markers for checking
xml_marker="<name>ce</name>"
lst_marker="Chechen (Latin, QWERTY, US)"
# Insert content into XML files if not already present
insert_if_not_exists_xml "${xkb_path}/rules/evdev.xml" "rules/evdev.xml" "${xml_marker}"
insert_if_not_exists_xml "${xkb_path}/rules/base.xml" "rules/evdev.xml" "${xml_marker}"
# Insert content into LST files if not already present
insert_if_not_exists_lst "${xkb_path}/rules/evdev.lst" "rules/evdev.lst" "${lst_marker}"
insert_if_not_exists_lst "${xkb_path}/rules/base.lst" "rules/evdev.lst" "${lst_marker}"
echo "Reboot your system to apply the changes."