Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Redcar is a graphical application that is installed via a Ruby gem, and I have installed it in a Ruby environment that is managed by RVM.

A launcher icon isn't automatically installed, so I need to create one myself. I've tried using Unity's "Keep in launcher" option for the icon that is displayed while Redcar is running:

Redcar and Unity

But when I exit Redcar and then click the launcher icon, the icon only flashes and Redcar does not open.

How can I create a working launcher icon?

I tried creating ~/.local/share/applications/redcar.desktop with the following contents:

[Desktop Entry]
Type=Application
Version=1.0
Name=Redcar
Comment=A programmer's text editor written in Ruby!
Icon=/home/ak/.rvm/gems/ruby-1.9.2-p290/gems/redcar-0.11/share/icons/redcar-icon-beta.png
Exec=/home/ak/.rvm/gems/ruby-1.9.2-p290/bin/redcar
Categories=Development;IDE;

The file is executable and is shown with the Redcar icon when I browse to ~/.local/share/applications in Nautilus, but nothing happens when I double-click it. Redcar runs fine when I enter /home/ak/.rvm/gems/ruby-1.9.2-p290/bin/redcar in a terminal.

share|improve this question
    
I updated my answer, hope it works for you. –  jrg Mar 15 '12 at 19:33

3 Answers 3

up vote 2 down vote accepted

Ruby gems are installed to ~/.rvm/gems/ruby-$version@$gemset/ with RVM.

First, download this icon and save to ~/.local/share/icons/redcar.png.

Now, save the following to ~/bin/redcar.sh and make it executable with chmod +x ~/bin/redcar.sh.

#!/bin/bash
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then

  \# First try to load from a user install
  source "$HOME/.rvm/scripts/rvm"

elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then

  \# Then try to load from a root install
  source "/usr/local/rvm/scripts/rvm"

else

  printf "ERROR: An RVM installation was not found.\n"

fi

rvm use 1.9.3@redcar-install
gem install redcar
redcar

Now, you'll need to create a desktop file manually pointing to the correct executable and icon. It should look something like:

[Desktop Entry]
Type=Application
Version=1.0
Name=Redcar
Comment=A programmer’s text editor written in Ruby and Java.
Icon=~/.local/share/icons/redcar.png
Exec=~/bin/redcar.sh
Categories=Development;IDE;

Place it in ~/.local/share/applications/redcar.desktop It should then show up in the dash search, and then you should be able to drag it to the Launcher.

share|improve this answer

In case someone else is not entirely satisfied with the way the above mentioned methods of doing this work, here's my cool installation script that should do everything (oh well if u want the launcher to the doc you'll need to drag it there by your self..). After this redcar will show up in the dash searches, can added to the launcher and can be launched from the command line with redcar command. It assumes rvm is already installed (as per user installation) and I guess you need java for jruby to work.

#!/bin/bash

echo "Ensure users local bin dir exists"
[[ ! -d ~/bin ]] && mkdir ~/bin
echo "done."

echo "Install jruby and redcar gem wrapping it to a wrapper"
rvm install jruby &&
rvm jruby@redcar --create &&
gem install redcar &&
redcar install &&
rvm wrapper jruby@redcar wrapped redcar &&
echo "For rvm to work properly with gnome shell make sure gnome shell session is set to use login shell" &&
echo "Adding alias to ~/.bash_login\nalias redcar=wrapped_recar" &&
echo -e '\nalias redcar=wrapped_redcar' >> ~/.bash_login &&
echo "Creating a wrapper script to ~/bin for launching the app from launcher" &&
echo '#!/bin/bash
shopt -s expand_aliases
[[ -f ~/.rvm/scripts/rvm ]] && . ~/.rvm/scripts/rvm
alias redcar=wrapped_redcar
redcar' > ~/bin/redcar.sh &&
chmod u=rwx,og=r ~/bin/redcar.sh &&
echo "Creating launcher icon" &&
echo "[Desktop Entry]
Type=Application
Version=`redcar -v`
Name=Redcar
Comment=A programmer’s text editor written in Ruby and Java.
Icon=`find ~/.rvm -name redcar-icon-beta.png`
Exec=~/bin/redcar.sh
Categories=Development;IDE;" > ~/.local/share/applications/redcar.desktop
share|improve this answer

Ruby gems are installed to /var/lib/gems/1.8/ You'll need to create a desktop file manually pointing to the correct executable and icon. It should look something like:

[Desktop Entry]
Type=Application
Version=1.0
Name=Redcar
Comment=A programmer’s text editor written in Ruby!
Icon=/var/lib/gems/1.8/gems/redcar-0.11/share/icons/redcar-icon-beta
Exec=/var/lib/gems/1.8/gems/redcar-0.11/bin/redcar
Categories=Development;IDE;

Place it in ~/.local/share/applications/redcar.desktop It should then show up in the Dash, and you should be able to drag it to the Launcher.

For more general information about creating custom launchers in Unity, see this question:

How can I edit/create new launcher items in Unity by hand?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.