Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

Launching program in terminal

Sun Oct 13, 2013 6:00 pm

I am using mplayer to play a radio stream, instead of having to type out the whole URL every time i created a bash script that simply said:

Code: Select all

#!/bin/bash
mplayer http://whatever.mp3
This works fine when i run it from a terminal, i then got lazier still and decided to create a desktop shortcut to run the script so i created a .desktop file like this:

Code: Select all

[Desktop Entry]
Name=Planetrock
Comment=Planetrock
Exec=/home/pi/planetrock.sh
icon=/usr/share/icons/gnome/scalable/places/gnome-foot.svg
Terminal=True
Type=Application
StartupNotify=true
However this does not work, if i change the line to "Terminal=False" it then launches mplayer and begins to play the stream but it is in the background, it doesn't open a terminal so i cannot control mplayer with the keyboard shortcuts.
I know nothing about .desktop files so i just copied one that was already there and just modified it to suit my needs so there may be a few lines there i don't need. I have googled the line about the terminal and everywhere seems to say putting true there should open a terminal but it's not working for me.
Anybody got any ideas?
Cheers, Hiro.

User avatar
tony1tf
Posts: 53
Joined: Tue Jul 03, 2012 12:33 pm

Re: Launching program in terminal

Fri Oct 25, 2013 2:33 pm

Hi Hiro

Have you had success yet? I am struggling with the same problem to get a desktop shortcut to run a shell script. This particular one is to run mpide for generating code for the Chipkit Pi, and normally I open a terminal and cd to the directory and type ./mpide.
I tried to use Exec=<directory>./mpide in the desktop file, but that did nothing, either with Terminal=false (or true). I have managed to get an lxterminal to run with its working directory at the place where my code is. But as soon as I try to make lxterminal execute a command with --command='./mpide' or similar it falls over and doesn't do anything.
Here is the non-working code I have at the moment - saved on the desktop as mpide.desktop :

Code: Select all

[Desktop Entry]
Encoding=UTF-8
Type=Application
Path=/home/pi/mpide-0023-raspberrypi-20130920
Name=mpide
Name[en_GB]=mpide
Icon=/home/pi/mpide-0023-raspberrypi-20130920/lib/theme/mpide-icon.png
Exec=lxterminal --working-directory='/home/pi/mpide-0023-raspberrypi-20130920' -t 'mpide terminal' --command='./mpide'
Comment[en_GB]=start up Chipkit Pi desktop app
Terminal=false
StartupNotify=true
The -t '…' is supposed to give the terminal a title, but gets overwritten by the --working-directory='…' command.
If I remove the --command='./mpide' the terminal window opens and I can type ./mpide to start up the script, but with it in I see a terminal window flash up and then disappear.

I have read lots of posts on this but many people seem to have the same problem. BTW I tried creating the desktop file by copying another, or with the lxshortcut command which has been referred to elsewhere - makes no difference. It also doesn't seem to matter whether the desktop file is made executable or not - most of the normal desktop shortcuts do not have the execute flag set.

Frustratingly
Tony

Hiro
Posts: 78
Joined: Fri Dec 30, 2011 11:09 am

Re: Launching program in terminal

Tue Oct 29, 2013 8:38 pm

Hi Tony, i hadn't had any success at all until i read your post but you gave me an idea that worked for me. I don't know if it will work for you as i'm not sure we are trying to achieve exactly the same thing but below is what worked for me.

Code: Select all

[Desktop Entry]
Name=Planetrock
Comment=Planetrock
Exec=lxterminal  --command=/home/pi/planetrock.sh
icon=/usr/share/icons/gnome/scalable/places/gnome-foot.svg
Terminal=false
Type=Application
StartupNotify=true
The only thing i am curious about is the need to have "Terminal=false" there and it doesn't work if that is set for true.
I hope this is of some help to you but if not thanks for the idea as it certainly helped me.
Cheers, Hiro.

fawad ahmad
Posts: 3
Joined: Tue Mar 01, 2016 4:00 pm

Re: Launching program in terminal

Wed Mar 02, 2016 6:27 am

hey hiro

well i am doing the same job and searching for couples of days ,but your post help me alot and i am done with my task....
thanx man :)

actually i want a desktop aap for watsaapp,previously i have to write two commands on terminal then it goes on working ..now i just double click on it ,and here i m go
thank you

Return to “Troubleshooting”