Skip to content

Instantly share code, notes, and snippets.

@Abdallah-Abdelazim
Last active March 10, 2022 22:04
Show Gist options
  • Save Abdallah-Abdelazim/b58a5e48be1de6b93148139282219ec0 to your computer and use it in GitHub Desktop.
Save Abdallah-Abdelazim/b58a5e48be1de6b93148139282219ec0 to your computer and use it in GitHub Desktop.
Linux Bash script to start an application minimized (useful for autostart minimized on login)

To start an application minimized (like the Todoist snap as in below), create a script similar to the following.
You can add the script to autostart on login in your DE.

#!/bin/bash
# Launch Todoist as a background process
/var/lib/snapd/desktop/applications/todoist_todoist.desktop&
# Loop, waiting for the window to initialise
i=0
while [ $i -lt 20 ]
do
        sleep 1
        # check if the window can be found
        window=`wmctrl -l|grep "Todoist"`
        if [ "$window" != "" ]
        then
                # Found the window
                for w in $window
                do
                        # Minimise the window
                        xdotool windowminimize $w
                done
                break
        fi
done

Source: https://www.reddit.com/r/kde/comments/b0k01e/start_application_at_login_minimized/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment