How to create & pin Unity shortcut to a specific command / shellscript

This is not a duplicate as I've spent a good while trying to find a solution from Ask Ubuntu and Googling, to no avail. It is a specific problem after successfully pinning the shortcut to Unity.

The command I am attempting to pin is:

rdesktop -u user -d DOMAIN -g 1380x849 -r sound:local -p password -x 0x80 -P -a 32 -k fi 192.168.1.103

Alright, so the things I've tried are:

  1. Manually create rdesk.desktop that would use the application rdesktop with some command parameters to connect to a remote machine and automatically log in. I can successfully drag this launcher to Unity.

  2. Create a launcher via the Main Menu utility, hitting the Ubuntu icon and launching the session from there, then pinning the actual rdesktop icon that appears upon launch.

Both methods work partly. I can get a nice shortcut with the icon of my choice into the task bar with (1), but upon clicking this shortcut a second (actual rdesktop) icon pops to the bottom of the Unity bar. Pinning this second icon works, but it doesn't actually do anything once clicked AFTER I've closed the session. The pinned icon from the (2) method acts exactly the same.

On mouse over, the second icon shows me: rdesktop - 192.168.1.103

How can I create a shortcut to the rdesktop command with parameters, and pin it to Unity so the icon I click gets highlighted and responds to clicks even after closing the session? Alternatively I guess I could somehow edit the second pinned icon to work with the correct parameters so that rdesktop would actually open, I just couldn't find it anywhere in the file system to take a peek.

Edit: here's my .desktop entry which I dragged into Unity

[Desktop Entry]
Name=Remotedesktop Client
Comment=Connect to a remote Windows Terminal-Server
Exec=rdesktop -u name -d DOMAIN -g 1380x849 -r sound:local -p password -x 0x80 -P -a 32 -k fi 192.168.1.103
Icon=/usr/share/icons/hicolor/scalable/apps/nm-device-wired.svg
Terminal=false
Hidden=false
Type=Application
Version=1.0
Encoding=UTF-8

Here's a screenshot for clarification:

enter image description here

Upper black highlighted one is my .Desktop, and the lower is what I get when I click it. The upper actually will only work once, and if I unpin it and redrag it to Unity, it will work again, one time.


Solution 1:

You need to setup the WMClass to rdesktop in your .desktop file. This one works for me:

[Desktop Entry]
Version=1.0
Type=Application
Name=Gacela
Exec=rdesktop #####:####
Icon=/usr/share/icons/gacela.png
Comment=Conexion co Gacela
Categories=Internet;
Terminal=false
StartupNotify=true
StartupWMClass=rdesktop
GenericName=

To get the WMClass of any running window, you need to use this command:

xprop

and click on the window that you want to identify. Look for the value of WM_CLASS in the output, or grep it if you prefer a smaller output:

xprop | grep WM_CLASS