Bug 403666

Summary: Can't pin GUI applications started by script
Product: [Plasma] plasmashell Reporter: michal.konecny
Component: Task Manager and Icons-Only Task Manager widgetsAssignee: Eike Hein <hein>
Status: REOPENED ---    
Severity: normal CC: cristiano.moraes, michal.konecny, nate, plasma-bugs, qydwhotmail, yellow.cat87355
Priority: NOR Keywords: usability
Version: 5.14.4   
Target Milestone: 1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: TeamSpeak_pin_example
TeamSpeak desktop file
desktop file that is unable to be pinned to taskbar

Description michal.konecny 2019-01-27 19:42:14 UTC
Created attachment 117691 [details]
TeamSpeak_pin_example

SUMMARY
When the application is started by script, it can't be pinned to panel. For example https://github.com/flathub/com.teamspeak.TeamSpeak can't be pinned.

STEPS TO REPRODUCE
1. Install TeamSpeak from Flathub
2. Run application
3. Try to pin application

OBSERVED RESULT
Pin option is grayed out

EXPECTED RESULT
Pin option is available

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora 29
(available in About System)
KDE Plasma Version: 5.14.4
KDE Frameworks Version: 5.54.0
Qt Version: 5.11.3

ADDITIONAL INFORMATION
I tried to add `StartupWMClass=TeamSpeak` to desktop file and this didn't helped .
Comment 1 Nate Graham 2019-02-06 03:52:16 UTC
When you say "started from a script" do you mean that you ran `flatpak run com.teamspeak.TeamSpeak` in a terminal window or a script? Or that you opened the application from a GUI method and just happen to know that its desktop file calls a terminal command?
Comment 2 michal.konecny 2019-02-06 07:55:17 UTC
Desktop file is executing 'teamspeak' script which starts ts3client_run.sh.
ts3client_run.sh is setting few env variables and then starting the correct executable for 32 or 64 bit. 

I saw the same behavior on another flatpak (https://github.com/flathub/com.bluejeans.BlueJeans), which is using the similar exec script in desktop file.
Comment 3 Nate Graham 2019-02-07 15:22:44 UTC
Thanks! Do you notice the same behavior with non-Flatpak apps started from desktop files that have a script in the exec line?
Comment 4 michal.konecny 2019-02-07 21:22:24 UTC
Created attachment 117917 [details]
TeamSpeak desktop file
Comment 5 michal.konecny 2019-02-07 21:23:40 UTC
I tried it again with teamspeak flatpak, this time I created a desktop file, that executed directly the ts3client_runscript.sh script outside the flatpak and the result was same.

I'm adding the desktop file as attachment.

To use it, just install the flatpak and copy this to .local/share/applications
Comment 6 Nate Graham 2019-02-07 21:30:31 UTC
Thanks. Can you comment on whether or not this happens for you with a non-flatpak app?
Comment 7 michal.konecny 2019-02-07 21:35:28 UTC
This is a non-flatpak version. This is the same as if you download the teamspeak from official page and execute it.
Comment 8 Nate Graham 2019-02-07 22:19:07 UTC
Ah Ok. thanks. Can confirm.
Comment 9 michal.konecny 2022-01-08 17:35:23 UTC
I found out a workaround for this.

You can pin the application by searching for it in Application Launcher, right clicking on it and choose Pin to Taskbar. Only caveat is that if you launch it it will open another app on taskbar (the app launched by the script).
Comment 10 yellow.cat87355 2023-01-19 13:57:21 UTC
Created attachment 155425 [details]
desktop file that is unable to be pinned to taskbar
Comment 11 yellow.cat87355 2023-01-19 14:02:40 UTC
New to KDE and ran into this almost immediately. I really hope this issue isn't dead.

I've attached another .desktop in the hopes it might help. In my case it's TinyMediaManager which launches a javascript program. Pretty frustrating. Maybe possible to add these types of launchers via a widget instead?

Here are the contents of the script that is launched.

#!/usr/bin/env bash
#
# tinyMediaManager v4 by Manuel Laggner
# https://www.tinymediamanager.org/
# SPDX-License-Identifier: Apache-2.0
#
# legacy launch script for tinyMediaManager

# Allow the script to be called from any directory and through symlinks
TMM_DIR="$(dirname "$(test -L "${BASH_SOURCE[0]}" && \
    readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")"

# Ma! Start the car! :)
cd "$TMM_DIR" || return 1
./tinyMediaManager "$@"
Comment 12 Fushan Wen 2023-01-28 11:42:06 UTC
StartupWMClass should work. Check the class name matches the class name of the real window.
Comment 13 yellow.cat87355 2023-01-28 22:00:25 UTC
(In reply to Fushan Wen from comment #12)
> StartupWMClass should work. Check the class name matches the class name of
> the real window.

Sounded good, but I still can't get it to work :/

> $ xprop WM_CLASS
> WM_CLASS(STRING) = "org-tinymediamanager-TinyMediaManager", "org-tinymediamanager-TinyMediaManager"

> StartupWMClass=org-tinymediamanager-TinyMediaManager

So I tried with both even though they are identical, tried with and without quote, used semi-colon between them, but nothing has changed,.

Hard to find any real quality information on setting this parameters properly, but I can't figure it out with what little I found.