(SOLVED) How to create a launcher with consecutive commands?

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
ericramos1990

(SOLVED) How to create a launcher with consecutive commands?

Post by ericramos1990 »

Hi guys can anyone help me out?

I am trying to make a countdown timer with the sleep command and then having my music player (clementine) start with a song.

I came up with the following command:

sleep 10m && clementine '/home/eric/Music/Boom.mp3'

It works just fine in terminal, but I want to make it a simple launcher, but when I do, it just instantly closes.

I tried making launchers of the separate commands "sleep 10m" and "clementine '/home/eric/Music/Boom.mp3'" and they work, but when I make them into one single command with &&, it does not work.

I have tried making a launcher with the types "Application" and "Application in Terminal" and they both don't work.

Please give me your advice, thank you fellow minties =)
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
karlchen
Level 23
Level 23
Posts: 18173
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: How to create a launcher with consecutive commands?

Post by karlchen »

Hello, ericramos1990.

Create a simple shell script which executes the commands.

Code: Select all

#!/bin/bash
sleep 10m
clementine '/home/eric/Music/Boom.mp3'
Save the shell somewhere in your home folder. I use ~/Scripts. You might also use ~/bin. - You may have to create either folder.
Do not forget to make your script executable.

Code: Select all

chmod +x /path/to/scriptname
No need to tell you that you have to replace /path/to/scriptname by the real path and scriptname.
Finally create your launcher and tell it to execute the script.

HTH,
Karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
ericramos1990

Re: How to create a launcher with consecutive commands?

Post by ericramos1990 »

karlchen wrote:Hello, ericramos1990.

Create a simple shell script which executes the commands.

Code: Select all

#!/bin/bash
sleep 10m
clementine '/home/eric/Music/Boom.mp3'
Save the shell somewhere in your home folder. I use ~/Scripts. You might also use ~/bin. - You may have to create either folder.
Do not forget to make your script executable.

Code: Select all

chmod +x /path/to/scriptname
No need to tell you that you have to replace /path/to/scriptname by the real path and scriptname.
Finally create your launcher and tell it to execute the script.

HTH,
Karl
Hey Karl, thank you so much! Just starting Linux, and slowly learning new tricks. Thanks to you now I understand scripts somewhat, I am so excited to experiment and make my own!
Once again thanks! =)
User avatar
karlchen
Level 23
Level 23
Posts: 18173
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: (SOLVED) How to create a launcher with consecutive comma

Post by karlchen »

Hello, ericramos1990,

you're welcome and thanks for your feedback. :-)

Cheers,
Karl
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 762 days now.
Lifeline
pbanerjee

Re: (SOLVED) How to create a launcher with consecutive comma

Post by pbanerjee »

Not sure if this is best thread to ask my question.. will try out anyway.

I have a simple shell script that calls a package "apt-hotspot" to setup wifi hotspot on laptop using sudo login. The script is working fine when I run from command line.

My question is how can I execute my shell script from desktop without opening command line prompt?
I created a Launcher but it doesn't do anything.

Any idea buddys?

Cheers
pbanerjee

Re: (SOLVED) How to create a launcher with consecutive comma

Post by pbanerjee »

ok, I tried again using Desktop Launcher with "Run in Terminal" and it starts and executes correctly.
However, my script uses sudo to run a package. I don;t want the ecript to prompt for sudo password while executing. I have inserted "Here Document" within script that contacts my sudo password. But it is still prompting when I run from Desktop Launcher but doesn't prompt when I execute the script from command line.

My script:

Code: Select all

#!/bin/sh
sudo <<"EOF1"
MyPassword"\n"
EOF1
sudo ap-hotspot configure <<"EOF2"
ppp0
wlan0
MyWiFi
MyWiFiPassword
EOF2
sudo ap-hotspot start
How can I suppress the sudo password prompt when I execute from Desktop Launcher ?
User avatar
catweazel
Level 19
Level 19
Posts: 9763
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: How to create a launcher with consecutive commands?

Post by catweazel »

karlchen wrote:

Code: Select all

chmod +x /path/to/scriptname
No need to tell you that you have to replace /path/to/scriptname by the real path and scriptname.
So why did you tell him? :mrgreen: :mrgreen: :mrgreen:
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
ericramos1990

Re: (SOLVED) How to create a launcher with consecutive comma

Post by ericramos1990 »

LOL! My guess is that Linux users just can't help being awesome!
Locked

Return to “Beginner Questions”