Linux - recommended apps to open a file - linux

In Ubuntu Linux, let's say I create a simple text file. When I right click that file, there is option to open with other application. It will show a list of recommeded applications which could open a text file.
My question is that how does the OS know which app can open that file ? What does the app developer have to do to make it a candidate ?
Edit : What I also want to ask is that does the OS verify this in any way (that the developer has specified the app to open a particular file format) ; for e.g. a video playing application could mention itself to open a text file, but when the user tries to use it, there will be a problem.

Try creating Your app's .desktop file for showing your app in the Open with other application dialog. the .desktop file should look something like this
[Desktop Entry]
Encoding=UTF-8
Name=<appName>
Comment= some detail about the app
Exec=<appName> %u
Terminal=true
Type=Application
Icon=/usr/share/pixmaps/<appName>.svg
Categories=Application;Utility;TextEditor;
StartupNotify=true
MimeType=text/plain;
NoDisplay=true
Save this as ~/.local/share/applications/<appName>.desktop and the application will be automatically shown on Open with other application to be selected as default application.
The options for the .desktop files are many but its important to know what they mean.
nautilus-actions.org supplies a very good guide and explanations for creating your .desktop files and all the possible parameters that you can use on them so if you have any doubts about creating a special .desktop file you can visit the site and look at the examples there.
Note:- not sure if OS verifies if its a video playing application or not, but even if it would it will verify with MimeType and if the app have txt/plain and it a video player it would fail, but again i'm not sure on this.

Related

How can I put my GTK application in the desktop menus?

I started with programming a little time ago and I created my first running application with GTK 3.0. I did not use Glade, I do not know if worth highlight it. My code is working perfectly, but now I have a doubt, how can I make my own desktop menu application? I mean, I want that my application running up without compile in a terminal with GTK 3.0 compiler, but yes with a double click.
I have been seen these examples provided by GNOME Developer Center, but I confess that did not understand it: https://developer.gnome.org/integration-guide/stable/desktop-files.html.en#ex-sample-desktop-file
The idea is to create a file containing this sequence of lines:
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Sample Application Name
Comment=A sample application
Exec=application
Icon=application.png
Terminal=false
This file is my executable or it is a different file which points to my executable? If it is my executable, where can I insert it?
Thank you!
So basically this file will create a desktop entry for those configurations you provide for the corresponding directives in the file. Judging by your question, you are unable to find where to place your application executable in that directive.
Exec="/absolute/path/to/your/executable/file"
And the Name directive will hold the information of your application name. This is the one you will be querying for in your gnome applications search (which appears when you press the windows key).
This file will contain a .desktop extension. And this file itself is not executable. This will point to your application, making the gnome/ubuntu system understand that such application exists.
This will not directly create a desktop shortcut as in Windows, rather this will index your application which you can run from the application menu (ubuntu or gnome)
If you aren't sure where to place the file here's a hint from the documentation you linked.
Place this file in the /usr/share/applications directory so that it is accessible by everyone, or in ~/.local/share/applications if you only wish to make it accessible to a single user

Desktop icon in linux ubuntu qt [duplicate]

This question already has an answer here:
Qt Creator - how to set application icon for ubuntu linux?
(1 answer)
Closed 8 years ago.
Can someone give me a strait up answer on how to set up application icon in linux.
I have an application developed in Qt and I wont to show it on desktop but I wont to change it's default icon. I know that in linux I can't make icon as part of binary but how to connect icon with application?
Thanks...
Unix binaries don’t know about the concept resources of icons. Instead, a desktop entry file is used to describe each application. These files have the file name extension of desktop and are usually stored in $XDG_DATA_DIRS/applications or /usr/share/applications.
An Example of a .desktop file:
[Desktop Entry]
Type=Application
Name=My Application
Exec=myapplication %F
MimeType=image/x-mydata;
Icon=/install/path/myicon.png
The line reading [Desktop Entry] tells you that what follows is an entry for a desktop entry. Next is Type, which tells you that the entry will describe an application. According to Name, the application is called My Application. The Exec line tells the desktop what command to issue to start the application; in this case, it is myapplication. The %F part tells the desktop where to list the file names if a user starts the application by trying to open one or more data files. The connection between these data files and the application is handled using the MimeType entry that defines the mime type; that is, the file type that the application handles. The last line, Icon, tells you which icon to use. The easiest way is to specify an absolute path to the icon. If you specify only the file name, you must determine where to store the icon file so that the desktop environment can find it.
When installing applications on Unix, it is common to support the make target install,
which enables the user to type make install to copy the application files to a global location.
This is supported by QMake using install sets.

Program File saved file

I have developed an application in Visual Basic.net. When I install this application to a ProgramFiles/[Appname] folder, and I create a file that is saved in the same folder (a settings file, created from in the application), the file is not visible, yet the application can still read it.
Where is this file saved?
On Windows Vista and higher, writing to the Program Files directory requires administrative privileges. Your file is probably being affected by virtualization (a redirection of the write operation) to the virtual store. You can find it (in Windows 7) in C:\Users\<username>\AppData\Local\VirtualStore.
The obvious solution is not to try to save the settings in the wrong location in the first place. Your app should create a folder under %APPDATA%, and write it's settings there instead. This answer to a related question can provide some links that might help.

How to add new Mime Type and associate with new application?

I have a new file type ".xy2" and I would like to associate it with a custom application "shim". Does anyone know how to do it in a Linux?
Thanks
In case someone comes across the same problem. I found the answer:
Create new Mime Type. You can specify a different mime-type, in this video the author is using text, but you can use application or image etc.. All available types are listed in "usr/share/mime" folder.
Create your custom application and put a symlink into "usr/bin" folder.
Navigate to "~.local/share/applicatons" folder and create new_mime_name.desktop file.
Fill in information pertaining to your application. Here is an example of mine:
[Desktop Entry]
Terminal=false
Icon=libreoffice-math
Type=Application
Categories=Application;Utility;
Exec=shim %f
MimeType=application/xy2;
Name=shim
Comment=shim tool
Associate file types with your application. Read post from OM55 user.
You might need to reboot your system.

Can i merge icon with executable application in linux?

if you made up an application in linux you will get a blank ugly icon
but if i wanted to add an icon without going and make a desktop entry , is it possible ?
if i uploaded my portable app to the internet i would like that users see the icon merged to my portable app ! :)
Thanks
For scripts probably not, but for ELF binaries seen under Gnome (nautilus) you can try
elfres
http://www.compholio.com/elfres/
Most desktop environments on Linux follow the freedesktop.org Desktop Entry Specification for application descriptions and icons. You'll need a separate .desktop file in one of the XDG directories (specifically, applications within one of $XDG_DATA_DIRS) which will list an icon (which is an image file in another directory).

Resources