-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_desktop_icon.sh
More file actions
executable file
·77 lines (65 loc) · 2.13 KB
/
Copy pathsetup_desktop_icon.sh
File metadata and controls
executable file
·77 lines (65 loc) · 2.13 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
#!/bin/bash
# setup_desktop_icon.sh
# This script creates a proper .desktop entry for myUpdaterScriptV2.sh
# It will use the system 'system-software-update' icon.
SCRIPT_PATH="$(realpath ./myUpdaterScriptV2.sh)"
DESKTOP_FILE="$HOME/Desktop/UniversalUpdater.desktop"
OLD_DESKTOP_FILE="$HOME/Desktop/malware.desktop"
DEFAULT_ICON="$(realpath ./icon.png)"
SYSTEM_ICON="system-software-update"
CHOSEN_ICON=""
# --- Interact with User for Icon ---
echo "--- Icon Setup ---"
if [ -f "$DEFAULT_ICON" ]; then
echo "Default icon found at: $DEFAULT_ICON"
else
echo "No local 'icon.png' found."
fi
echo -n "Do you want to use a custom icon? (Enter path or leave empty for default): "
read -r USER_ICON_PATH
# Validate User Input
if [ -n "$USER_ICON_PATH" ]; then
# Expand tilde if present
USER_ICON_PATH="${USER_ICON_PATH/#\~/$HOME}"
if [ -f "$USER_ICON_PATH" ]; then
CHOSEN_ICON="$(realpath "$USER_ICON_PATH")"
echo "Using custom icon: $CHOSEN_ICON"
else
echo "Error: File not found at '$USER_ICON_PATH'. Falling back to default."
fi
fi
# Fallback Logic
if [ -z "$CHOSEN_ICON" ]; then
if [ -f "$DEFAULT_ICON" ]; then
CHOSEN_ICON="$DEFAULT_ICON"
echo "Using default local icon."
else
CHOSEN_ICON="$SYSTEM_ICON"
echo "Using system generic icon."
fi
fi
# Ensure script is executable
chmod +x "$SCRIPT_PATH"
# Create the .desktop file content
cat > "$DESKTOP_FILE" <<EOL
[Desktop Entry]
Version=1.0
Type=Application
Terminal=true
Name=Universal Updater
Comment=Update system packages and dev tools
Exec="$SCRIPT_PATH"
Icon=$CHOSEN_ICON
Categories=System;Settings;
StartupNotify=true
EOL
# Make the desktop entry executable (required by GNOME/KDE)
chmod +x "$DESKTOP_FILE"
# Clean up old poorly named file if it exists
if [ -f "$OLD_DESKTOP_FILE" ]; then
echo "Removing legacy shortcut ($OLD_DESKTOP_FILE)..."
rm "$OLD_DESKTOP_FILE"
fi
echo "✅ Desktop shortcut created at: $DESKTOP_FILE"
echo "You can now run the updater by clicking the 'Universal Updater' icon on your desktop."
echo "Note: On Ubuntu 20.04+, right-click the icon and select 'Allow Launching' if prompted."