Isn’t this supposed to cover such occasions as that and restart the server.
I only have a Pi-Zero so far so have never tested the effect with the normal Electron setup just Chromium standalone kiosk style.
So I don’t actually no if or what the mechanism to restart the browser (Electron) is.
If it doesn’t refresh via MMM-WatchDog you can always use xdotools to send keys to an Xwindow and all you need to do is a ‘ctrl+F5’ which is a refresh and drops the cache so all is effectively loaded as new.
sudo apt-get install xdotool
Then with ~/MagicMirror/run-start.sh add a line and nano xdotool.sh and chmod a+x xdotool.sh
if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
export DISPLAY=:0 # Set by default display
fi
sh xdotool.sh &
electron js/electron.js $1
Dunno what the Electron class is but really its just Chromium in a wrapper so expecting that actually that will work.
If not you will just have to do a bit of testing to find the class or PID of electron http://manpages.ubuntu.com/manpages/trusty/man1/xdotool.1.html
@dgregory19 You need external window film as there are 2 types installed internal / external.
For a magic mirror you need external or yes it will be back to front when you apply it.
if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
export DISPLAY=:0 # Set by default display
fi
sh xdotool.sh &
node serveronly $1
xdotool.sh
The above will make Chromium refresh on any config.js changes or any restart of the server.
If have been banging my head against a brick xorg / plymouth combination for no reason than to get a smooth splash screen all the way till the browser displays.
This seems far more trouble than its worth.
I included lightdm as thought that might make things easier but might drop it as it seems to make no difference and just adds bloat.
Rather than an install script a guide on how easy it is to install NodeJS and magic mirror works for all Pi and also includes 0 scripts which don’t use the incompatible electron Armv7l package
Its up to you which you use but as in the name Raspbian Raspbian Stretch Lite Latest is the lightest and likely to create the best results.
For a mirror that will generally be remote and a mirror installing a full desktop is likely pointless.
Flash the image using Etcher from https://www.balena.io/etcher/
Boot and then enter your WiFi details as the presumption is you will have a WiFi mirror.
So our flash is complete and we are going to boot our pi zero and create some settings. All we need is the SSID of your WiFi router (The name it lists up as when you connect) My ssid=“TALKTALKF20CC3” My psk=“VE3JAX5F” (MyWifi password)
So we are going to login: login: = pi password = raspberry
then type: sudo raspi-config and press enter
Choose 2: Network Choose N2: WiFi Select your country. Enter your ssid. Enter your wifi password.
Choose 5: Interfaces Choose P2: SSH Yes to enable.
Tab to finish and Yes to reboot
We need a SSH client such as Putty or Bitvise.
Also Notepad++ is a great little editor that supports Unix & Windows LF/EOF formats.
If your unsure the sugestions is Bitvise & Notepad++
When the Pi reboots in the boot console log on screen you should now see a line My IP address is … copy that into the Server Host address and the pi/raspberry login details and login.
Update your system and install the base packages for MagicMirror
Pi0/1 owners yeap the first boot update/upgrade to get the latest will be a :sleeping: experience with Pi 2/3 owners being slightly less :sleeping:.
So now we have a completely updated and upgraded Pi and now to install Mirror specific packages.
NodeJS for Pi 0/1 Armv6l is supported but not pakaged due to problems with Chromium compile for electron, this is no problem as the NodeJS NVM NodeVersionManager is excellent and probably should be used for all Pi versions.
If you have a Pi 2/3 armv7l processor then you can install NodeJS via raspbian packages sudo-apt-get instal… but the NVM gives far better control.
Read the GitHub ReadMe for a run down of how to use NVM and what it is capable of.
To install
Then we will enter the MagicMirror folder and start the install
cd ~/MagicMirror && npm install
More :sleeping: time.
So that MagicMirror will autostart and restart on failure we are going to install the NodeJS Process Manager PM2 and if you need further infomation the documentation is great.
So to install
npm install pm2@latest -g
Then we are going to ask PM2 for the correct startup command and paste that into the console.
pm2 startup
Which for me returns, but trust PM2 and not me.
[PM2] To setup the Startup Script, copy/paste the following command:
sudo env PATH=$PATH:/home/pi/.nvm/versions/node/v10.15.1/bin /home/pi/.nvm/versions/node/v10.15.1/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
So do as said and copy & paste what PM2 tells you.
This is where us Pi0/1 and 2/3 owners depart as the need of use of Chromium rather Electron dicates some small changes.
For Pi 0/1 owners.
For Pi 2/3 owners the last thing is.
Thats it unless you wish to read Make things Plymouth pretty and Save my Flash in the above to folders on instructions how to have a MagicMirror splash screen and how to use zram and tools to limit flash writes to a minimium. Apart the last bit about raspi-config and desktop autologin.
So back to Pi0/1 users.
The quickest and easiest way is to create a ~/.Xsession file and here is a sample config.
nano ~/.Xsession
Paste the following
xset s off
xset -dpms
xset s noblank
sleep 20
chromium-browser --noerrdialogs --kiosk http://localhost:8080 --incognito --disable-translate --window-size=1920,1080 --window-position=0,0
Apols as have been editing and doing new for the last couple of days the unlink is nothing to worry about as if you run the script again it just deletes previous symbolic links.
I have changed the way I install and going to update that github repo maybe tonight prob tomoz.
But here is my much prefered method as basically its standard magicmirror install after you have installed node.
So here is a quick run down from a new flash of Stretch Lite onto your SD.
Boot the Pi0
sudo raspi-config
enable ssh, set your wifi, set boot to autologin console
so if you create a script node.sh throw this in just to get the latest or just grab it yourself either /usr/local or sym link it to a neater separate folder.
The only thing we need to do is change the /MagicMirror/run-start.sh from
if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
export DISPLAY=:0 # Set by default display
fi
electron js/electron.js $1
to
if [ -z "$DISPLAY" ]; then #If not set DISPLAY is SSH remote or tty
export DISPLAY=:0 # Set by default display
fi
sh xdotool.sh &
node serveronly $1
electron will not run on the zero hence why we installed chromium and make these changes.
we will also add xdotool.sh which is a sendkey ctrl+F5 which clears the java cache & refreshes as killing and restarting is heavy lifting for the zero and likely unnecessary.
When I do the git I will do something where after 3 concurrent refreshes it will kill and restart.
and that will give you the command for the correct startup so just copy and paste what the startup command tells you, which tells me, prob don’t even need to sym link it.
sudo env PATH=$PATH:/opt/nodejs/bin /opt/nodejs/lib/node_modules/pm2/bin/pm2 startup systemd -u pi --hp /home/pi
add the job and save
pm2 start ~/MagicMirror/installers/pm2_MagicMirror.json
pm2 save
copy config.js to /MagicMirror/config and sudo reboot.
I will sort that out as said prob tomoz as actually the install is now far closer to defacto Pi2/3 install.
I will give you a shout here when complete but the above should get you going.
[edit] Whoops you need something to autostart chromium
Configure /home/pi/.Xsession (create new)
xset s off
xset -dpms
xset s noblank
chromium-browser --noerrdialogs --kiosk http://localhost:8080 --incognito --disable-translate --window-size=1920,1080 --window-position=0,0
A final sudo raspi-config and set boot for desktop autologin.
Lols it would seem so, as so far much effort but no completed magic mirror, but much fun :)
Its been really interesting introduction to nodejs and a whole previously hidden browser console.
I am still banging my head with this PiZero as really with any complexity the proc load goes crazy.
Great if you keep it relatively simple, but being trying ‘other’ browsers to be lighter and to my surprise chromium is by the the best. Midori & Epiphany even after java problems or bad animation are still no lighter from what I am seeing in Top.
Its a tremendous project and I will bung it a donation when I have a bit of cash.
As that is a top tip and ‘small’ ?
Dont know what you mean with that. I think you don’t need to give it a class but with this class you can determine the size of the text.
remoteFile is a file, not a folder. But it can be anywhere, however if it’s not in the module directory you ned to give the absolute path “/home/pi/…”
Starting to get to grips with things Pages just suspends and restarts scripts for each page they are allocated.
So it just needs to be referenced once in pages.