BreakingExpress

Flip any web site right into a Linux desktop app with open supply instruments

Mastodon is a superb open supply, decentralised social community. I exploit Mastodon daily, and it is most likely commonest to make use of Mastodon by means of its net interface (though being open supply, there are numerous other ways to work together with it, together with terminal-based functions and cellular apps), however I choose devoted software home windows.

Recently, I found Nativefier, and I can now take pleasure in Mastodon, or another net app, as a desktop software on my Linux desktop. Nativefier takes a URL and wraps it with the Electron framework, which runs the open supply Chromium browser as its backend however runs as its personal executable software. Nativefier is licensed underneath the MIT license and is on the market for Linux, Windows, and macOS.

Installing Nativefier

Nativefier requires Node.js

Installing Nativefier is so simple as working:

$ sudo npm set up -g nativefier

On my Ubuntu desktop, I needed to improve NodeJS first, so remember to examine what variations of Node is required once you set up Nativefier.

Once put in, you possibly can examine your model of Nativefier to confirm that it has been put in:

$ nativefier --version
45.0.4

Running nativefier --help lists all choices the app helps.

Setup

I like to recommend that you simply create a brand new folder referred to as ~/NativeApps earlier than you begin creating apps with Nativefier. This helps maintain your functions good and arranged.

$ mkdir ~/NativeApps
cd ~/NativeApps

Creating an app for Mastodon

I’ll begin by creating an app for mastodon.technology.

Use the command:

$ nativefier --name Mastodon
--platform linux --arch x64
--width 1024 --height 768
--tray --disable-dev-tools
--single-instance https://mastodon.know-how

The choices on this instance do the next:

  • --name: Sets the app title to Mastodon
  • --platform: Sets the app’s platform to Linux
  • –arch x64: Sets the structure to x64
  • --width 1024 --height 768: Sets the apps’ dimensions on launch
  • --tray: Creates a tray icon for the app
  • --disable-dev-tools: Disables Chrome dev instruments
  • --single-instance: Only permits one occasion of the app

Running that single command reveals the next output:

Preparing Electron app...

Converting icons...
Packaging... This will take a number of seconds, perhaps minutes if the requested Electron isn't cached but...
Packaging app for platform linux x64 utilizing electron v13.4.0 Finalizing construct...

App constructed to /residence/tux/NativeApps/Mastodon-linux-x64, transfer to wherever it is smart for you and run the contained executable file (prefixing with ./ if vital)

Menu/desktop shortcuts are as much as you, as a result of Nativefier can't know the place you are going to transfer the app. Search for "linux .desktop file" for assist, or see https://wiki.archlinux.org/index.php/Desktop_entries

The output reveals that the recordsdata get positioned in /residence/tux/NativeApps/Mastodon-linux-x64. When you cd into this folder, you see a file named Mastodon. This is the primary executable that launches the app. Before you possibly can launch it, you need to give it the suitable permissions.

$ cd Mastodon-linux-x64
chmod +x Mastodon

Now, execute ./Mastodon to see your Linux app launch!

Creating an app for my weblog

For enjoyable, I’m going to create an app for my weblog web site as nicely. What good is having a tech weblog if there is no Linux app for it?

The command:

$ nativefier -n ayushsharma
-p linux -a x64
--width 1024 --height 768
--tray --disable-dev-tools
--single-instance https://ayushsharma.in

$ cd ayushsharma-linux-x64
chmod +x ayushsharma

Creating an app for findmymastodon.com

And lastly, here is an app for my pet challenge, findmymastodon.com.

The command:

$ nativefier -n findmymastodon
-p linux -a x64
--width 1024 --height 768
--tray --disable-dev-tools
--single-instance https://findmymastodon.com

$ cd findmymastodon-linux-x64
chmod +x findmymastodon

Creating Linux desktop icons

With the apps created and the executables able to go, it is time to create desktop icons.

As an illustration, here is methods to create a desktop icon for the Mastodon launcher. First, obtain an icon for Mastodon. Place the icon in its Nativefier app listing as icon.png.

Then create a file referred to as Mastodon.desktop and enter this textual content:

[Desktop Entry]
Type=Application
Name=Mastodon
Path=/residence/tux/NativeApps/Mastodon-linux-x64
Exec=/residence/tux/NativeApps/Mastodon-linux-x64/Mastodon
Icon=/residence/tux/NativeApps/Mastodon-linux-x64/icon.png

You can transfer the .desktop file to your Linux desktop to have it as a desktop launcher. You can even place a duplicate of it in ~/.native/share/functions so it reveals up in your software menu or exercise launcher.

Conclusion

I like having devoted apps for instruments I exploit usually. My favourite characteristic about having an app for Mastodon is that after I log in to Mastodon, I haven’t got to log in once more! Nativefier runs Chromium beneath. So it is capable of bear in mind your session identical to any browser does. I’d like to provide a particular because of the Nativefier workforce for taking the Linux desktop one step nearer to perfection.


This article initially appeared on the author’s website and is republished with permission.

Exit mobile version