How to get that bouncing animation when launching apps with commands?

Hi, I have a script for launching certain apps via terminal, This is for launching Softwares via my phone - ssh over LAN, or just in general via konsole or yakuake when I have plasmashell not running (I know It’s not supposed to be closed but I do it until I get more memory).

I find remembering gtk-launch & flatpak run commands along with complex App IDs is a little unnecessary. so this Python based launcher wrapper script takes aploch add <alias> <AppID> to add alias and launches set Application via aplonch <alias>, there are also aplonch list and aplonch edit commands to list set aliases and open config file in kate.

It manages a custom configuration file located at ~/.config/simple-launcher.conf, utilizing KDE’s kstart utility to initiate process execution

Primary target command - kstart6 --application <target>
Secondary Fallback - kstart5 --application <target>
Final Fallback - subprocess.Popen

These method is working fine to launch all apps I set with it, just one polishing finish I’d like to add to it is that bouncing app icon animation that plays when launching apps via andromeda launcher/panel/keyboard global shortcuts.
Not necessary, but would love to see it working.

(If anyone wanna try launching apps via similar method and remote ssh, It directly doesnt work because ssh connects as non-GUI headless session, but I already use KDE Connect to run a command - konsole -e tmux new-session -A -s a1, followed by command on ssh tmux new-session -A -s a1 to attach the session onto GUI and then open softwares, I was already using tmux and KDE Connect so might as well take advantage)

kstart is using a .desktop file - so setting the following property should provide the desired feedback.

[Desktop Entry}
...
StartupNotify=true
...
1 Like

Okay that makes sense, but the script already uses kstart6 --application [ID], it is basically telling KDE to look up the existing .desktop file for that App ID and run it.
Most apps I have like KdenLive, should already have StartupNotify=true set in their system files by default.
I manually checked GIMP and Zen Browser’s .desktop files, they both have that StartupNotify=true.

If I’m not wrong, the .desktop files are meant to have this entry (I read this on freedesktop.org 6 Recognized desktop entry keys) and not the script, I don’t even know where I’d put that in the script.

From what I read and put in the script - Python 3 script runs the command kstart6 --application <ID>, and here is what I assume happens technically

  • kstart6 takes the App ID (like app.zen_browser.zen) and searches the system directories (/usr/share/applications and ~/.local/share/applications) for a matching .desktop file.
  • Once found, it reads that file to find the Exec= line (to know what command to run) and the Icon= line (to know which icon to bounce).
  • Because StartupNotify=true is present, kstart6 sends a request to the Wayland Compositor (KWin) to start the animation.

These animation play as intended when I launch stuff via keyboard shortcuts/GUI methods, I was confused why its not working, so before I made this topic I asked Gemini AI - it said : might be some sort of a token like XDG_ACTIVATION_TOKEN is being used by system when launching apps normally. or might be Wayland security rejecting script-requested animations.

For reference, I’ve tried these methods :

  • kstart6 --application <ID> : Doesn’t Play Animation
  • qdbus6 org.kde.KLauncher /KLauncher startServiceByDesktopName <ID> "" : Doesn’t Play Animation
  • gio launch <desktop_file> : Doesn’t Play Animation
  • gtk-launch <ID> : Doesn’t Play Animation
  • Keyboard global shortcuts : Plays Animation
  • When opening files via Dolphin : Plays Animation (at least for Kate, VLC, Gwenview etc)

There is no kstart6 on Manjaro only kstart and kstart5, I think it depends on the window manager and how the system is generally composed.

Learned that a few hours ago, script must be running on kstart5 fallback the whole time, its now been updated.

Also decided to leave that animation alone, too complex to deal for such a small polish.
and added a new function with qml.

Script pulls the requested app’s icon and qml draws custom animation on the screen, Discovered that system doesn’t allow to pull icons from .desktop files, fortunately I was using custom icon for one of the apps which worked. So downloaded most used app’s icons and use a custom directory (Couldn’t find where flatpak puts all icons, only found some icons in exports folder).

kstart5 is just a link to kstart:

ls -la /usr/bin/kstart*
-rwxr-xr-x 1 root root 22840 Jan 14 06:49 /usr/bin/kstart
lrwxrwxrwx 1 root root     6 Jan 14 06:49 /usr/bin/kstart5 -> kstart

oh okay.

Phython

   try:
        subprocess.Popen(['kstart', '--application', target],
                         stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
    except FileNotFoundError:
        try:
            subprocess.Popen(['kstart6', '--application', target],
                             stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
        except FileNotFoundError:
            try:
                subprocess.Popen(['kstart5', '--application', target],
                                 stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
            except FileNotFoundError:
                try:
                    subprocess.Popen(target.split(), preexec_fn=os.setpgrp,
                                     stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                except Exception as e:
                    print(f"Failed to launch: {e}", file=sys.stderr)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.