EzDevInfo.com

.desktop interview questions

Top .desktop frequently asked interview questions

Are there any GUI apps that can create .desktop files?

My question is simple. Is there any fast and easy way of creating .desktop files for shortcuts?

For example, I think you can right click and create .desktop shortcuts in Linux Mint.

I already know how to create them from a text editor like this:

[Desktop Entry] Type=Application 
Name=Eclipse Comment=Eclipse IDE
Icon=/home/jahedev/dev/eclipse-std/icon.png
Exec=/home/jahedev/dev/eclipse-std/eclipse
Terminal=false
Categories=Development;IDE;Java;
StartupWMClass=Eclipse
Name[en_US]=Eclipse

So are there any GUI apps that can do this?


Source: (StackOverflow)

How can I find *.desktop files?

To the best of my knowledge, all shortcuts in the Unity Launcher have a corresponding *.desktop file. I have one shortcut (for skrooge) that doesn't have an icon. How can I find the *.desktop file corresponding to this shortcut so that I can add an icon to it?


Source: (StackOverflow)

Advertisements

How to order desktop icons by name in XFCE?

I'm using Xfce 4.8 installed on Ubuntu 12.04.2 LTS and I'm wondering what's the alternative for Right-click -> Order by name on XFCE. Right now, when I right click on my desktop, it looks like this:

right click menu on desktop in Xfce

As you can see, there's no option for rearranging the icons. If my assumption is correct, it can't be done directly via GUI. I saw this thread, but that doesn't really explain how to achieve the same result. Any ideas?


Source: (StackOverflow)

How can I edit/create new launcher items in Unity by hand?

Will Unity allow making custom launcher icons from .desktop files or via menu editing system? (Right now the launcher doesn't give the option to "keep in launcher" on all programs.

For some programs I use, I have to make custom launchers or .desktop files.

For instance, daily blender builds are generally just folders with an executable.

In basic Gnome or KDE, I can make a new menu entry with the menu editing system. Then, I can also add it to Docky either from the menu or by dragging a .desktop file to it. Unity launcher doesn't support drag and drop, so thats not a bug or anything, but when I open a .desktop file, it has unpredictable results. Most time it will not have "keep in launcher". Sometime it will have a pinnable item without the .desktop's icon, and if I pin the item to the launcher, it will not call upon the program again after closing it. I've also gotten it to just work with a .desktop file for celtx.


Source: (StackOverflow)

Running a .desktop file in the terminal

From what I can gather, .desktop files are shortcuts that allow application's settings to be customized. For instance, I have lots of them in my /usr/share/applications/ folder.

If I open that folder in nautilus, I can run these applications just by double clicking its associated file, e.g. double-clicking firefox.desktop runs Firefox. However, I can't find a way to do the same thing via terminal.

If I do gnome-open foo.desktop it simply opens foo.desktop as a text file. If I make it executable and then run it in bash it simply fails (which is expected, it's clearly not bash script).
EDIT: Doing exec /fullpath/foo.desktop gives me a Permission denied message, even if I change ownership to myself. If I make executable and do the same command, the terminal tab I'm using simply closes (I'm guessing it crashes). Finally, if I do sudo exec /fullpath/foo.desktop, I get an error reporting sudo: exec: command not found.

That's my question, how can I run a foo.desktop file from the terminal?


Source: (StackOverflow)

Creating a .desktop file for a new application

I just installed the lastest version of UGENE. I works fine but in order to use it, I have to enter the following in the terminal: cd ugene-1.11.5/ then execute ./ugene -ui to launch UGENE GUI.

This takes too long. I would like to build a .desktop file for UGENE to be used in Ubuntu 12.04 so that I can simply open it from the unity launcher.

Not sure if this is helpful but the website says: By default ugene script launches the command-line version of UGENE.

Here's what I have (not sure if it's right):

[Desktop Entry]
Version=1.0
Name=my Unipro UGENE
GenericName=Integrated Bioinformatics Suite
Comment=Unipro UGENE is a cross-platform visual environment for DNA and protein sequence analysis.
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
Exec=/home/samuel/ugene-1.11.5 ./ugene -ui -c %F
Icon=/usr/share/icons/hicolor/scalable/apps/ugene.svg
Type=Application
Terminal=true
Categories=Utility;Development;
StartupWMClass=UGENE

I added the launcher named my Unipro UGENE to my unity bar and tried opening it but it doesn't appear. I must be missing something. I don't know what the StartWMCClass field is suppose to be nor do I know whether I entered the correct MimeType.


Source: (StackOverflow)

What represent the StartupWMClass field of a .desktop file?

I am working on this pre-existent .desktop file and I have a doubt:

The file content is:

[Desktop Entry]
#Icon=connect-data-space
Icon=XCloud
Categories=Utility;
Type=Application
#Exec=/usr/share/ConnectDataSpace/appl/launcher.sh
Exec=/usr/share/XCloud/appl/launcher.sh
Name[en_US]=Connect Data Space
#Name=Connect Data Space
Name=XCloud
Comment[en_US]=
Comment=
StartupNotify=true
Terminal=false
OnlyShowIn=GNOME;Unity;
StartupWMClass=ConnectDataSpace
Actions=CheckUpgrade

[Desktop Action CheckUpgrade]
Name=Verifica Aggiornamenti
#Exec=java -jar /usr/share/ConnectDataSpace/appl/lib/shellExtBridge.jar -checkupgrade
Exec=java -jar /usr/share/XCloud/appl/lib/shellExtBridge.jar -checkupgrade
OnlyShowIn=GNOME;Unity;

What exactly represent the StartupWMClass field of this file?

Tnx

Andrea


Source: (StackOverflow)

My .bashrc alias not run in .desktop file

I've added the following line to the .bashrc file:

alias midos="sh /home/erkanmdr/Belgeler/midos/midos.sh"

This command works fine in the terminal and tty. But not working in my .desktop shortcut file.

midos.desktop file:

[Desktop Entry]
Name=MiDoS
Exec=midos
Icon=/home/erkanmdr/Belgeler/midos-128.png
Terminal=true

How do I execute my midos command in the .desktop shortcut file?


Source: (StackOverflow)

How do I determine an application's process name?

This is the situation:

Working on (the next version of) a Unity Quick List editor, I would like to add a reliable way of "restarting" launcher icons. To do so, I need to remove the icon (editing gsettings) and replace it on the same position. So far no problem. However, if the application in question is running, user will possibly lose data, as the application will quit when it's icon is removed from the launcher. What I need is a reliable way to find an application's process name, to let the editor check in the list of running processes if the application is running, and send a warning message to the user that the icon can not be restarted if the application is running.

What I did so far is make the editor look into the desktop file, to read the command, also read the command, stripped from the directory section, and furthermore look into possible remote scripts the desktop file command might refer to, looking for strings starting with "./"

Although the method seems to work well with all applications I tested it on, I have the feeling there must be an easier way to cover the problem in an "all in one" way...

Is there?

Also suggestions to catch more exceptional situations are welcome!


Source: (StackOverflow)

Where is the $HOME folder located?

I read recently that .desktop files that are used as desktop shortcuts are placed in the $HOME/Desktop directory. Where is this directory?

Also, what does the $ part mean / do?


Source: (StackOverflow)

Set Multiple values for StartupWMClass (to group under same launcher in Unity)

This a specific example of a generic problem I haven't been able to find a solution for yet.

I have a program (Android Virtual Device Manager) that launches 'sub-programs' (namely emulators or virtual devices) from within itself (also can be launched from else where). I want any instances of EITHER of these programs to be grouped under the same Unity icon.

I have created a .desktop file to try and accomplish this but don't exactly know how to go about it. The desktop file is as follows:

#!/usr/bin/env xdg-open

[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Name=Android Virtual Device
Icon=/home/ben/.icons/android.svg
Exec=/home/ben/usr/bin/android avd
StartupWMClass=Android Virtual Device Manager

From what I understand, StartupWMClass is what I need to set to achieve this correctly. I have obtained the two class names ('Android Virtual Device Manager' and 'emulator64-arm') using xprop WM_CLASS on the repsective windows. Both work individually (the launcher icon is correctly attached to the program no matter what way it is launched), but I cannot get it to work for both.

I am assuming that I somehow need to set two values for StartupWMClass but have not been able to do it correctly (or know if it is a valid operation). I have tried, colon separated like environment variables, comma separated, quotes, etc and I cannot find any hints in the official documentation.

Any suggestions?

EDIT:

Another, more pedantic, but probably more identifiable example is with Matlab. I am running 2013a and the splash screen that initially shows and the program have completely different WM_CLASS values. This means, when I click my launcher with StartupWMClass=com-mathworks-util-PostVMInit in it, the splash screen comes up with a different (default Unknown) Unity icon, while the rest comes up grouped under my launcher.

By using xprop WMCLASS and clicking on first the splash screen, then repeating with an active Matlab session I get the following terminal output:

ben@ben-OptiPlex-9010:~$ xprop WM_CLASS
WM_CLASS(STRING) = "MATLAB", "MATLAB"
ben@ben-OptiPlex-9010:~$ xprop WM_CLASS
WM_CLASS(STRING) = "sun-awt-X11-XFramePeer", "com-mathworks-util-PostVMInit"

If I could specify something along the lines of:

StartupWMClass=com-mathworks-util-PostVMInit&&MATLAB

That would work perfectly (as both work separately) but I have no idea of the syntax, if it even exists. I just know nothing I have tried has worked thus far.

Any help or a definitive answer either way would be great as I believe this is a pretty fundamental element of a well functioning desktop.


Source: (StackOverflow)

Custom right-click action in Unity Launcher keeps cursor busy for 20 seconds

To have a "minimize window" option through right click on an icon in the Unity launcher (Ubuntu 14.04), I followed the detailed instructions here about changing a .desktop file and made a custom Firefox launcher in ~/.local/share/applications/ folder. The relevant part of the .desktop file is:

Actions=NewWindow;NewPrivateWindow;Minimize

[Desktop Action NewWindow]
Name=Open a New Window
Exec=firefox -new-window
OnlyShowIn=Unity;

[Desktop Action NewPrivateWindow]
Name=Open a New Private Window
Exec=firefox -private-window
OnlyShowIn=Unity;

[Desktop Action Minimize]
Name=Minimize Windows
Exec=sh /home/myusername/Documents/xdotool_sh/minimize.sh firefox
OnlyShowIn=Unity;

The desktop action "Minimize" invokes a simple shell script, minimize.sh that has the following content:

#/bin/bash
name=$1
for i in $(xdotool search --class "$name"); do
    xdotool windowminimize $i
done

The script uses xdotool, that can be installed from the official repositories, to find all the firefox windows, iterate over them and minimize them.

The script works and the launcher right menu option "Minimize Windows" works as well, but as soon as the windows are minimized, the mouse pointer gets in "busy" mode and stays like this for about 20 seconds (although the mouse actions are still responsive).

Does anyone know why starting a shell script from a right menu option in Unity could lead to this behaviour?

EDIT: Apparently the wait period is inevitable, as explained in Jacob Vlijm's answer. Since the mouse remains responsive, avoiding the transformation of the pointer in the spinning wheel is a partial esthetic workaround, as explained on askubuntu.

EDIT2: giving the system a fake window is a better solution, as explained by Jacob below.


Source: (StackOverflow)

How can I add folder shortcuts to the Unity Launcher?

I want to add some folder to the launcher so that I can access them at ease. How do I add shortcut to launcher?


Source: (StackOverflow)

Create a .desktop file that opens and execute a command in a terminal

I would like to know how to write the Exec command of a .desktop file to open a new terminal and execute a shell script in it. The shell script is working and accessible by all users. When launching the script from the terminal everything works, but it doesn't when trying to launch the script from a .desktop file.

Here are some combinations I have already tried:

Exec=gnome-terminal -x sh -c 'echo hello'
Exec=sh -c 'gnome-terminal echo hello'
Exec=sh -c 'echo hello'
Exec=echo hello

The .desktop terminal option is set to true.


Source: (StackOverflow)

How do I diagnose "There was an error launching the application"?

I created a my-app.desktop file for a program I wrote. When I double-click it, I get the error message "There was an error launching the application". How can I get more detailed information about what the problem is?

I saw a reference to a "details" section of the dialog box, but there is nothing like that present in the one I see. If I were on my Mac, I'd open the Console app to see if any errors were logged, but I haven't learned of anything similar on Ubuntu.

(Note that unlike other similarly-titled questions, I am not asking what's wrong with this particular .desktop file; I want to know how to find out in general.)


Source: (StackOverflow)