The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

Solving xdg-open special URI opening problems

asked 2013-03-02 13:03:43 +0000

mikevmk gravatar image

updated 2013-03-02 15:38:50 +0000

Hi

Is there any clear (not dirty-hack style) way to make xdg-open open URIs like 'magnet:...' and so on? I've created workaround (see the patch), but maybe there is better way?

Thank you

--- /usr/bin/xdg-open.orig  2013-03-02 16:02:36.184184989 +0400
+++ /usr/bin/xdg-open   2013-03-02 16:51:53.878851407 +0400
@@ -384,7 +384,11 @@

 open_generic_xdg_mime()
 {
-    filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
+    if [ -z $not_file ]; then
+        filetype=`xdg-mime query filetype "$1" | sed "s/;.*//"`
+    else
+        filetype=x-scheme-handler/`echo "$1" | cut -d: -f 1`
+    fi
     default=`xdg-mime query default "$filetype"`
     if [ -n "$default" ] ; then
         xdg_user_dir="$XDG_DATA_HOME"
@@ -444,6 +448,9 @@
                 exit_success
             fi
         fi
+        elif (echo "$1" | egrep -q '^[a-zA-Z+\.\-]+:'); then
+            not_file=1
+            open_generic_xdg_mime "$1"
     fi

     OLDIFS="$IFS"

UPDATE: Script for adding support for all your current x-scheme-handler types http:// pastebin.com/qkVbkrqq . Still looking for better solution

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
4

answered 2014-04-21 08:23:06 +0000

badboy_ gravatar image

Just provide desktop files and a correct entry as follows:

$ cat ~/.local/share/applications/mimeapps.list
[Default Applications]
x-scheme-handler/magnet=add-torrent.desktop
$ cat ~/.local/share/applications/add-torrent.desktop
[Desktop Entry]
Name=Add Torrent
GenericName=Torrent
Comment=Add a manget link to the Torrent Client
Exec=script-to-add-torrent %U
TryExec=script-to-add-torrent
Terminal=false
Type=Application
MimeType=x-scheme-handler/magnet
edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-02 13:03:43 +0000

Seen: 623 times

Last updated: Apr 21 '14