Wednesday, April 17, 2013

Tasker to proximity screen off


Tasker to proximity screen off

 

If you are using proximity screen off pro or smart screen off, you may know how convenient it is to automate our lives via built-in proximity sensor.

 

Now I am going to show you how tasker done this job to replace proximity screen off pro.

 

Before all of it, just a reminder, you may go to tasker preference interface, and click on the tab of monitor, then pull down the screen, you will find the option for proximity sensor, “No” means proximity sensor will shut off when the screen turns off, back on when the screen turns on. I guess it might avoid any unnecessary loss for the sensor since you may prefer saving more battery.

 

Profile 1: (proximity screen off 1)

 

Context-state-sensor-proximity sensor

 

Action-variable-variable set-name %Proximity, to On

Exit action- variable-variable set-name %Proximity, to Off

 

 

Profile 2: (proximity screen off 2)

 

Context 1-state-sensor-proximity sensor

 

Context 2-state-display-display orientation, portrait  # if you are playing some game which requires full screen in landscape, this profile would not interrupt.

 

Context 3-state-phone-call, type-any, invert    # this action is to avoid the situation while incoming or outgoing call occurs.

 

Context 4-state-app-not camcorder, camera, flashlight   # for some specific apps, you might not want to be interrupted as well. Eg. Like you are using flashlight.

 

Action 1-task-wait 5 seconds       # give you 5 seconds to avoid some unexpected cases.

 

Action 2-display-system lock, if  %Proximity~On   # 5 seconds later if it is still being fired, then system lock the phone.

 

 

21 comments:

  1. Replies
    1. I am glad I can help.

      Enjoy !

      Cathy

      Delete
    2. Hey I noticed the proximity sensor stays on constantly with this version. I modified it a bit to only turn it on after the device is upside down and not in any restricted apps.

      Here's a link to the modified version on Reddit: http://www.reddit.com/r/tasker/comments/1m4rrq/how_to_have_your_screen_turn_off_when_you_put/

      Side note: You've made the sidebar!

      Delete
    3. Hi, Chris Register,

      to turn the proximity sensor off while the screen is off, you just need to go to tasker preference and the monitor tab and pull down to find the proximity snsor option, and switch it to No, which means you don't want to keep sensor working while the screen is off.

      I have already mentioned this attention in the post, if you noticed.

      Have fun!

      Cathy

      Delete
  2. Stupid question, but can I just copy and paste this into taker?

    ReplyDelete
    Replies
    1. Hi,

      sorry, you cannot copy and paste it. do it step by step, please.

      Cathy

      Delete
  3. Hi! This works, but for a while only. I don't know but Tasker will see that the proximity sensor is active even if there's nothing in front of it. This usually happens after a couple of hours. I've tested the sensor if it's fauly but it's working as intended(tested via other proximity app). When I re install tasker, it works as intended then the problem happens again.

    Any ideas?

    Thanks!

    ReplyDelete
    Replies
    1. Hi,

      what specific version of tasker are you using? i suspect it is due to the tasker version installed in your phone is malfunctioning.

      Cathy

      Delete
  4. Hi,
    Both profile have same name?

    ReplyDelete
    Replies
    1. Hi,

      sorry about that, you may rename it as any other characters as you like.

      Cathy

      Delete
  5. I've tried my own brand of this and had some issues so I gave yours a shot and I'm still running into to the same problem. Basically, if put your hand in front of the sensor for 2 seconds, remove it for a second or two, and then cover it again for 2 seconds, the screen goes out. I'm trying to find a way that the 5 second count will reset whenever the sensor is clear. That way the sensor needs to be covered for 5 consecutive seconds. I tried using a Stop task when exiting but that doesn't work either. The only thing I found that works fairly well is to split the Wait task into five 1 second waits instead of one 5 second wait. This gives the exit tasks time to run before the time is up. Any other suggestions?

    ReplyDelete
    Replies
    1. Hi,

      i get a little bit confused of your question.

      covered 2 seconds then undo 1 second, then re-covered 2 seconds, that sounds like a little bit joking.

      i didn't say it is not possible, just think it could rarely happen. right?

      however, if you insist, i guess counting the sensor covered time is the final solution for you.

      e.g. when the profile is active, mark a timestamp, then if the profile turns into inactive, exit task, mark another timestamp, then you are able to count if it is running time is up to 5 seconds or not.

      of course, to be more convenient, you may use python sl4a script instead.

      Cathy

      Delete
    2. I did it like this: I have a counter variable, which is increased every time the proximity sensor is not blocked any more. And I have a variable, which is set to this value when the proximity sensor is blocked. Then it waits 4 seconds (or how long you like) and locks the screen if the counter equals the second variable and the proximity sensor is still blocked.

      Delete
  6. Can you make pictures? I dont know where to put these commands

    ReplyDelete
    Replies
    1. Hi,

      it is not that much difficult indeed.

      get some time, read my entries, then tell yourself you can.

      Cathy

      Delete
  7. Pent's suggestion which requires only 1 profile:

    Profile: Prox
    Context: State: Proximity
    Task:
    Wait 1 Second
    System Lock If %PACTIVE Matches *,Prox,*

    i.e. only lock if it's still active (i.e. prox sensor still covered) after a second.

    Suggestion is posted at https://groups.google.com/d/msg/tasker/WtjpvFd6P5s/EpovFLlNcbcJ

    ReplyDelete
  8. Thank you,
    I can not two actions in profile 2.
    Only one action to profile 2.
    How to possible two action?

    ReplyDelete
    Replies
    1. Hi,

      excuse me, i get sorta confused of your comment.

      could you please explain it a little bit detailed?

      i will see what i can do for you.

      Cathy

      Delete
  9. Hi there, thanks for the manual. I cannot, however, add more than 3 "States" to a single profile. After adding "Context 3-state-phone-call, type-any, invert" I cannot add another "State"-context. It seems like a software limitation. I'm on the latest version of Tasker as of today. Any idea if anything can be done, besides dropping one of the components? Thanks in advance.

    ReplyDelete
    Replies
    1. I'm sorry, I've seen that the "Application" context is not under "State" (any more?) but a seperate context in the menu, which allowed me to include all the contexts.

      Another question I've got: I have created only 1 profile, and skipped the "if %Proximity~On" part in Action 2. In fact, I've simplified this rule down to the following:

      [Context 1] + [Context 2] + [Context 3] + [Context 4] => [Action 1] + [display-system lock]

      It works like expected. Am I missing something with this simplified set of rules? What?

      Delete
    2. Once again I found the answer myself a minute after posting the question. Sorry for spamming you!

      Thanks for the manual!

      Delete