guysoft/MagicMirrorOS

Unable to turn off/on hdmi connected display from inside container

mafraqs opened this issue · 2 comments

I was following the well made instructions in the documentation to get MMM-Pir-Sensor-Lite to run.

The raspberrypi was setup using the 2021-04-13_2021-03-04-magicmirroros-buster-armhf-lite-0.2.0.zip.
I switched the image within the docker-compose.yml to karsten13/magicmirror:buster_fat.

The PIR sensor itself is up and running and detects motion just as it should.
Unfortunately, I can't get the monitor to turn off and on automatically.

xrandr and vcgencmd return command not found when run inside the container.

What else can I try?

docker-compose.yml

version: '3'

services:
  magicmirror:
    container_name: mm
    image: karsten13/magicmirror:buster_fat
    volumes:
      - ../mounts/config:/opt/magic_mirror/config
      - ../mounts/modules:/opt/magic_mirror/modules
      - ../mounts/css:/opt/magic_mirror/css
      - /opt/vc:/opt/vc:ro
      - /tmp/.X11-unix:/tmp/.X11-unix
      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
    devices:
      - /dev/vchiq
      - /dev/gpiomem
    environment:
      DISPLAY: unix:0.0
    network_mode: host
    shm_size: "128mb"
    restart: unless-stopped
    command:
      - npm
      - run
      - start

PIR sensor in config.js

{
	module: "MMM-PIR-Sensor-Lite",
	position: "top_center",
	config: {
		title: 'I see you',
		sensorPin: 23, // GPIO pin
		deactivateDelay: 20000, // 20 sec
		showCountDown: true,
		showDetection: true,
		commandType: 'vcgencmd'
	}
},

I was following the well made instructions in the documentation to get MMM-Pir-Sensor-Lite to run.

these instructions were made for bullseye images, not for buster ...

It may could work if you add - /usr/bin/vcgencmd:/usr/bin/vcgencmd under volumes: section which mounts the missing vcgencmd into the container.

You have to setup MMM-Pir-Sensor-Lite to run with vcgencmd (already done in above config.js).

Thank you very much for the incredibly fast response, @khassel.
What you suggest is exactly what I've tried in my several hours tinkering action and it always failed due to missing dependencies.

However, your answer has motivated me again to do further research.
In the meantime I have even consulted chatGPT and squeezed every bit of information out of it.

Long story short, I found a setup that works (I'm not sure if all these keys under volumes are necessary):

version: '3'

services:
  magicmirror:
    container_name: mm
    image: karsten13/magicmirror:buster_fat
    volumes:
      - ../mounts/config:/opt/magic_mirror/config
      - ../mounts/modules:/opt/magic_mirror/modules
      - ../mounts/css:/opt/magic_mirror/css
      - /usr/bin/vcgencmd:/usr/bin/vcgencmd
      - /usr/lib/arm-linux-gnueabihf/libvcos.so.0:/usr/lib/arm-linux-gnueabihf/libvcos.so.0
      - /usr/lib/arm-linux-gnueabihf/libvchiq_arm.so.0:/usr/lib/arm-linux-gnueabihf/libvchiq_arm.so.0
      - /opt/vc:/opt/vc:ro
      - /tmp/.X11-unix:/tmp/.X11-unix
      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
    devices:
      - /dev/vchiq
      - /dev/gpiomem
    environment:
      - LD_LIBRARY_PATH=/opt/vc/lib
    network_mode: host
    shm_size: "128mb"
    restart: unless-stopped
    command:
      - npm
      - run
      - start