How to create a starter script for your applications in Linux

I want to tell you the story of Ted. He is a friend who is passionate about computer science and a passionate Linux user. Every day, Ted starts his day by turning on his PC and starting the applications necessary for his daily work, let’s talk about the classic email clients, browsers, chats, and more.

Every day, Ted repeats the same gestures. Every day, every week, every month, every year. Click, click, and click again. And then, finally, it can really work on content. One day, Ted had a nice idea: why not create a script that makes all the applications start at once, so as to find my desk ready for work in a moment?

Here’s how Ted created his personal script launcher, the ‘starter’.

The starter. A bash script to simplify and automate the work routine

A starter is a script that acts as a launcher for different applications and with just one click you’ll be able to launch more applications at one time. In the video above, we show you how to create a script to launch 4 different applications, in particular Thunderbird, Telegram Desktop, Firefox, and Google Chrome. And also how to assign a different virtual desktop to every app and also how to autostart the script at log-in so you can have your work desktop ready at start-up.

Note – In the video, every application has a specific virtual desktop assigned. We used the KDE desktop environment and to do this you need to right-click the tab-bar of the application and select More Action > Configure app settings > Desktop > Apply initially > then select the virtual desktop number of your choice. For other desktop like GNOME or Xfce, you can do the same with settings or extensions.

To create a starter, first you need to create a launcher bash script to launch the applications. In this example, we create a starter.sh script file in the hidden ~/.scripts folder. So, in a terminal session:

$ mkdir ~/.scripts

$ touch ~/.scripts/starter.sh

Edit the created file with your text editor of choice. CTRL-H to show hidden folder in the file manager and double-click (or single for KDE and Elementary) on the script file. Alternatively, in the terminal session:

$ vim ~/.scripts/starter.sh

And populate it whit something like this:

!/bin/bash
/usr/bin/thunderbird &
/usr/bin/telegram-desktop -- %u &
/usr/bin/firefox &
/usr/bin/google-chrome-stable %U &
exit 0

Make the script executable:

$ chmod +x ~/.scripts/starter.sh

Now, we need to create the system-wide launcher and provide it with a icon.

$ touch ~/.local/share/applications/Starter.desktop

And edit it with your editor of choice or in a terminal:

$ vim ~/.local/share/applications/Starter.desktop

Fill it with this code:

[Desktop Entry]
Categories=Utilities;
Comment[en_US]=
Comment=
Exec="/home/cialu/.scripts/starter.sh"
GenericName[en_US]=Starter
GenericName=Starter
Icon=alienarena
MimeType=
Name[en_US]=Starter
Name=Starter
Terminal=false

As you see, you must put the full path to the script, so change this:

Exec="/home/cialu/.scripts/starter.sh"

With your username:

Exec="/home/<your-username-here>/.scripts/starter.sh"

Also, for the icon we selected the default KDE alienarena icon, but you can choose the icon you want or also download a new one from the Internet and put the path-to-icon in this line:

Icon=alienarena

As an example, if you put the downloaded icon in the same .scripts hidden folder, something like this:

Icon="/home/<your-username-here>/.scripts/<icon-downloaded-from-internet>.png"

Save all and that’s done. Now, open your application launcher and you’ll find the Starter app with the selected icon. Click on it and the applications will start.

For a more automated process, you can make the script autostart at login so you can have your work desktop ready at every start. To do this, put the script in the Autostart session of the KDE (GNOME, Xfce, and others provide something similar too) system settings. Alternatively, you can put the path to the script (/home/<your-username>/.scripts/starter.sh in this case) in the ~/.profile hidden file.

In the video, we explained step by step, but if you need more help ask it in the comments below.

Addition

If you want to assign applications a specific desktop to work on DEs that do not have this functionality such as Xfce, you can use a small utility called wmctrl. It is a command-line tool to interact with an EWMH/NetWM compatible X Window Manager and is perfectly useful for the purpose. Once installed, simply edit the script as follows:

!/bin/bash
/usr/bin/thunderbird &
/usr/bin/telegram-desktop -- %u &
/usr/bin/firefox &
/usr/bin/google-chrome-stable %U &
/usr/bin/wmctrl -i -r thunderbird -t 1 &
/usr/bin/wmctrl -i -r telegram-desktop -t 1 &
/usr/bin/wmctrl -i -r firefox -t 2 &
/usr/bin/wmctrl -i -r google-chrome-stable -t 3 &
exit 0

You can find wmctrl in our GitHub repository: https://github.com/cialu-net/wmctrl.