• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Having trouble with screen on and off? Here are some tips that could help

Scheduled Pinned Locked Moved Tutorials
14 Posts 7 Posters 3.0k Views 7 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    mumblebaj Module Developer
    last edited by Nov 7, 2024, 3:35 PM

    Hey guys,

    Just a little note for for those who are struggling.

    I have recently upgraded from my RPi 3B+ to RPi 5 4GB. MM has been running fine for a while now and all my modules are running sweet.

    One thing I have been struggling with was getting the Pi to shut off the output at night and then on again in the morning. The old way, vcgencmd display_power 0 and vcgencmd display_power 1 does not work on the RPi5.

    In order to get things working again, and after a lot of research I have managed to get this working now. Below are 2 scripts that I have which are called from crontab at specified times.

    You have to ensure that both of the below scripts are executeable. To do this you need to run the following command. chmod +x mon.sh mof.sh from the command prompt.

    mof.sh - Monitor Off.
    Create a file: nano mof.sh and add the below.

    #!/bin/bash
    export WAYLAND_DISPLAY=wayland-1
    export XDG_RUNTIME_DIR=/run/user/1000
    /usr/bin/wlr-randr --output HDMI-A-1 --off
    

    Explanation

    • Declare a variable for WAYLAND_DISPLAY
    • Declare a variable for XDG_RUNTIME_DISPLAY (I had an issue with this and only found recently that I needed to declare this as well in the script)
    • Execute the wlr-randr command to turn off the display

    mon.sh - Monitor On
    Create a file: nano mon.sh and add the below to it.

    #!/bin/bash
    export WAYLAND_DISPLAY=wayland-1
    export XDG_RUNTIME_DIR=/run/user/1000
    /usr/bin/wlr-randr --output HDMI-A-1 --on --mode 1920x1080@60Hz --transform 270
    

    Explanation

    • Declare a variable for WAYLAND_DISPLAY
    • Declare a variable for XDG_RUNTIME_DISPLAY (I had an issue with this and only found that I needed to declare this as well in the script)
    • Execute the wlr-randr command to turn on the display
    • lI have to supply options to this command as I needed to ensure that when the monitor is turned on, it has the same pixilation and rotation etc. This is achieved by passing --mode 1929x1080@60Hz and to ensure it is flipped 90 degrees I pass the option --transform 270.

    To obtain your current screen settings you run wlr-randr from the command prompt and you will be shown the current settings for your mirror. You can then use those values and substitute them for the values above if yours is different. This will also confirm if your monitor is HDMI-A-1 or if it is called something else.

    Crontab
    To instantiate a crontab you do crontab -e from the command line.
    Add the following entries at the bottom of the file.

    00 06 * * * /home/pi/mon.sh >> /home/pi/mon.log 2>&1
    00 21 * * * /home/pi/mof.sh >> /home/pi/mof.log 2>&1
    

    From the above, it will turn the output on at 6am and turn it off at 9pm.

    Hope this helps somebody.

    Check out my modules at: https://github.com/mumblebaj?tab=repositories

    R L B 3 Replies Last reply Nov 9, 2024, 1:35 PM Reply Quote 3
    • R Offline
      reviewsfornerds @mumblebaj
      last edited by Nov 9, 2024, 1:35 PM

      @mumblebaj Thank you for this tutorial.

      I have been able to modify the MMM-Remote-Control config to use these commands for monitor on and off, and the command “/usr/bin/wlr-randr --output HDMI-A-1 --off” works in ssh terminal, however the log file shows the error “failed to connect to display” when running this as a cron job.

      Would you have any insight as to what I could do? What would I need to provide in order for you to assist?

      I am on Wayland desktop

      M S 2 Replies Last reply Nov 11, 2024, 3:40 PM Reply Quote 1
      • M Offline
        mumblebaj Module Developer @reviewsfornerds
        last edited by Nov 11, 2024, 3:40 PM

        @reviewsfornerds Hi. Apologies for the late reply. Was away for the weekend.

        Can you share your script that you are calling? Also the output of wlr-randr.

        Check out my modules at: https://github.com/mumblebaj?tab=repositories

        1 Reply Last reply Reply Quote 0
        • S Offline
          sdetweil @reviewsfornerds
          last edited by Nov 11, 2024, 3:45 PM

          @reviewsfornerds said in Having trouble with screen on and off? Here are some tips that could help:

          the log file shows the error “failed to connect to display”

          yes, the command wants to know WHICH ‘display’ you want to control
          and normally would get that from the environment variables of the terminal window you are running the command in

          BUT

          the module is running it in the background, with NO window, no env variable… oops…

          IN addition, ‘specifying’ the window info may not work as the environment running the wlr_randr command was NOT started UNDER the window manager

          how to fix THAT is beyond my knowledge… as each of these depends on different stuff…
          (and you put it in cron, and cron runs as ROOT, not the local user you would be if you had a terminal window… even more fun)

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • C Offline
            captsi
            last edited by Nov 20, 2024, 10:20 AM

            Thank you for the tutorial, it solved my issues of sending the screen to sleep at night. For whatever reasons, I had to use wayland-0 and HDMI-A-2 on my installation.

            M S 2 Replies Last reply Nov 20, 2024, 4:36 PM Reply Quote 1
            • M Offline
              mumblebaj Module Developer @captsi
              last edited by Nov 20, 2024, 4:36 PM

              @captsi HDMI-A-2 is probably because you plugged into 2. Glad it helped you though.

              Check out my modules at: https://github.com/mumblebaj?tab=repositories

              1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @captsi
                last edited by Nov 20, 2024, 5:10 PM

                @captsi said in Having trouble with screen on and off? Here are some tips that could help:

                I had to use wayland-0 and HDMI-A-2

                wayland is the software screen interface,
                HDMI- is the hardware screen interface

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                1 Reply Last reply Reply Quote 0
                • L Offline
                  langejos @mumblebaj
                  last edited by Nov 25, 2024, 12:45 AM

                  @mumblebaj

                  Works great, but when the monitor switches back on, chromium does not start maximized and shows the infobar, both of which are managed in the [autostart] section of wayfire.ini. Is there a way to get the MM display back just as when the Pi launches fresh?

                  S M 2 Replies Last reply Nov 25, 2024, 2:36 AM Reply Quote 0
                  • S Offline
                    sdetweil @langejos
                    last edited by Nov 25, 2024, 2:36 AM

                    @langejos switch back to x11 in raspi-config

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    L 1 Reply Last reply Dec 9, 2024, 5:15 PM Reply Quote -1
                    • G Offline
                      Gejakem
                      last edited by Nov 25, 2024, 10:42 AM

                      For me I needed to use wayland-0 on a RPI5 using the ribbon-display cable.
                      From the wlr-randr i got this

                      DSI-1 “(null) (null) (DSI-1)”
                      Physical size: 154x86 mm
                      Enabled: yes
                      Modes:
                      800x480 px, 60.028999 Hz (preferred, current)
                      Position: 368,332
                      Transform: 90
                      Scale: 1.000000

                      So I used DSI-1 instead of HDMI.
                      Also I removed the --mode information since i got something like “Mode 800x480 not recognized”, but apparently my display defaults to that.

                      1 Reply Last reply Reply Quote 0
                      • 1
                      • 2
                      • 1 / 2
                      • First post
                        Last post
                      Enjoying MagicMirror? Please consider a donation!
                      MagicMirror created by Michael Teeuw.
                      Forum managed by Sam, technical setup by Karsten.
                      This forum is using NodeBB as its core | Contributors
                      Contact | Privacy Policy