Ubuntu – Configuring screen timeout/lock based on location

dconfgnome

I want to enable screen timeout and locking when my laptop is located in the LAN of my company and I want to disable this when I'm at home. For location detection I use whereami with a simple detection like this:

default unknown
testdhcp    '172.16.*.*'     work
testdhcp    '192.168.36.*'   home

Now I need to set the corresponding settings when I enter or leave the "work" network. But I have problems finding out where Gnome stores this stuff. I already found out where to toggle the "Lock" button in the screen configuration dialog. I do it like this in the whereami configuration:

!work su -c "dconf write /org/gnome/desktop/screensaver/lock-enabled false" k
=work su -c "dconf write /org/gnome/desktop/screensaver/lock-enabled true" k

This works so far. But I also need to configure the "Turn off after" setting in the screen configuration dialog. I found these three keys in dconf which are influences by it:

/org/gnome/desktop/session/idle-delay
/org/gnome/settings-daemon/plugins/power/sleep-display-battery
/org/gnome/settings-daemon/plugins/power/sleep-display-ac

But when I change them manually then it doesn't work and the screen dialog doesn't read the new value either. So I guess there are more keys I have to change but I can't find them (I search feature in this new dconf stuff would be nice).

So what settings have I to change to disable/enable the screen timeout?

Best Answer

Found it. idle-delay must be of type uint32 and not a string like the other two values. So this works for me:

=work su -c "dconf write /org/gnome/desktop/screensaver/lock-enabled true" k
=work su -c "dconf write /org/gnome/desktop/session/idle-delay 'uint32 120'" k
=work su -c "dconf write /org/gnome/settings-daemon/plugins/power/sleep-display-ac 120" k
=work su -c "dconf write /org/gnome/settings-daemon/plugins/power/sleep-display-battery 120" k
!work su -c "dconf write /org/gnome/desktop/screensaver/lock-enabled false" k
!work su -c "dconf write /org/gnome/desktop/session/idle-delay 'uint32 0'" k
!work su -c "dconf write /org/gnome/settings-daemon/plugins/power/sleep-display-ac 0"  k
!work su -c "dconf write /org/gnome/settings-daemon/plugins/power/sleep-display-battery 0" k