2020-05-09 15:26:12 +08:00
|
|
|
|
# 创建 Desktop Entry
|
|
|
|
|
|
2020-12-25 01:00:53 +08:00
|
|
|
|
## 1.系统级设置
|
|
|
|
|
|
2020-05-09 15:26:12 +08:00
|
|
|
|
Linux 桌面图标入口不仅仅是一个可编辑文件,称作 Desktop Entry,扩展名为“.desktop”。一般集中保存在 /usr/share/applications 目录下。
|
|
|
|
|
|
2020-12-25 01:00:53 +08:00
|
|
|
|
两个应用程序 .desktop 参考模板如下:
|
2020-05-09 15:26:12 +08:00
|
|
|
|
|
2020-05-20 16:18:39 +08:00
|
|
|
|
```ini
|
2020-05-09 15:26:12 +08:00
|
|
|
|
[Desktop Entry]
|
|
|
|
|
Name=GtkTerm
|
|
|
|
|
Type=Application
|
|
|
|
|
Comment=A gtk+ based serial port communication program
|
|
|
|
|
Exec=/usr/bin/gtkterm
|
|
|
|
|
Icon=gtkterm
|
|
|
|
|
MimeType=x-scheme-handler/gtkterm;
|
|
|
|
|
Categories=Network;
|
|
|
|
|
```
|
|
|
|
|
|
2020-12-25 01:00:53 +08:00
|
|
|
|
```ini
|
|
|
|
|
[Desktop Entry]
|
|
|
|
|
Name=STM32CubeIDE
|
|
|
|
|
Comment=STM32CubeIDE 1.5.0
|
|
|
|
|
GenericName=STM32CubeIDE
|
|
|
|
|
Exec=env GDK_BACKEND=x11 stm32cubeide %F
|
|
|
|
|
Icon=stm32cubeide
|
|
|
|
|
Path=/opt/stm32cubeide/
|
|
|
|
|
Terminal=false
|
|
|
|
|
StartupNotify=true
|
|
|
|
|
Type=Application
|
|
|
|
|
Categories=Development
|
|
|
|
|
```
|
|
|
|
|
|
2020-05-09 15:26:12 +08:00
|
|
|
|
应用程序图标保存在 /usr/share/icons 目录下,图标通过 MIME 配置文件与程序关联。
|
2020-12-25 01:00:53 +08:00
|
|
|
|
|
|
|
|
|
## 2.用户级设置
|
|
|
|
|
|
|
|
|
|
在 ~/.local/share/applications 目录下也可以保存 Desktop Entry,这个目录属于用户级别设置,只对当前用户有效。
|
|
|
|
|
|
|
|
|
|
如果 ~/.local/share/applications 与 /usr/share/applications 目录下存在同名称文件,则用户级别设置生效。有时系统级别设置有效,而用户级别设置无效,将导致菜单中无法找到该应用的入口。
|
2020-12-25 01:03:15 +08:00
|
|
|
|
|
|
|
|
|
## 3.特殊说明
|
|
|
|
|
|
|
|
|
|
修改 ~/.local/share/applications 或 /usr/share/applications 目录中的内容后需要执行一下:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
sync
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
命令,确保修改生效。
|