Proximity / ambient light sensor
#1
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?
#2
What about using
http://eradman.com/entrproject/ ?

Enviado desde mi ONEPLUS A5010 mediante Tapatalk
#3
Auto-backlight is managed in gnome-settings-daemon, you can probably add some code to it for theme switching.
#4
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!
#5
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)
#6
This is a known issue.
As you can see from the issue ideally it should only behave like this when a call is active.
#7
(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....hone.Call/
#8
(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


Possibly Related Threads…
Thread Author Replies Views Last Post
  Proximity sensor is oversensitive (was "Screen blanks when making call") treebeard 5 2,647 08-02-2022, 03:16 PM
Last Post: treebeard
  Notification light when entering low power Barugon 5 3,368 11-22-2021, 06:20 AM
Last Post: beta-user
  Proximity sensor dims screen doidolinux 8 4,017 08-09-2021, 11:14 PM
Last Post: tllim
  Toggle light & dark themes with a launcher. MtnSk8 0 1,421 03-14-2021, 12:20 AM
Last Post: MtnSk8
  After update the green light comes on then the system hangs joz_mak 6 6,397 11-11-2020, 09:23 AM
Last Post: antiX-Dave
  Proximity sensor always active - screen turns off randomly? bitnick 10 9,963 09-12-2020, 03:58 AM
Last Post: a-wai
  led light jesica 27 29,459 09-11-2020, 11:01 AM
Last Post: ergo owl

Forum Jump:


Users browsing this thread: 1 Guest(s)