PINE64
Proximity / ambient light sensor - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: PinePhone (https://forum.pine64.org/forumdisplay.php?fid=120)
+--- Forum: PinePhone Software (https://forum.pine64.org/forumdisplay.php?fid=121)
+---- Forum: Mobian on PinePhone (https://forum.pine64.org/forumdisplay.php?fid=139)
+---- Thread: Proximity / ambient light sensor (/showthread.php?tid=10595)



Proximity / ambient light sensor - antiX-Dave - 07-07-2020

Going off into my thoughts in the flashlight app thread I have been trying to see where the proximity /light sensor is being monitored to blank the screen if covered. I have not yet found where this is but suspect it is programmed within phosh/phoc. I was hoping to add a section to this where if the light level is above the threshold to blank the screen but below another threshold it would change the gtk theme to a dark variant.

After spending some time looking and not finding, I thought it might be done with an udev rule like:
Code:
# Set the theme based on light level
ACTION=="add|change", SUBSYSTEM=="iio", KERNEL=="iio:device1", ATTR{in_illuminance_raw}=="[0-9]|[0-9][0-9]", RUN+="/bin/su mobian -c /usr/local/bin/set-dark-theme"

Where set-dark-theme contains
Code:
#!/bin/sh
gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark

Of course doing only this would need a manual reset; but it should be good enough for testing...
Unfortunately the event does not trigger when the light level changes, only when the sensor is added as far as udev is concerned. This works by restarting udev which is nice, but does not really help anything.

Next I thought to hook into the lock screen unlock where a script would run to check the value in /sys/bus/iio/devices/iio\:device1/in_illuminance_raw and set the theme accordingly. (If you had an incorrect theme pressing the power button and unlocking would switch it) Tried a few spots that I thought might hook into the lock screen but without success.

It is probably not the best idea to constantly probe. However as a proof of concept, a simple bash script. (Most visible difference with gnome-clocks and the flashlight app)
Code:
#!/bin/sh
while : ; do
    reading=`cat /sys/bus/iio/devices/iio\:device1/in_illuminance_raw`
    if [ "$reading" -lt "100" ]; then
        gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark
        while : ; do
            reading=`cat /sys/bus/iio/devices/iio\:device1/in_illuminance_raw`
            if [ "$reading" -gt "100" ]; then
                gsettings set org.gnome.desktop.interface gtk-theme Adwaita
                break;
            fi
            sleep 10;
        done
    sleep 10;
    fi
done       

Any information/pointers to bring this past a looping bash script?


Proximity / ambient light sensor - e-minguez - 07-07-2020

What about using
http://eradman.com/entrproject/ ?

Enviado desde mi ONEPLUS A5010 mediante Tapatalk


RE: Proximity / ambient light sensor - a-wai - 07-08-2020

Auto-backlight is managed in gnome-settings-daemon, you can probably add some code to it for theme switching.


RE: Proximity / ambient light sensor - wibble - 07-08-2020

Whatever you do, please make sure it has hysteresis - flipping the theme every few seconds when the lighting is marginal will be a major annoyance!


RE: Proximity / ambient light sensor - vicky - 07-08-2020

When I used the phone I noticed that the screen gets turned dark grey when the proximity sensor is covered (e.g. by my hand).
It is rather annoying for me when I am in landscape mode.
Is there a way to turn that behavior off unless I am making a call? In my opinion it would be nice to be able to change it in the settings using the GUI.

(I posted it here because there is also proximity sensor in the thread name)


RE: Proximity / ambient light sensor - devrtz - 07-08-2020

This is a known issue.
As you can see from the issue ideally it should only behave like this when a call is active.


RE: Proximity / ambient light sensor - wibble - 07-08-2020

(07-08-2020, 02:24 PM)devrtz Wrote: This is a known issue.
As you can see from the issue ideally it should only behave like this when a call is active.
Is there a current equivalent to the freesmartphone.org APIs being worked on and used for this sort of thing?
http://www.freesmartphone.org/specs/org.freesmartphone.Phone.Call/


RE: Proximity / ambient light sensor - pinephonenewbee - 11-20-2020

(07-08-2020, 02:17 PM)vicky Wrote: When I used the phone I noticed that the screen gets turned dark grey when the proximity sensor is covered (e.g. by my hand).
It is rather annoying for me when I am in landscape mode.
Is there a way to turn that behavior off unless I am making a call? In my opinion it would be nice to be able to change it in the settings using the GUI.

(I posted it here because there is also proximity sensor in the thread name)
Hello,

dis you find a solution to this issue?
I have exactly the same with Mobian.
One more thing, when in landscape mode the phone screen flip 180° after each wake up..

Thanks