-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-shortcut.sh
More file actions
executable file
·50 lines (38 loc) · 1.44 KB
/
create-shortcut.sh
File metadata and controls
executable file
·50 lines (38 loc) · 1.44 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
#!/bin/bash
# Configuration
WIDTH=500
HEIGHT=400
# Prompt for Shortcut Name
SHORTCUT_NAME=$(zenity --entry --width=$WIDTH --height=$HEIGHT \
--title="Create a Shortcut" \
--text="Enter the name of your shortcut:")
[ -z "$SHORTCUT_NAME" ] && zenity --error --width=$WIDTH --text="Shortcut name is required!" && exit 1
# Prompt for Executable Path
EXEC_PATH=$(zenity --file-selection --width=$WIDTH --height=$HEIGHT \
--title="Select Executable File")
[ -z "$EXEC_PATH" ] && zenity --error --width=$WIDTH --text="Executable path is required!" && exit 1
# Prompt for Icon File (Optional)
ICON_PATH=$(zenity --file-selection --width=$WIDTH --height=$HEIGHT \
--title="Select an Icon (Optional)" --file-filter="Images | *.png *.xpm *.jpg *.svg")
# Prompt for Description (Optional)
DESCRIPTION=$(zenity --entry --width=$WIDTH --height=$HEIGHT \
--title="Description" \
--text="Enter a short description (optional):")
# Create the .desktop file
DESKTOP_FILE="$HOME/.local/share/applications/$SHORTCUT_NAME.desktop"
cat <<EOF > "$DESKTOP_FILE"
[Desktop Entry]
Type=Application
Name=$SHORTCUT_NAME
Exec="$EXEC_PATH"
Icon=${ICON_PATH:-utilities-terminal}
Comment=$DESCRIPTION
Terminal=false
Categories=Utility;
EOF
# Make it executable
chmod +x "$DESKTOP_FILE"
# Success message
zenity --info --width=$WIDTH --height=100 --title="Success" \
--text="Shortcut '$SHORTCUT_NAME' has been created successfully!\nYou can find it in your application menu."
exit 0