How to execute a program so that it open in terminal?

How do i run a executable program with double click but let it open in terminal (was generated by pyinstaller) and is for logging. So its prints its output in the terminal. If i run it over the terminal ./program it works. But how do i let it open over the double click in terminal mode?

Get a list of your apps:

ls -la /usr/share/applications

Edit the .desktop file for your app(s) to read “Terminal=true”:

sudo nano /usr/share/applications/<app-name>.desktop

To save changes press Ctrl+O and ENTER.
Exit nano with Ctrl+X.

1 Like

its not listed there. I compiled it with pyinstaller. So i think i have to add it first?

You can add apps by right-clicking (Whisker)Menu > Edit Menu > Add user application (something along those lines - my menu is not in english). Then tick “Run in terminal”.

You probably dont want to sudo edit the system file anyways.
But rather create/copy/edit the desktop file in ~/.local/share/applications/

1 Like

Even better.

So i did the following
(pybot) [eisbergsalat@eisbergsalat-pc wurmbot]$ touch ~/.local/share/applications /wurmbot.desktop
(pybot) [eisbergsalat@eisbergsalat-pc wurmbot]$ mousepad ~/.local/share/applications/wurmbot.desktop
(pybot) [eisbergsalat@eisbergsalat-pc wurmbot]$ cat ~/.local/share/applications/wurmbot.desktop
Terminal=True

For those who wanna know. It just a discord bot and i dont want to open each time a terminal and write ./name
But its not working. My executable doenst have a extention just the Name. Do i have to move it somewhere? EILI5 pls

If it’s not in your $PATH, you have to specify the file’s location /path/to/file.

Thats not enough … you still need things in that Desktop file.

Things like:

[Desktop Entry]
Comment=
Exec=pinball
Name=Pinball
NoDisplay=false
Path[$e]=
StartupNotify=true
Terminal=0
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=
[Desktop Entry]
Type=Application
Version=1.0
Name=GoogleDriveJ
Comment=Google Drive cloud storage
Path=/usr/bin
Exec=jak-cli --url https://www.google.com/drive/ --title GoogleDriveJ --icon applications-internet --online true
Icon=applications-internet
Terminal=false
Categories=Network;
1 Like

So like this seems what im looking for?
So Path = the path to the executable?
and exec will be just the name? wurmbot ?

[Desktop Entry]
Type=Application
Version=1.0
Name=Wurm Bot
Comment=Wurm Bot
Path=/home/eisbergsalat/projects/wurmbot/dist/
Exec=./wurmbot
Icon=applications-internet
Terminal=True
Categories=Entwicklung;

Looks liek this now but it crashes on start up. Ok seems like error on my side. Will fix it.

yup.

~/.local/share/applications/wurmbot.desktop

[Desktop Entry]
Type=Application
Name=Wurmbot
Comment=Stuff I say about wurmbot
Path=/PATH/TO/WURMBOT
Exec=wurmbot
Icon=applications-internet
Terminal=true
TerminalOptions=
Categories=Development;

Something like that ^

EDIT. Oh you edited in yours…

First make Terminal=true lowercase… for giggles.
Also the Exec line I dont think you need to include ./

2 Likes

So is working now. Thanks very much. And thank you for the patience and the EILI5. Im currently a bit to much on essential pain killers and cannt really think straight.

If i dont add ./ infront of the wurmbot it doenst work and i get file not found error

[Desktop Entry]
Type=Application
Name=WurmBot
Comment=Wurm Bot
Path=/home/eisbergsalat/projects/wurmbot/dist/
Exec=./wurmbot
Icon=applications-internet
Terminal=true
Categories=Entwicklung;

I do i add a terminal title?

You are welcome, Glad its working then :slight_smile:

I am not sure what you mean by terminal title?
Which terminal emulator to use, or display title on a tab, or ? …

I mean the executable will open within the terminal, or open a terminal and prints its results there. That terminal title i want to set to “Wurm Bot”. Iam using xfce-terminal.
If i run xfce4-terminal -T “Wurm Bot” i get a terminal with that name

I see.
In current state you can probably set options in TerminalOptions line with T title or --title=title, as that is an option of xfce4-terminal. (but note this is considered a deprecated entry)

You could also go about it another way… even skip the Path part (remove it)
And then use something like

Exec=xfce4-terminal -e "bash -c '/path/to/wurmbot'"

Which should do that for you probably … and you could also throw the -T title option in there too.

2 Likes

Now it working.
Terminaloptions didnt work for me but the exec works

[Desktop Entry]
Type=Application
Name=WurmBot
Comment=Wurm Bot
Exec=xfce4-terminal -T “Wurm Bot” -e “bash -c ‘/home/eisbergsalat/projects/wurmbot/dist/wurmbot’”
Icon=applications-internet
Terminal=true
Categories=Entwicklung;

Ah there we go.
Yeah its been a while making one all specific for a terminal application.
I only just now learned the “TerminalOptions” entry was deprecated :stuck_out_tongue:
https://developer.gnome.org/desktop-entry-spec/

Cheers.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.