How to ADD to default applications list?

Questions about applications and software
Forum rules
Before you post please read this

How to ADD to default applications list?

Postby FigNeutron on Tue Jan 22, 2013 12:39 pm

Hello friends:

Please take note of the title before responding......I know how to set the default programs for opening a file, however, I want to be able to execute my Python programs in terminal just by double-clicking, instead of opening terminal and typing...

Code: Select all
python /directory/location/of/file


Is there any way to add Python to the list of "Recommended Applications" list when setting this option? Or a custom command line for executing a file (found in LXDE or openbox environments).

Thank you in advance.

Regards,
FigNeutron

EDIT: After tinkering for a few minutes with the solution on this website...
http://www.libre-software.net/change-the-default-application-linux-mint-ubuntu
...I have managed to get terminal to open but it closes after a second. I can't even see the text that appears in the window. Any help?
FigNeutron
Level 1
Level 1
 
Posts: 3
Joined: Sat Jan 19, 2013 1:12 am

Linux Mint is funded by ads and donations.
 

Re: How to ADD to default applications list?

Postby xenopeek on Tue Jan 22, 2013 1:31 pm

This is what I have working for me (edit: I got this information from http://standards.freedesktop.org/deskto ... index.html). Open your file manager, press Ctrl+H to show hidden files and folders, and go to .local/share/applications in your home folder. Create a new text file, call it "python.desktop". Edit the python.desktop file and put the following in it:
Code: Select all
[Desktop Entry]
Type=Application
Name=Python
Exec=python %U
Terminal=true
MimeType=text/x-python;
Categories=Development;

Save and close the file, and in the Programming section of your menu you should now have an entry called Python. If you click that, a terminal will open and you will start an interactive Python session.

Now, in your file manager right-click a Python script of yours and from the context menu select Properties (this may only work on Cinnamon 1.6.7 with Nemo as your file manager). Then go to the "Open With" tab, and click on "Show other applications". In the list you will now find Python, so Add it and if you want "Set as default". If you now double-click a Python script of yours, it will be run on a terminal with the Python interpreter.

If you don't want your scripts to run in a terminal by default, replace "Terminal=true" with "Terminal=false".

The terminal will close as the application finishes. So if you want the terminal to stay open, edit your script to wait for user input at the end. For Python 2.7:
Code: Select all
raw_input("<Press ENTER to close>")

For Python 3:
Code: Select all
input("<Press ENTER to close>")

Edit 2: of course, if you make a Python script file executable and then double-click it--the file manager will ask you if you want to edit or execute it, without the need for any of the above...
User avatar
xenopeek
Level 21
Level 21
 
Posts: 14889
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: How to ADD to default applications list?

Postby FigNeutron on Tue Jan 22, 2013 2:45 pm

xenopeek wrote:This is what I have working for me....


Wow, excellent help.

I cannot say that it worked for me precisely following your directions, but I suppose that is the purpose of tinkering with computers, is it not? :)

I have, however, gotten it to work, and used a combination of your help and the website mentioned above and getting PCManFM for its versatile options for executing files. Thanks.
FigNeutron
Level 1
Level 1
 
Posts: 3
Joined: Sat Jan 19, 2013 1:12 am


Return to Software & Applications

Who is online

Users browsing this forum: alainPannetier, Google [Bot] and 16 guests