Monday 23 April 2012

Creating a Redcar Launcher in Linux

The inspiration for the Redcar editors name

To create a Redcar launcher in Linux, first create a script which launches Redcar from the command line (I keep my scripts in ~/bin). Save this as start_redcar.sh, or similar (the .sh extension is required). The contents of this script are:
 #!/bin/bash
 source ~/.bashrc  
 /home/<USERNAME>/.rvm/gems/ruby-1.9.3-p125/bin/redcar  
Redcar Launcher Script

In the above script, <USERNAME> is my Linux username, and it's followed by my Redcar installation path. Your Redcar installation path may be different - to find it, open a terminal window and type:
 which redcar  

This will output your Redcar installation path.

The key to the above script is the source command. This means the launcher will have access to your RVM and Redcar installations - without this line, the script will work when you run it from within a terminal window, but fail when you create the launcher, as the terminal has access to .bashrc, whereas by default, the launcher won't.

To test the script, first make it executable, by opening a terminal window and navigating to the script directory. Then run
 chmod +x start_redcar.sh  

Then launch the script, typing
 ./ start_redcar.sh  

Where start_redcar.sh is the name of your script.

If Redcar opens, everything has gone according to plan so far - now we need to create the launcher. To do this, right click on the desktop, and find Create New Launcher. Under Name, enter "Redcar" (without the quotes), and under Command, browse to the script we previously created. Finally, to give the launcher the Redcar icon, click the icon, and browse to:
 /home/<USERNAME>/.rvm/gems/ruby-1.9.3-p125/gems/redcar-icons-0.3/icons/redcar-icon-beta.png  

Press OK and the launcher will be created on your desktop. To add this to Cairo-dock, or another Linux dock interface, simply drag the launcher onto the dock.

Examples of the two files created above can be found in this gist. Enjoy your new Redcar launcher!

P.S!  Are you learning Ruby or Ruby on Rails? I highly recommend The Ruby Programming Language and The Rails 3 Way as useful references. Of course, you can always check out the bookstore for other books I've found useful.

Update May-20-12: This post is now linked to from the Redcar Wiki!


1 comment:

  1. hicolor icons for app https://github.com/flaccid/redcar-application-icons and .desktop file, https://github.com/flaccid/archlinux-packages/blob/master/ruby-redcar/redcar.desktop

    ReplyDelete

Please leave a comment if you find this blog helpful or interesting! I'd love to hear from you!