Linux – Run Commands From It’s Icon

(Bu yazının Türkçesi için tıklayın)

Description :

Thanks to this file, we can start our programs without terminal even if it needs to get command on terminal to start (like Python programs) with double click to its icon (really .png icon 🙂 ) or we can write commands to facilitate our works.
Our examples will be thats :
-I have been writing FTassembler (will be published soon in my blog 🙂 ) program using Python and Tkinter (GUI). Firstly, we run this program just by double click without TERMINAL.
-After that, I share informations to copy a file from place to place by double click without terminal.

Running A Python Script By Double Click Without Terminal :

  1. Open text editor.
  2.  Copy the following text to text editor. (Also there is mine and a screenshot below as example)
    [Desktop Entry]
    Version=1.0
    Encoding=UTF-8
    Type=Type of our process
    Terminal=Choose whether to open the terminal 
    Name=Name of double click file
    Exec=Command(This command will run by terminal)
    Comment=Comment about process
    Icon=Icon's location
    Name[en]=English name of double click file

    My text :

    [Desktop Entry]
    Version=1.0
    Encoding=UTF-8
    Type=Application
    Terminal=false
    Name=KomutPython
    Exec=python3 /home/ft/CiftTiklama/FTassembler.py
    Comment=Assembler
    Icon=/home/ft/CiftTiklama/IconPython.png
    Name[en]=KomutPython
    

    Screenshot :

  3. After that, save your file as fileName.desktop to wherever you want.
  4. Finally, we need to set permission issue of fileName.desktop :
    Use command : chmod u=rwxst fileName.desktop

    Or use GUI :
    a) Right click to fileName.desktop.
    b) Continue with “Properties”.
    c) Go to “Permissions” tab and activate the “Execute”.
  5. After all these operations, .desktop part of fileName will be invisible and you will be able to run the program wherever you want.

Screenshot after the bouble click to my command file : (No terminal)

 

As you know, this is not only to run our Python programs. This can also be used formany different processes. For example, to copy a file by double click, your fileName.desktop should be like this :

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Type=Application
Terminal=false
Exec=cp /home/ft/Desktop/Target.png /home/ft/Desktop/CopyOfTarget.png
Comment=Copy a file
Icon=/home/ft/Desktop/CopyIcon.png
Name=CopyCommand 
Name[en]=CopyCommand

Name of this process is Desktop Entry. You can find more info about Desktop Entry from Google.
My OS : Ubuntu 14.04

1 yorum

Bir yanıt bırakın