Ubuntu 18.04 将程序添加到 Gnome 桌面菜单栏

更新日期: 2018-06-26 阅读次数: 14920 分类: Linux

类似于 windows 的快捷方式,Gnome 会查看

  • /usr/share/applications
  • ~/.local/share/applications

这两个目录下的 .desktop 文件。

例如

$ ls /usr/share/applications
simplenote.desktop
gedit.desktop

$ ls ~/.local/share/applications
wechat_dev_tools.desktop
chrome-blpcfgokakmgnkcojhhkbfbldkacnbeo-Default.desktop

simplenote.desktop 的内容

[Desktop Entry]
Name=Simplenote
Comment=Simplenote for Linux
Exec="/opt/Simplenote/simplenote" %U
Terminal=false
Type=Application
Icon=simplenote
StartupNotify=true
Categories=Utility;

wechat_dev_tools.desktop 的内容

[Desktop Entry]
Name=微信web开发者工具
Comment=The development tools for wechat web develop
Categories=Development;WebDevelopment;IDE;
Exec=/home/zhongwei/install/wechat_web_devtools/bin/wxdt %U
Icon=/home/zhongwei/install/wechat_web_devtools/dist/package.nw/static/image/logo@2x.png
Type=Application
Terminal=false
X-Desktop-File-Install-Version=0.23

chrome-aohghmighlieiainnegkcijnfilokake-Default.desktop 的内容

cat ~/.local/share/applications/chrome-aohghmighlieiainnegkcijnfilokake-Default.desktop
#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Terminal=false
Type=Application
Name=Docs
Exec=/opt/google/chrome/google-chrome --profile-directory=Default --app-id=aohghmighlieiainnegkcijnfilokake
Icon=chrome-aohghmighlieiainnegkcijnfilokake-Default
NoDisplay=true
StartupWMClass=crx_aohghmighlieiainnegkcijnfilokake

命令行程序

从文档看,Terminal=true 支持从命令行执行。

参考

https://developer.gnome.org/integration-guide/stable/desktop-files.html.en

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式