-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPy_VBox_Install.py
More file actions
55 lines (41 loc) · 1.75 KB
/
Py_VBox_Install.py
File metadata and controls
55 lines (41 loc) · 1.75 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
#!/usr/bin/env python3
# Script Name: VBox_Install
# Author: Raphael Chookagian
# Date of latest revision: 10/05/2023
# Purpose: Script installs VirtualBox and settings to place it in the dock/desktop
import subprocess
def run_command(command, exit_on_failure=True):
"""
Run a shell command and check its status.
"""
result = subprocess.run(command, shell=True, text=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode != 0 and exit_on_failure:
print(f"Error encountered when running command: {command}")
print(result.stderr)
sys.exit(1)
return result.stdout
def install_virtualbox():
"""
Function to install VirtualBox and add it to favorites.
"""
run_command("sudo apt install virtualbox -y")
# Download the VirtualBox extension pack
run_command("wget https://download.virtualbox.org/virtualbox/6.1.38/Oracle_VM_VirtualBox_Extension_Pack-6.1.38.vbox-extpack")
# Install the VirtualBox extension pack
run_command("VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.38.vbox-extpack")
# Cleanup - remove the downloaded extension pack
run_command("rm Oracle_VM_VirtualBox_Extension_Pack-6.1.38.vbox-extpack")
# Add VirtualBox to favorites
add_to_favorites("virtualbox.desktop")
def add_to_favorites(desktop_file):
"""
Function to add an application to favorites in GNOME Shell.
"""
favorites = run_command("gsettings get org.gnome.shell favorite-apps")
favorites = favorites.strip().rstrip("]").rstrip() + f", '{desktop_file}']"
run_command(f"gsettings set org.gnome.shell favorite-apps '{favorites}'")
def main():
run_command("sudo apt update")
install_virtualbox()
if __name__ == "__main__":
main()