-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
62 lines (49 loc) · 1.57 KB
/
Copy pathinstall.sh
File metadata and controls
62 lines (49 loc) · 1.57 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
#!/bin/bash
# Define variables
EXECUTABLE_NAME="Pingstats"
EXECUTABLE_FILE="Pingstats"
ICON_NAME="pingstats"
ICON_FILE="pingstats.png"
DESKTOP_FILE="${EXECUTABLE_NAME}.desktop"
USER_HOME=$(eval echo ~$USER) # Get the absolute path to the user's home directory
ICONS_DIR="$USER_HOME/.local/share/icons/hicolor/256x256"
DESKTOP_DIR="$USER_HOME/.local/share/applications"
EXECUTABLE_DIR="$USER_HOME/.local/share/pingstats"
ICON_PATH="$ICONS_DIR/${ICON_FILE}"
DESKTOP_PATH="$DESKTOP_DIR/${DESKTOP_FILE}"
EXECUTABLE_PATH="$EXECUTABLE_DIR/${EXECUTABLE_FILE}"
# Check if the executable exists in the current directory
if [ ! -f "$EXECUTABLE_NAME" ]; then
echo "Error: $EXECUTABLE_NAME not found in the current directory."
exit 1
fi
# Check if the icon file exists in the current directory
if [ ! -f "$ICON_FILE" ]; then
echo "Error: $ICON_FILE not found in the current directory."
exit 1
fi
# Ensure the directories exist
mkdir -p "$ICONS_DIR"
# Copy the icon to the icons directory
cp "$ICON_FILE" "$ICON_PATH"
# Write the .desktop file
cat << EOF > "$DESKTOP_FILE"
[Desktop Entry]
Version=1.0
Type=Application
Name=$EXECUTABLE_NAME
Exec=$EXECUTABLE_PATH
Icon=$ICON_PATH
Terminal=false
StartupNotify=true
Categories=Utility;Application;
EOF
# Make the .desktop file executable
chmod +x "$DESKTOP_FILE"
# Move the .desktop file to the applications directory
mv "$DESKTOP_FILE" "$DESKTOP_DIR"
# Create the application directory
mkdir -p "$EXECUTABLE_DIR"
# Move the executable to the application directory
mv "$EXECUTABLE_NAME" "$EXECUTABLE_PATH"
echo "Shortcut created successfully!"