\n\n\n\n下面是一个小 shell 脚本,可以使用您的所有书签更新您的主页快速列表。无需手动操作。它读取您的书签文件\n并从中创建菜单项。它还添加了“Root\n Filemanager”菜单项。
\n\n\n\n
\n
\n\n- 将下面列出的脚本复制到一个空文件中,并将其放入\n 脚本文件夹中(我们假设是 ,
\n~/bin/并且您选择的脚本名称\n 是unityhome.bash)。- \n
运行脚本一次以添加条目:
\n\nRun Code Online (Sandbox Code Playgroud)bash ~/bin/unityhome.bash\n- \n
或者,您可以让 cron 每隔一段时间为您运行一次脚本。要将其添加到 cron,请在 shell 中输入以下命令:
\n\nRun Code Online (Sandbox Code Playgroud)\n\ncrontab -e An editor will open. There add a line like:\n\n@reboot /bin/bash/ $HOME/bin/unityhome.bash > /dev/null 2>&1\n如果您不执行此步骤,并且想要更新快速列表,则每次更改 nautilus 书签时都必须手动运行脚本。
- \n
更改仅在您下次登录或按 Alt+F2 后生效
\n\nRun Code Online (Sandbox Code Playgroud)\n\nunity --replace So do that. *Note: Don\'t run `unity --replace`\n在终端中。如果您关闭该终端,它将终止与其的统一。*
- \n
享受并查看类似的 gnome-terminal 脚本,它解析您的 ssh 书签(在 \n 中
~/.ssh/config)。脚本:\n -------- 这是脚本:
\n\nRun Code Online (Sandbox Code Playgroud)\n\n#!/bin/bash\n# tabsize: 4, encoding: utf8\n#\n# \xc2\xa9 2011 con-f-use@gmx.net. Use permitted under MIT license:\n# http://www.opensource.org/licenses/mit-license.php\n# \n# CONTRIBUTORS: Chris Druif <cyber.druif@gmail.com>\n# Scott Severance <http://www.scottseverance.us/>\n# \n# This script updates the unity quicklist menu for nautilus to\n包含用户\n # 个书签。更新将在 Unity 重新启动后生效(无论是在下次登录时还是通过调用“unity --replace”)。
\n\nRun Code Online (Sandbox Code Playgroud)\n\n# location of template and unity bar launchers\nnautempl="/usr/share/applications/nautilus-home.desktop"\ntarget="$HOME/.local/share/applications/nautilus-home.desktop"\nbookmarks="$HOME/.gtk-bookmarks"\n\n# backup if file already exists\nif [ -e "$target" ]; then\n echo "Creating backup of: $target."\n mv -n "$target" "$target.bak"\nfi\n\n# copy template\ncp "$nautempl" "$target"\n\nsed -i "s/\\(OnlyShowIn=GNOME;\\)/\\1Unity;/" "$target"\n\necho "X-Ayatana-Desktop-Shortcuts=" >> $target\n\nbmcount=0\nwhile read bmline; do\n bmcount=$(($bmcount+1)) # number of current bookmark\n bmname=${bmline#*\\ } # name of the bookmark\n bmpath=${bmline%%\\ *} # path the bookmark leads to\n # deal with bookmarks that have no name\n if [ "$bmname" = "$bmpath" ]; then\n bmname=${bmpath##*/}\n fi\n # fix spaces in names and paths\n bmname="$(echo "$bmname" | sed \'s/%20/ /g\')"\n bmpath="$(echo "$bmpath" | sed \'s/%20/ /g\')"\n # extend shortcut list with current bookmark\n sed -i\n"s/(X-Ayatana-Desktop-Shortcuts=.*)/\\1Scg${bmcount};/" "$target"\n # 写入书签信息\n cat - >> "$target" <\n\ n
Run Code Online (Sandbox Code Playgroud)\n[Scg$bmcount Shortcut Group]\nName=$bmname\nExec=nautilus "$bmpath"\nOnlyShowIn=Unity\nEOF\ndone < "$bookmarks"\n\n# Add a root file manager entry\nsed -i "s/\\(X-Ayatana-Desktop-Shortcuts=.*\\)/\\1RootFM;/" "$target"\ncat - >> "$target" <<EOF\n\n[RootFM Shortcut Group]\nName=Root\nExec=gksudo nautilus\nOnlyShowIn=Unity\nEOF\n\nexit 0\n