Script to make a Linux native app from URL [work in progress]

The following script uses Nativefier (Electron) to build a binary from a web site and create a .desktop launcher:
Dependencies:

  • kdialog
  • npm
  • nativefier

Use npm to install nativefier:
npm install nativefier -g

Script:

#! /bin/bash

# DEPENDENCIES
# NPM & Nativefier & Kdialog:
# npm install nativefier -g

URL=`kdialog --inputbox URL`;
NAME=`kdialog --inputbox Name`;
CSS=`kdialog --getopenfilename ~`;
ICON=`kdialog --geticon applications`;

BINPATH=`kdialog --getexistingdirectory ~`;

cd "$BINPATH";

nativefier --inject="$CSS" --name="$NAME" "$URL" "$BINPATH";

cd ~/.local/share/applications;
touch "$NAME".desktop;
echo "[Desktop Entry]
Name="$NAME"
Exec='"$BINPATH"/"$NAME"-linux-x64/"$NAME"'
Icon="$ICON"
StartupNotify=true
Terminal=false
Type=Application
Actions=OpenInBrowser;

[Desktop Action OpenInBrowser]
Name=Open in the browser
Exec=xdg-open "$URL"
Icon=internet-web-browser
" > "$NAME".desktop;

kdialog --passivepopup "App created";

Instruction to use the script:

Prepare the script in a .sh file and eventually a custom CSS or JS file to be injected into the app to customize it:

16-11-04 17:11

Start the script, it will ask for URL:

16-11-04 17:12

Then app name (don’t use spaces or special character at the moment):

16-11-04 17:13-1

Select a CSS or JS file (press Cancel if you don’t have one):

16-11-04 17:14

Select an icon:

16-11-04 17:15

Select a folder where the binary will be saved (the .desktop launcher will link to it, don’t move it):

16-11-04 17:17

A notification will appear when the process will be completed:

16-11-04 17:18

Open the menu and search for your app:

16-11-04 17:19

This the difference between this app with custom CSS and the original site in the browser:

16-11-04 17:23

This is just a proof of concept.

Comments (Markdown supported):

Leave a Reply