-
Notifications
You must be signed in to change notification settings - Fork 0
/
open.sh
executable file
·63 lines (52 loc) · 1.53 KB
/
open.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
#!/bin/bash
if [[ "$@" =~ "https://" ]] || [[ "$@" =~ "http://" ]]; then
echo "[Info] Received a request: $@, interpreting as link"
/usr/lib/flatpak-xdg-utils/xdg-open "$@"
exit $?
fi
if [ ${trashAppUnsafe} ]; then
link="$2"
xdg-open "$2"
exit $?
else
if [[ "$(echo $@ | cut -c '1-8' )" =~ 'file://' ]]; then
fakeDirBase="${HOME}"
realDirBase="${XDG_DATA_HOME}/${stateDirectory}"
link=$(echo "$1" | sed "s|${fakeDirBase}|${realDirBase}|g")
echo "[Info] received a file open request: $1, translated to ${link}"
/usr/lib/flatpak-xdg-utils/xdg-open "${link}"
exit $?
else
fakeDirBase="${HOME}"
realDirBase="${XDG_DATA_HOME}/${stateDirectory}"
link=$(echo "$2" | sed "s|${fakeDirBase}|${realDirBase}|g")
fi
fi
echo "[Info] received a request: $@, translated to ${link}"
if [[ ${portableUsePortal} = 1 ]]; then
/usr/lib/flatpak-xdg-utils/xdg-open $(dirname "${link}")
if [[ $? = 0 ]]; then
exit 0
fi
fi
echo "[Info] Initiating D-Bus call..."
dbus-send --print-reply --dest=org.freedesktop.FileManager1 \
/org/freedesktop/FileManager1 \
org.freedesktop.FileManager1.ShowItems \
array:string:"file://${link}" \
string:fake-dde-show-items
if [[ $? = 0 ]]; then
exit 0
fi
/usr/lib/flatpak-xdg-utils/xdg-open $(dirname "${link}")
if [[ $? = 0 ]]; then
exit 0
fi
if [ -f /usr/bin/dolphin ] && [ ${XDG_CURRENT_DESKTOP} = KDE ]; then
/usr/bin/dolphin --select "${link}"
elif [ -f /usr/bin/nautilus ] && [ ${XDG_CURRENT_DESKTOP} = GNOME ]; then
/usr/bin/nautilus $(dirname "${link}")
else
xdg-open $(dirname "${link}")
fi
fi