What is the function of the .desktop file in desktop Linux distributions? - linux

I have the following situation: I have to modify a .desktop file that is into the package of an application of which I am working.
I have a strange problem that happens when I try to open the content of the file. If I click on it and then I try to click on "Open" it give me an error message that means in English: "LAUNCHER OF APPLICATIONS UNRELIABLE"
The only way to open the .desktop file is for me is to run the following shell command:
sudo gedit myApplication.desktop
Why is this so? Why does the error message appear when I try to open the .desktop file normally?
The content of the .desktop file is:
[Desktop Entry]
Icon=myApplication
Categories=Utility;
Type=Application
Exec=/usr/share/MyApplication/appl/launcher.sh
Name[en_US]=Connect Data Space
Name=My Application Name
Comment[en_US]=
Comment=
StartupNotify=true
Terminal=false
OnlyShowIn=GNOME;Unity;
StartupWMClass=MyApplication
Actions=CheckUpgrade
[Desktop Action CheckUpgrade]
Name=Verifica Aggiornamenti
Exec=java -jar /usr/share/MyApplication/appl/lib/shellExtBridge.jar -checkupgrade
OnlyShowIn=GNOME;Unity;
And now I have some doubts about it:
1) Icon: reading some documentation it seems to me that if I put an icon called myApplication.png inside the folder /usr/share/pixmaps of my package, it use this icon, is it right?
2) Exec: reading some documentation it seems to me that this field specifies the path to the file that is executed when my icon is clicked, is it right? But in this case what file is executed? /usr/share/MyApplication/appl/launcher.sh or /usr/share/MyApplication/appl/lib/shellExtBridge.jar -checkupgrade.
I think the first file is executed, but then what is the functionality of the file in the second Exec statement?
In general, what is the functionality of the .desktop file? It seems to me that it only adds my application icon to the Unity toolbar to start my application clicking on it. Is that right, or is there additional functionality of the .desktop file?

The .desktop file is a shortcut that points to the executable and add an icon to that particula shortcut.
have you noticed all the .desktop files in /user/share/applications It's there all the shortcuts are gathered. You may take some inspiration from there.
that depends on which icon you point the .desktop file to. (i'm not sure about this one but the icon could also be stored in /usr/share/icons)
yes it's right. The Exec field specifies which file that should be executed. It's the [desktop entry] you should look at so it's the /usr/share/MyApplication/appl/launcher.shfile that is executed
As I can see it will give your shortcut an icon, a name and it will point the shortcut to the /usr/share/MyApplication/appl/launcher.sh file. The StartupWMClass property will do so that your application dosen't actually create a new open application icon in unity instead it will light up the shortcut you already created.
check out this for more info about that.
the Category property Categories=Utility; is made so that gnome2, gnome-fallback, xfce and MATE desktop environments can place the shortcut at the correct position(because they have menus).
i can't tell what the last 4 lines in the desktop file does but i think they are executed when you run the app updater. so that your java app updates itself. Or it will create an update entry when you right click on the icon in the unity launcher so that you can update it through the small right-click menu (but i don't know)
I'm not sure about all this, so correct me if i'm wrong. But some info is better than nothing :)

Related

how i can change the default icon in the left of the window in Mac OS?

Now I want to design a simple game by using python, the step I want to do is to add an icon on the left of the window.
However, when I type
game_window.iconbitmap('favicon.ico')
game_window.mainloop()
the system just tell me Document Drag Error.
I am sure I save favicon and the both in the desktop and both of the path is correct.
I search this question in the internet but all of them are using window os.
If your icon is in the same folder as your file, the script will surely work...
I think that you're getting the error because you didn't save the file you're working on for the first time.
Try the following:
Save your file in the same folder another time (if you've already done it).
If it doesn't work, then write the full path of the icon

How to set icon(or .ico file) on executable file in linux system?

I've been trying to set icon on executable file(.exe) in linux and macOS.
what I learn is there are 3 places icon sets: on taskbar, window bar, and executable file thumbnail.
I have set on taskbar and window bar, but not on exe file.
(By the way, I've already done on 3 of them in windows using visual studio.)
and I might not know exact term of it, so I will show the example below:
enter image description here
I guess .rc file should be in makefile.
If so, I could solve it also in macOS.
If not, I want to know how to set in linux and macOS too.
Please let me know how to use it and set it. Thanks in advance.
p.s. I set icons on window bar and taskbar using GLFWimage and working on openGL3 & c++.
glfwSetWindowIcon(window, 1, &icon);
I guess .rc file should be in makefile.
While there is a "standardized" way for storing icons in Windows .exe files, there is no such method for "ELF" files (the most common executable file format under Linux).
on taskbar and window bar
The icon used by the window manager (e.g. for the task bar) is typically stored as "X11 window property". A "X11 window property" is some data assigned to a window by a program.
The program must provide the icon image as array and call the function XChangeProperty() (this is what the function glfwSetWindowIcon() indirectly does).
It is not necessary that the icon is stored in a special way (comparable to the .rc file in Windows); the program can simply store the icon in some const array or even calculate the icon image data before calling XChangeProperty().
... but not on exe file.
As I already have written, there is no "standardized" way to store icons in executable files for Linux.
Some file managers "know" certain programs and display the corresponding icons: They know that "xterm" is a terminal program, so they display the terminal icon. However, this icon is not stored inside the executable file but in the file manager: If you rename any executable file to "xterm", the terminal icon will be displayed.
There is an extension named "elfres" (it was named "elficon" some years ago) that allows adding icons to ELF executable files. The web site of that extension is found here. On the linked web site you also find a screen shot with an example - so you can check if I understood you correctly and this is what you are talking about.
Unfortunately, this is a non-standard extension. For this reason a "standard" Linux installation will not check if an executable file contains an icon and therefore not show the icon.
If you use the "elfres" method, you must install a special plug-in; otherwise the icons of executable files are not shown.

How to activate the favorites icon on the taskbar?

My application is in the selected taskbar(GNOME, dash-to-panel). When a window opens, a new icon appears in the taskbar. How to make so that the favorites icon is activated and a new one does not appear (as in other applications: Gedit, Nautilus)
Answer: Need a correct StartupWMClass entry. Find entry: in a terminal xprop WM_CLASS
Sounds like you don't have a launcher, in GNOME environments usually a .desktop file. This file tells the desktop which kind of application your app is, allows you to create right-click actions (such as New Window, New Private Window, etc.). Here is an example:
[Desktop Entry]
Name=<Name of Your App>
Exec=<command to execute>
Terminal=<true/false depending on whether you run it on a terminal>
Icon=<name of the icon for your app (icon has to be installed on the system)>
Type=Application
Categories=<Office;Game;etc; (semi-colon separated)>
Keywords=Something;Other Thing;
There is a good guide by GNOME here.

How to drag a url to a .desktop shortcut

I have created a new .desktop shortcut in LXDE, and added that shortcut to the "Application Launch Bar". I can drag a file onto the shortcut, and the filename will be passed to a script successfully. However, when I drag a link from either Firefox or Chrome, the link is not passed as an argument.
The important parts of my .desktop file are as follows:
[Desktop Entry]
Exec=/bin/bash /home/myUserName/test.sh %u
Terminal=false
StartupNotify=true
And /home/myUserName/test.sh simply contains:
echo "!$1!" > /home/myUserName/test.txt
just to prove that it's passing arguments.
I've read the freedesktop standards.
I had only Chrome installed when I discovered the problem, but I read that chrome was saving files instead of links, so I switched to Firefox; however the URL is still not passing to the desktop shortcut.
I hope I'm overlooking something, as this seems to be a huge gap in continuity with freedesktop standards.
Any suggestions?
EDIT: After testing, Firefox saves an HTML file instead of a link just like Chrome, so it appears to be an LXDE bug rather than a browser bug. I'll assume that my next endeavor is to find out why.
I've not completely absorbed the delineation between a window manager and a desktop manager, but I believe that LXDE is the culprit, either directly or indirectly, in conjunction with pcmanfm.
I've read that installing pcmanfm-mod might solve my problem, and I've also read that pcmanfm is no longer being developed, and is replaced by spacefm, which is out of my scope to install right now, as it is not available in my distribution.
To bottom-line it, XFCE with Thunar has solved the problem. I added a "Launcher" to my newly-installed XFCE-Panel, and its EXEC is identical to the one in the original post, and the %u is now successfully passed to my script when I drag a link from Firefox. I have not tried to drag a link from Chrome, but I feel it would work as well.

Sublime Text "Unable to save"

I didnt change any file paths and everything was working fine. I made one quick change saved it ok, did another change and I went to save it and got the following error. How can I solve this. It will save other files ok
Unable to save
D:\xampp\htdocs\websites\dev.liverpool\style\main.scss
Error:
MoveFileEx(D:\xampp\htdocs\websites\dev.liverpool\style\.sublae1.tmp, D:\xampp\htdocs\websites\dev.liverpoolzstylezmain.scss) failed,
Access is denied.
seems it's because Windows or another program is blocking the file. Sublime text uses a temporal file instead of editing the file directly, and when you save the file uses a API command to move this edited file to the original, so this command has restrictions when one file is locked and Sublime shows this alert.
Maybe this setting {"atomic_save": false} will work for you.
Go to the path where you installed sublime text 2 and...
Right click on the sublime_text 2.exe file.
Go to its properties.
Go to compatibility section under this.
Set its privilege level to "Run this program as an administrator".
Now change settings for all users and there also check the field "Run this program as an administrator".
Apply the changes.
I just solved the same issue on Sublime Text 3 beta, Stable Channel Build 3065 by doing the following under Windows 7:
Navigate to the Sublime Text 3 executable file, wherever you have it installed.
Right-click it and select properties.
Click on the tab marked "Security"
About half way down the tab, on the right hand side, under the list of group and user names is this little button:
Click it.
If your machine is setup the way I suspect it is (otherwise you probably would not be having this issue), you should be prompted for your administrator account credentials. Enter them.
Now, select the Users group in the list, then take a look in the box at the bottom labeled 'Permissions for Users'. Put a check mark in the 'Allow' column for the 'Write' item.
Click 'Apply'
Click 'OK'
You should be set. What this does is it essentially gives Sublime the ability to write files while running with regular user privileges, no administrator level access required. Upon taking a better look at your error, what is happening is Sublime Text is creating a temp file for editing, rather than editing to file itself, then attempting to overwrite the original file with the temp on save. The problem is that the program is not being run by a user with sufficient privileges to perform the overwrite, hence the failure with an 'Access denied' message.
A simple and effective solution: Right-click on the file you want to save, in my case it is index.html, go to the properties and uncheck read-only.
The Sublime text will start working fine.
I have come across this error quite many times and by un-checking read-only file attribute of index.html, I am able to get rid of it
I found out more ways to fix this:
Close and reopen the Sublime Text windows or
Open the file with Np++, add a space, save, quit, then you're prompted by ST to reload the file, click yes, and it works again... or
Open the FTP console to see if there's a transaction in progress - then cancel it
In my case the SFTP plugin seems to be causing this problem, as when the FTP connection is timed out, the file which is waiting to be uploaded is being used, and you try to overwrite it.
This happens because you're using ScoutApp or Compass, they block your SCSS files because they are checking for changes as you specified for a directory for those files.
I suggest you reading this:
http://aspirecode.com/how-to-add-sass-support-in-sublime-text/
Good luck!
On mac using a remote volume sometimes I experience this. The solution is to remove the temp file then save again and all fixed.
IE: if you are working on test.html then the temp file would be ._test.html
Remove ._test.html then save again.
For Mac-
Try changing the destination from 'Macintosh HD' to 'Documents' or any other folder.
Worked for me.
The plugin of Superlime solved this problem. It tries to save the file as root in SublimeText.
Reference Link: https://github.com/azubr/Superlime
Try switching your SublimeText process priority to higher level in process manager (it has to have higher priority than your scss compiling app, if you're using one).
It seems to have worked for me.
if it's not working after doing all suggestions, reinstall the program
On Mac I saved the file in Home directory and it gave me this alert, later when I re saved the file again this time in Document directory the file is working now. Using SublimeText 3.
I found this occurred when the folders are read-only. Right-click on the folders where your site is contained and see if read-only is selected in the properties.
Just open it as an administrator.
Because I want to edit anything and write as admin all the time, I set this program to always open as an administrator using "Configure Applications to Always Run as an Administrator".
Just got your file folder properties which you want to save and deselect to read only attribute.

Resources