0
UPDATE

Disclaimer: Cross-posted to SUL (which I know is usually discouraged) How to set a shell script as KDE file association. Since with only 14 views and no response whatsoever within 3 days I do not have much hope here.


I'm connecting to a Win10 with an *.rdp file supplied by Citrix Netscaler Gateway via download in my FF.

I wrote a shell script that takes the *.rdp file as $1 and it works in Bash:

...
set -x
xfreerdp "$1" /monitors:0,2 /floatbar:sticky:off,default:hidden,show:always /u:<me> /p:<...>
...

To be able to run this script from within GUI apps I created a new File Association with Known Type: application/rdp since *.RDP, *.rdp was assigned to Remmina before (and I removed these two from there):

File Association RDP

There's a ~/.local/share/applications/Bash-RDP.desktop.

In FF I have set:

FF Settings > Application > RDP

But, this neither works when opening the downloaded *.rdp in FF's downloads drop-down or Downloads Library nor in my Downloads folder in Dolphin. If I do so xfreerdp appears in the taskbar with a progress circle for a few seconds only and without any further visual representation. And an xfreerdp task remains at every try which I have to kill afterwards.

UPDATE

This is strange. My old (working) Known Type x-remmina has now the Filename Patterns *.rdpx, *.remmina. (I mentioned above that I moved *.RDP, *.rdp from there to my new one.):

x-remmina

There's xfreerdp first in the Application Preference Order and exactly this is taken when selecting an *.rdp file, such ignoring my new known type, my associated filename patterns, my application preference and finally my script. How do I know? I changed the order to:

Changed Application Preference Order

and the *.rdp file opened in Kate.

Is this worth a bug report?

UPDATE 2

It was, for me: New custom Known Type in File Associations is ignored.

2 Answers2

1

Do not use the -c option. The parameter to that option is not a script file – the parameter itself is the script that will receive the remainder as $1, $2, etc. So what you have right now is one script (nameless) calling another script (rdp.sh), in which case the positional arguments are never "passed through" implicitly – that would only happen if $1 or $@ were used explicitly, e.g.:

Program: bash
Arguments: -c '~/bin/rdp.sh "$1"' -- %U

(You need to specify a dummy argument, such as the -- here, because the first argument that follows will actually be stored in the special $0, not in $1.)

Usually, though, you can omit the whole -c option and have Bash directly run a script file as the original intention probably was:

Program: bash
Arguments: /home/gerold/bin/rdp.sh %U

(This is also why the first argument that follows is stored in the special $0 instead of becoming $1.)

This does lose the ability to use ~/-expansion in arguments, but that's rarely an issue (if the .desktop file were shared between multiple users on the same system, then the script would be in /usr/bin anyway).

To simplify it even further, chmod +x your script (and make sure it has the usual #! header), then you'll be able to do:

Program: /home/gerold/bin/rdp.sh
Arguments: %U

In this case, Program: rdp.sh would be enough if your $PATH is correct.

grawity
  • 501,077
0

Finally I achieved what I want by:

  1. File AssociationsKnow Types: rdp- Remove
  2. Know Types: x-remminaFilename Patterns+ Add: *.rdp & *.RDP
  3. Application Preference Order+ Add...Konsole
  4. Select Konsole️ Edit...Application:
    1. Program: /bin/bash
    2. Arguments: /home/<user>/bin/rdp.sh %U
  5. Make sure that Konsole is at the top in Application Preference Order.
  6. Enjoy!

UPDATE

If found that this has a drawback: When selecting Konsole from the system menu or bottom panel it appears on the bottom panel for less than a second and disappears. If I right-klick its icon and select Open a New Window or ... Tab it opens normally.