forked from petrstepanov/gnome-macos-remap-wayland
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·167 lines (134 loc) · 6.72 KB
/
install.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/bash
# Create temporary install directory
BASE_DIR=`pwd`
mkdir -p ~/Downloads && cd ~/Downloads
# Remove previously downloaded archives (if any)
rm -rf ./xremap*
# Detect architecture
ARCH=`uname -m`
echo "INFO: Detected ${ARCH} PC architecture."
# Exit if unsupported architecture
if [ "${ARCH}" != "x86_64" ] && [ "${ARCH}" != "aarch64" ]; then
echo "ERROR: Unsupported architecture. Please compile and install Xremap manually:"
echo " https://github.com/k0kubun/xremap"
exit 1
fi
# Detect compositor type (X11 or Wayland)
if [ "${XDG_SESSION_TYPE}" == "x11" ]; then
echo "INFO: Detected X11 compositor."
ARCHIVE_NAME="xremap-linux-${ARCH}-x11.zip"
elif [ "${XDG_SESSION_TYPE}" == "wayland" ]; then
echo "INFO: Detected Wayland compositor."
ARCHIVE_NAME="xremap-linux-${ARCH}-gnome.zip"
else
echo "ERROR: Unsupported compositor."
exit 1
fi
# Download latest release from GitHub
wget https://github.com/xremap/xremap/releases/latest/download/$ARCHIVE_NAME
# Extract the archive
echo "INFO: Extracting the archive..."
if ! command -v unzip &> /dev/null; then
echo "ERROR: Command \"unzip\" not found."
exit 0
fi
unzip -o ./xremap-linux-${ARCH}-*.zip
# Remove old binary (if any)
if command -v gnome-terminal &> /dev/null ; then
echo "INFO: Removing old binary..."
sudo rm -rf /usr/local/bin/xremap
fi
# Install new binary (if any)
echo "INFO: Installing the binary..."
sudo cp ./xremap /usr/local/bin
# Tweaking server access control for X11
# https://github.com/k0kubun/xremap#x11
if [ "${XDG_SESSION_TYPE}" == "x11" ]; then
xhost +SI:localuser:root
fi
# Copy Xremap config file with macOS bindings
CONFIG_DIR=~/.config/gnome-macos-remap/
echo "INFO: Copying the xremap config file..."
mkdir -p $CONFIG_DIR
cp $BASE_DIR/config.yml $CONFIG_DIR
# Copy systemd service file
SERVICE_DIR=~/.local/share/systemd/user/
echo "INFO: Installing systemd service..."
mkdir -p $SERVICE_DIR
cp $BASE_DIR/gnome-macos-remap.service $SERVICE_DIR
# Copy bash scripts
BIN_DIR=~/.local/bin/
echo "INFO: Copying bash scripts..."
mkdir -p $BIN_DIR
cp $BASE_DIR/bin/*.sh $BIN_DIR
# Run Xremap without sudo
# https://github.com/xremap/xremap?tab=readme-ov-file#running-xremap-without-sudo
sudo gpasswd -a ${USER} input
echo 'KERNEL=="uinput", GROUP="input", TAG+="uaccess"' | sudo tee /etc/udev/rules.d/input.rules
# Instantiate the service
systemctl --user daemon-reload
systemctl --user enable gnome-macos-remap
systemctl --user start gnome-macos-remap
# Tweak gsettings
echo "INFO: Tweaking GNOME and Mutter keybindings..."
# Ensure default system xkb-options are not turned on - may interfere
gsettings reset org.gnome.desktop.input-sources xkb-options
# Disable overview key ⌘ - interferes with ⌘ + ... combinations
gsettings set org.gnome.mutter overlay-key ''
# Minimize one window and all windows - conflicts with show hidden files in Nautilus
# gsettings set org.gnome.desktop.wm.keybindings minimize "['<Control>h']"
gsettings set org.gnome.desktop.wm.keybindings minimize "[]"
# Minimize all windows
gsettings set org.gnome.desktop.wm.keybindings show-desktop "['<Control>d']"
# Set switch applications to ⌘+TAB, switch application windows ⌘+`
gsettings set org.gnome.desktop.wm.keybindings switch-applications "['<Control>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "['<Shift><Control>Tab']"
gsettings set org.gnome.desktop.wm.keybindings switch-group "['<Control>grave']"
gsettings set org.gnome.desktop.wm.keybindings switch-group-backward "['<Shift><Control>grave']"
# ⌘ - Set default change input source shortcuts
gsettings reset org.gnome.desktop.wm.keybindings switch-input-source
gsettings reset org.gnome.desktop.wm.keybindings switch-input-source-backward
# Switch workspaces conflicts with default GNOME window left/right tiling
gsettings set org.gnome.mutter.keybindings toggle-tiled-left "[]"
gsettings set org.gnome.mutter.keybindings toggle-tiled-right "[]"
# Switch workspaces
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "['<Super>Left']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "['<Super>Right']"
# Paste in terminal (if set via Ctrl+V, not Shift+Ctrl+V) interferes with default GNOME show notification panel shortcut
gsettings set org.gnome.shell.keybindings toggle-message-tray "[]"
# Toggle overview (with mac's F3 key)
gsettings set org.gnome.shell.keybindings toggle-overview "['LaunchA']"
# Show all applications (with mac's F4 key and imitate spotlight)
gsettings set org.gnome.shell.keybindings toggle-application-view "['<Primary>space', 'LaunchB']"
# Setting relocatable schema for Terminal
if command -v gnome-terminal &> /dev/null ; then
echo "INFO: Found GNOME Terminal. Applying tweaks..."
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ copy '<Shift><Super>c'
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ paste '<Shift><Super>v'
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ new-tab '<Shift><Super>t'
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ new-window '<Shift><Super>n'
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ close-tab '<Shift><Super>w'
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ close-window '<Shift><Super>q'
gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ find '<Shift><Super>f'
fi
# Screenshots
# gsettings set org.gnome.shell.keybindings screenshot "['<Primary><Shift>numbersign']"
# gsettings set org.gnome.shell.keybindings show-screenshot-ui "['<Shift><Control>dollar']"
# gsettings set org.gnome.shell.keybindings screenshot-window "['<Shift><Control>percent']"
gsettings set org.gnome.shell.keybindings screenshot "['<Shift><Control>3']"
gsettings set org.gnome.shell.keybindings show-screenshot-ui "['<Shift><Control>4']"
gsettings set org.gnome.shell.keybindings screenshot-window "['<Shift><Control>5']"
# Disable screensaver to avoid potential issues
gsettings set org.gnome.settings-daemon.plugins.media-keys screensaver "[]"
# Restart is required in order for the changes in the `/usr/share/dbus-1/session.conf` to take place
# Therefore cannot launch service right away
# Download and enable Xremap GNOME extension (for Wayland only)
if [ "${XDG_SESSION_TYPE}" == "wayland" ]; then
RED=`tput setaf 1`
RESET=`tput sgr0`
echo "INFO: ${RED}Action Required${RESET}. Install the xremap extension and restart your PC."
echo " https://extensions.gnome.org/extension/5060/xremap/"
else
gnome-extensions disable xremap@k0kubun.com
echo "INFO: Please restart your computer."
fi