Sunday, November 11, 2012

[Ubuntu Linux] Installing a program and making it accessible through CLI and Unity

So, today, I wanted to install a famous text editor called "Sublime Text 2" in my Ubuntu installation. I downloaded the tar file provided by them. Like many programs, I found no installer package or program but just the executables. Yes it was usable but I wanted more. I wanted to call the program with it's name not always navigate to the directory where I downloaded it just to use it. So I found this tutorial here and made it accessible via both Unity Dash and CLI (Terminal). I realized I often fall into this kind of problem when I'm using Ubuntu / Linux in general. So, I decided to write down the things I have to know when I'm doing such a thing.
First of all, you need to move your executables folder to the /usr/lib directory. Suppose you're too installing Sublime Text. You extract it via the tar tool like this.
tar xf Sublime\ Text\ 2\ Build\ 2181\ x64.tar.bz2
Then you get the folder "Sublime Text 2". You move it to the /usr/lib directory using this command.
sudo mv Sublime\ Text\ 2 /usr/lib/
Now you create a Symbolic Link, more like a Command to call the application via command line interface (CLI) using this
sudo ln -s /usr/lib/Sublime\ Text\ 2/sublime_text /usr/bin/sublime
Now create a launcher (icon you search for using HUD)
sudo sublime /usr/share/applications/sublime.desktop
Edit that .desktop file (specify what it does) and configure it to run Sublime Text when it's clicked on, paste all this in it, you can even spend time trying to understand it (for future applications)
[Desktop Entry]
Version=1.0
Name=Sublime Text 2
# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413.
GenericName=Text Editor

Exec=sublime #The symbolic link
Terminal=false #Don't run it using terminal
Icon=/usr/lib/Sublime Text 2/Icon/48x48/sublime_text.png #Which icon to use
Type=Application #Type type type :P
Categories=TextEditor;IDE;Development #More info
X-Ayatana-Desktop-Shortcuts=NewWindow

[NewWindow Shortcut Group]
Name=New Window
Exec=sublime -n
TargetEnvironment=Unity
That's it, now you can run the program using terminal (without pointing to where it's stored) and click on a launcher to run it. :)

No comments:

Post a Comment

Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...