-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
84 lines (71 loc) · 2.76 KB
/
install.sh
File metadata and controls
84 lines (71 loc) · 2.76 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
#!/bin/bash
# Function to find the correct Python executable
find_python_command() {
# List of possible Python commands to check
python_candidates=("python3" "python" "python3.11" "python3.10" "python3.9" "python3.8")
for cmd in "${python_candidates[@]}"; do
if command -v "$cmd" >/dev/null 2>&1; then
# Check if it's Python 3
version_output=$("$cmd" --version 2>&1)
if echo "$version_output" | grep -q "Python 3"; then
echo "$cmd"
return 0
fi
fi
done
echo "python3" # Fallback to python3
return 1
}
# Get the absolute path of the directory where this install.sh script is located
# This is the LinuxVitals directory, regardless of where it's installed
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
linuxvitals_path="$SCRIPT_DIR"
# Verify this is actually the LinuxVitals directory by checking for key files
if [ ! -f "$linuxvitals_path/launch.py" ] || [ ! -d "$linuxvitals_path/icon" ]; then
echo "Error: This doesn't appear to be the LinuxVitals directory."
echo "Expected to find launch.py and icon/ directory in: $linuxvitals_path"
exit 1
fi
echo "LinuxVitals directory found at: $linuxvitals_path"
# Detect the correct Python command
python_cmd=$(find_python_command)
python_full_path=$(which "$python_cmd" 2>/dev/null)
if [ -z "$python_full_path" ]; then
echo "Warning: Python 3 not found. Using 'python3' as fallback."
python_full_path="python3"
else
echo "Found Python at: $python_full_path"
fi
# Create the applications directory if it doesn't exist
mkdir -p $HOME/.local/share/applications
# Create the .desktop file
cat << EOF > $HOME/.local/share/applications/org.LinuxVitals.desktop
[Desktop Entry]
Version=1.0
Type=Application
Name=LinuxVitals
Comment=Monitor and control your CPU
Exec=$python_full_path $linuxvitals_path/launch.py
Icon=$linuxvitals_path/icon/LinuxVitals-Icon.png
Terminal=false
Categories=Utility;Application;
StartupWMClass=org.LinuxVitals
EOF
# Make the .desktop file executable
chmod +x $HOME/.local/share/applications/org.LinuxVitals.desktop
# Update desktop database to refresh icon cache
if command -v update-desktop-database >/dev/null 2>&1; then
update-desktop-database $HOME/.local/share/applications 2>/dev/null
fi
echo ""
echo "✓ LinuxVitals installation completed successfully!"
echo ""
echo "Installation details:"
echo " • Desktop file: $HOME/.local/share/applications/org.LinuxVitals.desktop"
echo " • Python executable: $python_full_path"
echo " • LinuxVitals path: $linuxvitals_path"
echo " • Icon path: $linuxvitals_path/icon/LinuxVitals-Icon.png"
echo ""
echo "You can now launch LinuxVitals from your application menu or by running:"
echo " python3 $linuxvitals_path/launch.py"
echo ""