-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefault.nix
41 lines (36 loc) · 1.15 KB
/
default.nix
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
{ writeShellScriptBin
, glib
}:
# TODO can this maybe suck less
# https://discourse.nixos.org/t/making-xdg-open-more-resilient/16777
writeShellScriptBin "xdg-open" ''
# uncomment to get logs somewhere and tail -f it.
# exec > >(tee -i ~/dev/xdg-open-portal-log.txt)
# exec 2>&1
targetFile=$1
>&2 echo "xdg-open workaround: using org.freedesktop.portal to open $targetFile"
openFile=OpenFile
# https://github.com/flatpak/xdg-desktop-portal/issues/683
# if [ -d "$targetFile" ]; then
# openFile=OpenDirectory
# fi
if [ -e "$targetFile" ]; then
exec 3< "$targetFile"
${glib}/bin/gdbus call --session \
--dest org.freedesktop.portal.Desktop \
--object-path /org/freedesktop/portal/desktop \
--method org.freedesktop.portal.OpenURI.$openFile \
--timeout 5 \
"" "3" {}
else
if ! echo "$targetFile" | grep -q '://'; then
targetFile="https://$targetFile"
fi
${glib}/bin/gdbus call --session \
--dest org.freedesktop.portal.Desktop \
--object-path /org/freedesktop/portal/desktop \
--method org.freedesktop.portal.OpenURI.OpenURI \
--timeout 5 \
"" "$targetFile" {}
fi
''