Score:0

Desktop shortcut from a .sh with a delay

ps flag

I want to have a desktop shortcut for TWO apps in .sh format with a 15 seconds' delay between them during the launch. Is it possible? What kind of script I have to do for that? If anyone can give me an exemple please? (Ubuntu desktop 22.04)

Thx guys!

guiverc avatar
cn flag
there is a BASH/shell command `sleep` that allows you to specify how many seconds to delay; why not use it between the execution of apps?
Pinedours avatar
ps flag
Normally I launch the two apps with cli. But it's for launch rapidly with double click for users who doesn't know bash command..
Pinedours avatar
ps flag
I don't know what I have to write in the script, I never did that. Usually I copy paste existent scripts I find on internet, but I didnt find this. '
Score:0
cn flag

For sure it is possible! In any .sh script, you can combine as many commands as you wish! Then use the sleep command to include a delay.

1. Create a launcher script: Thus, if you have two apps, myapp1.sh and myapp2.sh, make a third app for example myapplauncher.sh, with the contents

#!/bin/bash
myapp1.sh &
sleep 15
myapp2.sh

This launches the first app and forks it to the background (by adding the &). Thus, the script immediately proceeds with a sleep 15 command, introducing the 15 second pause. Then the second app is launched.

2. Create a .desktop launcher: The next step is to make a .desktop shortcut for myapplauncher.sh.

The easiest way may be to install a tool "Alacarte" or "MenuLibre". This provides a graphical interface to create desktop launchers.

Alternatively, create a .desktop launcher yourself. It should contain at minimum:

[Desktop Entry]
Name=Editor
Exec=gedit
Type=Application

You can add a comment (Comment=...), specify an icon (Icon=...), and more. You can see many examples of .desktop files under /usr/share/applications.

When finished creating the .desktop launcher, copy it into ~/.local/share/applications if it has to appear in the menu of your user only, or into /usr/local/share/applications if the launcher should be available for all users. To achieve the latter, you need root permissions.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.