Repository navigation
Expand file tree
/
Copy path2-GenSoftware.sh
More file actions
executable file
·300 lines (257 loc) · 10.4 KB
/
Copy path2-GenSoftware.sh
File metadata and controls
executable file
·300 lines (257 loc) · 10.4 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/bash
set -e
# Detect if running in CI environment (GitHub Actions, etc.)
is_ci() {
[[ -n "$CI" ]] || [[ -n "$GITHUB_ACTIONS" ]] || [[ -n "$RUNNER_OS" ]] || [[ -n "$CIINSTALL" ]]
}
execute() {
echo "$ $*"
OUTPUT=$($@ 2>&1)
if [ $? -ne 0 ]; then
echo "$OUTPUT"
echo ""
echo "Failed to Execute $*" >&2
exit 1
fi
}
# Get the OS LTS version (24.04 or 26.04)
get_os_lts_version() {
if [[ $(
. /etc/os-release
echo $ID
) == "ubuntu" ]]; then
version_id=$(
. /etc/os-release
echo $VERSION_ID
)
# Only support LTS releases: 24.04 and 26.04
if [[ ${version_id} == "24.04" || ${version_id} == "26.04" ]]; then
echo ${version_id}
else
echo "Unsupported Ubuntu version: ${version_id}. This script supports Ubuntu 24.04 and 26.04 LTS only." >&2
exit 1
fi
else
# For unofficial ubuntu flavours, check codename
ubuntu_codename=$(
. /etc/os-release
echo $UBUNTU_CODENAME
)
version_id=$(
. /etc/os-release
echo $VERSION_ID
)
if [[ ${ubuntu_codename} == "noble" ]] || [[ ${version_id} == "24.04" ]]; then
echo "24.04"
elif [[ ${version_id} == "26.04" ]]; then
echo "26.04"
else
echo "Unsupported Ubuntu version: ${version_id} (codename: ${ubuntu_codename}). This script supports Ubuntu 24.04 and 26.04 LTS only." >&2
exit 1
fi
fi
}
OS_VERSION=$(get_os_lts_version)
# Skip desktop environment tweaks in CI (no GUI)
if ! is_ci; then
if [[ $XDG_CURRENT_DESKTOP = *"GNOME"* ]]; then
execute sudo apt install gnome-tweaks gnome-shell-extensions -y
elif [[ $XDG_CURRENT_DESKTOP = *"MATE"* ]]; then
execute sudo apt install mate-tweak -y
fi
fi
# Install VS Code and Cursor IDEs
# Check and install VS Code
if [ -x "$(command -v code)" ]; then
echo "VS Code already installed, skipping it"
else
echo "Installing VS Code..."
curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/microsoft.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" | sudo tee /etc/apt/sources.list.d/vscode.list >/dev/null
execute sudo apt update
execute sudo apt install code -y
fi
# Check and install Cursor
if [ -x "$(command -v cursor)" ]; then
echo "Cursor already installed, skipping it"
else
echo "Installing Cursor..."
# Add Cursor's GPG key
curl -fsSL https://downloads.cursor.com/keys/anysphere.asc | gpg --dearmor | sudo tee /etc/apt/keyrings/cursor.gpg >/dev/null
# Add the Cursor repository
echo "deb [arch=amd64,arm64 signed-by=/etc/apt/keyrings/cursor.gpg] https://downloads.cursor.com/aptrepo stable main" | sudo tee /etc/apt/sources.list.d/cursor.list >/dev/null
# Update and install
sudo apt update
sudo apt install cursor
fi
### General Software from now on ###
### CI-Compatible Tools (work in both CI and desktop environments) ###
# Google Chrome browser (can run headless in CI)
if [ -x "$(command -v google-chrome-stable)" ]; then
echo "Google Chrome already installed, skipping it"
else
echo "Installing Google Chrome..."
curl -fsSL https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list >/dev/null
execute sudo apt update
execute sudo apt install google-chrome-stable -y
fi
### GUI-Only Tools (skip in CI environments) ###
if ! is_ci; then
# Install Brave browser
sudo curl -fsSLo /usr/share/keyrings/brave-browser-archive-keyring.gpg https://brave-browser-apt-release.s3.brave.com/brave-browser-archive-keyring.gpg
sudo curl -fsSLo /etc/apt/sources.list.d/brave-browser-release.sources https://brave-browser-apt-release.s3.brave.com/brave-browser.sources
execute sudo apt update
execute sudo apt install brave-browser -y
# System monitoring tools
execute sudo apt install lm-sensors psensor -y
# Flameshot - screenshot tool with annotation
execute sudo apt install flameshot -y
# GNOME/Wayland support: native Wayland mode, portal permission, and Super+Shift+S
if [[ "${XDG_CURRENT_DESKTOP:-}" == *GNOME* ]] && [[ "${XDG_SESSION_TYPE:-}" == "wayland" ]]; then
mkdir -p "$HOME/.local/share/applications"
if [[ -f /usr/share/applications/org.flameshot.Flameshot.desktop ]]; then
sed 's|^Exec=|Exec=env QT_QPA_PLATFORM=wayland |' /usr/share/applications/org.flameshot.Flameshot.desktop > "$HOME/.local/share/applications/org.flameshot.Flameshot.desktop"
elif [[ -f ./config_files/org.flameshot.Flameshot.desktop ]]; then
cp ./config_files/org.flameshot.Flameshot.desktop "$HOME/.local/share/applications/org.flameshot.Flameshot.desktop"
fi
# Pre-grant the GNOME screenshot portal permission (works around the denied/unasked state)
if command -v dbus-send >/dev/null 2>&1; then
dbus-send --session --print-reply=literal --dest=org.freedesktop.impl.portal.PermissionStore /org/freedesktop/impl/portal/PermissionStore org.freedesktop.impl.portal.PermissionStore.SetPermission string:'screenshot' boolean:true string:'screenshot' string:'org.flameshot.Flameshot' array:string:'yes' >/dev/null 2>&1 || true
fi
# Add a GNOME custom shortcut: Super+Shift+S -> Flameshot
if command -v dconf >/dev/null 2>&1 && command -v python3 >/dev/null 2>&1; then
python3 - <<'PYINNER'
import re
import shutil
import subprocess
def run(cmd):
try:
r = subprocess.run(cmd, capture_output=True, text=True)
return r.stdout.strip(), r.returncode
except FileNotFoundError:
return "", 127
if not shutil.which("dconf"):
raise SystemExit(0)
list_path = "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/"
base = "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings"
out, rc = run(["dconf", "read", list_path])
current = out if out else "[]"
paths = re.findall(r"'([^']+)'", current)
target = None
for p in paths:
name, _ = run(["dconf", "read", p + "/name"])
command, _ = run(["dconf", "read", p + "/command"])
if "Flameshot" in name or "flameshot" in command:
target = p
break
if target is None:
used = set()
for p in paths:
match = re.search(r"/custom(\d+)/$", p)
if match:
used.add(int(match.group(1)))
index = 0
while index in used:
index += 1
target = f"{base}/custom{index}/"
paths.append(target)
body = "[" + ", ".join(f"'{p}'" for p in paths) + "]"
run(["dconf", "write", list_path, body])
run(["dconf", "write", target + "/name", "'Flameshot'"])
run(["dconf", "write", target + "/command", "'sh -c -- \"QT_QPA_PLATFORM=wayland flameshot gui\"'"])
run(["dconf", "write", target + "/binding", "'<Super><Shift>s'"])
PYINNER
fi
fi
# Disk management
execute sudo apt install gparted -y
# Grub customization and image editor
# Add PPA for grub-customizer (not available in default repos)
execute sudo add-apt-repository ppa:danielrichter2007/grub-customizer -y
execute sudo apt update
execute sudo apt install grub-customizer gimp -y
# Screen recorder
execute sudo apt install kazam -y
# Media player and VPN, as snaps
sudo snap install vlc
sudo snap install surfshark
# Stremio from Flathub
execute sudo apt install flatpak -y
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo flatpak install -y flathub com.stremio.Stremio
# Remote desktop client
sudo snap install remmina
fi
### GitHub and GitLab CLIs
if [ -x "$(command -v gh)" ]; then
echo "GitHub CLI already installed, skipping it"
else
execute sudo apt-get install gh -y
fi
if [ -x "$(command -v glab)" ]; then
echo "GitLab CLI already installed, skipping it"
else
# Ubuntu's glab package lags the release used day to day. Take the latest .deb.
glab_deb_url="$(
curl -fsSL "https://gitlab.com/api/v4/projects/gitlab-org%2Fcli/releases/permalink/latest" |
python3 -c 'import json,sys; rel=json.load(sys.stdin); print(next(a["direct_asset_url"] for a in rel["assets"]["links"] if a["name"].endswith("_linux_amd64.deb")))'
)"
curl -fsSL "$glab_deb_url" -o /tmp/glab.deb
sudo dpkg -i /tmp/glab.deb
rm -f /tmp/glab.deb
fi
### AWS CLI and Session Manager plugin
if [ -x "$(command -v aws)" ]; then
echo "AWS CLI already installed, skipping it"
else
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip -q awscliv2.zip
sudo ./aws/install
rm -rf ./aws awscliv2.zip
fi
if [ -x "$(command -v session-manager-plugin)" ]; then
echo "AWS Session Manager plugin already installed, skipping it"
else
curl -fsSL "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o /tmp/session-manager-plugin.deb
sudo dpkg -i /tmp/session-manager-plugin.deb
rm -f /tmp/session-manager-plugin.deb
fi
### dltop, herdr, and the xhisper fork
if [ -x "$(command -v dltop)" ]; then
echo "dltop already installed, skipping it"
else
execute sudo apt-get install pipx -y
pipx install dltop
pipx ensurepath
fi
if [ -x "$(command -v herdr)" ]; then
echo "herdr already installed, skipping it"
else
curl -fsSL https://herdr.dev/install.sh | sh
fi
if [ -x "$(command -v xhisper)" ]; then
echo "xhisper already installed, skipping it"
else
# The pipewire tools package is named pipewire-bin or pipewire-utils depending on the release.
pipewire_tools=pipewire-bin
if apt-cache show pipewire-utils >/dev/null 2>&1; then pipewire_tools=pipewire-utils; fi
execute sudo apt-get install -y build-essential pipewire "$pipewire_tools" jq ffmpeg wl-clipboard python3-gi gir1.2-gtk-3.0 bc
xhisper_src="$(mktemp -d)"
# This branch is the fork actually in use. abszar/main does not carry the conda and X11 fixes.
git clone --depth 1 --branch fix/conda-env-and-clipboard-detection https://github.com/rsnk96/xhisper-ubuntu-linux.git "$xhisper_src"
make -C "$xhisper_src"
sudo make -C "$xhisper_src" install
rm -rf "$xhisper_src"
sudo usermod -aG input "$USER"
echo 'KERNEL=="uinput", GROUP="input", MODE="0660"' | sudo tee /etc/udev/rules.d/99-uinput.rules >/dev/null
sudo udevadm control --reload-rules || true
if [[ -e /dev/uinput ]]; then
sudo udevadm trigger /dev/uinput || true
fi
fi
if [[ ! -n $CIINSTALL ]]; then
echo ""
echo "Note: If you were added to the docker or input group, please log out and log back in for changes to take effect."
fi
echo "Script finished"