有时自己手动安装的程序(比如各种解压缩直接能运行的程序,并不是通过.deb文件包安装),通常不会在 应用程序列表 显示,这样有点不方便,其实我们可以手动创建快捷方式。
环境:
Ubuntu 20.04 Desktop(LTS)
要添加快捷方式的位置
1.应用程序列表

应用程序列表 的快捷方式默认的存放路径为:/usr/share/applications
,在这个目录手动添加一个aaa.desktop
文件,用户root,属组root,权限:644,内容为:
[Desktop Entry]
Version=x.y
Name=ProgramName
Name[zh_CN]=ProgramName
Comment=This is my comment
Exec=/xxx/xxx/aaa
Icon=/xxx/xxx/xxx.png
Terminal=false
Type=Application
Categories=Utility;Application;
其中,Version
项可以省略不写,Name[zh_CN]
项在中文语言环境时可以显示的名字,到此在应用程列表里就会显示图标了(如下图VS Code)。

2.桌面
原理同上,不过,在已经添加了 应用程序列表 的快捷方式后,直接复制aaa.desktop
文件到桌面就行,无需再编辑一遍,不过要注意当前用户的权限(用户为当前用户,属组为当前用户的属组,权限为:644),以及打开“允许启动”选项,完成后显示图标。


注意事项:
- 执行程序的文件名与快捷方式的文件名最好保持一致,否则程序不能收藏至dock栏(如图:image1),或者即使收藏到了dock栏(在 应用程序列表 的图标右键收藏:图:image2),运行后也不会出现在dock对应的图标上,而是另开一个图标(如图:image3)。如本人是添加VS Code的快捷方式,执行程序的全路径:
/home/**/Software/VSCode-linux-x64/bin/code
,文件名就是:code
,所以快捷方式文件就是code.desktop
。



附:本人的desktop文件内容(路径中**为用户名):
[Desktop Entry]
Name=VS Code
Name[zh_CN]=Visual Studio Code
Comment=Visual Studio Code, multi-platform code editor for Linux
Exec=/home/**/Software/VSCode-linux-x64/bin/code
Icon=/home/**/Software/VSCode-linux-x64/resources/app/resources/linux/code.png
Type=Application
Categories=Application;
Encoding=UTF-8
StartupNotify=true
参考资料:
Ubuntu官网: ubuntu.com
Ubuntu指南: 创建.desktop文件
网友评论