Start a program in the terminal from a launcher
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.
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.
- Cannondale
- Level 3
- Posts: 114
- Joined: Mon Jan 02, 2023 11:27 am
Start a program in the terminal from a launcher
New to LM and running Cinnamon 21.
I have a python script that I would like to execute from a desktop launcher.
Is this possible or would I have to wrap the python call in a bash script and call the bash script from the launcher?
I have not been able to find the correct launcher syntax.
I have a python script that I would like to execute from a desktop launcher.
Is this possible or would I have to wrap the python call in a bash script and call the bash script from the launcher?
I have not been able to find the correct launcher syntax.
Last edited by LockBot on Tue Sep 19, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
First computer: Radio Shack Computer TRS-80 Model 3. Zilog Z80 2.03 MHz CPU, 16k RAM, Two floppy drives, TRS-DOS (BASIC included)
Re: Start a program in the terminal from a launcher
You can execute it directly as say
and do a
/where/ever/script.py
(from a launcher or otherwise) if you make it executable, i.e., if you have it start with e.g.Code: Select all
#!/usr/bin/env python3
chmod +x /where/ever/script.py
. You can alternatively also execute it explicitly as python3 /where/ever/script.py
(which is what the above ends up doing anyway); certainly never an intermediary bash script is needed.- Cannondale
- Level 3
- Posts: 114
- Joined: Mon Jan 02, 2023 11:27 am
Re: Start a program in the terminal from a launcher
Thanks for the information rene. I have the following in my launcher and nothing happens when double clicked.
Command:
/home/jer/rsync_bk2_menu.py
Note that the python script runs fine when executed from the terminal. What am I missing?
Command:
/home/jer/rsync_bk2_menu.py
Note that the python script runs fine when executed from the terminal. What am I missing?
First computer: Radio Shack Computer TRS-80 Model 3. Zilog Z80 2.03 MHz CPU, 16k RAM, Two floppy drives, TRS-DOS (BASIC included)
-
- Level 8
- Posts: 2187
- Joined: Wed Aug 14, 2019 1:02 am
Re: Start a program in the terminal from a launcher
Does your python script exit immediately after finish running? If so, the terminal window can't persist and will exit together too if you run from launcher or double click the file icon. Add an
Method 2: Keep the script as is. But in Terminal, Edit > Preferences > Command > When command exits: > "Hold the terminal open"
input()
to the end of your script if you want to keep the terminal output in view.Method 2: Keep the script as is. But in Terminal, Edit > Preferences > Command > When command exits: > "Hold the terminal open"
- Cannondale
- Level 3
- Posts: 114
- Joined: Mon Jan 02, 2023 11:27 am
Re: Start a program in the terminal from a launcher
I created a test python script called test.py with only an input statement.
Created a new launcher to launch test.py.
Launcher still does nothing when double clicked.
Created a new launcher to launch test.py.
Launcher still does nothing when double clicked.
First computer: Radio Shack Computer TRS-80 Model 3. Zilog Z80 2.03 MHz CPU, 16k RAM, Two floppy drives, TRS-DOS (BASIC included)
Re: Start a program in the terminal from a launcher
Code: Select all
gnome-terminal -- /home/jer/test.py -q
man gnome-terminal
for more info.This assumes your script starts with the shebang described by rene and you have made it executable.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
- Cannondale
- Level 3
- Posts: 114
- Joined: Mon Jan 02, 2023 11:27 am
Re: Start a program in the terminal from a launcher
Thanks Andy! That was the syntax!
man page link also very helpful!
man page link also very helpful!
First computer: Radio Shack Computer TRS-80 Model 3. Zilog Z80 2.03 MHz CPU, 16k RAM, Two floppy drives, TRS-DOS (BASIC included)
Re: Start a program in the terminal from a launcher
A somewhat better -- since it uses the configured terminal application rather than hard-coded gnome-terminal -- alternative to Andy's above reply is making sure the launcher has
It seems that choice is in Cinnamon not provided via checkbox in the supposedly rclick->Properties screen you get in Cinnamon/Nemo you're posting screenshots of? Certainly it is in Xfce (in the "Launcher" tab of said properties) but I've noticed Cinnamon to be wonky in similar respect before. Even then though I am pretty sure at least that you get that option while creating the launcher, so I suppose you won't have missed it. What in any cased works is rclick->"Open With" a text editor and adding
Terminal=true
.It seems that choice is in Cinnamon not provided via checkbox in the supposedly rclick->Properties screen you get in Cinnamon/Nemo you're posting screenshots of? Certainly it is in Xfce (in the "Launcher" tab of said properties) but I've noticed Cinnamon to be wonky in similar respect before. Even then though I am pretty sure at least that you get that option while creating the launcher, so I suppose you won't have missed it. What in any cased works is rclick->"Open With" a text editor and adding
Terminal=true
manually.- Cannondale
- Level 3
- Posts: 114
- Joined: Mon Jan 02, 2023 11:27 am
Re: Start a program in the terminal from a launcher
Thanks for the additional information rene!
First computer: Radio Shack Computer TRS-80 Model 3. Zilog Z80 2.03 MHz CPU, 16k RAM, Two floppy drives, TRS-DOS (BASIC included)
Re: Start a program in the terminal from a launcher
Yes, you don't get that option with cinnamon, so you can either follow rene's suggestion (probably the simplest), or a route to the same answer and bit of background...
Everything you see on the desktop is a .desktop file in
The same is true for everything you see in the mint menu, they live in
Everything you see on the desktop is a .desktop file in
/home/you/Desktop
, they are text files following a defined format, you can go there and edit the files. A sample entry (for a HP15C calculator emulator I manually installed):
Code: Select all
[Desktop Entry]
Encoding=UTF-8
Name=HP15C
Exec=hp15c
Comment=
Terminal=false
Icon=hp15c.png
Type=Application
Name[en_GB]=HP15C
GenericName=HP15C
StartupNotify=false
Categories=Utility
/usr/share/applications
or $HOME/.local/share/applications
.Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Re: Start a program in the terminal from a launcher
Cinnamon/Nemo doesn't even when creating the launcher provide for setting a working directory, which has been an issue quite a few times as well. Seems that launcher interface should be overhauled, dragging it out of the GNOME "possibilities are confusing" morass.
Re: Start a program in the terminal from a launcher
Out of interest, what is the setting in a .desktop file for that?
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Re: Start a program in the terminal from a launcher
Path=
; viewtopic.php?t=392839 (by the way; if someone wonders why I'd say "quite a few times" if I'd seem unaware until that recent thread: it has in fact been quite a few times but I only later remembered; searching the forum yields many more of those threads).- Cannondale
- Level 3
- Posts: 114
- Joined: Mon Jan 02, 2023 11:27 am
Re: Start a program in the terminal from a launcher
Thanks Andy! This additional information provided the context I needed to get the big picture. I added Terminal=true to my particular launcher, as rene suggested, and removed "gnome-terminal --" from the launcher properties. Works great!AndyMH wrote: ⤴Sun Mar 19, 2023 1:00 pm Yes, you don't get that option with cinnamon, so you can either follow rene's suggestion (probably the simplest), or a route to the same answer and bit of background...
Everything you see on the desktop is a .desktop file in/home/you/Desktop
, they are text files following a defined format, you can go there and edit the files. A sample entry (for a HP15C calculator emulator I manually installed):The same is true for everything you see in the mint menu, they live inCode: Select all
[Desktop Entry] Encoding=UTF-8 Name=HP15C Exec=hp15c Comment= Terminal=false Icon=hp15c.png Type=Application Name[en_GB]=HP15C GenericName=HP15C StartupNotify=false Categories=Utility
/usr/share/applications
or$HOME/.local/share/applications
.
Thanks to both of you again!
First computer: Radio Shack Computer TRS-80 Model 3. Zilog Z80 2.03 MHz CPU, 16k RAM, Two floppy drives, TRS-DOS (BASIC included)
Re: Start a program in the terminal from a launcher
FWIW I use crazy commands like this in a launcher to run my Perl programs:
Code: Select all
gnome-terminal -- bash -c "cd /home/mike/Documents/00MikeF && sleep 0.2 && /usr/bin/perl drgopen.pl && sleep 0.2 && exit; exec bash -i"
- Cannondale
- Level 3
- Posts: 114
- Joined: Mon Jan 02, 2023 11:27 am
Re: Start a program in the terminal from a launcher
You're a wizard Mike!
First computer: Radio Shack Computer TRS-80 Model 3. Zilog Z80 2.03 MHz CPU, 16k RAM, Two floppy drives, TRS-DOS (BASIC included)