-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·116 lines (96 loc) · 3.71 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·116 lines (96 loc) · 3.71 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env bash
set -e
case $1 in
-l)
MAIN_DIR=$PWD
;;
*)
REPONAME='Alt-for-ANSI'
MAIN_DIR="$(mktemp --directory "${TMPDIR:-/tmp}"'/'"$REPONAME"'-XXXXXXXXXXX')"
git clone --filter=blob:none https://github.com/Drazape/"$REPONAME".git "$MAIN_DIR"
;;
esac
MIDNIGHT_INSTALL_SCRIPT_DIR="$MAIN_DIR"/layouts/midnight/install
GRAPHENE_INSTALL_SCRIPT_DIR="$MAIN_DIR"/layouts/graphene/install
cd "$MAIN_DIR"/layouts
# Layouts
chmod +x {"$GRAPHENE_INSTALL_SCRIPT_DIR","$MIDNIGHT_INSTALL_SCRIPT_DIR"}/install.sh
cd "$GRAPHENE_INSTALL_SCRIPT_DIR"
sudo ./install.sh
cd "$MIDNIGHT_INSTALL_SCRIPT_DIR"
sudo ./install.sh
# Shift Preservation types
sudo mv "$MAIN_DIR"/types /usr/share/xkeyboard-config-2/types/alt-for-ansi && echo "Successfully wrote the new types"
COMPLETE_PATH="/usr/share/xkeyboard-config-2/types/complete"
INCLUDE_STATEMENT=' include "alt-for-ansi"'
if ! grep -q "$INCLUDE_STATEMENT" "$COMPLETE_PATH"; then
TMP_FILE=$(mktemp)
awk -v inc="$INCLUDE_STATEMENT" '/^};/ {print inc} {print}' "$COMPLETE_PATH" > "$TMP_FILE"
sudo tee "$COMPLETE_PATH" < "$TMP_FILE" > /dev/null
rm "$TMP_FILE"
echo "Successfully added include statement to $COMPLETE_PATH"
else
echo "Include statement already exists in $COMPLETE_PATH. No changes made."
fi
echo ''
echo 'Successfully installed!'
# Choose layout
echo 'Select a layout to activate:'
echo '1) Mid-Night'
echo '2) Graphene'
read -p 'Enter your choice (1 or 2): ' -n 1 -r choice
case $choice in
1)
if [ "$(localectl status | grep 'X11 Variant: ' | cut -f 5 -d ' ')" != "midnight" ]; then
localectl set-x11-keymap us pc105 midnight
sudo localectl set-x11-keymap us pc105 midnight
fi
# Set for Compositor
if [ "$XDG_CURRENT_DESKTOP" == "GNOME" ]; then
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us+midnight')]"
elif [ "$XDG_CURRENT_DESKTOP" == "KDE" ]; then
kwriteconfig6 --file kxkbrc --group Layout --key LayoutList us
kwriteconfig6 --file kxkbrc --group Layout --key VariantList midnight
dbus-send --session --type=signal --reply-timeout=100 --dest=org.kde.keyboard /Layouts org.kde.keyboard.reloadConfig
else
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
echo "You're running Wayland with a compositor other than GNOME or KDE"
echo "I don't know how to enable the layout for your compositor."
echo "You will need to manually enable it in your window manager."
exit 1
else
setxkbmap us -variant midnight
fi
fi
echo "Mid-Night layout activated."
;;
2)
if [ "$(localectl status | grep 'X11 Variant: ' | cut -f 5 -d ' ')" != "graphene" ]; then
localectl set-x11-keymap us pc105 graphene
sudo localectl set-x11-keymap us pc105 graphene
fi
# Set for Compositor
if [ "$XDG_CURRENT_DESKTOP" == "GNOME" ]; then
gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'us+graphene')]"
elif [ "$XDG_CURRENT_DESKTOP" == "KDE" ]; then
kwriteconfig6 --file kxkbrc --group Layout --key LayoutList us
kwriteconfig6 --file kxkbrc --group Layout --key VariantList graphene
dbus-send --session --type=signal --reply-timeout=100 --dest=org.kde.keyboard /Layouts org.kde.keyboard.reloadConfig
else
if [ "$XDG_SESSION_TYPE" == "wayland" ]; then
echo "You're running Wayland with a compositor other than GNOME or KDE"
echo "You will need to manually enable it in your window manager."
exit 1
else
setxkbmap us -variant graphene
fi
fi
echo "Graphene layout activated."
;;
*)
echo "Invalid choice. No layout activated"
;;
esac
# Clean up
echo ''
rm -rf "$MAIN_DIR"