Terminal command to add/remove .desktop files in task manager?

Is there a terminal command to remove and add a given .desktop file into the task manager in Plasma, as if you had done it manually by right-clicking and picking “Remove” or dragging and dropping a .desktop file onto it?

When I asked on IRC yesterday, I was told about xdg-desktop-menu, but neither its “install” nor “uninstall” sub-commands have any effect on my task manager (the icons don’t get removed or added). The commands give no error output, as if they worked. I carefully read the manual. I even tried wrong paths to make sure it shows errors if there is an actual error.

Note: If I drag and drop the very same .desktop files into the task manager, it works, so there is nothing wrong with the .desktop files themselves. But the point is to automate this.

Maybe the Plasma Scripting API is able to do that?

Other way is modifying ~/.config/plasma-org.kde.plasma.desktop-appletsrc and then restarting plasmashell




You could make a script that gets the .desktop names and then puts it in every or specific task managers, then reload the panels somehow or just restart plasma

Well, thanks for the information. This cleared up one thing that I’ve been wondering about. But it also introduces more question marks for me:

When looking at that file, and searching for “launchers=”, it does indeed seem as if the items in the task manager are just “linking” to the actual .desktop files (it doesn’t copy them to some new cache location). But this goes completely against my experiences the last few days, when modifying my .desktop files seemed to have no impact when I clicked on them (they still seemed to use the old data).

But today, as I was preparing a test after closing and starting Plasma/task manager, it did use the new data without me doing anything other than edit the .desktop file. I don’t know what to make of this. I tried numerous times just a couple of days ago and it most certainly did NOT use the new data then. It used the “cached” data, leading me to believe that it copies the .desktop files into some special location (just like XFCE’s panel/launchers did).

Well, um… I guess my question is void for now. But I have a feeling that it will go back to behaving like it did before, as it usually goes when I unexpectedly find that something is working as expected…

If I drag an application from the Application Launcher, the *.desktop file name as it appears in /usr/share/applications or ~/.local/share/applications is what gets added to the task manager launchers= variable.

For me changing the ~/.local/share/applications/*.desktop file does reload the launcher in the task manager automatically, but for the Application Launcher favorites it changes after plasmashell restart.

And today I found this post which looks exactly like the problem you’re facing?

Also, for manual .desktop files dragged into the panel it creates a different kind of widget:


localPath=/home/luis/.local/share/plasma_icons/Turn Off Screen.desktop
url=file:///home/luis/.local/share/applications/Turn Off Screen.desktop

So it is making a copy of the desktop file to /.local/share/plasma_icons, but isn’t updating it when the original file changes?

So unless I completely broke my installation after trying plasma 6 in the same user this looks like another bug, can you confirm the same happens to you?

Sorry, I’ve read your response but don’t know what exactly you want me to test. I don’t know if I was clear (or if I responded in a different thread), but it seems to be working as expected for me now. Not sure what I did wrong before, or changed. I do know that some of the icons I added to the task manager had no way to remove them, which is why I entered the “edit mode” to begin with (which is a nightmare).