一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Linux|Centos|Ubuntu|系統進程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務器之家 - 服務器系統 - Linux - 用開源工具將任何網站變成 Linux 桌面應用

用開源工具將任何網站變成 Linux 桌面應用

2021-11-11 23:12Linux中國Ayush Sharma Linux

最近,我發現了 Nativefier,現在我可以在我的 Linux 桌面上把 Mastodon 或其他任何網頁應用作為桌面應用來使用。Nativefier 將一個 URL 用 Electron 框架包裝起來,它將開源的 Chromium 瀏覽器作為后端,但使用自己的可執行程序運行。

用開源工具將任何網站變成 Linux 桌面應用

使用 Nativefier 和 Electron 從任何網站創建桌面應用。

Mastodon 是一個很好的開源、去中心化的社交網絡。我每天都在使用 Mastodon,通過它的網頁界面使用 Mastodon 可能是最常見的方式(盡管因為開源,它有許多不同的交互方式,包括基于終端的應用和移動應用),但我更喜歡專門的應用窗口。

最近,我發現了 Nativefier,現在我可以在我的 Linux 桌面上把 Mastodon 或其他任何網頁應用作為桌面應用來使用。Nativefier 將一個 URL 用 Electron 框架包裝起來,它將開源的 Chromium 瀏覽器作為后端,但使用自己的可執行程序運行。Nativefier 采用 MIT 許可證,可用于 Linux、Windows 和 MacOS。

安裝 Nativefier

Nativefier 需要 Node.js。

安裝 Nativefier 只需運行:

  1. $ sudo npm install -g nativefier

在我的 Ubuntu 桌面上,我必須先升級 NodeJS,所以當你安裝 Nativefier 時,一定要檢查需要哪個 Node 版本。

安裝完畢后,你可以檢查你的 Nativefier 的版本,以驗證它是否已經安裝:

  1. $ nativefier --version
  2. 45.0.4

運行 nativefier --help 列出了應用支持的所有選項。

設置

我建議你在開始用 Nativefier 創建應用之前,創建一個名為 ~/NativeApps 的新文件夾。這有助于保持你的應用有序。

  1. $ mkdir ~/NativeApps
  2. cd ~/NativeApps

為 Mastodon 創建一個應用程序

我將首先為 mastodon.technology 創建一個應用。

使用以下命令:

  1. $ nativefier --name Mastodon \
  2. --platform linux --arch x64 \
  3. --width 1024 --height 768 \
  4. --tray --disable-dev-tools \
  5. --single-instance https://mastodon.technology

這個例子中的選項做了以下工作:

  • --name:設置應用的名稱為 Mastodon
  • --platform:設置應用程序的平臺為 Linux
  • --arch x64:設置架構為 x64
  • --width 1024 --height 768:設置應用啟動時的大小
  • --tray:為應用創建一個托盤圖標
  • --disable-dev-tools:禁用 Chrome 開發工具
  • --single-instance:只允許應用有一個實例

運行這條命令會顯示以下輸出:

  1. Preparing Electron app...
  2.  
  3. Converting icons...
  4. Packaging... This will take a few seconds, maybe minutes if the requested Electron isn't cached yet...
  5. Packaging app for platform linux x64 using electron v13.4.0 Finalizing build...
  6.  
  7. App built to /home/tux/NativeApps/Mastodon-linux-x64, move to wherever it makes sense for you and run the contained executable file (prefixing with ./ if necessary)
  8.  
  9. Menu/desktop shortcuts are up to you, because Nativefier cannot know where you're going to move the app. Search for "linux .desktop file" for help, or see https://wiki.archlinux.org/index.php/Desktop_entries

輸出顯示,文件被放置在 /home/tux/NativeApps/Mastodon-linux-x64。當你 cd 進入這個文件夾,你會看到一個名為 Mastodon 的文件。這是啟動該應用的主要可執行文件。在你啟動它之前,你必須給它適當的權限。

  1. $ cd Mastodon-linux-x64
  2. chmod +x Mastodon

現在,執行 ./Mastodon 就可以看到你的 Linux 應用啟動了!

用開源工具將任何網站變成 Linux 桌面應用

Mastodon app launched

為我的博客創建一個應用

為了好玩,我也要為我的博客創建一個應用。如果沒有 Linux 應用,擁有一個技術博客有什么用?

用開源工具將任何網站變成 Linux 桌面應用

Ayush Sharma blog

命令是:

  1. $ nativefier -n ayushsharma \
  2. -p linux -a x64 \
  3. --width 1024 --height 768 \
  4. --tray --disable-dev-tools \
  5. --single-instance https://ayushsharma.in
  6.  
  7. $ cd ayushsharma-linux-x64
  8. chmod +x ayushsharma

為 findmymastodon.com 創建一個應用

最后,這是為我的寵物項目 findmymastodon.com 制作的應用。

用開源工具將任何網站變成 Linux 桌面應用

Find my mastodon website

命令是:

  1. $ nativefier -n findmymastodon \
  2. -p linux -a x64 \
  3. --width 1024 --height 768 \
  4. --tray --disable-dev-tools \
  5. --single-instance https://findmymastodon.com
  6.  
  7. $ cd findmymastodon-linux-x64
  8. chmod +x findmymastodon

創建 Linux 桌面圖標

應用已經創建并可以執行了,現在是創建桌面圖標的時候了。

作為示范,以下是如何為 Mastodon 啟動器創建一個桌面圖標。首先,下載一個 Mastodon 的圖標。將該圖標放在其 Nativefier 應用目錄下,名為 icon.png

然后創建一個名為 Mastodon.desktop 的文件并輸入以下文本:

  1. [Desktop Entry]
  2. Type=Application
  3. Name=Mastodon
  4. Path=/home/tux/NativeApps/Mastodon-linux-x64
  5. Exec=/home/tux/NativeApps/Mastodon-linux-x64/Mastodon
  6. Icon=/home/tux/NativeApps/Mastodon-linux-x64/icon.png

你可以把 .desktop 文件移到你的 Linux 桌面上,把它作為一個桌面啟動器。你也可以把它復制到 ~/.local/share/applications 中,這樣它就會出現在你的應用菜單或活動啟動器中。

總結

我喜歡為我經常使用的工具配備專門的應用。我最喜歡的一個 Mastodon 應用特點是,當我登錄到 Mastodon 之后,我就不必再次登錄了! Nativefier 在底層運行 Chromium。所以它能夠像其他瀏覽器一樣記住你的會話。我想特別感謝 Nativefier 團隊,他們讓 Linux 桌面離完美更近了一步。

原文鏈接:https://linux.cn/article-13975-1.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 2018亚洲男人天堂 | 国产在线观看网站 | 男人躁女人p| 18欧美同性videos可播放 | 1024免费观看完整版在线播放 | 九九热在线视频观看这里只有精品 | 天天中文 | 日日综合 | a v在线男人的天堂观看免费 | 日韩国产欧美一区二区三区 | 国产一区二区三区欧美精品 | 国产精品思瑞在线观看 | 岛国最新资源网站 | 啊哈~嗯哼~用力cao我小说 | 精品国产国产精2020久久日 | 九九热免费在线观看 | 久久99影院| 欧美一区二区三区成人看不卡 | 亚洲国产精品网站久久 | 胸大的姑娘中文字幕视频 | 色吊丝每日永久访问网站 | 久久夜色噜噜噜亚洲AV0000 | 青青操在线观看 | 欧美一级欧美一级高清 | jk制服喷水 | 玩高中女同桌肉色短丝袜脚文 | 国产码一区二区三区 | 国产精品久久久久影院色老大 | 精品99视频 | 国产最新进精品视频 | 久久婷婷五月综合色丁香花 | 色综合欧美色综合七久久 | 99成人国产精品视频 | 三年片韩国在线 | 偷偷狠狠的日日高清完整视频 | 成人区精品一区二区毛片不卡 | 精品久久久久久久高清 | 亚洲国产区男人本色在线观看欧美 | 久久成人免费大片 | 国内精品伊人久久大香线焦 | 天天插在线视频 |