This repository has been archived by the owner on Apr 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add_to_dolphin.sh
executable file
·67 lines (58 loc) · 1.61 KB
/
add_to_dolphin.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
67
#!/bin/bash
# Check if the script is running as root
if [ "$(id -u)" -ne 0 ]; then
# If not running as root, restart the script
# with elevated privileges using sudo
echo "This script requires root privileges. Restarting with sudo..."
sudo "$0" "$@"
exit $?
fi
# Define the paths
# Get the path to kio/servicemenus using qtpaths
servicemenus_path=$(qtpaths --locate-dirs GenericDataLocation kio/servicemenus)
# Check if the ServiceMenus directory exists
if [ ! -d "$servicemenus_path" ]; then
echo "Creating $servicemenus_path..."
mkdir -p "$servicemenus_path"
fi
select_action() {
echo "Press Key to select:"
echo "[1]: Install"
echo "[2]: Uninstall"
read -n 1 key
echo ""
if [ "$key" = "1" ]; then
echo "Installing..."
install
elif [ "$key" = "2" ]; then
echo "Uninstalling..."
uninstall
else
echo "You pressed '$key'. Not a recognized key. \
Press either [1] or [2]."
select_action
fi
}
install() {
script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$servicemenus_path"
command_on_convert="sh -c \"$script_dir/convert '"%U"'\""
file="convert.desktop"
filecontent="[Desktop Entry]\nType=Service\nMimeType=application/octet-\
stream;\nActions=convert\n\n[Desktop Action convert]\nName=Convert File\
\nIcon=inode-x-generic\nExec=$command_on_convert"
echo -e "$filecontent" > "$file"
chmod +x "$file"
exit_script
}
uninstall() {
cd "$servicemenus_path"
rm "./convert.desktop"
exit_script
}
exit_script() {
echo "Done. Press any key to exit."
read -n 1
exit 0
}
select_action