Create .desktop files for Ubuntu

Having created a couple of .desktop files lately to make launching apps easier, I thought I’d write myself a quick reminder of what I did and how it works. If it’s useful to you too, then great! I have one application in a weird path, and another that needs a specific environment variable set for it to work.

Let’s start with OBS. On 20.04 and because I’m using a Wacom Tablet, there is a magic incantation required when it runs. By creating a .desktop file for it, I can add that and run it from the usual launcher rather than needed a special terminal script or alias.

The file is ~/.local/share/applications/obs.desktop and looks like this:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=OBS Studio
Icon=/path/to/images/obs-logo.png
Exec=env QT_XCB_TABLET_LEGACY_COORDINATES=1 obs

I also have this one pinned as a favourite so it launches on a Super + [number] keyboard combination!

Another example is the webpages-as-apps I’ve been packaging lately (blog post coming on that too I promise but tl;dr try nativefier!), the executables are in a weird path and since I expect to re-package fairly often, I don’t want to have to copy things around all the time. No problem! The desktop file doesn’t care, and puts them in my proper launcher regardless:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Twitch Stream Manager
Exec=/wild/long/and/unlikely/path/StreamManagerLJ
Icon=/path/to/images/twitch-logo.png

Hopefully now I’ve written this down, I’ll remember how this works next time without having to come and look up all the instructions … AGAIN :)

One thought on “Create .desktop files for Ubuntu

Leave a Reply

Please use [code] and [/code] around any source code you wish to share.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)