Reason
I don’t use Facebook that much, but only Messenger to chat for work and friends – Although I like Telegram better, he is 3000 times better than his Messenger. The Messenger guy now seems to have an Official version on Windows, and the Linux side is like a stepchild. Every time you use it, you have to find it in your pile of tabs. So I understand to try it by myself. After a while of learning, there is a package that helps me with this, of course it is not a native app, but a wrapper of Electron.
Nativefier
Nativefier is an Electron wrapper used to create D esktop Applications for Linux and other platforms. However, I only use this on Linux so I can’t test it on other platforms. Alternatively, you can dabble in a little more for this application, for example inject javascript or css .
Installation and usage
Install this package, then set the global flag and use it for later. If not, it’s fine to remove the global flag.
1 2 | <span class="token function">sudo</span> <span class="token function">npm</span> i nativefier -g |
Use is extremely simple. Use nativefier to convert web app messenger.com for linux platform.
1 2 | nativefier https://www.messenger.com -p linux |
After running this command, nativefier will generate a folder called Messenger-linux-x64
At this point start up with the command
1 2 | ./Messenger.com |
That’s it, there is a Desktop Application already.
Extend
Of course, if that is not the case, it will not take full advantage of Nativefier’s features. Here, I will expand a bit more, I will make Dark Mode for my scabies app. Electron is a framework used to build desktop applications using html, css, javascript. Then this nativefier is built based on electrons. Thus, if you want to change the interface of the application, just add the dark mode css to it. To inject css in the natifier, use the flag —inject. So I fix the code a bit.
1 2 | nativefier https://www.messenger.com -p linux --inject dark.css |
Then go to Messenger-linux-x64/resources/app/inject
**** to edit the dark.css
file as follows. Someone’s wife on github
So there is a Messenger Dark Mode Desktop Application.
You can check out more cool Nativefier APIs here. There are many cool things that can be used.
At this point, it seems not enough, I still have to create a shortcut for it to click and run. Now, you must use some Linux SHELL commands.
The first is to create a shortcut for it called shortcut.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <span class="token shebang important">#!/bin/sh</span> <span class="token builtin class-name">set</span> -e <span class="token assign-left variable">WORKING_DIR</span> <span class="token operator">=</span> <span class="token variable"><span class="token variable">`</span> <span class="token builtin class-name">pwd</span> <span class="token variable">`</span></span> <span class="token assign-left variable">THIS_PATH</span> <span class="token operator">=</span> <span class="token variable"><span class="token variable">`</span> readlink -f $0 <span class="token variable">`</span></span> <span class="token builtin class-name">cd</span> <span class="token variable"><span class="token variable">`</span> <span class="token function">dirname</span> $ <span class="token punctuation">{</span> THIS_PATH <span class="token punctuation">}</span> <span class="token variable">`</span></span> <span class="token assign-left variable">FULL_PATH</span> <span class="token operator">=</span> <span class="token variable"><span class="token variable">`</span> <span class="token builtin class-name">pwd</span> <span class="token variable">`</span></span> /Lotion <span class="token builtin class-name">cd</span> <span class="token variable">${WORKING_DIR}</span> <span class="token function">cat</span> <span class="token operator"><<</span> EOS <span class="token operator">></span> Messenger.desktop <span class="token punctuation">[</span> Desktop Entry <span class="token punctuation">]</span> <span class="token assign-left variable">Name</span> <span class="token operator">=</span> Messenger Name <span class="token punctuation">[</span> en_US <span class="token punctuation">]</span> <span class="token operator">=</span> Messenger <span class="token assign-left variable">Comment</span> <span class="token operator">=</span> Unofficial Facebook Messenger application <span class="token keyword">for</span> Linux <span class="token assign-left variable">Exec</span> <span class="token operator">=</span> <span class="token string">" <span class="token variable">${FULL_PATH}</span> /Messenger"</span> <span class="token assign-left variable">Terminal</span> <span class="token operator">=</span> false <span class="token assign-left variable">Categories</span> <span class="token operator">=</span> Social <span class="token assign-left variable">Type</span> <span class="token operator">=</span> Application <span class="token assign-left variable">Icon</span> <span class="token operator">=</span> <span class="token variable">${WORKING_DIR}</span> /icon.png <span class="token assign-left variable">StartupWMClass</span> <span class="token operator">=</span> Messenger EOS <span class="token function">chmod</span> +x Messenger.desktop <span class="token comment">## This can be updated if this path is not valid. </span> <span class="token function">cp</span> -p Messenger.desktop ~/.local/share/applications |
Next is to create the install.sh
file
1 2 3 4 5 6 7 8 | <span class="token shebang important">#!/bin/bash</span> <span class="token assign-left variable">PD</span> <span class="token operator">=</span> <span class="token variable"><span class="token variable">`</span> <span class="token builtin class-name">pwd</span> <span class="token variable">`</span></span> <span class="token assign-left variable">INSTALL_DIR</span> <span class="token operator">=</span> <span class="token variable">$PD</span> <span class="token string">"/Messenger"</span> <span class="token builtin class-name">echo</span> <span class="token variable">$INSTALL_DIR</span> <span class="token function">mkdir</span> -p <span class="token variable">$INSTALL_DIR</span> <span class="token function">tar</span> xvf <span class="token variable">$PD</span> /Messenger-linux-x64.tar.xz -C <span class="token variable">$INSTALL_DIR</span> --strip <span class="token number">1</span> /bin/bash <span class="token variable">$PD</span> /shortcut.sh |
Then finish the remove.sh
file to give it full set
1 2 3 4 5 6 | <span class="token shebang important">#!/bin/bash</span> <span class="token assign-left variable">PD</span> <span class="token operator">=</span> <span class="token variable"><span class="token variable">`</span> <span class="token builtin class-name">pwd</span> <span class="token variable">`</span></span> <span class="token assign-left variable">INSTALL_DIR</span> <span class="token operator">=</span> <span class="token variable">$PD</span> <span class="token string">"/Messenger"</span> <span class="token function">rm</span> -r <span class="token variable">$INSTALL_DIR</span> <span class="token function">rm</span> ~/.local/share/applications/Messenger.desktop |
Conclude
The above is simply a package that helps me convert a Web App to the Desktop App. However, if Custom was good, then it wouldn’t be that great. In addition, I can use this guy to do some App for me, for example Zalo, or Whatsapp. It is also an application, because having an app is better than using a browser.
You can watch the repo at my GIthub.