为linux应用创建desktop入口

发布时间 2023-07-11 01:56:04作者: MinDreaMaster

自己下载的软件没有desktop入口(也就是相当于windows的快捷方式),需要自己创建

1.创建.desktop文件

touch xxx.desktop //xxx换成你的应用名
vim xxx.desktop //用你喜欢的编辑器打开

2.编辑.desktop内容

可以先看一下其他软件自带的desktop,是怎么写的。
以下是我的自己创建的:

[Desktop Entry]
Version=1.0
Type=Application
Name=TreeSheets
Comment=A hierarchical spreadsheet / outliner productivity tool.
Exec=/home/zzh/Apps/TreeSheets/treesheets %U
Terminal=false
Icon=/home/zzh/Apps/TreeSheets/share/icons/hicolor/scalable/apps/treesheets.svg
MimeType=application/x-treesheets;
Categories=Office;Utility;Spreadsheet;TextEditor;
Keywords=mindmaps;knowledge;organizer;organiser;information;brainstorming;pim;database;todo;

里面的参数可以精简,可以简化到这样:

[Desktop Entry]
Type=Application
Name=TreeSheets
Comment=A hierarchical spreadsheet / outliner productivity tool.
Exec=/home/zzh/Apps/TreeSheets/treesheets %U
Terminal=false
Icon=/home/zzh/Apps/TreeSheets/share/icons/hicolor/scalable/apps/treesheets.svg
Categories=Office;Utility;Spreadsheet;TextEditor;

这几个参数最主要,其中Exec和Icon,分别写你相应的可执行文件和图标的绝对路径即可(带文件名的路径)

3.将desktop文件放入~/.local/share /applications

如果自己没有修改设置,linux中desktop文件所在路径为 /usr/share/applications或者~/.local/share/applications

参考

https://help.gnome.org/admin//system-admin-guide/2.32/menustructure-desktopentry.html.en | Desktop Entry Files
https://developer-old.gnome.org/integration-guide/stable/desktop-files.html.en | Desktop files: putting your application in the desktop menus