Ask / Submit

Command line device lock

asked 2015-07-27 14:22:42 +0200

Tim Drub gravatar image


I would like to use the Situations app to disable the device lock when certain bluetooth devices are connected, e.g. the car or headset and to enable it again once they are not connected anymore. The events are well covered by the app but I am missing the command to dis-/enable locking.

Also, I would like to set the screen to always on, though "Kepp screen on when charging" is ok.

I played around a little bit with changing the configuration file at /usr/share/lipstick/devicelock/devicelock_settings.conf but this was very unstable. I think the first change worked but successive did not.

Any idea if this is possible or is this blocked due to security relevance. I would not even mind if I had to specify my pin/passwd on the command line (yeah I know but better than leaving it open at all times, right).

Thanks for the help. Regards


edit retag flag offensive close delete


Well, I came across that app before and didn't try it since I thought it would not do what I was looking for, so I just installed it.

Not sure, either I do not get the point of that app or it is a relict from times where the "Lock device with power button" or by swipe down on home screen was not available. As far as I can tell all that app does is lock the device according to the normal device lock settings. It cannot add or remove the PIN requirement.

I agree the introductory text Do you also hate to enter a password each time you lock the screen? Tired of going through all those menus, just to change the time to lock your device immediately? could make one think it just does this, but I do not achieve it.

Tim Drub ( 2015-07-27 19:32:30 +0200 )edit

Hei Tim,

Try fiddling with mcetool, of course, at your own risk.

LVPVS out.

LVPVS ( 2015-07-27 23:24:12 +0200 )edit

Nice call, I installed the tools, still I have not found what I am looking for. Since the mce tools originate from the Nokia days, is it possible not all the options are relevant to the Jolla device?

Anyway, if someone knows that this should work with the mce tools I'd appreciate any help very much. Thanks.

Tim Drub ( 2015-07-28 10:31:32 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2015-07-28 11:28:14 +0200

spiiroin gravatar image

updated 2015-07-28 12:28:50 +0200

rainisto gravatar image

Regarding temporarily disabling the device lock

I have no idea, but maybe @rainisto can cue in.

Regarding keeping the display on

While the settings ui only allows selecting between normal and keep display on while charging, mce itself supports all the blanking inhibit modes inherited from maemo: disabled, stay-on-with-charger, stay-on, stay-dim-with-charger & stay-dim.

For example "stay-dim" inhibit mode can be activated from command line via

mcetool --set-inhibit-mode=stay-dim

or via D-Bus with something equivalent to

dbus-send --system --type=method_call --print-reply=y /com/nokia/mce/request string:/system/osso/dsm/powerkey/blanking_mode variant:int32:1

But do note that applications should use blank prevention D-Bus interface instead of toggling settings (at least without direct user interaction). Convenience functionality for doing this from Qt/Qml/glib apps exists in nemo-keepalive. But since it is not yet harbour approved, lower level dbus interface needs to be used - more info at

Comment from @rainisto: There are few ways to prevent display lock from appearing, one is to send fake events that resets the useractivity idle timer.

Second way is to edit automatic_locking config value. But you cannot do that by direcyly editing the /usr/share/lipstick/devicelock/devicelock_settings.conf-file (since the values are also stored in another hidden place, but you need to use the devicelock tool which asks your current lockcode to change the values. Like if your lockcode is 123345, then command would be 1st to get the current value that you can restore:

/usr/lib/qt5/plugins/devicelock/encpartition --get-config-key /desktop/nemo/devicelock/automatic_locking

And then change the value to -1 (which will prevent locking):

/usr/lib/qt5/plugins/devicelock/encpartition --set-config-key 123345 /desktop/nemo/devicelock/automatic_locking -1

And in the end restore the original value, forexample 60:

/usr/lib/qt5/plugins/devicelock/encpartition --set-config-key 123345 /desktop/nemo/devicelock/automatic_locking 60

And disclaimer: commandline utility is not supported by harbour and can change at anytime, so applications should not rely on that one.

edit flag offensive delete publish link more


Nice, thanks.

So do I get this right, if the running Situations app issues this command:

  mcetool -P, --blank-prevent
    send blank prevent request

The display will not power off and once I run this

  mcetool -v, --cancel-blank-prevent
    send cancel blank prevent request

from within the same app, normal behaviour should take place again?

Tim Drub ( 2015-07-28 11:51:03 +0200 )edit

Note that the blank prevent is automatically canceled if: a) it is not renewed within 60 seconds b) the application that made the request exits or otherwise drops from the system bus.

So closer analogy (that works, but is useful only for mce testing/debugging) would be:

mcetool --blank-prevent --block=60 --blank-prevent --block=60 ... --cancel-blank-prevent

But the app itself needs to do it directly, i.e. when app wants to keep display on

  • make a method call to mce
  • start timer to repeat the call every 60 seconds

And when the display no longer needs to stay on:

  • stop the renew timer
  • make a method call to mce

Relevant D-Bus constants are defined in mce-headers package, originating from around here:

spiiroin ( 2015-07-28 12:15:45 +0200 )edit


Perfect, that is exactly what I was looking for. I added the commands to Sitautions and so far it looks good. Will test it for a while and - if I do not forget about it ;-) - report back.

Thanks guys, you are my men!

Tim Drub ( 2015-07-28 15:28:30 +0200 )edit
Login/Signup to Answer

Question tools



Asked: 2015-07-27 14:22:42 +0200

Seen: 756 times

Last updated: Jul 28 '15