如何在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.pswp.cn/news/278431.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/278431.shtml
英文地址,請注明出處:http://en.pswp.cn/news/278431.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

阿里再破記錄!代表中國企業首次在這項國際比賽中摘得銀牌!

2月9日在洛杉磯舉行的第11屆網絡搜索與數據挖掘國際會議(WSDM 2018)上,公布了今年的WSDM Cup競賽成績,來自阿里巴巴的AliOS團隊憑借優秀的算法能力,摘得榜眼。這是該賽事舉辦11屆以來,中國企業在該賽事上首…

關于IE 對 $.get 緩存的記錄

最近在IE9中碰到一個問題是, 當我對某個角色進行修改的時候,再點擊查詢還是修改之前的內容,但是實際數據庫已經修改成功,糾結了好一會兒之后,才發現是 $.get請求的問題。 因為 IE對get請求,如果請求url 相…

閃存驅動器_將閃存驅動器變成便攜式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. 隨著我們越來越接近…

thinkpaidE480office安裝文件夾

C:\Program Files (x86)\Microsoft Office\root\Office16需要嵌入office的小伙伴自行百度吧教程吧,網上有很多的轉載于:https://www.cnblogs.com/hgyzm/p/10303449.html

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. 現在…

程序員技術進階手冊(一)

AI正在迅速改變世界,對于程序員來說,這絕對是一個千載難逢的轉型機會。機器學習是計算機科學的一個子領域,在人工智能領域,機器學習逐漸發展成模式識別和計算科學理論的研究。從2016年起,機器學習到達了不合理的火熱巔…

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…

spring boot攔截器中獲取request post請求中的參數(轉)

文章轉自 https://www.jianshu.com/p/69c6fba08c92 轉載于:https://www.cnblogs.com/shuaiandjun/p/10306242.html

絕地求生大逃殺,改配置

提取效果設置配置文件 通過Procmon工具分析,絕地求生大逃殺效果設置的配置文件為 “C:\Users\Administrator\AppData\Local\TslGame\Saved\Config\WindowsNoEditor\GameUserSettings.ini”,設置好網吧需要的游戲效果后將“TslGame”文件夾提取出來即可&a…

如何使用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表格中最容易被誤解的功能之一。 它使…

共享內存

https://blog.csdn.net/tojohnonly/article/details/70246965 轉載于:https://www.cnblogs.com/132818Creator/p/10307072.html

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.…

Laravel 5 多個視圖共享數據的方法

我們都知道模板一般會用到繼承,導航欄就是一個很好的例子,但是導航欄的數據如何共享,比如有個導航的文件叫在view/navigation.blade.php為了簡單一點,文件里只有設置了一個變量1{{ $cqh }}現在的要求是每個頁面都會用到這個變量&a…

HR面 - 十大經典提問

1、HR:你希望通過這份工作獲得什么? 1)、自殺式回答:我希望自己為之工作的企業能夠重視質量,而且會給做得好的員工予以獎勵。我希望通過這份工作鍛煉自己,提升自己的能力,能讓公司更加重視我。 …

谷歌云使用賬號密碼_如何使用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提供了一種…