DUICUO

オープンソース ツールを使用して、任意の Web サイトを Linux デスクトップ アプリケーションに変換します。

[[434540]]

NativeFier と Electron を使用して、任意の Web サイトからデスクトップ アプリケーションを作成します。

Mastodonは素晴らしいオープンソースの分散型ソーシャルネットワークです。私はMastodonを毎日使っていますが、Webインターフェースを使うのがおそらく最も一般的な方法です(オープンソースなので、ターミナルベースやモバイルアプリケーションなど、様々な方法で操作できます)。しかし、私は専用のアプリケーションウィンドウを使うのが好きです。

最近Nativefierを発見し、Mastodonやその他のWebアプリケーションをLinuxデスクトップでデスクトップアプリケーションとして使えるようになりました。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 DevTools を無効にする
  • --single-instance : アプリケーションのインスタンスを 1 つだけ許可します。

このコマンドを実行すると、次の出力が表示されます。

  1. Preparing Electron app ...
  2. Converting icons ...
  3. Packaging ... This will take a few seconds , maybe minutes if the requested Electron isn 't cached yet...
  4. Packaging app for platform linux x64 using electron v13.4.0 Finalizing build...
  5. 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)
  6. 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アプリケーションがないと、技術ブログを書く意味がありませんよね?

Ayush Sharmaのブログ

コマンドは次のとおりです。

  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. $ cd ayushsharma - linux - x64
  7. chmod + x ayushsharma

findmymastodon.com 用のアプリケーションを作成する

最後に、これは私のお気に入りのプロジェクト findmymastodon.com 用に作成したアプリです。

私のマストドンウェブサイトを見つける

コマンドは次のとおりです。

  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. $ cd findmymastodon - linux - x64
  7. chmod + x findmymastodon

Linuxデスクトップアイコンの作成

アプリケーションが作成され、実行できる状態になりました。次はデスクトップ アイコンを作成します。

例として、Mastodonランチャーのデスクトップアイコンを作成する方法をご紹介します。まず、Mastodonアイコンをダウンロードします。アイコンをネイティブアプリのディレクトリ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を採用しているので、他のブラウザと同様にセッションを記憶できます。Linuxデスクトップを完璧に近づけてくれたNativefierチームに特に感謝したいと思います。