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]
Name=OBS Studio

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]
Name=Twitch Stream Manager

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 :)

Also published on Medium.

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.