Desktop icons should be simple, but they’re not on Ubuntu 18.04 LTS and newer releases like Ubuntu 19.10. Follow these easy steps to get desktop shortcuts for your favorite applications, just like on other operating systems and other Linux desktops.

桌面图标应该很简单,但不能在Ubuntu 18.04 LTS和更高版本(如Ubuntu 19.10)上使用。 按照这些简单的步骤,即可为您喜欢的应用程序获取桌面快捷方式,就像在其他操作系统和其他Linux桌面上一样。

是的,应该更容易 (Yes, It Should Be Easier)

Dropping shortcuts on the desktop is one of those things that Windows users do without overthinking about it. It’s unfortunate, but a newcomer to Linux can find doing that simple task a frustrating struggle. It’s the type of thing that gives them the impression that getting anywhere with Linux is going to be a long hard slog.

在桌面上放置快捷方式是Windows用户不加思索的事情之一。 不幸的是,但是Linux的新手会发现完成此简单任务令人沮丧。 正是这种类型给他们的印象是,要想在Linux上取得成功,将是一个漫长的艰难历程。

Even people who’ve used Linux for a little while and know their way around pretty well can find this topic much more of a struggle that it ought to be. In actual fact, it’s not difficult, but it is definitely counter-intuitive.

即使是使用Linux已有一段时间的人,也非常了解Linux的方式,他们也可以发现这个话题比以前更艰巨。 实际上,这并不难,但这绝对是违反直觉的。

安装GNOME调整 (Installing GNOME Tweaks)

By default, you can’t copy files or icons to Ubuntu’s GNOME Shell desktop. To make this possible you’ll need to use GNOME Tweaks to change a setting. Use this command to install it.

默认情况下,您不能将文件或图标复制到Ubuntu的GNOME Shell桌面。 为此,您需要使用GNOME Tweaks更改设置。 使用此命令进行安装。

sudo apt-get install gnome-tweaks

When it has installed, press the “Super” key (between the Control and Alt keys on the bottom-left of most keyboards) and type “tweaks”. The Tweaks icon will appear. Click on that to launch Tweaks.

安装后,按“超级”键(在大多数键盘的左下方,在Control和Alt键之间),然后键入“ tweaks”。 出现“调整”图标。 单击该按钮以启动“调整”。

This is the icon in Ubuntu 18.04. The icon will look different in Ubuntu 19.10. When Tweaks has launched, click on on “Desktop” in the left-hand pane. Click the “Show icons” slider button to allow desktop icons. You can choose whether you wish to have shortcuts to your home directory, the trash can, network servers, and mounted volumes shown on the desktop.

这是Ubuntu 18.04中的图标。 该图标在Ubuntu 19.10中看起来会有所不同。 启动Tweaks后,单击左侧窗格中的“桌面”。 单击“显示图标”滑块按钮以允许使用桌面图标。 您可以选择是否希望在桌面上显示主目录,垃圾箱,网络服务器和已安装卷的快捷方式。

Note that in Ubuntu 19.10, the desktop icon settings are under the Extensions settings, so click the “Extensions” entry in the left-hand pane.

请注意,在Ubuntu 19.10中,桌面图标设置位于扩展设置下,因此请单击左侧窗格中的“扩展”条目。

创建桌面快捷方式 (Creating a Desktop Shortcut)

To demonstrate this process, we’re going to create a desktop shortcut for LibreOffice writer. Now that we’ve turned on the ability to have icons on the desktop, we just need to drag something to the desktop, and we’ll have a shortcut. But what do we need to drag?

为了演示此过程,我们将为LibreOffice writer创建一个桌面快捷方式。 现在,我们已经启用了在桌面上显示图标的功能,我们只需要将某些东西拖到桌面上,就会有一个快捷方式。 但是,我们需要拖动什么?

It’s something called an application’s  .desktop file. These are text files that describe certain attributes about the application. Amongst other things, they tell the operating system where the binary executable resides in the file system. When you double-click the shortcut, Linux uses this information to find and launch the application’s binary file. We just need to find the right .desktop file.

这就是所谓的应用程序的.desktop文件。 这些是描述有关应用程序某些属性的文本文件。 除其他外,它们告诉操作系统二进制可执行文件在文件系统中的位置。 当您双击快捷方式时,Linux使用此信息来查找并启动应用程序的二进制文件。 我们只需要找到正确的.desktop文件。

Applications that are provided as part of a distribution’s default packages, or are installed from repositories, have their .desktop files installed into:

作为发行版默认软件包的一部分提供的应用程序,或从存储库安装的应用程序的.desktop文件安装到:

/usr/local/share/applications

Other applications that have been locally installed with system-wide access—meaning they are available for all users—usually have their .desktop files installed into:

在本地安装并具有系统范围访问权限的其他应用程序(意味着它们对所有用户都可用)通常将其.desktop文件安装到:

/usr/local/share/applications

Applications that have been installed so that they are only accessible to a single user have their .desktop files installed into the home directory of that user:

已安装的应用程序(仅供单个用户访问)将.desktop文件安装到该用户的主目录中:

~/.local.share/applications

LibreOffice is available for all users, so we’re going to launch Files and browse to the /usr/share/applications directory.  You’ll need to navigate to the appropriate directory for the application you’re looking for.

LibreOffice适用于所有用户,因此我们将启动“文件”并浏览到/usr/share/applications目录。 您需要导航到要查找的应用程序的适当目录。

Launch Files, and click on “Other locations” in the left-hand pane. Then navigate to Computer > usr > share > applications.

启动文件,然后单击左侧窗格中的“其他位置”。 然后导航至计算机> usr>共享>应用程序。

Scroll through the icons until you see the LibreOffice Writer icon. In Ubuntu 19.10, the icons all look like cogged wheels, so you’ll need to check the name of the file to make sure you have the correct .desktop file.

滚动浏览图标,直到看到LibreOffice Writer图标。 在Ubuntu 19.10中,所有图标看起来都像齿轮,因此您需要检查文件名以确保具有正确的.desktop文件。

To make certain you’ve found the .desktop file of the application you’re looking for, right-click the icon and select properties. You should see a line telling you this is a desktop configuration file. Close the properties dialog.

为确保已找到要查找的应用程序的.desktop文件,请右键单击该图标并选择属性。 您应该看到一行告诉您这是一个桌面配置文件。 关闭属性对话框。

Left-click on the LibreOffice Writer icon, hold the left mouse button down, and drag the icon to the desktop. Release the mouse button. Although this would usually move what was being dragged, in this case, it copies it.

左键单击LibreOffice Writer图标,按住鼠标左键,然后将图标拖到桌面。 释放鼠标按钮。 尽管这通常会移动被拖动的内容,但在这种情况下,它会对其进行复制

You’ve now got an icon on the desktop, but it doesn’t look anything like it should. What’s going on?

现在,您已经在桌面上有了一个图标,但是它看起来并不像它应该的样子。 这是怎么回事?

Although it doesn’t look like you’d expect, it is a working shortcut. Double-click it to launch the application, and you’ll be greeted with a warning dialog.

尽管看起来不像您期望的那样,但这是一个有效的捷径。 双击它以启动该应用程序,然后会出现一个警告对话框。

Click the “Trust and launch” button, and two things will happen.

单击“信任并启动”按钮,将发生两件事。

The icon will change its appearance and text label to look like you’d expect it to, and LibreOffice Writer will be launched.

该图标将更改其外观和文本标签,使其看起来像您期望的那样,然后将启动LibreOffice Writer。

You now have a LibreOffice Writer icon on the desktop that can be used as a shortcut to launch the application. You’ll only see the “Untrusted Application Launcher” dialog the first time you use the shortcut.

现在,您在桌面上有一个LibreOffice Writer图标,可以用作启动该应用程序的快捷方式。 首次使用快捷方式时,您只会看到“不受信任的应用程序启动器”对话框。

如果.desktop文件丢失怎么办? (What if the .desktop File is Missing?)

Sometimes applications do not provide a .desktop file. Programs that have been written in-house or applications you might have downloaded from Github, for example, often don’t come with a .desktop file.

有时应用程序不提供.desktop文件。 例如,内部编写的程序或您可能从Github下载的应用程序通常不带有.desktop文件。

That’s not a problem; we can easily create our own. All it is is a text file with the appropriate details listed in it.

那不是问题; 我们可以轻松创建自己的。 它只是一个文本文件,上面列出了适当的详细信息。

创建一个.desktop文件 (Creating a .desktop File)

On this test computer, we’ve got a program that doesn’t have a .desktop file.

在这台测试计算机上,我们有一个没有.desktop文件的程序。

The first thing to do is to check that the application runs. If it doesn’t, you’re not going to get it working with a .desktop file either. But you can spend a lot of time going round in circles wondering why your .desktop file doesn’t work. So, for the sake of being thorough, ensure you’re application launches and runs correctly when you start it manually.

首先要做的是检查应用程序是否运行。 如果没有,您也不会使用.desktop文件。 但是您可能会花很多时间盘算,想知道为什么您的.desktop文件不起作用。 因此,为彻底起见,请确保您在手动启动应用程序时启动并正确运行了应用程序。

A .desktop file is a text file with settings it in. On its own, that isn’t enough to display an icon. We need to use an icon that has been supplied with the application. We can see there is an icon called “ip_gc_icon.png” in the application directory, and we’ll use that.

.desktop文件是带有设置内容的文本文件。仅靠它本身不足以显示图标。 我们需要使用应用程序随附的图标。 我们可以看到应用程序目录中有一个名为“ ip_gc_icon.png”的图标,我们将使用它。

We can also see that the binary file is called gc . We’ll need that information shortly.

我们还可以看到二进制文件称为gc 。 我们很快将需要这些信息。

Open up an editor. We’re going to be using gedit, but you can use the editor of your choice.

打开一个编辑器。 我们将使用gedit ,但是您可以使用自己选择的编辑器。

The first line of the .desktop file must be:

.desktop文件的第一行必须是:

[Desktop Entry]

This identifies to Linux what it is you’re clicking on when you double-click it.

这将向Linux标识您双击它时要单击的内容。

All of the other entries in the .desktop file are composed of labels and values, joined by an equals sign =. Make sure you don’t have spaces directly before or after the equals sign.

.desktop文件中的所有其他条目均由标签和值组成,并由等号= 。 确保在等号之前或之后没有空格。

The next four lines describe the application.

接下来的四行描述了该应用程序。

Version=1.0
Name[en_US]=Geocoder
GenericName[en_US]=Interesting Point Geocoder
Comment[en_US]=Interesting Point Geocoder is a tool to create CSV files of geolocational data
  • The “Version” entry is the version number from the program.“版本”条目是程序的版本号。
  • The “Name” entry is the name of the application. Note that we’ve included a locale identifier, [en_US], which means US English. You could leave it out. If you were creating a multi-lingual .desktop file, these types of identifiers would be required for each different language section. They won’t make any difference here, but they’re a good habit to get into.“名称”条目是应用程序的名称。 请注意,我们包括了一个语言环境标识符[en_US],表示美国英语。 您可以忽略它。 如果要创建多语言的.desktop文件,则每种不同的语言部分都需要使用这些类型的标识符。 他们在这里没有任何区别,但是他们是一个很好的习惯。
  • The “GenericName” entry is used to hold a generic description of the application. This could be used to hold descriptions such as “video editor,” “web browser,” or “word processor.” This application doesn’t fall into any particular category, so we’ll just give it a longer version of the application name.“ GenericName”条目用于保存应用程序的一般描述。 它可以用来保存诸如“视频编辑器”,“ Web浏览器”或“文字处理器”之类的描述。 该应用程序不属于任何特定类别,因此我们只给它更长的版本。
  • The “Comment” entry can hold any descriptive text you like.“注释”条目可以包含您喜欢的任何描述性文本。

The next three lines provide information to Linux so that it knows where the binary executable is, and which icon it should use for the shortcut.

接下来的三行向Linux提供信息,以便它知道二进制可执行文件在哪里,以及该快捷方式应使用哪个图标。

Exec=/home/dave/geocoder/gc
Path=/home/dave/geocoder/
Icon=/home/dave/geocoder/ip_gc_icon.png
  • The “Exec” entry is the path to the binary executable. In our example, this is the gc executable.

    “ Exec”条目是二进制可执行文件的路径。 在我们的示例中,这是gc可执行文件。

  • The “Path” entry is the path to the working directory for the application.“路径”条目是应用程序工作目录的路径。
  • The “Icon” entry is the path to the icon file that you wish to use for the desktop shortcut.“图标”条目是您要用于桌面快捷方式的图标文件的路径。

The last three lines are supplementary data regarding the application.

最后三行是有关应用程序的补充数据。

Terminal=false
Type=Application
Categories=Application
  • The “Terminal” entry can be True or False. It indicates whether the application executes in a terminal or not. Our entry needs to be “false”.“终端”条目可以为True或False。 它指示应用程序是否在终端中执行。 我们的输入必须为“ false”。
  • The “Type” entry can be one of Application, Link, or Directory. Obviously, we want our entry to be “Application”.“类型”条目可以是“应用程序”,“链接”或“目录”之一。 显然,我们希望我们的条目为“ Application”。
  • The “Categories” entry may be used by Linux or GNOME to group similar or related applications in menus. We’re just going to enter a generic “Applications.”Linux或GNOME可以使用“类别”条目将菜单中的相似或相关应用程序分组。 我们将要输入通用的“应用程序”。

A full list of possible .desktop file entries and their values can be found in the .desktop file specification.

可能的.desktop文件条目及其值的完整列表可以在.desktop文件规范中找到。

Here’s our complete .desktop file:

这是我们完整的.desktop文件:

Save the file into the application directory, making sure it has a “.desktop” file extension. Our example file is called “Geocoder.desktop.”

将文件保存到应用程序目录中,确保文件扩展名为“ .desktop”。 我们的示例文件称为“ Geocoder.desktop”。

将.desktop文件复制到桌面 (Copying the .desktop FIle To the Desktop)

To copy the .desktop file onto the desktop, right-click it and select “Copy” from the context menu. Right-click on the desktop and select “Paste” from the context menu.

要将.desktop文件复制到桌面上,请右键单击该文件,然后从上下文菜单中选择“复制”。 右键单击桌面,然后从上下文菜单中选择“粘贴”。

When you double click the icon on the desktop, you’ll see the same warning dialog as earlier. Click the “Trust and Launch” button.

双击桌面上的图标时,您将看到与之前相同的警告对话框。 单击“信任并启动”按钮。

The desktop icon will take on its true appearance, and the application will be launched.

桌面图标将显示其真实外观,然后将启动该应用程序。

将.desktop文件复制到Applications文件夹 (Copying the .desktop FIle To the Applications Folder)

As this program is going to be used by a single user, we’ll copy the .desktop file to his local applications directory. In the program directory, use this command:

由于该程序将由单个用户使用,因此我们将.desktop文件复制到他的本地应用程序目录中。 在程序目录中,使用以下命令:

cp ./Geocoder.desktop ~/.local/share/applications

Putting the .desktop file in the local applications directory integrates the application into the GNOME search function. Press the “Super” key (between the Control and Alt keys on the bottom-left of most keyboards) and type the first part of your application’s name. Its icon will appear in the search results.

将.desktop文件放在本地应用程序目录中,会将应用程序集成到GNOME搜索功能中。 按“超级”键(在大多数键盘的左下角,在Control和Alt键之间),然后键入应用程序名称的第一部分。 其图标将出现在搜索结果中。

  • Left-Click it to launch the application.

    左键单击以启动应用程序。

  • Right-click it and select “Add to favorites” to add it to your Ubuntu dock.

    右键单击它,然后选择“添加到收藏夹”添加到您的Ubuntu扩展坞。

准备发射 (Ready for Launch)

So there you have it. A little long-winded, but simple enough.

所以你有它。 有点long,但是很简单。

And definitely counter-intuitive.

绝对违反直觉。

翻译自: https://www.howtogeek.com/445303/how-to-create-desktop-shortcuts-on-ubuntu/

如何在Ubuntu上创建桌面快捷方式相关推荐

  1. ubuntu clion 创建桌面快捷方式

    ubuntu clion 创建桌面快捷方式 首先在终端下输入 cd /usr/share/applications/ 进入applications目录下,建立一个clion.desktop文件 sud ...

  2. ubuntu创建php文件,ubuntu系统创建桌面快捷方式的方法

    在ubuntu系统中,自己安装的程序往往没有创建桌面快捷方式,每次都通过终端然后输入绝对路去径执行命令比较繁琐,其实可以像windows那样自己在桌面程序创建程序的快捷方式,这样方便了每次的启动. 这 ...

  3. Ubuntu系统创建桌面快捷方式

    在Ubuntu系统中创建桌面快捷方式 一般创建方法 在目录/usr/share/applications下,有安装软件时自动生成的的桌面快捷方式,将其复制到你的桌面 修改权限,右键图标,点击allow ...

  4. 如何在Ubuntu上使用MultiSystem创建多启动USB盘

    如何在Ubuntu上使用MultiSystem创建多启动USB盘 介绍 也许还有不少人不知道MultiSystem,它是一个用来在Linux系统中创建多启动usb盘的小型的开源软件.使用这个工具,我们 ...

  5. Ubuntu系统为程序创建桌面快捷方式

    为了不用每次都要进入命令行启动应用程序,为程序创建快捷方式是一个很方便的方法,尤其是你的程序需要在团队外部使用的时候. 桌面创建快捷方式一般使用.desktop为后缀的文件实现,该文件的内容格式基本要 ...

  6. Ubuntu安装Blender并创建桌面快捷方式的详细步骤(基于官方下载.tar.xz文件)

    Ubuntu安装Blender并创建桌面快捷方式的详细步骤(基于官方下载.tar.xz文件) 1. 下载Blender 从blender官网下载.tar.xz安装文件,下载网址为:https://ww ...

  7. Ubuntu安装pycharm并创建桌面快捷方式

    1.下载Pycharm社区版本:Pycharm下载地址 2.解压 3.执行pycharm.sh命令 4.点击continue按钮 5.新建项目即可 6.创建桌面快捷方式 7.在目录栏里面出现快捷方式

  8. ubuntu系统下,安装pycharm以及创建桌面快捷方式

    Ubuntu22.04存在问题: 今天尝试安装一个XXXX-x86_64.appimage软件,软件图表在桌面点击没有反映. 检查属性,已经设置为可执行文件. terminal cd进文件夹,输入 . ...

  9. 如何在Ubuntu上安装OnlyOffice Docs 7.1?

    如何在Ubuntu上安装OnlyOffice Docs 7.1? 什么是OnlyOffice Docs? OnlyOffice Docs是一套在线办公软件,可以打开阅读并编辑文档.表格和幻灯片文件,完 ...

最新文章

  1. jdbc获取结果行数_如何获取JDBC中的行数?
  2. 专家答疑:在ERP系统中确保销售订单准确性
  3. python json文件太大_python - python json.dump创建的文件太大 - 堆栈内存溢出
  4. 为系统加载右键注册控件选项【VB 注册控件】
  5. C++基础教程之类与对象
  6. 可供创业团队技术开发参考的10条经验
  7. python绘制混淆矩阵
  8. 《Java开发实战经典》习题第4章第10题:在排序好的数组中添加一个数字,将添加后的数字插入到数组合适的位置
  9. 从零开始学习Java设计模式 | 设计模式入门篇:教程导读
  10. 024 幂函数、指数函数、对数函数导数公式推导
  11. 电子罗盘的椭球拟合与椭球变换
  12. SCSI与USB的关系
  13. Win10下系统自带的各种监测工具
  14. web开发—— 前端基础(6) ——语义化标签
  15. 【LaTex】3.2 数据结构(TikZ)
  16. 【408】计算机网络第一轮强化笔记
  17. 5.类似mouse-click方法的替代方案(netlogo)
  18. C++ windows 创建快方式
  19. 技术评审中常见的一些问题
  20. 【你好面试官】008 Java内存模型指volatile底层原理详解、多处理器原子操作实现原理

热门文章

  1. 30 个实例详解 TOP 命令!
  2. 盘点关于IDEA的几个调试的实用技巧
  3. 最重要的是跑完,而不是刚开始跑得有多快
  4. jvm内存结构_浅谈JVM内存结构
  5. 智慧政务解决方案(28页)pdf_【金众电子】智慧政务解决方案
  6. linux系统硬盘设置密码,LUKS:Linux下磁盘加密
  7. 西里尔字符_如何设计西里尔字母Њ(Nje),Љ(Lje),Ћ(Tshe)和Ђ(Dje)
  8. matplotlib可视化_EDA:Geopandas,Matplotlib和Bokeh中的可视化
  9. 云栖专辑 | 阿里开发者们的第6个感悟:享受折磨
  10. bootstrap评分插件 Bootstrap Star Rating Examples