问题描述
Please note that right now, most of the information contained below is outdated and cannot be updated. Be careful, most of this won’t work on Ubuntu 12.04 and newer.
为Unity创建自定义启动器非常简单。快速清单提供了一种简单而有效的方式来快速访问特定应用程序的常用任务。
注意:从Ubuntu 11.10开始,此弹出选项已消失。现在只能通过编辑主文件夹中的文本文件来创建启动程序。
创建自定义启动器很简单。
-
Right-click在您的桌面上,然后点击创建一个启动器。
-
使用文本编辑器编辑.desktop文件。 (更多信息请参见我如何在启动器上放置一个Web应用程序?和here。)
那么,你在Unity上使用哪些自定义启动器?
注意:请限制每个答案的自定义启动器。另外,请提供它的一个截图。
最佳解决思路
主页图标快速列表
-
将’Home Folder’启动程序文件复制到您的主目录:
mkdir ~/.local/share/applications cp /usr/share/applications/nautilus-home.desktop ~/.local/share/applications
-
在gedit中打开文件进行编辑:
gedit ~/.local/share/applications/nautilus-home.desktop
-
从文件中删除以下行:
OnlyShowIn=GNOME;
-
将此文本添加到文件的底部,然后关闭并保存:
X-Ayatana-Desktop-Shortcuts=Videos;Documents;Music;Pictures;Downloads [Videos Shortcut Group] Name=Videos Exec=nautilus Videos TargetEnvironment=Unity [Documents Shortcut Group] Name=Documents Exec=nautilus Documents TargetEnvironment=Unity [Music Shortcut Group] Name=Music Exec=nautilus Music TargetEnvironment=Unity [Pictures Shortcut Group] Name=Pictures Exec=nautilus Pictures TargetEnvironment=Unity [Downloads Shortcut Group] Name=Downloads Exec=nautilus Downloads TargetEnvironment=Unity
-
注销并再次登录以查看更改。
次佳解决思路
SSH启动器
快速访问您最喜爱的SSH服务器列表。
-
在Terminal类型中使用gedit创建一个新文件:
gedit ~/.local/share/applications/ssh-launcher.desktop
-
复制&将此文本粘贴到以上文件中:[Desktop Entry] Version = 1.0 Name = Remote Servers Comment =登录到我的服务器Exec = gnome-terminal –disable-factory –sm-client-disable –class = remoteserver -x ssh -t minibox.local Terminal = false X-MultipleArgs = false Type = Application Icon = utilities-terminal StartupNotify = true StartupWMClass = RemoteServers X-Ayatana-Desktop-Shortcuts = Server1; [Server1 Shortcut Group] Name = SSH到minibox.local Exec = gnome-terminal –disable-factory –sm-client-disable –class = remoteserver -x ssh -t minibox.local TargetEnvironment = Unity Comment =您可以创建更多这些。只需添加到X-Ayatana-Desktop-快捷方式”Server2″,”Server3″等,然后将域名(在这种情况下,”minibox.local”)更改为您的服务器的名称。您还会注意到,默认操作(当您只需单击启动器中的图标)就是SSH到minibox.local中 – 您需要将其更改为最常用的服务器。
-
通过导航到Nautilus中的〜/.local /share /applications /拖放到启动器上。
第三种解决思路
Ubuntu软件中心快速列表
通过software-properties UI快速添加PPA并更新源。
-
使用Terminal将原始.desktop文件复制到您的主文件夹:
cp /usr/share/applications/ubuntu-software-center.desktop ~/.local/share/applications/
-
用gedit打开文件进行编辑:
gedit ~/.local/share/applications/ubuntu-software-center.desktop
-
在文件底部添加以下内容。这应该在行X-Ubuntu-Gettext-Domain = software-center后输入
。
X-Ayatana-Desktop-Shortcuts=SoftwareUpdates;SoftwareProperties;Synaptic;
[SoftwareUpdates Shortcut Group]
Name=Update Manager
Exec=update-manager -c
OnlyShowIn=Unity
[SoftwareProperties Shortcut Group]
Name=Add/Edit PPAs
Exec=gksu software-properties-gtk %u
OnlyShowIn=Unity
[Synaptic Shortcut Group]
Name=Synaptic Software Manager
Exec=gksu synaptic %u
OnlyShowIn=Unity
第四种思路
主页图标快速列表(auto-update来自书签)
这里有一个小型的shell脚本,用你所有的书签更新你的Home-Quicklist。没有手动操作。它读取您的书签文件并从中创建菜单项。它还添加了”Root Filemanager”菜单项。
-
将下面列出的脚本复制到一个空文件中,并将其放入您的scripts-folder中(我们将假定它是
~/bin/
,并且您选择的脚本名称为unityhome.bash
)。 -
运行脚本一次以添加条目:
bash ~/bin/unityhome.bash
-
可选地,你可能会让cron每隔一段时间为你运行脚本。要将它添加到cron中,请将follwing命令键入到shell中:
crontab -e
编辑将打开。在那里添加一行,如:
@reboot /bin/bash/ $HOME/bin/unityhome.bash > /dev/null 2>&1
如果您不这样做,那么如果您希望更新快速列表,则每次更改nautilus书签时都必须手动运行脚本。
-
更改仅在您下次登录时或在您按Alt + F2后生效
unity --replace
所以那样做。注意:不要在终端中运行
unity --replace
。如果你关闭那个终端,它会杀死它的团结。 -
享受并分析解析您的ssh书签的similar script for gnome-terminal(在
~/.ssh/config
中)。
脚本:
这是脚本:
#!/bin/bash
# tabsize: 4, encoding: utf8
#
# © 2011 con-f-use@gmx.net. Use permitted under MIT license:
# http://www.opensource.org/licenses/mit-license.php
#
# CONTRIBUTORS: Chris Druif <cyber.druif@gmail.com>
# Scott Severance <http://www.scottseverance.us/>
# jacopoL <jacopo.jl@gmail.com>
#
# This script updates the unity quicklist menu for nautilus to contain the user
# bookmarks. The updates will have efect after unity is restarted (either on
# the next login or by invoking 'unity --replace').
# location of template and unity bar launchers
nautempl="/usr/share/applications/nautilus-home.desktop"
target="$HOME/.local/share/applications/nautilus-home.desktop"
bookmarks="$HOME/.gtk-bookmarks"
# backup if file already exists
if [ -e "$target" ]; then
echo "Creating backup of: $target."
mv -n "$target" "$target.bak"
fi
# copy template
cp "$nautempl" "$target"
if ! grep -q 'OnlyShowIn=.*Unity' "$target"; then # add only if not already present
sed -i "s/\(OnlyShowIn=.*\)/\1Unity;/" "$target"
fi
# due to a bug in Unity (Ubuntu 11.10+) we will have to completely remove the OnlyShowIn line:
# https://bugs.launchpad.net/ubuntu/+source/unity/+bug/842257/comments/6
sed -i '/^OnlyShowIn=/d' "$target"
if ! grep -q 'X-Ayatana-Desktop-Shortcuts=' "$target"; then # add only if not already present
echo -e "\nX-Ayatana-Desktop-Shortcuts=\n" >> "$target"
else
echo >> "$target"
fi
bmcount=0
while read bmline; do
bmcount=$(($bmcount+1)) # number of current bookmark
bmname=${bmline#*\ } # name of the bookmark
bmpath=${bmline%%\ *} # path the bookmark leads to
# deal with bookmarks that have no name
if [ "$bmname" = "$bmpath" ]; then
bmname=${bmpath##*/}
fi
# fix spaces in names and paths
bmname="$(echo "$bmname" | sed 's/%20/ /g')"
bmpath="$(echo "$bmpath" | sed 's/%20/ /g')"
# fix accents in names and paths (for french users)
bmname="$(echo "$bmname" | python -c 'import sys,urllib;sys.stdout.write(urllib.unquote(sys.stdin.read()))')"
bmpath="$(echo "$bmpath" | python -c 'import sys,urllib;sys.stdout.write(urllib.unquote(sys.stdin.read()))')"
# extend shortcut list with current bookmark, prepending a ; if needed
sed -i "s/\(X-Ayatana-Desktop-Shortcuts=\(.*;$\|$\)\)/\1Scg${bmcount};/
t
s/\(X-Ayatana-Desktop-Shortcuts=.*\)/\1;Scg${bmcount};/" "$target"
# write bookmark information
cat - >> "$target" <<EOF
[Scg$bmcount Shortcut Group]
Name=$bmname
Exec=nautilus "$bmpath"
TargetEnvironment=Unity
EOF
done < "$bookmarks"
# Add a root file manager entry
sed -i "s/\(X-Ayatana-Desktop-Shortcuts=.*\)/\1RootFM;/" "$target"
cat - >> "$target" <<EOF
[RootFM Shortcut Group]
Name=Root
Exec=gksudo nautilus
TargetEnvironment=Unity
EOF
exit 0
改进:不要复制”Home folder”和”username”
如果您不希望将两个项目定位到您的主文件夹(快速列表底部的”Home Folder”和可点击的用户名),则可以替换以下代码:
# write bookmark information
cat - >> "$target" <<EOF
[Scg$bmcount Shortcut Group]
Name=$bmname
Exec=nautilus "$bmpath"
TargetEnvironment=Unity
EOF
done < "$bookmarks"
通过以下代码:
# write bookmark information
if [ "file://$HOME" != "$bmpath" ]; then
cat - >> "$target" <<EOF
[Scg$bmcount Shortcut Group]
Name=$bmname
Exec=nautilus "$bmpath"
TargetEnvironment=Unity
EOF
fi
done < "$bookmarks"
第五种思路
LibreOffice Quicklist
这为LibreOffice Start Center启动器创建了一个快速列表。
-
将原始.desktop文件复制到您的主目录进行编辑:
cp /usr/share/applications/libreoffice-startcenter.desktop ~/.local/share/applications
-
在gedit中打开:
gedit ~/.local/share/applications/libreoffice-startcenter.desktop
-
编辑MimeType行:
找到以下行:
MimeType=application/vnd.openofficeorg.extension;
用。。。来代替:
MimeType=application/vnd.oasis.opendocument.text;application/vnd.oasis.opendocument.text-template;application/vnd.oasis.opendocument.text-web;application/vnd.oasis.opendocument.text-master;application/vnd.sun.xml.writer;application/vnd.sun.xml.writer.template;application/vnd.sun.xml.writer.global;application/vnd.stardivision.writer;application/msword;application/vnd.ms-word;application/x-doc;application/rtf;text/rtf;application/vnd.wordperfect;application/wordperfect;application/vnd.openxmlformats-officedocument.wordprocessingml.document;application/vnd.ms-word.document.macroenabled.12;application/vnd.openxmlformats-officedocument.wordprocessingml.template;application/vnd.ms-word.template.macroenabled.12;application/vnd.oasis.opendocument.spreadsheet;application/vnd.oasis.opendocument.spreadsheet-template;application/vnd.sun.xml.calc;application/vnd.sun.xml.calc.template;application/vnd.stardivision.calc;application/vnd.stardivision.chart;application/msexcel;application/vnd.ms-excel;application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;application/vnd.ms-excel.sheet.macroenabled.12;application/vnd.openxmlformats-officedocument.spreadsheetml.template;application/vnd.ms-excel.template.macroenabled.12;application/vnd.ms-excel.sheet.binary.macroenabled.12;text/csv;application/x-dbf;application/vnd.oasis.opendocument.graphics;application/vnd.oasis.opendocument.graphics-template;application/vnd.sun.xml.draw;application/vnd.sun.xml.draw.template;application/vnd.stardivision.draw;application/vnd.oasis.opendocument.presentation;application/vnd.oasis.opendocument.presentation-template;application/vnd.sun.xml.impress;application/vnd.sun.xml.impress.template;application/vnd.stardivision.impress;application/mspowerpoint;application/vnd.ms-powerpoint;application/vnd.openxmlformats-officedocument.presentationml.presentation;application/vnd.ms-powerpoint.presentation.macroenabled.12;application/vnd.openxmlformats-officedocument.presentationml.template;application/vnd.ms-powerpoint.template.macroenabled.12;application/vnd.oasis.opendocument.formula;application/vnd.sun.xml.math;application/vnd.stardivision.math;
-
突出显示并复制下面的文本,然后将其粘贴到.desktop文件的底部:
X-Ayatana-Desktop-Shortcuts=Writer;Impress;Calc;Math;Draw [Writer Shortcut Group] Name=Writer Exec=libreoffice -writer %U TargetEnvironment=Unity [Impress Shortcut Group] Name=Impress Exec=libreoffice -impress %U TargetEnvironment=Unity [Calc Shortcut Group] Name=Calc Exec=libreoffice -calc %U TargetEnvironment=Unity [Math Shortcut Group] Name=Math Exec=libreoffice -math %U TargetEnvironment=Unity [Draw Shortcut Group] Name=Draw Exec=libreoffice -draw %U TargetEnvironment=Unity
注意:对于LibreOffice 3.4和3.4.1:在Exec中;
libreoffice
必须替换为`libreoffice3.4’,但似乎在Oneiric中我们不需要添加版本号。我正在从Oneiric测试它,并保持默认运行良好,添加版本号使快速列表无法使用 -
导航到〜/.local /share /applications,并将LibreOffice Start Center桌面文件拖放到启动器上。
LibreOffice Writer启动器可以进行类似的修改。
第六种思路
终端快速列表
-
使用Terminal将原始终端启动程序复制到您的主目录中:
cp /usr/share/applications/gnome-terminal.desktop ~/.local/share/applications
-
使用终端仍然使用gedit打开文件:
gedit ~/.local/share/applications/gnome-terminal.desktop
-
从文件中找到以下行:
OnlyShowIn=GNOME;
将上面的行替换为:
OnlyShowIn=GNOME;Unity;
-
将该文本添加到文件的底部,然后保存并放大关闭它:
X-Ayatana-Desktop-Shortcuts=NewWindow;NewTab;Top;Root; [NewWindow Shortcut Group] Name=New Window Exec=gnome-terminal --window TargetEnvironment=Unity [NewTab Shortcut Group] Name=New Tab Exec=xdotool windowfocus gnome-terminal key ctrl+shift+t TargetEnvironment=Unity [Root Shortcut Group] Name=Root Terminal Exec=gksudo gnome-terminal TargetEnvironment=Unity [Top Shortcut Group] Name=Top Exec=gnome-terminal --command top TargetEnvironment=Unity
-
要启用’New Tab’选项,您需要从Ubuntu Software Center安装
xdotool
-
关闭所有终端窗口,right-click在其启动器图标上,并取消勾选’Keep In Launcher’
-
打开Dash,运行
Terminal
,并显示带有快速列表的新启动程序。
第七种思路
Firefox Quicklist
将方便的Firefox选项添加到启动器。
-
将原始.desktop文件复制到您的主目录进行编辑:
cp /usr/share/applications/firefox.desktop ~/.local/share/applications
-
在gedit中打开:
gedit ~/.local/share/applications/firefox.desktop
-
查找并编辑以下行:
X-Ayatana-Desktop-Shortcuts=NewWindow;
匹配这条线:
X-Ayatana-Desktop-Shortcuts=NewWindow;SafeMode;ProfileManager;
-
将此文本添加到.desktop的底部,然后保存该文件:
[SafeMode Shortcut Group] Name=Open Firefox in safe mode Exec=firefox -safe-mode TargetEnvironment=Unity [ProfileManager Shortcut Group] Name=Firefox Profile Manager Exec=firefox -ProfileManager TargetEnvironment=Unity
第八种思路
Google服务启动器
自定义启动器,用于常见服务,如Gmail,日历,撰写新邮件。
-
打开文本编辑器创建一个新文件并粘贴下列文本:
[Desktop Entry] Version=1.0 Name=Google Services Exec=xdg-open https://accounts.google.com/ Terminal=false X-MultipleArgs=false Type=Application Icon=chrome-https___docs.google.com_ Categories=Network;WebBrowser; StartupNotify=true StartupWMClass=docs.google.com X-Ayatana-Desktop-Shortcuts=Plus;Inbox;Compose;Voice;Contacts;Calendar;Documents;Photos;Maps;Sites;Reader;Bookmarks Name[en_US]=Google Services (Gmail) [Plus Shortcut Group] Name=Plus Exec=xdg-open 'https://plus.google.com/u/0/' TargetEnvironment=Unity [Inbox Shortcut Group] Name=InBox Exec=xdg-open 'https://mail.google.com/mail/u/0/?shva=1#inbox' TargetEnvironment=Unity [Compose Shortcut Group] Name=Compose Exec=xdg-open 'https://mail.google.com/mail/?shva=1#compose' TargetEnvironment=Unity [Voice Shortcut Group] Name=Voice Exec=xdg-open 'https://www.google.com/voice/b/0?pli=1#inbox' TargetEnvironment=Unity [Contacts Shortcut Group] Name=Contacts Exec=xdg-open 'https://www.google.com/contacts' TargetEnvironment=Unity [Calendar Shortcut Group] Name=Calendar Exec=xdg-open 'https://calendar.google.com' TargetEnvironment=Unity [Documents Shortcut Group] Name=Documents Exec=xdg-open https://docs.google.com/ TargetEnvironment=Unity [Photos Shortcut Group] Name=Photos Exec=xdg-open 'https://plus.google.com/u/0/photos' TargetEnvironment=Unity [Maps Shortcut Group] Name=Maps Exec=xdg-open 'http://maps.google.com/maps?hl=en&tab=ml' TargetEnvironment=Unity [Sites Shortcut Group] Name=Sites Exec=xdg-open 'https://sites.google.com/?tab=m3&pli=1' TargetEnvironment=Unity [Reader Shortcut Group] Name=Reader Exec=xdg-open 'https://www.google.com/reader/view/?hl=en&tab=my' TargetEnvironment=Unity [Bookmarks Shortcut Group] Name=Bookmarks Exec=xdg-open 'https://www.google.com/bookmarks/l' TargetEnvironment=Unity
-
使用此文件夹位置和名称保存该文件:
~/.local/share/applications/google-services-launcher.desktop
-
通过导航到文件管理器中的
~/.local/share/applications/
将该文件拖放到启动器上。
您可以下载图标here。
第九种思路
Banshee Quicklist
-
将Banshee启动器复制到您的主目录,在终端中粘贴以下内容:
cp /usr/share/applications/banshee.desktop ~/.local/share/applications
-
打开这个新文件进行编辑:
gedit ~/.local/share/applications/banshee.desktop
-
突出显示并复制下面的文本,然后将其粘贴到文件底部。
X-Ayatana-Desktop-Shortcuts=Play;Pause;Stop;Previous;Next;Preferences [Play Shortcut Group] Name=Play Exec=banshee --play TargetEnvironment=Unity [Pause Shortcut Group] Name=Pause Exec=banshee --pause TargetEnvironment=Unity [Stop Shortcut Group] Name=Stop Exec=banshee --stop TargetEnvironment=Unity [Previous Shortcut Group] Name=Previous Exec=banshee --previous TargetEnvironment=Unity [Next Shortcut Group] Name=Next Exec=banshee --next TargetEnvironment=Unity [Preferences Shortcut Group] Name=Preferences Exec=banshee --show-preferences TargetEnviroment=Unity
第十种思路
Google文件快速列表
-
使用此命令创建一个新文件:
gedit ~/.local/share/applications/gdocs.desktop
-
粘贴在下面的文本中:
[Desktop Entry] Version=1.0 Name=Google Docs Exec=xdg-open https://docs.google.com/ Terminal=false X-MultipleArgs=false Type=Application Icon=chrome-https___docs.google.com_ Categories=Network;WebBrowser; StartupNotify=true StartupWMClass=docs.google.com X-Ayatana-Desktop-Shortcuts=Doc;Spreadsheet;Presentation;Drawing [Doc Shortcut Group] Name=New Document Exec=xdg-open https://docs.google.com/?action=newdoc TargetEnvironment=Unity [Spreadsheet Shortcut Group] Name=New Spreadsheet Exec=xdg-open https://spreadsheets.google.com/ccc?new TargetEnvironment=Unity [Presentation Shortcut Group] Name=New Presentation Exec=xdg-open https://docs.google.com/?action=new_presentation TargetEnvironment=Unity [Drawing Shortcut Group] Name=New Drawing Exec=xdg-open https://docs.google.com/drawings/create?hl=en TargetEnvironment=Unity
请注意,这会在您的默认浏览器中打开。对于Chrome /ium全屏应用程序,请使用
chromium-browser
和https:
与--app=https:
查找并替换xdg-open
。 -
将gdocs.desktop从〜/.local /share /applications /
参考资料