如何在Ubuntu上创建桌面快捷方式

Ubuntu 18.04's GNOME Shell desktop.

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
sudo apt-get install gnome-tweaks in a terminal window

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”。 出现“调整”图标。 单击该按钮以启动“调整”。

The Tweaks icon in Ubuntu 18.04

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后,单击左侧窗格中的“桌面”。 单击“显示图标”滑块按钮以允许使用桌面图标。 您可以选择是否希望在桌面上显示主目录,垃圾箱,网络服务器和已安装卷的快捷方式。

The desktop settings in the application window in Ubuntu 18.04

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文件。

Files window showing LibreOffice Writer icon

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文件,请右键单击该图标并选择属性。 您应该看到一行告诉您这是一个桌面配置文件。 关闭属性对话框。

LibreOffice Writer .desktop file properties dialog.

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?

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

Desktop icon immediately after being dragged to the desktop

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.

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

Warning dialog about an untrusted launcher

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。

Working LibreOffice Writer desktop shortcut.

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 。 我们很快将需要这些信息。

geocoder directory with icon visible

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文件:

Teh completed .desktop file in the gedit editor

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.

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

Untrusted Launcher warning dialog

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

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

Successfully launched application from desktop shortcut

将.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
cp ./Geocoder.desktop ~/.local/share/applications  in a terminal window

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键之间),然后键入应用程序名称的第一部分。 其图标将出现在搜索结果中。

Application icon being found by GNOME search
  • 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/

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/278431.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

阿里再破记录!代表中国企业首次在这项国际比赛中摘得银牌!

2月9日在洛杉矶举行的第11届网络搜索与数据挖掘国际会议(WSDM 2018)上,公布了今年的WSDM Cup竞赛成绩,来自阿里巴巴的AliOS团队凭借优秀的算法能力,摘得榜眼。这是该赛事举办11届以来,中国企业在该赛事上首…

闪存驱动器_将闪存驱动器变成便携式Web服务器

闪存驱动器Portable applications are very useful for getting work done on the go, but how about portable servers? Here’s how you can turn your flash drive into a portable web server. 便携式应用程序对于在旅途中完成工作非常有用,但是便携式服务器呢…

Android中文API-ViewStub

ViewStub控件是一个不可见,0尺寸得惰性控件。当ViewStub控件设置可见,或者调用inflate(),并运行完毕之后,ViewStub所指定的layout资源就会被载入。这个ViewStub就会被新载入的layout文件取代。ViewStub也会从其父控件中移除。因此…

如何播放梅西百货的感恩节大游行2019

Macy’s梅西百货As we draw ever closer to the Thanksgiving holiday, multiple things come to mind: turkey, Black Friday, and the Macy’s Thanksgiving Day Parade. With that in mind, you might want to find a way to stream it for your family. 随着我们越来越接近…

AJAX入门这一篇就够了

什么是Ajax Ajax(Asynchronous JavaScript and XML) 异步JavaScript和XML Ajax实际上是下面这几种技术的融合: (1)XHTML和CSS的基于标准的表示技术(2)DOM进行动态显示和交互(3)XML和XSLT进行数据交换和处理(4)XMLHttpRequest进行异步数据检索(5)Javascript将以上技术…

如何在iPhone和iPad上允许“不受信任的快捷方式”

Khamosh PathakKhamosh PathakShortcuts is now a stock app in iOS 13, iPadOS 13, and beyond. Thanks to Apple’s stricter rules, any shortcut you download from the internet is blocked. Here’s how you can allow untrusted shortcuts on your iPhone or iPad. 现在…

SpringBoot入门 (一) HelloWorld

一 什么是springboot springboot是一个全新的框架,它设计的目的简化spring项目的初始环境的搭建和开发,主要有以下几个特点: 1、简化初始配置 ,可与主流框架集成; 2、内置Servlet容器,无需在打War包&#x…

gmail附件调用_如何将Gmail附件保存到Google云端硬盘

gmail附件调用While you can access Gmail attachments by opening the related message deep within Google’s client, it’s not very convenient. You need a central location to access saved documents and images. This guide shows you how to save Gmail attachments…

如何使用VLOOKUP在Google表格中查找数据

VLOOKUP is one of the most misunderstood functions in Google Sheets. It allows you to search through and link together two sets of data in your spreadsheet with a single search value. Here’s how to use it. VLOOKUP是Google表格中最容易被误解的功能之一。 它使…

WPF项目学习.一

WPF项目搭建 版权声明:本文为博主初学经验,未经博主允许不得转载。 一、前言 记录在学习与制作WPF过程中遇到的解决方案。 使用MVVM的优点是 数据和视图分离,双向绑定,低耦合,可重用行,相对独立的设计和逻辑…

airpods_如何通过AirPods与其他人共享音乐

airpodsKhamosh PathakKhamosh PathakUsing the new Audio Sharing feature introduced in iOS 13.1 and iPadOS 13.1, you can share audio from one iPhone with two AirPods. You can watch a video or listen to a song along with your friend in just a tap! 使用iOS 13.…

谷歌云使用账号密码_如何使用Google密码检查

谷歌云使用账号密码Google has a tool designed to securely analyze your passwords against a database of ones that are known to be compromised and breached. Password Checkup is available as an extension or a web service. Here’s how to use it. Google提供了一种…

Jolicloud是一款适合上网本的漂亮新操作系统

Want to breathe new life into your netbook? Here’s a quick look at Jolicloud, a unique new Linux based OS that lets you use your netbook in a whole new way. 想为您的上网本注入新的活力吗? 快速浏览一下Jolicloud,这是一个独特的基于Linu…

Repeater片段

1.字段过长截取字符串 1.1 截取字符串类 可以直接substring 也可以<%# Utility.Common.GetShow( Eval("NewTitle").ToString(),20,true) %><td><%#fcwms.Common.GetContent.GetShow(Eval("com_address").ToString(), 19, true)%> </t…

谷歌浏览器的翻译功能在哪_如何在Google表格中使用AND和OR功能

谷歌浏览器的翻译功能在哪If you’ve ever wanted to check whether data from your Google Sheets spreadsheet meets certain criteria, you can use AND and OR. These logical functions give you TRUE and FALSE responses, which you can use to sort through your data.…

保存网络文章以供以后使用Instapaper阅读

Have you ever come across a bunch of great articles that you want to read online, but just don’t have the time? Today we take a look at an online service that allows you to read your articles later, either online, or on an iPhone, or eReader. 您是否曾经遇…

谷歌chrome xp_将非Google任务列表添加到Chrome

谷歌chrome xpMost people rely on a task list to help them remember what they need to do but not everyone wants one that is tied to a Google account. If you have been wanting an independent tasks list then join us as we look at the Tasks extension for Googl…

我们生活在最好的时代

2019独角兽企业重金招聘Python工程师标准>>> 没规划的人生叫拼图&#xff0c;有规划的人生叫蓝图&#xff1b; 没目标的人生叫流浪&#xff0c;有目标的人生叫航行&#xff01; 我们生活在最好的时代&#xff1a;在认知和学习机会上&#xff0c;人人平等&#xff0c…

MapReduce详解和WordCount模拟

最早接触大数据&#xff0c;常萦绕耳边的一个词「MapReduce」。它到底是什么&#xff0c;能做什么&#xff0c;原理又是什么&#xff1f;且听下文讲解。 是什么 MapReduce 即是一个编程模型&#xff0c;又是一个计算框架&#xff0c;它充分采用了分治的思想&#xff0c;将数据处…

无法创建系统映像_如何创建USB驱动器的映像

无法创建系统映像You can back up your USB drive by creating a saved image. You can then take that saved image and clone multiple USB sticks. This guide shows you how to create an image of your USB drive using Windows 10. 您可以通过创建保存的图像来备份USB驱动…