如何在 RVM 环境中为 Redcar 创建 Unity 启动器图标?

如何在 RVM 环境中为 Redcar 创建 Unity 启动器图标?

雷德卡是一个通过 Ruby gem 安装的图形应用程序,我已将其安装在由右心室

启动器图标不会自动安装,所以我需要自己创建一个。我尝试使用 Unity 的“保留在启动器中”选项来设置 Redcar 运行时显示的图标:

雷德卡和 Unity

但是当我退出Redcar然后单击启动器图标时,图标只会闪烁并且Redcar不会打开。

如何创建一个可以工作的启动器图标?

我尝试创建~/.local/share/applications/redcar.desktop以下内容:

[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;

该文件是可执行文件,当我在 Nautilus 中浏览时,会显示 Redcar 图标~/.local/share/applications,但双击它时没有任何反应。当我进入/home/ak/.rvm/gems/ruby-1.9.2-p290/bin/redcar终端时,Redcar 运行正常。

答案1

~/.rvm/gems/ruby-$version@$gemset/ Ruby gems与 RVM 一起安装。

第一的,下载此图标并保存至~/.local/share/icons/redcar.png

现在,将以下内容保存到~/bin/redcar.sh并使用使其可执行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

现在,您需要手动创建一个指向正确可执行文件和图标的桌面文件。它应该看起来像这样:

[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;

将它放入其中,~/.local/share/applications/redcar.desktop然后它应该出现在破折号搜索中,然后您应该能够将它拖到启动器。

答案2

Ruby gems 安装到/var/lib/gems/1.8/您需要手动创建一个指向正确可执行文件和图标的桌面文件。它应该看起来像:

[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;

将它放入后~/.local/share/applications/redcar.desktop它就会显示在 Dash 中,然后您就可以将它拖到启动器中。

有关在 Unity 中创建自定义启动器的更多常规信息,请参阅以下问题:

如何在 Unity 中手动编辑/创建新的启动器项?

答案3

如果其他人对上述方法的效果不完全满意,这里有我很酷的安装脚本,它可以完成所有工作(哦,如果你想将启动器拖到文档中,你需要自己将其拖到那里……)。此后,redcar 将出现在 dash 搜索中,可以添加到启动器中,并可以使用 redcar 命令从命令行启动。它假设 rvm 已经安装(根据用户安装),我想你需要 java 才能使 jruby 工作。

#!/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

相关内容