Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

xdg open has ignored my directives. I have found several threads regarding how to open ssh://user@ip links (these are in our monitoring software). I have run the following commands:

gconftool-2 -s /desktop/gnome/url-handlers/ssh/command '/home/dankney/bin/SSH.handler %s' --type String
gconftool-2 -s /desktop/gnome/url-handlers/ssh/enabled --type Boolean true
gconftool-2 -s /desktop/gnome/url-handlers/ssh/needs_terminal --type Boolean true

Yet still when I attempt to use xdg-open (as the chrome browser does) it attempts to sftp instead...

xdg-open ssh://root@1.2.3.4
gvfs-open: sftp://root@1.2.3.4/: error opening location: The specified location is not mounted

It seems to be set correctly in the registery thingy

gconftool-2 -a /desktop/gnome/url-handlers/ssh
 command = /home/dankney/bin/SSH.handler %s
 needs_terminal = true
 enabled = true

Oh - here is the ls -alFh and contents of SSH.handler

ls -alFh /home/dankney/bin/SSH.handler 
-rwxrwxr-x 1 dankney dankney 133 Sep 18 21:16 /home/dankney/bin/SSH.handler*


cat /home/dankney/bin/SSH.handler*
#!/bin/bash
url=$1
protocol=${url//:*/}
machine=${url//*:\/\//}
machine=${machine%/}
/usr/bin/gnome-terminal -e "$protocol $machine"

what gives?

Oh - btw - the shell script indeed does work if run from command line...

share|improve this question

I wanted to change what xdg-open does with ssh:// links, to replace konsole with yakuake as handler. And this is what I did on my Kubuntu 15.10 (KDE Frameworks 5.15.0):

  1. found out what's the handler:

    $ xdg-mime query default x-scheme-handler/ssh
    ktelnetservice5.desktop
    
  2. located the handler on the disk:

    $ locate ktelnetservice5.desktop
    /usr/share/app-install/desktop/kio:ktelnetservice5.desktop
    /usr/share/applications/ktelnetservice5.desktop
    

    in my case I had to edit /usr/share/applications/ktelnetservice5.desktop

  3. edited the handler replacing

    Exec=ktelnetservice5 %u
    

    with

    Exec=/path/to/some/script.sh %u
    

where that script looks like this:

#!/bin/bash
qdbus org.kde.yakuake /yakuake/window toggleWindowState; qdbus org.kde.yakuake /yakuake/sessions addSession && qdbus org.kde.yakuake /yakuake/sessions runCommand "ssh `echo $1 | cut -d'/' -f3`"

and was given execute privileges:

chmod +x /path/to/some/script.sh

And that's it!

share|improve this answer

First you should set up a protocol handler, like this:

xdg-mime default ssh.desktop x-scheme-handler/ssh

Then make a desktop entry file and put it somewhere like /usr/share/applications (perhaps it would be better to put it somewhere in ~/.config, though not sure where).

ssh.desktop:

[Desktop Entry]
Terminal=false
Type=Application
Exec=/home/dankney/bin/SSH.handler %F

Then next time xdg-open is called, it will use the ssh.desktop handler, which in turn will delegate the call to your shell script.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.