Sublime Forum

Launching Sublime from Unity

#1

When I open Sublime it shows in Unity launcher. If I right click and select “Keep in launcher” it will indeed stay there after closing Sublime but clicking “pinned” icon won’t start sublime. The icon will blink for a while and then stop.

Ubuntu 11.10.

0 Likes

#2

The best way to do this, is to create your own custom launcher for Sublime. Make sure you have a sublime.desktop file in ~/.local/share/applications (You can also put it in /usr/share/applications if you want it to be available to all users on the box, but you’ll need root privileges to do so.) Here’s a copy of mine:

[Desktop Entry] Name=Sublime Text Editor Comment=Sublime Text Editor Exec="/home/jim/bin/Sublime Text 2/sublime_text" %F MimeType=text/plain; Terminal=false Type=Application Icon=/home/jim/Pictures/sublime-64px.png Categories=GNOME;GTK;Utility;TextEditor;Development;Utility;

Keep in mind that you’ll need to know the path to the executable and the path to the icon that you want to use.

0 Likes

#3

Very nice to know, thank you.

But can this process be made less painful by default? I guess we would need Jon to publish packages instead (or in addition) to just zip files.

0 Likes

#4

You can install it via this PPA: webupd8.org/2011/03/sublime- … u-ppa.html

Once you do that you will be able to pin it in Unity.

0 Likes

#5

[quote=“rchl”]Very nice to know, thank you.

But can this process be made less painful by default? I guess we would need Jon to publish packages instead (or in addition) to just zip files.[/quote]

I’ve actually symlinked /usr/bin/sublime to my local bin folder/sublime executable. This way, I just delete the entire folder and unTar the new one every time a release is made. This won’t affect the symlink or the pinned icon on my Unity or Gnome3 menu.

There has been quite a bit of yelling on the Oneric forums about Unity and Gnome’s decision to make this process harder. (I’ve spoken out a few times against it too… it’s like creating a PIF file back in Windows 3.1 days… not exactly a step forward)

Otherwise, the suggestion above to use the PPA should work just fine for you.

0 Likes

#6

Here’s my version:

[Desktop Entry]
Type=Application
Terminal=false
Name=Sublime Text 2
StartupNotify=true
GenericName=Text Editor
Comment=Edit text files
Exec=/path_to/st2/sublime_text %U
MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-perl;text/x-python;application/x-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/xml;text/html;text/css;text/x-sql;text/x-diff;x-directory/normal;inode/directory;
Categories=GNOME;GTK;Utility;TextEditor;Application;Development;
Icon=emacs #don't like the default icon
Name[en_US]=Sublime Text 2
X-Ayatana-Desktop-Shortcuts=NewWindow;

[NewWindow Shortcut Group]
Name=New Editor Window
Exec=/path_to/st2/sublime_text --new-window
TargetEnvironment=Unity

Save this code as Sublime Text.desktop under ~/.local/share/applications and drag that file to Unity dock.
Now that the launcher is there, you can actually drag and drop files and folders (yes, folders too) onto the icon. You can also right click and open a new window:



Hope this gets included by default some day. /cc @jon

0 Likes

#7

I guess we would need Jon to publish packages instead (or in addition) to just zip files.

0 Likes

#8

Not necessarily. He could still just distribute a zip file, but add the .desktop file to it, along with perhaps a short install.sh or something to put the appropriate files in the right places.

0 Likes

#9

[quote=“ekolguy”]Here’s my version:

[Desktop Entry]
Type=Application
Terminal=false
Name=Sublime Text 2
StartupNotify=true
GenericName=Text Editor
Comment=Edit text files
Exec=/path_to/st2/sublime_text %U
MimeType=text/plain;text/x-chdr;text/x-csrc;text/x-c++hdr;text/x-c++src;text/x-java;text/x-dsrc;text/x-pascal;text/x-perl;text/x-python;application/x-php;application/x-httpd-php3;application/x-httpd-php4;application/x-httpd-php5;application/xml;text/html;text/css;text/x-sql;text/x-diff;x-directory/normal;inode/directory;
Categories=GNOME;GTK;Utility;TextEditor;Application;Development;
Icon=emacs #don't like the default icon
Name[en_US]=Sublime Text 2
X-Ayatana-Desktop-Shortcuts=NewWindow;

[NewWindow Shortcut Group]
Name=New Editor Window
Exec=/path_to/st2/sublime_text --new-window
TargetEnvironment=Unity

[/quote]

The [NewWindow Shortcut Group] section doesn’t work under 12.04, though I think the reference to Ayatana Desktop is probably a clue. This worked for me:

[Desktop Entry]
Name=Sublime Text 2
Exec="/opt/Sublime Text 2/sublime_text" %F
MimeType=text/plain;
Terminal=false
Type=Application
Icon=sublime_text
Categories=GNOME;GTK;Utility;TextEditor;Development;
Actions=New;

[Desktop Action New]
Name=New Editor Window
Exec="/opt/Sublime Text 2/sublime_text" --new-window
MimeType=text/plain;
OnlyShowIn=Unity;
0 Likes

#10

Do you mind if I include this in my patch for the Sublime Text Unoffical Documentation?

I plan on also including this

tar vxjf Sublime\ Text\ 2.0.1.tar.bz2 -C /opt/ sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/sublime


http://c758482.r82.cf2.rackcdn.com/Sublime Text 2.0.1.tar.bz2 http://c758482.r82.cf2.rackcdn.com/Sublime Text 2.0.1 x64.tar.bz2
The one sticking point that I’m having is that the URL to get the latest version is very ugly and changes on each new version. Having like a 302 redirect to the real current version in it’s CDN location would greatly help. Something like:

http://www.sublimetext.com/latest386.tar.bz2 http://www.sublimetext.com/latestx64.tar.bz2

Would be awesome.

0 Likes