Skip to content

Instantly share code, notes, and snippets.

@ElectroluxV2
Created January 4, 2022 09:51
Show Gist options
  • Save ElectroluxV2/55a2e5c41a0606111b41f585d69baee2 to your computer and use it in GitHub Desktop.
Save ElectroluxV2/55a2e5c41a0606111b41f585d69baee2 to your computer and use it in GitHub Desktop.
How to create proper linux .desktop launcher

Making proper .desktop entry

Our showcase program will be psst-gui located in /home/mate/psst/target/release and has icon located /home/mate/icons/psst.png. You can use which psst command to get installation path of program.

Psst is fast and multi-platform Spotify client with native GUI written in Rust GitHub repository.

Run psst as you would normally run it.

We need to get proper StartupWMClass value for our program. While running psst open terminal and type this command: xprop WM_CLASS, notice your cursor turned into a crosshair. That is because you must click on the main window of the program.
After doing such you will be left with something like that: WM_CLASS(STRING) = "psst-gui", "Psst-gui". Remember these values between quotes. We will be using one of them in a second.

Create a psst-gui.desktop file under one of locations.

  • ~/.local/share/applications (launcher will be visible only for your user)
  • ~/Desktop (same as above but you may like launcher to be clickable from desktop, requires being executable)
  • /usr/share/applications (launcher will be visible for all users, requires root privileges)

Put following content into newly created .desktop file.

StartupWMClass's value is one of the strings obtained by executing xprop psst. Which one? The one that works for you. But probably the latest to the right.

[Desktop Entry]
Encoding=UTF-8
Name=Psst
Exec=/home/mate/psst/target/release/psst-gui
Icon=/home/mate/icons/psst.png
Type=Application
StartupWMClass=Psst-gui
Categories=Audio;

You can list all possible categories here You can also read specification of .desktop files here

Save and savor newly created launcher.

Now you should have working desktop launcher for any program you can possibly have. In case something went wrong, remember that Unix is a case-sensitive system, so watch out for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment