-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
238 lines (193 loc) · 7.97 KB
/
setup.py
File metadata and controls
238 lines (193 loc) · 7.97 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
import subprocess, sys, os, shutil
separator = "\n" + "-" * 75
home_path = os.path.expanduser("~")
# Check if using root
def check_root():
if os.geteuid() != 0:
sys.exit("You HAVE to run this script as root!")
# A custom run command that always executes with shell=True
def run(command):
try:
subprocess.run(command, shell = True, check = True)
except KeyboardInterrupt:
print(separator)
print("\nOperation interupted by user.")
quit()
except subprocess.CalledProcessError as e:
print(f"Command failed with error code {e.returncode}")
# A function that checks if a binary exists or not and return True or False accordingly.
def binary_exists(binary):
if (shutil.which(binary)):
return True
else:
return False
# A custom makedirs command that always executes with exist_ok=True
def mkdir(directory):
os.makedirs(directory, exist_ok=True)
# Take all of the values from a dicitionary and add them to a string and finally return the string
def dictionary_values_to_string(dictionary):
return " ".join(dictionary.values())
# Take all of the keys from a dicitionary and add them to a string and finally return the string
def dictionary_keys_to_string(dictionary):
return " ".join(dictionary.keys())
# Add the flatpak block to the .profile file.
def update_profile():
profile_path = os.path.expanduser("~/.profile")
# Put this in the .profile file
flatpak_block = """
# Add Flatpak data directories to XDG_DATA_DIRS
if [ -d "/var/lib/flatpak/exports/share" ]; then
export XDG_DATA_DIRS="/var/lib/flatpak/exports/share:$XDG_DATA_DIRS"
fi
if [ -d "$HOME/.local/share/flatpak/exports/share" ]; then
export XDG_DATA_DIRS="$HOME/.local/share/flatpak/exports/share:$XDG_DATA_DIRS"
fi
"""
# Append the block to the end of the file
with open(profile_path, "a") as f:
f.write(flatpak_block)
print("Successfully added Flatpak paths to .profile.")
print("Please log out and back in for changes to take effect.")
# Install flatpaks from a flatpaks dictionary
def install_flatpaks(flatpaks):
print(f"Checking if Flatpak is installed... \n{separator}")
if not binary_exists("flatpak"):
print(f"Flatpak is not installed, installing Flatpak... \n{separator}")
flathub_remote = "https://dl.flathub.org/repo/flathub.flatpakrepo"
run("sudo apt install flatpak gnome-software-plugin-flatpak -y")
# Add the Flatpak remote
run(f"flatpak remote-add --user --if-not-exists flathub {flathub_remote}")
update_profile()
install_flatpaks(flatpaks)
else:
flatpaks_command = dictionary_values_to_string(flatpaks)
flatpaks_staged = dictionary_keys_to_string(flatpaks)
print(f"Installing the following flatpaks: \n {flatpaks_staged} {separator}")
run(f"flatpak install --user {flatpaks_command} -y")
print(separator)
# Add the vscode apt repo
def add_vscode_repo():
print(f"Adding the Vscode apt repo...{separator}")
run("echo \"code code/add-microsoft-repo boolean true\" | sudo debconf-set-selections")
run("sudo apt update")
print(separator)
# Downloads the .deb files from a debs dictionary
def download_debs(debs):
debs_command = dictionary_values_to_string(debs)
debs_staged = dictionary_keys_to_string(debs)
# Make a dedicated folder before downlaoding the .deb files
mkdir("/tmp/setup_debs")
print(f"Downloading the following packages: \n {debs_staged} {separator}")
run(f"wget -nc -P /tmp/setup_debs {debs_command}")
print(separator)
# Installs native apt packages from a dictionary
def install_natives(natives):
natives_command = dictionary_values_to_string(natives)
natives_staged = dictionary_keys_to_string(natives)
add_vscode_repo()
print(f"Installing the following packages: \n {natives_staged} {separator}")
run(f"sudo apt install {natives_command} -y")
print(separator)
# Install Rust
def install_rust():
print(f"Installing Rust... \n{separator}")
run("curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y")
print(separator)
# Install node version manager
def install_nvm():
print(f"Installing Node version manager... \n {separator}")
run("wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash")
print(separator)
print(f"Installing NodeJS LTS... \n {separator}")
run("~/.nvm/nvm.sh install --lts")
print(separator)
# Configure Arabic fonts
def config_arabic_fonts():
mkdir("github")
os.chdir("github")
print(f"Cloning the Arabic fonts repo... \n{separator}")
run("git clone https://github.com/samad20/arabicFonts4Linux.git")
print(separator)
os.chdir("arabicFonts4Linux")
print(f"Configuring Arabic fonts... \n{separator}")
run("./changeFont.sh")
print(separator)
os.chdir(home_path)
# Install the msi-ec driver
def install_msiec():
os.chdir("github")
print(f"Cloning the msi-ec driver repo... \n{separator}")
run("git clone https://github.com/BeardOverflow/msi-ec")
os.chdir("msi-ec")
print(f"Building and installing the msi-ec driver... \n {separator}")
run("sudo apt install build-essential linux-headers-generic dkms -y")
run("sudo make dkms-install")
os.chdir(home_path)
print(separator)
def main():
debs = {
"Zoom": "https://cdn.zoom.us/prod/6.7.5.6891/zoom_amd64.deb",
"TickTick": "https://download.ticktick.app/download/linux/linux_deb_x64/ticktick-8.0.0-amd64.deb",
"Steam": "https://cdn.akamai.steamstatic.com/client/installer/steam.deb",
"MControlCenter": "https://github.com/dmitry-s93/MControlCenter/releases/download/0.5.1/MControlCenter-0.5.1-Ubuntu_25.04.deb"
}
flatpaks = {
"Blanket": "com.rafaelmardojai.Blanket",
"bottles": "com.usebottles.bottles",
"CubeTimer": "io.github.vallabhvidy.CubeTimer",
"desktop": "org.telegram.desktop",
"desktopeditors": "org.onlyoffice.desktopeditors",
"DistroShelf": "com.ranfdev.DistroShelf",
"Emote": "com.tomjwatson.Emote",
"ExtensionManager": "com.mattjakeman.ExtensionManager",
"Flatseal": "com.github.tchx84.Flatseal",
"gearlever": "it.mijorus.gearlever",
"Heroic Games": "com.heroicgameslauncher.hgl",
"kdenlive": "org.kde.kdenlive",
"KeePassXC": "org.keepassxc.KeePassXC",
"localsend_app": "org.localsend.localsend_app",
"MissionCenter": "io.missioncenter.MissionCenter",
"Motrix": "net.agalwood.Motrix",
"mpris-timer": "io.github.efogdev.mpris-timer",
"Mumble": "info.mumble.Mumble",
"Obsidian": "md.obsidian.Obsidian",
"OptimusUI": "de.z_ray.OptimusUI",
"ProtonPlus": "com.vysp3r.ProtonPlus",
"Ptyxis": "app.devsuite.Ptyxis",
"qBittorrent": "org.qbittorrent.qBittorrent",
"samaya": "io.github.redddfoxxyy.samaya",
"Sober": "org.vinegarhq.Sober",
"Studio": "com.obsproject.Studio",
"Vesktop": "dev.vencord.Vesktop",
"VLC": "org.videolan.VLC",
"whatsie": "com.ktechpit.whatsie",
"Word Book": "dev.mufeed.Wordbook",
"Bazaar": "io.github.kolunmi.Bazaar"
}
natives = {
"Podman": "podman",
"Distrobox": "distrobox",
"Fastfetch": "fastfetch",
"Java 25": "openjdk-25-jre",
"Virt manager":"virt-manager",
"Vscode": "code",
"Vnstat": "vnstat",
"GCC": "gcc",
"Git": "git",
"Local packages": "/tmp/setup_debs/*.deb",
"Python lsp": "python3-pylsp",
"Flake 8": "flake8",
"Full Python": "python3-full"
}
download_debs(debs)
install_natives(natives)
# Add fastfetch to the .bashrc file
run("echo \"fastfetch\" >> ~/.bashrc")
run("echo \"set tabsize 4\" > ~/.nanorc")
install_flatpaks(flatpaks)
install_rust()
install_nvm()
install_msiec()
config_arabic_fonts()
if __name__ == "__main__":
main()