首页 > 其他分享 >创建桌面启动器即快捷方式

创建桌面启动器即快捷方式

时间:2024-05-15 17:29:46浏览次数:14  
标签:桌面 GNOME NO FirefoxName application 启动器 FullName desktop 快捷方式

参考:https://blog.csdn.net/ken2232/article/details/130413147

一、麒麟系统下创建桌面启动器三种方式:

1. 直接拷贝法

/usr/share/applications/ # 在此目录下,体现在左下角的开始菜单中。

/home/userName/Desktop #在此目录下,体现在具体用户userName(如:用户 Abc)的桌面上。

对于已经存在于开始菜单中的直接到 /usr/share/applications/ 目录下,拷贝对应的 .desktop 文件,放在自己的桌面目录下 /home/userName/Desktop,即可显示再桌面上。 

2. 自建 .desktop 文件

并不是所有的可执行文件,都有对应的 .desktop 文件。因此,需要自建。 

3. 典型的 .desktop 文件,由 linuxdeployqt 工具默认生成的:

[Desktop Entry]
Type=Application
Name=My Test                    #应用的名字(快捷方式显示的文字)
Exec=/opt/Test/Test             #应用的执行路径(绝对路径)
Icon=/opt/Test/Test.png         #应用的图标(绝对路径)
Comment=This is my test         #说明信息
Terminal=true                   #是否允许在终端启动

二、自建桌面启动器:

x.desktop文件语法解释:

关键词                      意义
[Desktop Entry]        文件头
Encoding                  编码
Name                       应用名称
Name[xx]                 不同语言的应用名称
GenericName          描述
Comment                 注释
Exec                        执行的命令
Icon                         图标路径
Terminal                  是否使用终端
Type                        启动器类型
Categories              应用的类型(内容相关)

x.desktop文件的内容对应项目说明:

[Desktop Entry]
# 编码
Encoding=UTF-8
# 版本(非必须)
Version=0.8.9
# 类型
Type=Application        

# 名称,在桌面上显示的名字。 快捷方式的名字
Name=Android Studio
# 注释
Comment=Android Studio IDE
# 通用名(描述)
GenericName=Android Studio
# 执行命令,可执行程序的路径
Exec=/opt/android-studio/bin/studio.sh %f   #启动程序。%f会出现在默认打开方式列表
# 图标位置,支持常见图片格式
Icon=/opt/android-studio/bin/studio.png         

# 这个很关键,当前表明这个快捷方式不是从终端打开。是否允许终端打开,一般为false
Terminal=false         

# 当 Type 为应用时,表示工作空间路径
Path=
# 分类
Categories=Development;
# 此参数请参考其他文章,我暂时没能理解:)
StartupNotify=true

创建启动器(.Desktop文件)

有些软件提供的启动方式为 .sh 文件,每次启动都需要在终端运行命令。不是很方便,通过查找资料了解到可以创建一个启动器来解决问题。

在linux中,一切皆文件。 启动器就是一个后缀为 .desktop 文件。
我创建的 intelliJ idea 的启动器,文件内容如下 

[Desktop Entry]
Encoding=UTF-8
Name=IntelliJ IDEA
GenericName=IntelliJ IDEA
Comment=The Java IDE for Professional Developers by JetBrains
Exec=/opt/SoftWare/idea-IU-172.4343.14/bin/idea.sh %f
Icon=/opt/SoftWare/idea-IU-172.4343.14/bin/idea.png
Terminal=false
Type=Application
Categories=Application;Programme;

使用流程:

创建文件,以.desktop为后缀。
编写内容,修改权限
双击启动程序,添加信任
移动到/usr/share/applications/目录下,这样就可以在左上角应用程序中显示

 

说明:

其中 Exec 常用的参数有:%f %F %u %U

%f:单个文件名,即使选择了多个文件。如果已选择的文件不在本地文件系统中(比如说在HTTP或者FTP上),这个文件将被作为一个临时文件复制到本地,%f将指向本地临时文件;

%F:文件列表。用于程序可以同时打开多个本地文件。每个文件以分割段的方式传递给执行程序。

%u:单个URL。本地文件以文件URL或文件路径的方式传递。

%U:URL列表。每个URL以分割段的方式传递给执行程序。本地文件以文件URL或文件路径的方式传递。
————————————————
版权声明:本文为CSDN博主「为何不能下定决心?」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Future_promise/article/details/78215201

 

Table 2. Standard Keys

KeyDescriptionValue TypeREQ?Type
Type This specification defines 3 types of desktop entries: Application (type 1), Link (type 2) and Directory (type 3). To allow the addition of new types in the future, implementations should ignore desktop entries with an unknown type. string YES  
Version Version of the Desktop Entry Specification that the desktop entry conforms with. Entries that confirm with this version of the specification should use 1.5. Note that the version field is not required to be present. string NO 1-3
Name Specific name of the application, for example "Mozilla". localestring YES 1-3
GenericName Generic name of the application, for example "Web Browser". localestring NO 1-3
NoDisplay NoDisplay means "this application exists, but don't display it in the menus". This can be useful to e.g. associate this application with MIME types, so that it gets launched from a file manager (or other apps), without having a menu entry for it (there are tons of good reasons for this, including e.g. the netscape -remote, or kfmclient openURL kind of stuff). boolean NO 1-3
Comment Tooltip for the entry, for example "View sites on the Internet". The value should not be redundant with the values of Name and GenericName. localestring NO 1-3
Icon Icon to display in file manager, menus, etc. If the name is an absolute path, the given file will be used. If the name is not an absolute path, the algorithm described in the Icon Theme Specification will be used to locate the icon. iconstring NO 1-3
Hidden Hidden should have been called Deleted. It means the user deleted (at their level) something that was present (at an upper level, e.g. in the system dirs). It's strictly equivalent to the .desktop file not existing at all, as far as that user is concerned. This can also be used to "uninstall" existing files (e.g. due to a renaming) - by letting make install install a file with Hidden=true in it. boolean NO 1-3
OnlyShowInNotShowIn

A list of strings identifying the desktop environments that should display/not display a given desktop entry.

By default, a desktop file should be shown, unless an OnlyShowIn key is present, in which case, the default is for the file not to be shown.

If $XDG_CURRENT_DESKTOP is set then it contains a colon-separated list of strings. In order, each string is considered. If a matching entry is found in OnlyShowIn then the desktop file is shown. If an entry is found in NotShowIn then the desktop file is not shown. If none of the strings match then the default action is taken (as above).

$XDG_CURRENT_DESKTOP should have been set by the login manager, according to the value of the DesktopNames found in the session file. The entry in the session file has multiple values separated in the usual way: with a semicolon.

The same desktop name may not appear in both OnlyShowIn and NotShowIn of a group.

string(s) NO 1-3
DBusActivatable A boolean value specifying if D-Bus activation is supported for this application. If this key is missing, the default value is false. If the value is true then implementations should ignore the Exec key and send a D-Bus message to launch the application. See D-Bus Activation for more information on how this works. Applications should still include Exec= lines in their desktop files for compatibility with implementations that do not understand the DBusActivatable key. boolean NO  
TryExec Path to an executable file on disk used to determine if the program is actually installed. If the path is not an absolute path, the file is looked up in the $PATH environment variable. If the file is not present or if it is not executable, the entry may be ignored (not be used in menus, for example). string NO 1
Exec Program to execute, possibly with arguments. See the Exec key for details on how this key works. The Exec key is required if DBusActivatable is not set to true. Even if DBusActivatable is trueExec should be specified for compatibility with implementations that do not understand DBusActivatable. string NO 1
Path If entry is of type Application, the working directory to run the program in. string NO 1
Terminal Whether the program runs in a terminal window. boolean NO 1
Actions Identifiers for application actions. This can be used to tell the application to make a specific action, different from the default behavior. The Application actions section describes how actions work. string(s) NO 1
MimeType The MIME type(s) supported by this application. string(s) NO 1
Categories Categories in which the entry should be shown in a menu (for possible values see the Desktop Menu Specification). string(s) NO 1
Implements A list of interfaces that this application implements. By default, a desktop file implements no interfaces. See Interfaces for more information on how this works. string(s) NO  
Keywords A list of strings which may be used in addition to other metadata to describe this entry. This can be useful e.g. to facilitate searching through entries. The values are not meant for display, and should not be redundant with the values of Name or GenericName. localestring(s) NO 1
StartupNotify If true, it is KNOWN that the application will send a "remove" message when started with the DESKTOP_STARTUP_ID environment variable set. If false, it is KNOWN that the application does not work with startup notification at all (does not shown any window, breaks even when using StartupWMClass, etc.). If absent, a reasonable handling is up to implementations (assuming false, using StartupWMClass, etc.). (See the Startup Notification Protocol Specification for more details). boolean NO 1
StartupWMClass If specified, it is known that the application will map at least one window with the given string as its WM class or WM name hint (see the Startup Notification Protocol Specification for more details). string NO 1
URL If entry is Link type, the URL to access. string YES 2
PrefersNonDefaultGPU If true, the application prefers to be run on a more powerful discrete GPU if available, which we describe as “a GPU other than the default one” in this spec to avoid the need to define what a discrete GPU is and in which cases it might be considered more powerful than the default GPU. This key is only a hint and support might not be present depending on the implementation. boolean NO 1
SingleMainWindow If true, the application has a single main window, and does not support having an additional one opened. This key is used to signal to the implementation to avoid offering a UI to launch another window of the app. This key is only a hint and support might not be present depending on the implementation. boolean NO 1

 

例子

在此目录下的例子:

/usr/share/applications/

# python3.9.desktop

 

[Desktop Entry]
Name=Python (v3.9)
Comment=Python Interpreter (v3.9)
Exec=/usr/bin/python3.9
Icon=/usr/share/pixmaps/python3.9.xpm
Terminal=true
Type=Application
Categories=Development;
StartupNotify=true
NoDisplay=true

 

 

# git-cola.desktop

        

[Desktop Entry]
Name=Git Cola
Comment=The highly caffeinated Git GUI
Comment[cs]=Git GUI s vysokým obsahem kofeinu
Comment[zh_TW]=高咖啡因含量的 Git 圖形介面
TryExec=git-cola
Exec=git-cola --prompt
Icon=git-cola
StartupNotify=true
Terminal=false
Type=Application
Categories=Development;RevisionControl;
X-KDE-SubstituteUID=false

 

# yad-icon-browser.desktop

         

[Desktop Entry]
Encoding=UTF-8
Name=Icon Browser
Name[fr]=Navigateur d'Icônes
Name[it]=Navigatore di icone
Name[pt_BR]=Ícone do navegador
Name[ru]=Броузер иконок
Name[sk]=Prehliadač ikon
Name[uk]=Павігатор іконок
Name[zh_TW]=圖示瀏覽器
Comment=Inspect GTK Icon Theme
Comment[fr]=Parcourir les icônes du thème GTK
Comment[it]=Sfoglia le icone del tema GTK
Comment[pt_BR]=Inspecionar ícone tema do GTK
Comment[ru]=Исследование темы иконок GTK
Comment[sk]=Preskúmať tému ikon GTK
Comment[uk]=Перегляд теми іконок GTK
Comment[zh_TW]=檢閱 GTK 圖示布景主題
Categories=GTK;Development;
Exec=yad-icon-browser
Icon=yad
Terminal=false
Type=Application
StartupNotify=true

 

# featherpad.desktop

         

[Desktop Entry]
Name=FeatherPad
GenericName=Text Editor
GenericName[cs]=Textový editor
GenericName[da]=Tekstredigering
GenericName[de]=Texteditor
GenericName[es]=Editor de texto
GenericName[eo]=Tekst-Redaktilo
GenericName[fa]=ويرايشگر متن
GenericName[hu]=Szövegszerkesztő
GenericName[it]=Editor di testo
GenericName[ja_JP]=テキストエディタ(Qt)
GenericName[pl]=Edytor tekstu
GenericName[pt]=Editor de texto
GenericName[ru]=Текстовый редактор
GenericName[sv]=Textredigering
GenericName[tr]=Metin Düzenleyici
GenericName[zh_CN]=文本编辑器
Comment=Lightweight Qt text editor
Comment[cs]=Nenáročný textový editor, založený na Qt
Comment[da]=Letvægts Qt-tekstredigering
Comment[es]=Editor de texto ligero basado en Qt
Comment[eo]=Malpeza tekst-redaktilo bazita sur Qt
Comment[fa]=ويرايشگر سبک متن
Comment[hu]=Gyors szövegszerkesztő Qt-ben
Comment[ja_JP]=軽量 Qt テキストエディタ
Comment[pl]=Lekki edytor tekstu oparty na Qt
Comment[pt]=Editor de texto leve baseado em Qt
Comment[ru]=Лёгкий текстовый редактор на Qt
Comment[sv]=Lättviktig Qt-textredigering
Comment[tr]=Hafif Qt tabanlı metin düzenleyici
Comment[zh_CN]=轻量级 Qt 文本编辑器
Exec=featherpad %U
Icon=featherpad
Terminal=false
Type=Application
MimeType=text/plain;
Categories=Qt;Utility;TextEditor;
X-KDE-StartupNotify=false;
Keywords=Text;Editor;Plaintext;
Actions=new-window;standalone-window;

         

[Desktop Action new-window]
Name=New Window
Name[cs]=Nové okno
Name[de]=Neues Fenster
Name[eo]=Nova Fenestro
Name[fa]=پنجره‌ی جديد
Name[it]=Nuova finestra
Name[hu]=Új ablak
Name[pt]=Nova Janela
Name[sv]=Nytt Fönster
Exec=featherpad --win

         

[Desktop Action standalone-window]
Name=Standalone Window
Name[de]=Eigenständiges Fenster
Name[eo]=Memstara Fenestro
Name[fa]=پنجره‌ی مستقل
Name[sv]=Fristående Fönster
Exec=featherpad --standalone

 

# firefox.desktop

        

[Desktop Entry]
Categories=Network;WebBrowser;
Comment[en_US]=Browse the World Wide Web
Comment=Browse the World Wide Web
Comment[bg]=Сърфиране в Мрежата
Comment[ca]=Navegueu per el web
Comment[cs]=Prohlížení stránek World Wide Webu
Comment[de]=Im Internet surfen
Comment[el]=Περιηγηθείτε στον παγκόσμιο ιστό
Comment[es]=Navegue por la web
Comment[fa]=صفحات شبکه جهانی اینترنت را مرور نمایید
Comment[fi]=Selaa Internetin WWW-sivuja
Comment[fr]=Navigue sur Internet
Comment[hu]=A világháló böngészése
Comment[it]=Esplora il web
Comment[ja]=ウェブを閲覧します
Comment[ko]=웹을 돌아 다닙니다
Comment[nb]=Surf på nettet
Comment[nl]=Verken het internet
Comment[nn]=Surf på nettet
Comment[no]=Surf på nettet
Comment[pl]=Przeglądanie stron WWW
Comment[pt]=Navegue na Internet
Comment[pt_BR]=Navegue na Internet
Comment[ru]=Обозреватель Всемирной Паутины
Comment[sk]=Prehliadanie internetu
Comment[sv]=Surfa på webben
Encoding=UTF-8
Exec=firefox %u
GenericName[en_US]=Web Browser
GenericName=Web Browser
GenericName[bg]=Интернет браузър
GenericName[ca]=Navegador web
GenericName[cs]=Webový prohlížeč
GenericName[de]=Webbrowser
GenericName[el]=Περιηγητής ιστού
GenericName[es]=Navegador web
GenericName[fa]=مرورگر اینترنتی
GenericName[fi]=WWW-selain
GenericName[fr]=Navigateur Web
GenericName[hu]=Webböngésző
GenericName[it]=Browser Web
GenericName[ja]=ウェブ・ブラウザ
GenericName[ko]=웹 브라우저
GenericName[nb]=Nettleser
GenericName[nl]=Webbrowser
GenericName[nn]=Nettlesar
GenericName[no]=Nettleser
GenericName[pl]=Przeglądarka WWW
GenericName[pt]=Navegador Web
GenericName[pt_BR]=Navegador Web
GenericName[ru]=Интернет-браузер
GenericName[sk]=Internetový prehliadač
GenericName[sv]=Webbläsare
Icon=firefox
MimeType=text/html;image/png;image/jpeg;image/gif;application/xml;application/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;application/rss+xml;application/rdf+xml;
Name[en_US]=Firefox
Name=Firefox
Name[bg]=Firefox
Name[ca]=Firefox
Name[cs]=Firefox
Name[el]=Firefox
Name[es]=Firefox
Name[fa]=Firefox
Name[fi]=Firefox
Name[fr]=Firefox
Name[hu]=Firefox
Name[it]=Firefox
Name[ja]=Firefox
Name[ko]=Firefox
Name[nb]=Firefox
Name[nl]=Firefox
Name[nn]=Firefox
Name[no]=Firefox
Name[pl]=Firefox
Name[pt]=Firefox
Name[pt_BR]=Firefox
Name[ru]=Firefox
Name[sk]=Firefox
Name[sv]=Firefox
StartupNotify=true
StartupWMClass=Firefox
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-GNOME-FullName=Firefox Web Browser
X-GNOME-FullName[bg]=Интернет браузър (Firefox)
X-GNOME-FullName[ca]=Navegador web Firefox
X-GNOME-FullName[cs]=Firefox Webový prohlížeč
X-GNOME-FullName[el]=Περιηγήτης Ιστού Firefox
X-GNOME-FullName[es]=Navegador web Firefox
X-GNOME-FullName[fa]=مرورگر اینترنتی Firefox
X-GNOME-FullName[fi]=Firefox-selain
X-GNOME-FullName[fr]=Navigateur Web Firefox
X-GNOME-FullName[hu]=Firefox webböngésző
X-GNOME-FullName[it]=Firefox Browser Web
X-GNOME-FullName[ja]=Firefox ウェブ・ブラウザ
X-GNOME-FullName[ko]=Firefox 웹 브라우저
X-GNOME-FullName[nb]=Firefox Nettleser
X-GNOME-FullName[nl]=Firefox webbrowser
X-GNOME-FullName[nn]=Firefox Nettlesar
X-GNOME-FullName[no]=Firefox Nettleser
X-GNOME-FullName[pl]=Przeglądarka WWW Firefox
X-GNOME-FullName[pt]=Firefox Navegador Web
X-GNOME-FullName[pt_BR]=Navegador Web Firefox
X-GNOME-FullName[ru]=Интернет-браузер Firefox
X-GNOME-FullName[sk]=Internetový prehliadač Firefox
X-GNOME-FullName[sv]=Webbläsaren Firefox
X-KDE-SubstituteUID=false
X-KDE-Username=
X-MultipleArgs=false

 

 

 

标签:桌面,GNOME,NO,FirefoxName,application,启动器,FullName,desktop,快捷方式
From: https://www.cnblogs.com/qingzhen/p/18194364

相关文章

  • 桌面图标间距Bug:Win10/Win11桌面图标占用空间变成长方形怎么办?
    阅读全文:https://itxiaozhang.com/win10-win11-desktop-icon-bug-rectangular-fix/此教程配合视频学习效果最佳,视频教程在文章末尾。问题描述在使用Windows10或Windows11操作系统时,桌面图标的间距突然变得很大,变成了长方形。该问题通常发生在修改屏幕分辨率、连接外部显示......
  • 桌面图标间距Bug:Win10/Win11桌面图标占用空间变成长方形怎么办?
    阅读全文:https://itxiaozhang.com/win10-win11-desktop-icon-bug-rectangular-fix/此教程配合视频学习效果最佳,视频教程在文章末尾。问题描述在使用Windows10或Windows11操作系统时,桌面图标的间距突然变得很大,变成了长方形。该问题通常发生在修改屏幕分辨率、连接外部显示......
  • 超简洁的todolist工具,电脑桌面高效计划管理软件
    对于上班族来说,在电脑上使用一款高效计划管理软件至关重要。这样的工具不仅能帮助我们清晰地规划和追踪工作任务,还能有效提高工作效率,减少遗漏和延误。例如,当我们面临多个项目并行时,通过管理软件可以一目了然地查看各项任务的进度和优先级,从而合理分配时间和精力。那么,哪款电脑桌......
  • Ubuntu 实例桌面版
    基于ubuntu18.04安装的桌面版本,桌面使用xfce4,集成了Pytorch2.3.0、cuda11.8、Python3.10、VNC、noVNC、VSCode-Server。立即免费体验:https://gpumall.com/login?type=register&source=cnblogs在镜像市场选择xfce4-desktop镜像,然后进行创建实例#autodl#恒源云#矩池云#算......
  • deepin20.9启动器修改大圆角为小圆角
    获取源代码:aptsourcedde-launcher修改代码:vimsrc/windowedframe.cpp,623行caseTopRight:path.moveTo(topLeft.x(),topLeft.y());path.lineTo(topRight.x()-m_radius,topRight.y());//path.arcTo(topRight.x()-m_radius*2,topRight.y(),m_radius*......
  • 高DPI下windows远程桌面缩放问题
    第一步:打开注册表:HKEY_LOCAL_MACHINE>SOFTWARE>Microsoft>Windows>CurrentVersion>SideBySide新建DWORD(32bit)的项,命名为:PreferExternalManifest,打开PreferExternalManifest,将值设为1,16进制。第二步打开记事本输入如下代码:<?xmlversion="1.0"encoding=&quo......
  • 良心实用的电脑桌面便利贴,好用的便利贴便签小工具
    在日常办公中,上班族经常需要记录临时任务、重要提醒或者突发的灵感。比如,在紧张的项目会议中,忽然想到一个改进的点子,或者是在处理邮件时,需要记下对某个客户的回复要点。在这些场景下,如果能直接在电脑桌面上使用便利贴或便签工具,将会大大提高工作效率。那么,哪款电脑桌面便利贴是良......
  • 使用python在windows系统操作快捷方式
    其实问题是由上一篇文章(https://www.cnblogs.com/anpengapple/p/18179353)的结尾引出来的。不需要了解背景的话,我现在需要做的是,右键打开桌面上的chrome快捷方式的属性,在目标的后面增加一个参数。我不想傻傻地手动添加,想交给程序来处理。 首先需要简单来说一下,windows的快捷方式......
  • win10电脑桌面便签纸怎么设置?添加桌面便签方法
    对于上班族来说,电脑桌面上的电子便签纸是一项不可或缺的工具。在快节奏的工作环境中,我们经常需要随时记录重要信息、安排工作任务,而电子便签纸以其便捷性和实时性成为了我们的得力助手。想象一下,在紧张的项目讨论中,你需要快速记下同事的建议;或是在灵感迸发时,你想要立刻捕捉那些闪......
  • Electron桌面应用
    Electron介绍Electron集成了chromium(支持最新特性的浏览器)与Node.js(javascript运行时,可实现文件读写)NativeAPI是(提供统一原生界面操作的能力)工作流程:启动APP启动主进程,创建窗口,加载指定界面,开启渲染进程,渲染进程需要进行通信(如新增歌曲打开文件夹选择MP3文件)需通过主进程调用......