-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdteset.sh
66 lines (53 loc) · 1.81 KB
/
dteset.sh
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
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: dteset <AppImage>"
exit 1
fi
APPIMAGE="$1"
echo "**********************************"
echo "Desktop Entry Setter"
echo "**********************************"
read -p "Path to the AppImage [default: $(pwd)/${APPIMAGE}]: " path
path=${path:-$(pwd)/${APPIMAGE}}
echo "Type:"
echo "1) Application"
echo "2) Link"
echo "3) Directory"
read -p "Choose the type [default: 1]: " type_choice
case "$type_choice" in
2) type="Link" ;;
3) type="Directory" ;;
*) type="Application" ;;
esac
read -p "Name [default: ${APPIMAGE%.AppImage}]: " name
name=${name:-${APPIMAGE%.AppImage}}
read -p "Exec [default: ${path}]: " exec
exec=${exec:-${path}}
read -p "Icon [default: utilities-terminal]: " icon
icon=${icon:-utilities-terminal}
read -p "Categories (semicolon-separated) [default: Utility;Application;]: " categories
categories=${categories:-Utility;Application;}
echo ""
echo "--> The details you entered will result in the following desktop entry:"
echo "[Desktop Entry]"
echo "Type=${type}"
echo "Name=${name}"
echo "Exec=${exec}"
echo "Icon=${icon}"
echo "Categories=${categories}"
echo ""
read -p "Is this correct? Y/n: " confirmation
if [[ "${confirmation,,}" != "n" ]]; then
mkdir -p ~/.local/share/applications
echo "[Desktop Entry]" > ~/.local/share/applications/${name}.desktop
echo "Type=${type}" >> ~/.local/share/applications/${name}.desktop
echo "Name=${name}" >> ~/.local/share/applications/${name}.desktop
echo "Exec=${exec}" >> ~/.local/share/applications/${name}.desktop
echo "Icon=${icon}" >> ~/.local/share/applications/${name}.desktop
echo "Categories=${categories}" >> ~/.local/share/applications/${name}.desktop
echo "Desktop entry set."
echo "**********************************"
else
echo "Desktop entry not set."
echo "**********************************"
fi