We have moved to a new Sailfish OS Forum. Please start new discussions there.

Turn the screen off/on based on proximity sensor when unlocked

asked 2015-07-12 05:14:43 +0200

Quawerty gravatar image

With my Insmat flip cover, I'd really like the screen to turn off when I cover it and turn back on when I uncover it again (until it took me so long the phone locked itself already).

This would be only case for an unlocked phone.

The new event, condition -> action would be as follows:

  • proximity sensor covered, phone unlocked -> turn the screen off (blank)
  • proximity sensor uncovered, phone unlocked -> turn the screen on and reset respect timers as if a keepalive tap had occured

It is quite simple addition to behaviour and from what I found, it is nearly the same as how the phone work during a call. (Except for locking the touch during the call, which may or may not be implemented in this case.)

Battery concerns: From what I found out about proximity sensor, it runs all the time already. If software polling would be required for this, once a second should be quite enough at least for locking.

As I would expect this naturally from the system, I am tagging this a feature request.

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted

answered 2015-08-04 07:59:43 +0200

spiiroin gravatar image

updated 2016-02-09 21:01:34 +0200

On devices that have a dedicated lid open/closed sensor it already works almost as requested.

There might be some obvious side effects (display blanks in normal use if proximity sensor is covered) and some more subtle ones, but I created tasks to public mer bug tracker that effectively should implement the requested feature:

  1. Make proximity sensor work as if it were a dedicated lid sensor https://bugs.merproject.org/show_bug.cgi?id=1201
  2. Allow tuning of lid open/close actions https://bugs.merproject.org/show_bug.cgi?id=1202

EDIT: The above are implemented and available in sfos >= 2.0.0

To enable use for example:

 mcetool --set-ps-acts-as-lid=enabled --set-lid-sensor-mode=enabled --set-lid-open-actions=unblank --set-lid-close-actions=tklock

And to disable again:

mcetool --set-ps-acts-as-lid=disabled --set-lid-sensor-mode=disabled

And sfos >= 2.0.2 onwards ambient light sensor can be used to avoid blanking when - say - hand is hovering over the proximity sensor, but als still sees some light:

mcetool --set-filter-lid-with-als=enabled --set-filter-lid-als-limit=0
edit flag offensive delete publish link more


Well, great news, thanks. Except I avoid SFOS 2.0 because of the interface, so I likely won't see this working. (I'm stuck on with few patches - that's likely the best UI I can possibly imagine.) Well, my own problem I decided to go the unsupported way. :-)

Quawerty ( 2016-02-25 20:37:22 +0200 )edit

@spiiroin Is there a way to delay the blanking with like a second or so?

Tanghus ( 2017-02-16 12:15:50 +0200 )edit

@Tanghus Not without code changes. At the moment raw, undelayed proximity sensor values are acted on as if lid were reported closed/opened. (If the als filtering is used, it might induce some minor delay to action.)

spiiroin ( 2017-02-16 14:00:53 +0200 )edit

@spiiroin I disabled it again as it collided with the LPM onhover mode - but thanks anyways :)

But BTW: what does als stand for? Except without mentioning Stephen Hawking ...

Tanghus ( 2017-02-17 01:02:52 +0200 )edit

@Tanghus "Ambient Light Sensor". So the als filtering for lid is roughly supposed to be: "ignore lid=closed unless als reports zero light"

spiiroin ( 2017-02-17 07:12:30 +0200 )edit
Login/Signup to Answer

Question tools



Asked: 2015-07-12 05:14:43 +0200

Seen: 642 times

Last updated: Feb 09 '16