如何在Ubuntu上创建桌面快捷方式
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.
桌面圖標(biāo)應(yīng)該很簡(jiǎn)單,但不能在Ubuntu 18.04 LTS和更高版本(如Ubuntu 19.10)上使用。 按照這些簡(jiǎn)單的步驟,即可為您喜歡的應(yīng)用程序獲取桌面快捷方式,就像在其他操作系統(tǒng)和其他Linux桌面上一樣。
是的,應(yīng)該更容易 (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的新手會(huì)發(fā)現(xiàn)完成此簡(jiǎn)單任務(wù)令人沮喪。 正是這種類(lèi)型給他們的印象是,要想在Linux上取得成功,將是一個(gè)漫長(zhǎng)的艱難歷程。
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已有一段時(shí)間的人,也非常了解Linux的方式,他們也可以發(fā)現(xiàn)這個(gè)話題比以前更艱巨。 實(shí)際上,這并不難,但這絕對(duì)是違反直覺(jué)的。
安裝GNOME調(diào)整 (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.
默認(rèn)情況下,您不能將文件或圖標(biāo)復(fù)制到Ubuntu的GNOME Shell桌面。 為此,您需要使用GNOME Tweaks更改設(shè)置。 使用此命令進(jìn)行安裝。
sudo apt-get install gnome-tweaksWhen 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.
安裝后,按“超級(jí)”鍵(在大多數(shù)鍵盤(pán)的左下方,在Control和Alt鍵之間),然后鍵入“ tweaks”。 出現(xiàn)“調(diào)整”圖標(biāo)。 單擊該按鈕以啟動(dòng)“調(diào)整”。
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中的圖標(biāo)。 該圖標(biāo)在Ubuntu 19.10中看起來(lái)會(huì)有所不同。 啟動(dòng)Tweaks后,單擊左側(cè)窗格中的“桌面”。 單擊“顯示圖標(biāo)”滑塊按鈕以允許使用桌面圖標(biāo)。 您可以選擇是否希望在桌面上顯示主目錄,垃圾箱,網(wǎng)絡(luò)服務(wù)器和已安裝卷的快捷方式。
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.
請(qǐng)注意,在Ubuntu 19.10中,桌面圖標(biāo)設(shè)置位于擴(kuò)展設(shè)置下,因此請(qǐng)單擊左側(cè)窗格中的“擴(kuò)展”條目。
創(chuàng)建桌面快捷方式 (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?
為了演示此過(guò)程,我們將為L(zhǎng)ibreOffice writer創(chuàng)建一個(gè)桌面快捷方式。 現(xiàn)在,我們已經(jīng)啟用了在桌面上顯示圖標(biāo)的功能,我們只需要將某些東西拖到桌面上,就會(huì)有一個(gè)快捷方式。 但是,我們需要拖動(dòng)什么?
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.
這就是所謂的應(yīng)用程序的.desktop文件。 這些是描述有關(guān)應(yīng)用程序某些屬性的文本文件。 除其他外,它們告訴操作系統(tǒng)二進(jìn)制可執(zhí)行文件在文件系統(tǒng)中的位置。 當(dāng)您雙擊快捷方式時(shí),Linux使用此信息來(lái)查找并啟動(dòng)應(yīng)用程序的二進(jìn)制文件。 我們只需要找到正確的.desktop文件。
Applications that are provided as part of a distribution’s default packages, or are installed from repositories, have their .desktop files installed into:
作為發(fā)行版默認(rèn)軟件包的一部分提供的應(yīng)用程序,或從存儲(chǔ)庫(kù)安裝的應(yīng)用程序的.desktop文件安裝到:
/usr/local/share/applicationsOther applications that have been locally installed with system-wide access—meaning they are available for all users—usually have their .desktop files installed into:
在本地安裝并具有系統(tǒng)范圍訪問(wèn)權(quán)限的其他應(yīng)用程序(意味著它們對(duì)所有用戶都可用)通常將其.desktop文件安裝到:
/usr/local/share/applicationsApplications 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:
已安裝的應(yīng)用程序(僅供單個(gè)用戶訪問(wèn))將.desktop文件安裝到該用戶的主目錄中:
~/.local.share/applicationsLibreOffice 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適用于所有用戶,因此我們將啟動(dòng)“文件”并瀏覽到/usr/share/applications目錄。 您需要導(dǎo)航到要查找的應(yīng)用程序的適當(dāng)目錄。
Launch Files, and click on “Other locations” in the left-hand pane. Then navigate to Computer > usr > share > applications.
啟動(dòng)文件,然后單擊左側(cè)窗格中的“其他位置”。 然后導(dǎo)航至計(jì)算機(jī)> usr>共享>應(yīng)用程序。
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.
滾動(dòng)瀏覽圖標(biāo),直到看到LibreOffice Writer圖標(biāo)。 在Ubuntu 19.10中,所有圖標(biāo)看起來(lái)都像齒輪,因此您需要檢查文件名以確保具有正確的.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.
為確保已找到要查找的應(yīng)用程序的.desktop文件,請(qǐng)右鍵單擊該圖標(biāo)并選擇屬性。 您應(yīng)該看到一行告訴您這是一個(gè)桌面配置文件。 關(guān)閉屬性對(duì)話框。
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圖標(biāo),按住鼠標(biāo)左鍵,然后將圖標(biāo)拖到桌面。 釋放鼠標(biāo)按鈕。 盡管這通常會(huì)移動(dòng)被拖動(dòng)的內(nèi)容,但在這種情況下,它會(huì)對(duì)其進(jìn)行復(fù)制。
You’ve now got an icon on the desktop, but it doesn’t look anything like it should. What’s going on?
現(xiàn)在,您已經(jīng)在桌面上有了一個(gè)圖標(biāo),但是它看起來(lái)并不像它應(yīng)該的樣子。 這是怎么回事?
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.
盡管看起來(lái)不像您期望的那樣,但這是一個(gè)有效的捷徑。 雙擊它以啟動(dòng)該應(yīng)用程序,然后會(huì)出現(xiàn)一個(gè)警告對(duì)話框。
Click the “Trust and launch” button, and two things will happen.
單擊“信任并啟動(dòng)”按鈕,將發(fā)生兩件事。
The icon will change its appearance and text label to look like you’d expect it to, and LibreOffice Writer will be launched.
該圖標(biāo)將更改其外觀和文本標(biāo)簽,使其看起來(lái)像您期望的那樣,然后將啟動(dòng)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.
現(xiàn)在,您在桌面上有一個(gè)LibreOffice Writer圖標(biāo),可以用作啟動(dòng)該應(yīng)用程序的快捷方式。 首次使用快捷方式時(shí),您只會(huì)看到“不受信任的應(yīng)用程序啟動(dòng)器”對(duì)話框。
如果.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.
有時(shí)應(yīng)用程序不提供.desktop文件。 例如,內(nèi)部編寫(xiě)的程序或您可能從Github下載的應(yīng)用程序通常不帶有.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.
那不是問(wèn)題; 我們可以輕松創(chuàng)建自己的。 它只是一個(gè)文本文件,上面列出了適當(dāng)?shù)脑敿?xì)信息。
創(chuàng)建一個(gè).desktop文件 (Creating a .desktop File)
On this test computer, we’ve got a program that doesn’t have a .desktop file.
在這臺(tái)測(cè)試計(jì)算機(jī)上,我們有一個(gè)沒(méi)有.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.
首先要做的是檢查應(yīng)用程序是否運(yùn)行。 如果沒(méi)有,您也不會(huì)使用.desktop文件。 但是您可能會(huì)花很多時(shí)間盤(pán)算,想知道為什么您的.desktop文件不起作用。 因此,為徹底起見(jiàn),請(qǐng)確保您在手動(dòng)啟動(dòng)應(yīng)用程序時(shí)啟動(dòng)并正確運(yùn)行了應(yīng)用程序。
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文件是帶有設(shè)置內(nèi)容的文本文件。僅靠它本身不足以顯示圖標(biāo)。 我們需要使用應(yīng)用程序隨附的圖標(biāo)。 我們可以看到應(yīng)用程序目錄中有一個(gè)名為“ ip_gc_icon.png”的圖標(biāo),我們將使用它。
We can also see that the binary file is called gc . We’ll need that information shortly.
我們還可以看到二進(jìn)制文件稱(chēng)為gc 。 我們很快將需要這些信息。
Open up an editor. We’re going to be using?gedit, but you can use the editor of your choice.
打開(kāi)一個(gè)編輯器。 我們將使用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標(biāo)識(shí)您雙擊它時(shí)要單擊的內(nèi)容。
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文件中的所有其他條目均由標(biāo)簽和值組成,并由等號(hào)= 。 確保在等號(hào)之前或之后沒(méi)有空格。
The next four lines describe the application.
接下來(lái)的四行描述了該應(yīng)用程序。
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. “版本”條目是程序的版本號(hào)。
- 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. “名稱(chēng)”條目是應(yīng)用程序的名稱(chēng)。 請(qǐng)注意,我們包括了一個(gè)語(yǔ)言環(huán)境標(biāo)識(shí)符[en_US],表示美國(guó)英語(yǔ)。 您可以忽略它。 如果要?jiǎng)?chuàng)建多語(yǔ)言的.desktop文件,則每種不同的語(yǔ)言部分都需要使用這些類(lèi)型的標(biāo)識(shí)符。 他們?cè)谶@里沒(méi)有任何區(qū)別,但是他們是一個(gè)很好的習(xí)慣。
- 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”條目用于保存應(yīng)用程序的一般描述。 它可以用來(lái)保存諸如“視頻編輯器”,“ Web瀏覽器”或“文字處理器”之類(lèi)的描述。 該應(yīng)用程序不屬于任何特定類(lèi)別,因此我們只給它更長(zhǎng)的版本。
- 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.
接下來(lái)的三行向Linux提供信息,以便它知道二進(jìn)制可執(zhí)行文件在哪里,以及該快捷方式應(yīng)使用哪個(gè)圖標(biāo)。
Exec=/home/dave/geocoder/gc Path=/home/dave/geocoder/ Icon=/home/dave/geocoder/ip_gc_icon.pngThe “Exec” entry is the path to the binary executable. In our example, this is the gc executable.
“ Exec”條目是二進(jìn)制可執(zhí)行文件的路徑。 在我們的示例中,這是gc可執(zhí)行文件。
- The “Path” entry is the path to the working directory for the application. “路徑”條目是應(yīng)用程序工作目錄的路徑。
- The “Icon” entry is the path to the icon file that you wish to use for the desktop shortcut. “圖標(biāo)”條目是您要用于桌面快捷方式的圖標(biāo)文件的路徑。
The last three lines are supplementary data regarding the application.
最后三行是有關(guān)應(yīng)用程序的補(bǔ)充數(shù)據(jù)。
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”. “終端”條目可以為T(mén)rue或False。 它指示應(yīng)用程序是否在終端中執(zhí)行。 我們的輸入必須為“ false”。
- The “Type” entry can be one of?Application, Link, or Directory. Obviously, we want our entry to be “Application”. “類(lèi)型”條目可以是“應(yīng)用程序”,“鏈接”或“目錄”之一。 顯然,我們希望我們的條目為“ 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可以使用“類(lèi)別”條目將菜單中的相似或相關(guān)應(yīng)用程序分組。 我們將要輸入通用的“應(yīng)用程序”。
A full list of possible .desktop file entries and their values can be found in the .desktop file specification.
可能的.desktop文件條目及其值的完整列表可以在.desktop文件規(guī)范中找到。
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.”
將文件保存到應(yīng)用程序目錄中,確保文件擴(kuò)展名為“ .desktop”。 我們的示例文件稱(chēng)為“ Geocoder.desktop”。
將.desktop文件復(fù)制到桌面 (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文件復(fù)制到桌面上,請(qǐng)右鍵單擊該文件,然后從上下文菜單中選擇“復(fù)制”。 右鍵單擊桌面,然后從上下文菜單中選擇“粘貼”。
When you double click the icon on the desktop, you’ll see the same warning dialog as earlier. Click the “Trust and Launch” button.
雙擊桌面上的圖標(biāo)時(shí),您將看到與之前相同的警告對(duì)話框。 單擊“信任并啟動(dòng)”按鈕。
The desktop icon will take on its true appearance, and the application will be launched.
桌面圖標(biāo)將顯示其真實(shí)外觀,然后將啟動(dòng)該應(yīng)用程序。
將.desktop文件復(fù)制到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:
由于該程序?qū)⒂蓡蝹€(gè)用戶使用,因此我們將.desktop文件復(fù)制到他的本地應(yīng)用程序目錄中。 在程序目錄中,使用以下命令:
cp ./Geocoder.desktop ~/.local/share/applicationsPutting 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文件放在本地應(yīng)用程序目錄中,會(huì)將應(yīng)用程序集成到GNOME搜索功能中。 按“超級(jí)”鍵(在大多數(shù)鍵盤(pán)的左下角,在Control和Alt鍵之間),然后鍵入應(yīng)用程序名稱(chēng)的第一部分。 其圖標(biāo)將出現(xiàn)在搜索結(jié)果中。
Left-Click it to launch the application.
左鍵單擊以啟動(dòng)應(yīng)用程序。
Right-click it and select “Add to favorites” to add it to your Ubuntu dock.
右鍵單擊它,然后選擇“添加到收藏夾”將其添加到您的Ubuntu擴(kuò)展塢。
準(zhǔn)備發(fā)射 (Ready for Launch)
So there you have it. A little long-winded, but simple enough.
所以你有它。 有點(diǎn)long,但是很簡(jiǎn)單。
And definitely counter-intuitive.
絕對(duì)違反直覺(jué)。
翻譯自: https://www.howtogeek.com/445303/how-to-create-desktop-shortcuts-on-ubuntu/
總結(jié)
以上是生活随笔為你收集整理的如何在Ubuntu上创建桌面快捷方式的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 如何使YouTube视频连续循环播放
- 下一篇: 在Ubuntu服务器上打开第二个控制台会