Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

Linux 系統將 Sublime Text 固定到啟動器的完整教學

編輯:關於 Linux

Sublime Text 是一款廣受歡迎的程式碼編輯器,支援 Linux 等多種作業系統。在 Linux 環境中,若想像一般應用程式一樣將 Sublime Text 固定到啟動器並單擊即可啟動,需要建立對應的 Desktop Entry 檔案。本文將詳細說明操作步驟。

原理:Desktop Entry 機制

在 Linux 桌面環境中,能夠出現在啟動器並擁有圖標的程式,皆依賴 .desktop 設定檔。這些檔案通常位於 /usr/share/applications/ 目錄下。我們可以透過終端機查看現有範例:

cd /usr/share/applications/
ll

你將看到許多以 .desktop 結尾的檔案,它們定義了程式的啟動指令、圖標路徑、顯示名稱等資訊。

建立 Sublime Text 的 Desktop Entry

  1. 切換至應用程式目錄並建立設定檔:
    cd /usr/share/applications/
    sudo gedit sublime-text.desktop
    
  2. 在編輯器中輸入以下內容(請根據實際安裝路徑調整):
    [Desktop Entry]
    Version=1.0
    Type=Application
    Name=Sublime Text
    Comment=Sophisticated text editor for code, markup and prose
    Exec=/opt/sublime_text/sublime_text %F
    Icon=/opt/sublime_text/Icon/256x256/sublime-text.png
    Terminal=false
    MimeType=text/plain;
    Categories=TextEditor;Development;Utility;
    StartupNotify=true
    
    關鍵欄位說明:
    • Exec:啟動指令,%F 表示支援開啟多個檔案參數,使程式出現在「以其他應用程式開啟」列表中。
    • Icon:圖標絕對路徑,建議使用 PNG 格式。
    • Name:啟動器顯示名稱。
    • 所有路徑必須使用絕對路徑。
  3. 儲存檔案後,在應用程式選單中找到 Sublime Text 並啟動一次,隨即右鍵點選啟動器圖標選擇「鎖定到啟動器」。關閉程式後,再次點擊啟動器圖標即可正常啟動。

常見問題與提示

  • 若圖標不顯示,請確認 Icon 路徑正確且檔案存在。
  • 若啟動無反應,請檢查 Exec 指令路徑是否與實際安裝位置一致(可用 which sublime_text 查詢)。
  • 此方法適用於大多數符合 FreeDesktop 標準的桌面環境(如 GNOME、KDE、Unity 等)。

完成上述步驟後,Sublime Text 便能像原生應用程式一樣整合在你的 Linux 桌面環境中,大幅提升開發效率。

Copyright © Windows教程網 All Rights Reserved