Skip to content

Turn off screen after certain time #465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
danielkastberg opened this issue Dec 25, 2024 · 7 comments
Open

Turn off screen after certain time #465

danielkastberg opened this issue Dec 25, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@danielkastberg
Copy link

I would like to turn off the screen after midnight. Is it possible since flutter pi runs without X11 or Wayland?
I read online but all posts are mentioning something related to X11 or Wayland like "xset", "tvservice" or "xrandr" but no use since they require X11 or Wayland running.

Can this be done or do I have to turn the power off the PI during nighttime?

@DisDis
Copy link
Contributor

DisDis commented Dec 25, 2024

You can take my example of turning the screen on and off on the Pi4 https://github.com/DisDis/dslideshow/tree/master/deb_factory/template_build_arm64/opt/dslideshow/scripts

@danielkastberg
Copy link
Author

Thank you! I'm away from my PI but will test it when I get back. I used tvservice before and got "Can't find display" but then I know it should work for the flutter pi

@tryy3
Copy link

tryy3 commented Dec 31, 2024

I had a similar case and thought I would share my solution.
I am running a Pi 5 with the new Touch Screen Display 2 and I couldn't get any of the tools that people recommended (tvservice, xrandr etc.) but managed to find that I could change the brightness directly with the backlight class.

Under /sys/class/backlight/ I was able to find my display and then set the brightness to 0 or max_brightness.
So In my case I can turn it off using echo 0 | sudo tee /sys/class/backlight/11-0045/brightness and turn it on with echo 20 | sudo tee /sys/class/backlight/11-0045/brightness

In my case I wanted "screensaver" functionality so changing the brightness worked wonderful since the display is on and reactive just no brightness. So I could just make a widget that lives at the top with a GestureDetector to trigger a timer.
Your case might be a bit different though and brightness might not be enough.

@danielkastberg
Copy link
Author

You can take my example of turning the screen on and off on the Pi4 https://github.com/DisDis/dslideshow/tree/master/deb_factory/template_build_arm64/opt/dslideshow/scripts

tvservice doesn´t seem to be included anymore in Bookworm. Have been replaced with vcgencmd. Tried vcgencmd display_power 0 but vcgencmd only works with vc4-fkms-v3d.

I had a similar case and thought I would share my solution. I am running a Pi 5 with the new Touch Screen Display 2 and I couldn't get any of the tools that people recommended (tvservice, xrandr etc.) but managed to find that I could change the brightness directly with the backlight class.

Under /sys/class/backlight/ I was able to find my display and then set the brightness to 0 or max_brightness. So In my case I can turn it off using echo 0 | sudo tee /sys/class/backlight/11-0045/brightness and turn it on with echo 20 | sudo tee /sys/class/backlight/11-0045/brightness

In my case I wanted "screensaver" functionality so changing the brightness worked wonderful since the display is on and reactive just no brightness. So I could just make a widget that lives at the top with a GestureDetector to trigger a timer. Your case might be a bit different though and brightness might not be enough.

My display doesn´t show up in backlight, just an empty folder...

Also tried ddcutil but running ddcutil getvcp scan results in Display not found.
I'm using the Wavesahre 11.9 inch touch display. https://www.waveshare.com/wiki/11.9inch_Touch_Monitor
Maybe this screen just won´t work without X11...

@ardera ardera self-assigned this Jan 13, 2025
@ardera ardera added the enhancement New feature or request label Jan 13, 2025
@FibreFoX
Copy link

FibreFoX commented Feb 2, 2025

When running on a Raspberry Pi 3B+ with current Debian Bookworm, I would run kmsblank -c 0 to disable the display (which is connected via HDMI). But sadly this does not work:

Connector 0: blank
Failed to set DPMS: -13

When flutter-pi is not running, that command works and disables the display as expected (that tool waits for a keypress to resume the display). I assume because the way flutter-pi works, the command is "clashing" with my flutter app running.

Maybe this should be added into the docs somewhere, haven't found anything about this.

@danielkastberg
Copy link
Author

I solved it with changing the display driver to fkms.
dtoverlay=vc4-fkms-v3d
and then I could control the power with vcgencmd
vcgencmd display_power 0 && vcgencmd display_power 1
Not a sustainable solutions since the fkms has been deprecated but works for now.
I'll try /sys/class/backlight/ and see if that can work with kms-driver

@DisDis
Copy link
Contributor

DisDis commented May 1, 2025

@FibreFoX @danielkastberg I implemented first version. It works fine.
#478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants