User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 
In my previous post I showed the code I used to create a temperature monitor for my Raspberry Pi. All well and good but a bit messy when running from a terminal unless you alter the row and column it prints at or clear the screen first.
What I wanted to do then was create a desktop shortcut. The following info applies to anything really that you need a shortcut to.

First thing to note is that when you create a shortcut and double click it that a popup appears saying the file seems to be an executable and asking what you want to do with it. Very annoying and took a lot of Googling to find, so lets straighten that out as a starting point.

It will say something along the lines of "The text file 'System Temperature' seems to be an executable script. What do you want to do with it?"

Open File Manager and navigate to Edit/Preferences. Tick the box that says "Don't ask options on launch executable file". Close the preferences you're done!

In your File Manager navigate to /home/pi/desktop/
Right click in the large pane and click on Create New/Empty File
Name the file System Temperature.desktop - a new text file icon will  appear - right click and select Text Editor
Paste the following code into this empty file.

[Desktop Entry]
Name=System Temperature
#Use the name of the script you created if different

Exec=python temp-mon.py 
#This is just a picture I downloaded from the internet into my pictures folder 

Icon=/home/pi/Pictures/thermometer_PNG93.png 
Terminal=true
Type=Application
Path=/home/pi/
GenericName=System Temperature
Comment[en_US]=System Temperature
StartupNotify=false
X-KeepTerminal=true

Save the file and close the editor and File Manager - you should now see an Icon with your file name on the desktop - double click and a terminal will open showing the system temperature.

If you get an error about xterm try either installing or reinstalling xterm or create a symbolic link to lxterminal that can be called by xterm with the command 
sudo ln -s /usr/bin/lxterminal /usr/bin/xterm