[Feature Request] A right click "Entomber" script

I’m currently working with a steam deck which has limited write access and space. As such, I’d like to be able to remove programs while still leaving a .desktop file with the correct icon that would reinstall the program next time the icon is clicked.

for flatpaks this would change a line like

“Exec=/user/bin/flatpak run --command=kodi tv.kodi.Kodi”

to

"Exec=sh -c ‘xdg-open appstream://tv.kodi.Kodi.desktop’ %U

I imagine that you can do similar changes with apps installed with pacman or other installers.

After the .desktop is changed, you would just then trigger the normal uninstall process.

I’ve dubbed this process “Entombing”.

What do you expect that this will do? On my Neon Plasma it opens Discover showing an error. Using xdg-open appstream://tv.kodi.Kodi opens Discover with the page for Kodi where I can click “Install” to have Kodi installed.

Do you expect that the process to re-launch such “entombed” application would be:

  1. Click the launcher shortcut and wait for Discover to open.
  2. Click Install and wait for the application to install, and rewrite the launcher shortcut.
  3. Close Discover.
  4. Click the launcher icon again to actually launch the application.

That doesn’t seem all that useful to me.

If you want to automate the conversion of a real desktop entry (launcher shortcut) to one that calls xdg-open appstream://, you may want to use the appstreamcli tool. My first try was to do something like this:

name="$( awk -F= '$1=="Name"{print$2}' < app.desktop)"
identifier=$(appstreamcli search "$name" | awk '$1=="Identifier:"{print$2}' | head -n1)
echo "xdg-open appstream://$identifier"

Then you can use the identifier to create a new desktop entry that will execute the appstream:// URL.

Note though that appstreamcli search often returns more than one result and they may not be ordered in the way that you expect.

It launching Discover is what my example code is supposed to do. I assumed that is KDE’s preferred method,

but you do make a great point that it could be more simple by taking the existing info from a .desktop file and converting it into something like
“/usr/bin/flatpak install tv.kodi.Kodi --noninteractive & /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=kodi tv.kodi.Kodi”

also the right click menu could automatically uninstall the app by running something like “/usr/bin/flatpak install tv.kodi.Kodi --noninteractive” then moving the new .desktop file so it has the same name and location as the original. I’m assuming it will be automatically overwritten on a reinstall.

These are examples for flatpaks which is what steamos uses, other test cases would be needed for other installers and systems.

You can write a service menu for Dolphin that will add an action to the right click menu of a .desktop file, which can run a script to do all the “entombing”. That’s the easy part - parsing the .desktop file, figuring out what to do, making sure errors are handled and providing feedback to the user is the hard part - but it all seems very doable.

If you write something and want me to review, drop me a ping :smiley: