Sublime Forum

Linux .desktop file

#1

Hey Everyone,

I’ve create a basic sublime.desktop file for Linux. This will both automatically show Sublime in Gnome’s menus and allow you to set Sublime as the default editor for your files. If you’re using Ubuntu, this file should be placed in the /usr/share/applications directory.

You will have to edit the file to point to the location of the icon you wish to use. I simply used the logo from this post: https://forum.sublimetext.com/t/new-logo-discussion/1174/19

Hope this helps someone.
sublime.desktop.zip (330 Bytes)

0 Likes

#2

If you prefer not to have to mess with root, you can put it in ~/.local/share/applications/ as well. This will make it only show up for your account though. I personally put all my non-deb packaged programs into ~/.bin so I don’t have to muddle with the system. Hopefully by release they will have a .deb and a .rpm.

0 Likes

#3

I’m trying this under XFCE (Crunchbang linux / Debian squeeze) and I get the menu fine.

However when Sublime opens up after click on a file from the file manager the contents of the file are not displayed. If I drag and drop files into Sublime they open fine. I’m using the latest Alpha of Sublime 2. Anyone else have this problem?

Here’s my sublime.desktop file:

#!/usr/bin/env xdg-open [Desktop Entry] Name=Sublime Text GenericName=Text Editor Comment=Edit source code Exec="/home/tom/bin/Sublime Text 2/sublime_text" %U Terminal=false Type=Application StartupNotify=true MimeType=text/plain; Icon=/home/tom/images/sublime.png Categories=TextEditor;Development;Utility;

0 Likes

#4

remove the %U in the exec line. It just opened a blank file called %U for me. Using LinuxMint 10 and GNOME.

0 Likes

#5

Thanks for the reply but it doesn’t make any difference for me. This could just be me not understanding XFCE but based on the other .desktop files it should work.

When I click a file that has been set to open with Sublime I get a new instance of Sublime every time and also the contents of the window is blank. This happen whether I have %U or not. See attached screenshot:


0 Likes

#6

I agree, ~/.local/share/applications/ is actually a better place to put the desktop file. That being said, I prefer to put locally installed programs in ~/opt and then link the binaries in ~/bin (the local bin folder should automatically added to your path, at least that’s what happens on all my Ubuntu machines).

Also, I am willing to create a deb and setup a ppa for Ubuntu if jps gives me the ok.

0 Likes

#7

[quote=“knitatoms”]Thanks for the reply but it doesn’t make any difference for me. This could just be me not understanding XFCE but based on the other .desktop files it should work.

When I click a file that has been set to open with Sublime I get a new instance of Sublime every time and also the contents of the window is blank. This happen whether I have %U or not. See attached screenshot:[/quote]

http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html defines the specs for the .desktop file. The spec is meant to be implementation agnostic, and %U is defined as “A list of URLs. Each URL is passed as a separate argument to the executable program. Local files may either be passed as file: URLs or as file path.” I’m not entirely sure why it doesn’t work for you, but try opening any .desktop file for a program that does work (found in /usr/share/applications) in a text editor. That should give you an idea of what does work on your system.

0 Likes

Sublime Text application cannot be found within "Open with other application" list in Gnome
#8

Try using %F rather than %U: Sublime Text 2 expects a list of file names as arguments, rather than URLs.

0 Likes

#9

Thanks - that helps - I now get the content of the file. But I still get a new instance of Sublime for each file opened. The docs suggest %F (capital F) should prevent that.

Gedit works fine and new files open in a new tab. My gedit .desktop file has the same settings as the Sublime .desktop file.

Maybe a Sublime issue or does it work OK for other people?

0 Likes

#10

Sublime Text 2 requires a very recent version of GIO (part of gnome) for single instance support. If you run it from a terminal, it’ll print a message to stderr if single instance support is disabled.

0 Likes

#11

Thanks Jon - that’s the problem!

Worth noting as I’m on the just released Debian Squeeze and the default libgio is not new enough.

0 Likes

#12

Anyone know how I could get it working without upgrading to testing (Wheezy)? It appears to have a high enough version of the package but I’d rather not upgrade:

packages.debian.org/source/wheezy/glib2.0

0 Likes

#13

I was just looking into this, and it seems the current Ubuntu 11.04 builds (codename natty) are still on libgio 2.22.0. How difficult would it be to update this package manually - is it a crazy string of dependencies where trying to do it from source would destroy my GNOME install or my mind - and/or where should I be making my voice heard to try and get this package updated before natty goes to beta (if there’s any chance of that?)

0 Likes

#14

11.04 has a recent enough version of libgio, at least the versions I’ve tested (alpha2 and alpha3). I believe any version of Ubuntu from 10.10 onwards is fine.

0 Likes

#15

Hi John,

There is no way to implement the single instance support with libgio 2.24 that is included with Ubuntu 10.04?

Thanks

0 Likes