今天到網上搜ubuntu創建桌面快捷方式,發現盡是些不負責任,有問題的教程,故我也發教程一篇
在你的Home/Desktop文件夾下面新建一個xxx.desktop的文件,並且加上執行權限
復制代碼
代碼如下:
chmod +x xxx.desktop
具體內容參照下面的模板,順便講一下linux下軟件的安裝方法,以sublime text 2為例
下載sublime linux的安裝包,在你的home目錄新建一個目錄名,可以叫app,或者myapps啥的,你自己明白就行,就是軟件的安裝目錄,把sublime text 2解壓到裡面,於是整體的目錄結構如下
代碼如下:
--homeyournam
----apps
------sublime text 2
下面解釋下模板的內容,第一行,是凡是標有可執行標記的腳本必備的注釋,內容為執行該腳本的解釋器地址,這裡是解釋桌面快捷方式用的
第二行開始就是具體的內容了
解釋兩個重要的地方,地一個是exec,這個是你的可執行文件的地址,如果中間包含空格,那麼用引號擴起來
Icon,這個是你的應用的圖標,要不默認圖標很難看
代碼如下:
#!/usr/bin/env xdg-open
[Desktop Entry]
Categories=Development;
Comment[zh_CN]=
Comment=
Exec="/home/bowman/apps/Sublime Text 2/sublime_text"
GenericName[zh_CN]=Sublime Texe 2
GenericName=Sublime Texe 2
Icon="/home/bowman/apps/Sublime Text 2/Icon/256x256/sublime_text.png"
MimeType=
Name[zh_CN]=Sublime Texe 2
Name=Sublime Texe 2
Path=
StartupNotify=true
Terminal=false
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=owen
關於category,這裡有一個主要列表可供選擇
he table below lists all Main Categories.
Main Category Description Notes
AudioVideo Application for presenting, creating, or processing multimedia (audio/video)
Audio An audio application Desktop entry must include AudioVideo as well
Video A video application Desktop entry must include AudioVideo as well
Development An application for development
Education Educational software
Game A game
Graphics Application for viewing, creating, or processing graphics
Network Network application such as a web browser
Office An office type application
Science Scientific software
Settings Settings applications Entries may appear in a separate menu or as part of a "Control Center"
System System application, "System Tools" such as say a log viewer or network monitor
Utility Small utility application, "Accessories"
references:
http://standards.freedesktop.org/menu-spec/latest/apa.html#main-category-registry
http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html