-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
Allow for screen to dim after a certain amount of time #2
Comments
Note: There is built-in screen blanking functionality (settings for it are in the Pi Configuration app, or in |
Might be configurable with
|
I did find the command |
Indeed, changing that value changes the screen timeout, and persists across reboots. HOWEVER, I did a quick test to see if a tap on the blank screen just wakes the screen, or is sent through as a normal 'click'. And annoyingly, it's sent through as a 'click'. So 'tap to wake' is not really an option, at least unless you designate a 'safe area' on your UI that you can tap to wake... or if you design a circuit that jiggles a mouse input when vibration is detected, and you tap the side of the display, something like that :/ Demo: tap-to-wake-screen.MOVGoing to ask on the forums: 'Tap to wake' Touch Display is risky |
From @6by9 on the Pi Forums:
So it sounds like a fix could be made, but it may be a little complicated. It'd be awesome to have that fix on the OS level so I don't have to do some weird shenanigans with a system service. For now, I'm just touching in a part of the screen where I know there are no buttons. |
It's probably broken now that everything is wayland, but you can take a look at my fork of this pi-touchscreen-dimmer, maybe just for some more inspiration. I've been using it to get auto dimming on my pi for years now https://github.com/gabeklavans/pi-touchscreen-dimmer. It doesn't quite achieve your 2. goal because the first tap both "wakes" and registers as a normal tap, but it's close. Just tested it on a latest raspberry pi OS with wayland, dimming works, but the touch event doesn't. Might need more tinkering. I think any of the logic there can be lifted for this project pretty easily. |
It's more of a workaround than fix but I've setup an automation in Home Assistant that will turn the display on/off when motion is detected. It doesn't fix the issue however does mean that when someone's in the room and may want to use the panel the display is on so they don't accidentally press a button when waking the screen up. I'm using a Pi 3B with Bookworm 64bit installed and the original Raspberry Pi display so there may be some difference. You can turn the backlight on or off by changing the value in For my display setting To setup the automation I setup passwordless SSH authentication between Home Assistant and the Pi. On the Pi I then created two scripts and changed the permissions for
Backlight On
Backlight Off
I had to create them as scripts on the Pi as running the command directly through Home Assistant would fail whereas calling the script didn't. Then I setup shell commands in Home Assistant by adding the below to my
You can run the command directly from the Home Assistant terminal with the After a restart of HA to get the shell commands to appear I created two automations.
Now whenever motion is detected the screen comes on and goes off when people leave the room. Like I said it doesn't fix the issue but depending on use case it may do the job. A possible next step would be to present the backlight controls to HA as entities that could then be used as part of a normal motion-activated blueprint rather than create two seperate automations. |
Something like this might be just the ticket. Couple it with radar-based presence sensors (I've been testing some Everything Presence sensors around the studio), and you could have the screen only come on while someone is detected in the room a bit more reliably than standard PIR sensors too. Otherwise I could tie it into my Simplisafe automation (when 'Off', turn on the display...). |
Indeed, one other thing I've found is that the permissions on |
I am using a rpi 4 and the older screen as well as the official case for both. (hacked a bit to hold a pwm fan) I think I am going to use one of two methods...
Neither option is fantastic but it should get me by in the meantime. |
Could you use an HC-SR04 distance sensor, and rather than use tap to wake, just have the display turn on when there's something within x distance? That way, it's not only off when you're away from the building but remains off if you're nowhere near the screen, that might be even more useful than tap to wake. |
Swayidle sounds like the right approach. You can execute multiple actions on different timeouts as well. Example Regarding the wake-up button press also being passed through to Chromium: maybe you could spawn some kind of "lockscreen" which doesn't require a password and just unlocks everything once it receives any input. If its started shortly before disabling the output via test_screen_block.py#!/usr/bin/env python3
import gi
gi.require_version("Gtk", "3.0")
gi.require_version("Gdk", "3.0")
from gi.repository import Gtk, Gdk
class ScreenSaver(Gtk.Window):
def __init__(self):
super().__init__()
self.connect('motion-notify-event', Gtk.main_quit)
self.connect('button-release-event', Gtk.main_quit)
self.set_events(Gdk.EventMask.POINTER_MOTION_MASK)
self.fullscreen()
self.show()
if __name__ == '__main__':
win = ScreenSaver()
Gtk.main() |
This seems like a great idea, but apparently we would need to run the following everytime the Pi is rebooted?
Or is there a way to make the permission persistent? |
You need a udev rule if you want to use bl_power and the permissions are wrong. I think |
Thanks for your input! I'm a bit of a newbie in Linux. I found out that I could possibly create a udev rule, but couldn't figure out how to do it for this specific permission(didn't find an example for this parameter). Unfortunately, I also can't figure out how to leverage the info in the link you provided. Thanks in advance |
If you look at /etc/udev/rules.d/99-com.rules, you'll see a number of lines at the start
SUBSYSTEM is probably "backlight" (you can use |
I don’t know whether I’m missing something but is it not just simplest to put a cronjob in that changes the permissions on each reboot? All I’ve done is add the below to roots crontab and it’s doing the job.
|
Using cron fails if the module is unloaded and reloaded. That may be an unusual situation, but it's possible. As I've said to thebishop85, 777 is incorrect for the permissions as you should not be able to execute that device. |
@thebishop85: Something like this will probably work to make the permissions permanent: echo 'SUBSYSTEM=="backlight", KERNEL=="10-0045", RUN+="/bin/chmod 666 /sys/class/backlight/%k/brightness"' | sudo tee -a /etc/udev/rules.d/backlight-permissions.rules I use something similar for my touch kiosk project, which also provides a Home Assistant integration to directly control the display brightness (using a dimmable light sensor):
@geerlingguy: I addressed this issue by removing focus from the kiosk window. As a result, the first click will focus the window instead of sending a click command into the webview. However, I still view this as a temporary workaround rather than a proper solution. |
To summarize a few previous points here, and at least get the screen dimming working via udev and the default labwc's autostart file, this was what I had to do: Add a new file /etc/udev/rules.d/99-kiosk.rules
Append the following to $HOME/.config/labwc/autostart:
|
Thanks @nj-dunn I followed your steps and managed to get it all working at the first attempt - touch kiosk is so much better than using the browser, and I like the MQTT integration. |
I've got it working with turning the screen backlight off when being unused and back on when swiping over the screen - it's not waking up on a tap. Not sure why, but I'm quite happy with that. Have a look at I've also added a device with category touch, which allows me to have gestures like zooming with to fingers, panning, etc.:
Not sure if all of these are needed, but that's what I have right now and it's working. For completeness, I have in |
For this feature to be useful:
That latter point would require a bit more work—not sure if the Pi Touch Display 2 has integration into Linux itself to have some kind of automatic screen dimming support out of the box (or failing that, turn it off or dim it to 0%)...
The text was updated successfully, but these errors were encountered: