sdetweil / MagicMirror_scripts

Magic Mirror installation and setup scripts
369 stars 64 forks source link

How to stop autostart ? ie to switch to server mode #40

Closed cruzanhtpc closed 2 years ago

cruzanhtpc commented 2 years ago

I used your script. Works Great! but im trying to see how to do i stop it from autostarting the client? Basically i want to run this in server mode only now and cant figureout how to do it with your script.

My end result is running MM in server mode (its already running and config with your script) and then loading midori on my pi zero 2 w. Or modifying your script to use Midori
Any help would be appreciated.

cruzanhtpc commented 2 years ago

for more context. I have couple of pi zero 2w, I want to run MM off my pi02w in server mode then launch midori in fullscreen to the mm page. or modify mm to use midori.

Reason. I have a module that loads background wallpaper and it will crash MM after about 20 min. and i think its because of chromium

I have a similar setup with Dakboard on a pi02w and running it with chromium will crash my dakboard , but after i switched to Midori, runs for days without issues changing wallpaper nonstop.

sdetweil commented 2 years ago

install adds a script, run-srart.sh

this is how we launch chrome over server

change the package.json start line to launch run-start.sh

then change the serverOnly parm in config.js to 'local'

then run-start will start server and launch chrome

but u can change to launch Midori instead

cruzanhtpc commented 2 years ago

sdetweil, Thank you for the quick response , i think i did it right. can you check my below.. i think i messed up Midori though, on my other pi i use in autostart @midori -e Fullscreen http://.....

config.js serverOnly: "local",

package.json "scripts": { "start": "/home/pi/MagicMirror/run-start.sh",

run-start (is this right?)

start chromium

  echo "Starting chromium browser now, have patience, it takes a minute"
  # continue to spool stdout to console
  tee <&3 &
    if [ $mac != 'Darwin' ]; then
    b="chromium"
  if [ $(which $b). == '.' ]; then
    b='midori'
   # b='chromium-browser'
  fi
    if [ $(which $b). != '.' ]; then
    "$b" -e Fullscreen --app=http://localhost:$port 2>/dev/null/ 
sdetweil commented 2 years ago

looks good.

didn't need full path on run-start in package.json. it's launched in the mm folder so "./run-start.sh"

would have been enough.

u can test it by running ./run-start.sh in the mm folder

bash -x ./run-start.sh

will show debug as it executes

the main logic tests if chromium is NOT found, then use chromium-browser raspi has one, Ubuntu has another.

cruzanhtpc commented 2 years ago

I update the json "start": "DISPLAY=\"${DISPLAY:=:0}\" ./run-start.sh",

im getting this error running bash -x ./run-start.sh

SyntaxError: Error parsing /home/pi/MagicMirror/package.json: Unexpected token / in JSON at position 213 at parse () at readPackage (node:internal/modules/cjs/loader:304:20) at readPackageScope (node:internal/modules/cjs/loader:329:19) at shouldUseESMLoader (node:internal/modules/run_main:39:15) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:74:24) at node:internal/main/run_main_module:17:47 { path: '/home/pi/MagicMirror/package.json'

And right i am using raspi, so it should be looking for chromium-browser right? or are you saying i need to modify the chromium also to say midori also?

sdetweil commented 2 years ago

"start":"./run-start.sh",

I don't remember which is which, but u can use the which ??? command to find the path to either executable

??? is chromium or chromium-browser

sdetweil commented 2 years ago

json, everything must be quoted, double quotes.

quotes inside quotes have to be escaped with \ in front of the internal ones

cruzanhtpc commented 2 years ago

ah ok, i think i got it now! had an error with the midori portion but now bash -x ./run-start.sh executes without an error. time to reboot and see if it loads all up as expected using midori

sdetweil commented 2 years ago

don't need to reboot. just pm2 restart 0

sdetweil commented 2 years ago

@cruzanhtpc did u get it to work?

cruzanhtpc commented 2 years ago

For the most part, sorry have been letting it run to see if it crashes etc... But yes Midori launches as expected.

I say most part because with chrome I could reduce the font size or module size by editing config.js , zoom: 0.6 and it would reduce everything. When using Midori doesn't seem to respect that zoom. So trying to figure out how to now scale everything down to the right zoom with Midori but no luck.

But I really appreciate it! Everything worked!

sdetweil commented 2 years ago

woohoo. glad to hear. I know nothing about Midori, sorry

cruzanhtpc commented 2 years ago

So question. In theory. If I didn't call your run-start.sh in start of the package.json. like omitted this. Couldn't I just Auto start Midori and point it to localhost. By editing /etc/xdg/lxsession/LXDE-pi/autostart

And adding

@midori -e Fullscreen http://localhost:8080

I'm asking since I trying to see if I can get Midori to zoomout via this method.

If so then what do I put in start for package.json ?

sdetweil commented 2 years ago

just

npm run server

not npm start

I don't know what the @ does in linux.in windows it sliences echo of the command being executed

cruzanhtpc commented 2 years ago

Where do I edit that ? Or how do I Auto start that at boot of pi?

cruzanhtpc commented 2 years ago

Oh ok, that is how I autostart Midori for my other pi 02w to load a page in Fullscreen at boot

sdetweil commented 2 years ago

edit that?

here is zooming on Midori

@midori -e Fullscreen -e ZoomIn -e ZoomIn -a http://10.0.0.254:8080 -p

(Google search)

I use pm2 to launch at boot works the same everywhere, I don't edit system files

make a bash script that does npm run server

then pm2 start script file

the pm2 save

then reboot

cruzanhtpc commented 2 years ago

Yeah that is the way I have been trying to get zoom to work via run-start.sh

Got it I'm not familiar with pm2 that's why I asked , but makes sense now that you said.

sdetweil commented 2 years ago

strange it doesnt zoom via runstart. it's just a script. nothing special..

wonder if it's because of npm or pm2 or both..

if I just run runstart from the mm folder does it work ok?

./run-start.sh

cruzanhtpc commented 2 years ago

When just running the script Midori Doesn't like the -e ZoomOut. Or -e ZoomIn but it does run with -e Fullscreen

sdetweil commented 2 years ago

i have added support for launching midori on linux

add

export external_browser=midori to the installers/mm.sh before the npm start line

run-start.sh will use that to launch midori over server-only mode