PINE64
phosh proximity sensor toggle script - 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)
+--- Thread: phosh proximity sensor toggle script (/showthread.php?tid=13888)



phosh proximity sensor toggle script - D4rkh0rs3 - 05-12-2021

id | grep root || sudo $0
NUMBER=`cat /sys/module/stk3310/drivers/i2c\:stk3310/2-0048/iio\:device2/in_proximity_scale`
if [ $NUMBER = 0.100000 ]
then
  echo turning off
  echo 6.4 > /sys/module/stk3310/drivers/i2c\:stk3310/2-0048/iio\:device2/in_proximity_scale
else
  echo turning on
  echo 0.1 > /sys/module/stk3310/drivers/i2c\:stk3310/2-0048/iio\:device2/in_proximity_scale
fi

works for me under manjaro phosh, YMMV
if it doesnt work see if that "iio\:device2" became device 1 or 0 or ...

is there an easy way to tie this to an icon?


RE: phosh proximity sensor toggle script - disctanger - 05-17-2021

Thank you for the script and the idea. Unfortunately, i don't know how to accomplish what you are looking for but i want to share my experience in toggling proximity sensor on my device.



> if it doesnt work see if that "iio\:device2" became device 1 or 0 or ...

In my case it was "iio\:device1"



I am also using Manjaro Phosh.



Additional note:

I had to run the command with sudo

sudo ./proximity-toggle.sh



The following is the script that toggles proximity sensor without problem:

[pp@pp-device ~]$ cat proximity-toggle.sh

Code:
id | grep root || sudo $0
NUMBER=`cat /sys/module/stk3310/drivers/i2c\:stk3310/2-0048/iio\:device1/in_proximity_scale`
if [ $NUMBER = 0.100000 ]
then
  echo turning off
  echo 6.4 > /sys/module/stk3310/drivers/i2c\:stk3310/2-0048/iio\:device1/in_proximity_scale
else
  echo turning on
  echo 0.1 > /sys/module/stk3310/drivers/i2c\:stk3310/2-0048/iio\:device1/in_proximity_scale
fi



RE: phosh proximity sensor toggle script - Trbl - 06-10-2021

This isn't turning it off...

put "blacklist stk3310" inside "/etc/modprobe.d/proximity.conf" to permanently turn it off or do "sudo rmmod stk3310" to turn it off until reboot.