My method was essentially the same as your’s.
I don’t have nomachine-session.desktop. I have NoMachine-base.desktop (plus a couple of variations for Unity and XFCE):
[Desktop Entry]
Encoding=UTF-8
Comment=Access NoMachine computers over the network
Exec=”/usr/NX/bin/nxplayer”
Icon=NoMachine-icon
Name=NoMachine
StartupWMClass=nxplayer.bin
Type=Application
NotShowIn=Unity;XFCE;
and NoMachine-nxs.desktop:
[Desktop Entry]
Encoding=UTF-8
Comment=NoMachine session
Exec=”/usr/NX/bin/nxplayer” –session
Icon=NoMachine-desktop
Name=NoMachine
Type=Application
MimeType=application/nx-session;
NoDisplay=true
There a couple of others for recording and video that don’t seem relevant.
I followed your steps with both of the above files as a base. The results are the same. The icon pins fine on the task manager but when I close the window and re-open by clicking on the pinned icon, it opens the main window on the server settings page. It does not load the session. It does group however.
If I find the desktop file again and double click it then the session loads and attaches to the pinned task manager icon and groups.