Discussion:
Custom URL Schemata?
fREW Schmidt
2016-09-07 04:39:44 UTC
Permalink
Hey all,

I'm trying to make a few custom url schemes for personal links to
myself, here is, as far as I know, a complete summary of what I've
tried:

$ cat install-xdg
#!/bin/dash

xdg-mime install ./xdg/frew-test.desktop
xdg-mime default frew-test.desktop x-scheme-handler/email

if [ $(xdg-mime query default x-scheme-handler/email) = "frew-test.desktop" ]; then
echo "IT WORKED!"
fi

$ cat ./xdg/frew-test.desktop
[Desktop Entry]
Name=Mutt-id
GenericName=Email Viewer
Comment=View emailz
TryExec=/home/frew/bin/email-handler
Exec= TryExec=/home/frew/bin/email-handler %u
Terminal=true
Type=Application
Icon=gvim
Categories=Utility;TextEditor;
StartupNotify=true
MimeType=x-scheme-handler/email;

$ cat ~/bin/email-handler
#!/bin/dash

echo $1

$ ./install-xdg
IT WORKED!

When I run `xdg-open email://foo`, instead of echoing foo (or maybe
email://foo) it always runs chrome.

What should I do? Are there logs I could look at?
--
fREW Schmidt
https://blog.afoolishmanifesto.com
David Faure
2016-10-29 16:27:31 UTC
Permalink
Post by fREW Schmidt
When I run `xdg-open email://foo`, instead of echoing foo (or maybe
email://foo) it always runs chrome.
What should I do? Are there logs I could look at?
xdg-open calls a DE-specific tool, so this is entirely dependent on which DE
you are using.

(If it's KDE, email me privately and we'll debug this.)
--
David Faure, ***@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5
David Faure
2016-10-29 19:40:45 UTC
Permalink
I don't really use a DE. I figured out a solution myself if
https://blog.afoolishmanifesto.com/posts/custom-uri-schemata-on-linux/
Interesting patch for xdg-open in there (to support Terminal=true).

My own testing (after forcing xdg-open to call the open_generic function)
indicates that xdg-terminal fails when called with multiple arguments
so I had to modify your patch slightly, to say
xdg-terminal "$command_exec $@"
instead of
xdg-terminal "$command_exec" "$@"

Here's the patch, any objections against me committing it?

diff --git i/scripts/xdg-open.in w/scripts/xdg-open.in
index cb41ac6..62ef54b 100644
--- i/scripts/xdg-open.in
+++ w/scripts/xdg-open.in
@@ -282,7 +282,11 @@ search_desktop_file()
args=$(( $args - 1 ))
done
[ $replaced -eq 1 ] || set -- "$@" "$target"
- "$command_exec" "$@"
+ if [ "$(get_key "${file}" "Terminal")" = true ]; then
+ xdg-terminal "$command_exec $@"
+ else
+ "$command_exec" "$@"
+ fi

if [ $? -eq 0 ]; then
exit_success
--
David Faure, ***@kde.org, http://www.davidfaure.fr
Working on KDE Frameworks 5
Achim Bohnet
2016-11-01 08:29:25 UTC
Permalink
Post by David Faure
I don't really use a DE. I figured out a solution myself if
https://blog.afoolishmanifesto.com/posts/custom-uri-schemata-on-linux/
Interesting patch for xdg-open in there (to support Terminal=true).
My own testing (after forcing xdg-open to call the open_generic function)
indicates that xdg-terminal fails when called with multiple arguments
so I had to modify your patch slightly, to say
instead of
with more than one argument xdg-termial is again called with several arguments.
Further one would never know if the program name or the first arg contained the space.

(0)***@ex-lm50:~$ cat xx
#!/bin/bash

echoargs () {
for x; do
echo -n "<<$x>>"
done
echo
}

echoargs ONE: "program $@"

echoargs TWO: "progam" "$@"
(0)***@ex-lm50:~$ bash xx "1 2 3" 4 5 " 6"
<<ONE:>><<program 1 2 3>><<4>><<5>><< 6>>
<<TWO:>><<progam>><<1 2 3>><<4>><<5>><< 6>>


IMHO xdc-terminal need to be fixed.

Achim
Post by David Faure
Here's the patch, any objections against me committing it?
diff --git i/scripts/xdg-open.in w/scripts/xdg-open.in
index cb41ac6..62ef54b 100644
--- i/scripts/xdg-open.in
+++ w/scripts/xdg-open.in
@@ -282,7 +282,11 @@ search_desktop_file()
args=$(( $args - 1 ))
done
+ if [ "$(get_key "${file}" "Terminal")" = true ]; then
+ else
+ fi
if [ $? -eq 0 ]; then
exit_success
--
Working on KDE Frameworks 5
_______________________________________________
xdg mailing list
https://lists.freedesktop.org/mailman/listinfo/xdg
--
To me vi is Zen. To use vi is to practice zen. Every command is
a koan. Profound to the user, unintelligible to the uninitiated.
You discover truth everytime you use it.
-- ***@lion.austin.ibm.com
Loading...