Merge lp:~cameronnemo/switchboard-plug-security-privacy/light-locker into lp:~elementary-apps/switchboard-plug-security-privacy/trunk

Proposed by Cameron Norman
Status: Merged
Merged at revision: 137
Proposed branch: lp:~cameronnemo/switchboard-plug-security-privacy/light-locker
Merge into: lp:~elementary-apps/switchboard-plug-security-privacy/trunk
Diff against target: 202 lines (+69/-81)
2 files modified
debian/control (+1/-0)
src/LockPanel.vala (+68/-81)
To merge this branch: bzr merge lp:~cameronnemo/switchboard-plug-security-privacy/light-locker
Reviewer Review Type Date Requested Status
elementary Apps team Pending
Review via email: mp+242584@code.launchpad.net

Description of the change

This is the branch to transition the security and privacy settings plug to light locker.

Three things here:

1) We need to import this light-locker branch for the lock-on-suspend setting to work: https://github.com/bluesabre/light-locker

2) The solution to the inactivity timeout is not exactly pretty. Unfortunately the main alternatives involve significant work in upstream software / big patches that software. That said, it works pretty reliably and I do not think it is significantly error prone.

3) The phrasing for "Lock screen after: Never" is a little awk. Also, I am not sure if the text is made longer that the nice alignment with the median at the center will be preserved. I am not too experienced with all those Gtk widgets, sorry.

I am hoping for some suggestions on that last one.

Anyway, basic synopsis of what it does is it uses Light Locker's gsettings schema vs. the gnome-screensaver one for lock on suspend. It also has a custom gsettings schema and a small script for inactivity timeouts through xautolock. Since we can not change the timeout on the fly, the plug kills the running xautolock process and starts a new one.

Unfortunately I will be on a scuba trip until wednesday night, so if there is some small issue feel free to work on it. You are even welcome to assign the bug to yourself and grab the bounty; I would much rather prefer coming closer to an rc than the $50.

Thanks for reviewing, Cameron Norman.

To post a comment you must log in.
99. By Cameron Norman

Avoid having two xautolock processes running

100. By Cameron Norman

Even more dependencies! (for gsettings command)

Revision history for this message
Cameron Norman (cameronnemo) wrote :

carl wrote:

>So if I follow you, you recommend to use light-locker. Which is also a solution for the "turn off the screen after x" feature that doesn't work at the moment, if this has to be believed: https://bugs.launchpad.net/switchboard-plug-power/+bug/1373602/comments/4

Well we have already settled on light-locker, but that component does not actually turn off the screen after a timeout. The xautolock process is locking the screen after a timeout specified in the dconf key org.pantheon.xautolock timeout. As a side effect, the screen is being shut off at that same timeout.

Revision history for this message
Simon Steinbeiß (ochosi) wrote :

There is no need for xautolock, because light-locker already listens to X11's blank-time signal (or if that isn't set, it listens to DPMS suspend or whatever). You can easily test that by enabling timed locking and setting your timeout to 1 minute in the terminal: "xset s 60" (by default it's 600 seconds, so 10 minutes).

If you're handling setting the xserver's blank times somewhere, this is the time it takes until your session will be auto-locked.

Revision history for this message
Cameron Norman (cameronnemo) wrote :

Yeah I saw your message about xset on Slack a few days ago, have not been able to update the branch yet.

So instead of calling xautolock in xautolock-elementary, we should just call `xset s $timeout`, yes?

That is nicer on the code side for sure, but I am getting an ugly flash where the screen turns on and off when light-locker does the VT switch. Do you know of any way to avoid that?

If not, it is not too noticeable, and the user will usually not notice it because they are away from the computer when this occurs.

101. By Cameron Norman

Use xset instead of xautolock

102. By Cameron Norman

Fix debian install file for the changed names

103. By Cameron Norman

Fix when lock timeout is never

Revision history for this message
Cody Garver (codygarver) wrote :

Does not seem to work after a lock has already occurred. I set screen lock timeout for 1 minute, then unlocked and waited another minute and the second lock never happened.

Revision history for this message
Cameron Norman (cameronnemo) wrote :

What is the X inactivity timeout setting before and after the first lock? Use `xset q` and look under the Screen Saver section to identify it.

104. By Cameron Norman

xset usage: Use DPMS standby instead of screensaver

Revision history for this message
Cameron Norman (cameronnemo) wrote :

Alright so I am using a different, but supposedly equivalent, setting in this new revision and it seems to have fixed the issue.

Revision history for this message
PerfectCarl (name-is-carl) wrote :

Not that this is related to this branch per se but could you fix those minor issues:
  - remove the "--save-temps" in cmake/PrecompileVala.cmake to fix the warning:
       warning: --save-temps has no effect when -C or --ccode is set

105. By Cameron Norman

Make sure the autostart file is placed in the correct location

Revision history for this message
PerfectCarl (name-is-carl) wrote :

I've been testing the branch and it works well on my single monitor set up.

As cody mentioned there is still an issue with app that steals the focus (slinghost and plank).
When any of those app is active (slinghost is opened) the session doesn't lock.

At the moment, it isn't clear where the bug lies: the plug, light-locker...

Revision history for this message
PerfectCarl (name-is-carl) wrote :

Note: not that this is related to this branch but the default value for apps.light-locker.lock-after-screensaver should be 1 instead of 5.

Setting the value to 1 makes the locking feels more responsive and decrease the time during which the screen is totally black (and a little stressful to be honest) before being redirected to the greeter.

106. By Cody Garver

Start adapting to elementary-dpms-helper

107. By Cameron Norman

Adapt plug UI to use elementary-dpms-helper

108. By Cody Garver

dpms helper has moved

109. By Cameron Norman

Use seconds for the dpms value, not minutes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2014-04-24 13:14:42 +0000
3+++ debian/control 2015-02-03 23:19:21 +0000
4@@ -18,6 +18,7 @@
5 Architecture: any
6 Depends: ${misc:Depends}, ${shlibs:Depends}
7 Enhances: switchboard
8+Recommends: elementary-dpms-helper
9 Description: Manage security and privacy
10 Switchboard plug for managing the security and privacy of your system.
11
12
13=== modified file 'src/LockPanel.vala'
14--- src/LockPanel.vala 2014-04-24 21:51:15 +0000
15+++ src/LockPanel.vala 2015-02-03 23:19:21 +0000
16@@ -22,117 +22,104 @@
17
18 public class SecurityPrivacy.LockPanel : Gtk.Grid {
19
20- Settings notification;
21- Settings screensaver;
22+ Settings locker;
23+ Settings dpms;
24
25 public LockPanel () {
26 column_spacing = 12;
27 row_spacing = 6;
28
29- notification = new Settings ("org.gnome.desktop.notifications");
30- screensaver = new Settings ("org.gnome.desktop.screensaver");
31-
32- var screen_lock_label = new Gtk.Label ("");
33- screen_lock_label.set_markup ("<b>%s</b>".printf (_("Lock screen:")));
34-
35- var screen_lock_switch = new Gtk.Switch ();
36- screen_lock_switch.active = true;
37- var switch_grid = new Gtk.Grid ();
38- switch_grid.valign = Gtk.Align.CENTER;
39- switch_grid.add (screen_lock_switch);
40+ locker = new Settings ("apps.light-locker");
41+ dpms = new Settings ("org.pantheon.dpms");
42
43 var screen_lock_combobox = new Gtk.ComboBoxText ();
44- screen_lock_combobox.append_text (_("After display turns off"));
45- screen_lock_combobox.append_text (_("30 seconds"));
46- screen_lock_combobox.append_text (_("1 minute"));
47- screen_lock_combobox.append_text (_("2 minutes"));
48- screen_lock_combobox.append_text (_("3 minutes"));
49+ screen_lock_combobox.append_text (_("Never"));
50 screen_lock_combobox.append_text (_("5 minutes"));
51- screen_lock_combobox.append_text (_("10 minutes"));
52+ screen_lock_combobox.append_text (_("15 minutes"));
53 screen_lock_combobox.append_text (_("30 minutes"));
54 screen_lock_combobox.append_text (_("1 hour"));
55- var delay = screensaver.get_uint ("lock-delay");
56- if (delay >= 3600) {
57- screen_lock_combobox.active = 8;
58- } else if (delay >= 1800) {
59- screen_lock_combobox.active = 7;
60- } else if (delay >= 600) {
61- screen_lock_combobox.active = 6;
62- } else if (delay >= 300) {
63+ screen_lock_combobox.append_text (_("2 hours"));
64+ var delay = dpms.get_uint ("standby-time");
65+ if (delay >= 7200) {
66 screen_lock_combobox.active = 5;
67- } else if (delay >= 180) {
68+ } else if (delay >= 3600) {
69 screen_lock_combobox.active = 4;
70- } else if (delay >= 120) {
71+ } else if (delay >= 1800) {
72 screen_lock_combobox.active = 3;
73- } else if (delay >= 60) {
74+ } else if (delay >= 900) {
75 screen_lock_combobox.active = 2;
76- } else if (delay > 0) {
77+ } else if (delay >= 300) {
78 screen_lock_combobox.active = 1;
79- } else {
80+ } else if (delay >= 0) {
81 screen_lock_combobox.active = 0;
82 }
83 screen_lock_combobox.notify["active"].connect (() => {
84 switch (screen_lock_combobox.active) {
85- case 8:
86- screensaver.set_uint ("lock-delay", 3600);
87- break;
88- case 7:
89- screensaver.set_uint ("lock-delay", 1800);
90- break;
91- case 6:
92- screensaver.set_uint ("lock-delay", 600);
93- break;
94 case 5:
95- screensaver.set_uint ("lock-delay", 300);
96+ dpms.set_uint ("standby-time", 7200);
97 break;
98 case 4:
99- screensaver.set_uint ("lock-delay", 180);
100+ dpms.set_uint ("standby-time", 3600);
101 break;
102 case 3:
103- screensaver.set_uint ("lock-delay", 120);
104+ dpms.set_uint ("standby-time", 1800);
105 break;
106 case 2:
107- screensaver.set_uint ("lock-delay", 60);
108+ dpms.set_uint ("standby-time", 900);
109 break;
110 case 1:
111- screensaver.set_uint ("lock-delay", 30);
112+ dpms.set_uint ("standby-time", 300);
113 break;
114 default:
115- screensaver.set_uint ("lock-delay", 0);
116+ dpms.set_uint ("standby-time", 0);
117 break;
118 }
119- });
120-
121- var ask_checkbutton = new Gtk.CheckButton.with_label (_("Ask for my password to unlock"));
122- ask_checkbutton.notify["active"].connect (() => {
123- screensaver.set_boolean ("ubuntu-lock-on-suspend", ask_checkbutton.active);
124- });
125- ask_checkbutton.active = screensaver.get_boolean ("ubuntu-lock-on-suspend");
126- var notification_checkbutton = new Gtk.CheckButton.with_label (_("Show notifications on lockscreen"));
127- notification_checkbutton.active = notification.get_boolean ("show-in-lock-screen");
128- notification_checkbutton.notify["active"].connect (() => {
129- notification.set_boolean ("show-in-lock-screen", notification_checkbutton.active);
130- });
131-
132- screen_lock_switch.notify["active"].connect (() => {
133- screen_lock_combobox.sensitive = screen_lock_switch.active;
134- ask_checkbutton.sensitive = screen_lock_switch.active;
135- notification_checkbutton.sensitive = screen_lock_switch.active;
136- screensaver.set_boolean ("lock-enabled", screen_lock_switch.active);
137- });
138- screen_lock_switch.active = screensaver.get_boolean ("lock-enabled");
139-
140- var fake_grid_left = new Gtk.Grid ();
141- fake_grid_left.hexpand = true;
142- var fake_grid_right = new Gtk.Grid ();
143- fake_grid_right.hexpand = true;
144-
145- attach (fake_grid_left, 0, 0, 1, 1);
146- attach (screen_lock_label, 1, 0, 1, 1);
147- attach (switch_grid, 2, 0, 1, 1);
148- attach (screen_lock_combobox, 3, 0, 1, 1);
149- attach (ask_checkbutton, 2, 1, 2, 1);
150- //attach (notification_checkbutton, 2, 2, 2, 1);
151- attach (fake_grid_right, 4, 0, 1, 1);
152+
153+ /* the set above races with the get in elementary-dpms-helper */
154+ Settings.sync ();
155+
156+ try {
157+ Process.spawn_async (null, { "elementary-dpms-helper" },
158+ Environ.get (), SpawnFlags.SEARCH_PATH, null, null);
159+ } catch (SpawnError e) {
160+ warning ("Failed to reset dpms settings: %s", e.message);
161+ }
162+ });
163+
164+ var timeout_label = new Gtk.Label (_("Lock screen after:"));
165+
166+ var lock_suspend_label = new Gtk.Label (_("Lock on sleep:"));
167+ var lock_suspend_switch = new Gtk.Switch ();
168+
169+ /* Synchronize lock_suspend_switch and GSettings value */
170+ lock_suspend_switch.active = locker.get_boolean ("lock-on-suspend");
171+ locker.bind ("lock-on-suspend", lock_suspend_switch, "active", SettingsBindFlags.DEFAULT);
172+
173+ timeout_label.margin_top = 15;
174+ lock_suspend_label.margin_bottom = 15;
175+ screen_lock_combobox.margin_top = 10;
176+ lock_suspend_switch.margin_bottom = 10;
177+
178+ lock_suspend_label.halign = Gtk.Align.END;
179+ timeout_label.halign = Gtk.Align.END;
180+ lock_suspend_switch.halign = Gtk.Align.START;
181+ screen_lock_combobox.halign = Gtk.Align.START;
182+
183+ var grid_left = new Gtk.Grid ();
184+ grid_left.expand = true;
185+ grid_left.halign = Gtk.Align.END;
186+ grid_left.valign = Gtk.Align.CENTER;
187+ var grid_right = new Gtk.Grid ();
188+ grid_right.expand = true;
189+ grid_right.halign = Gtk.Align.START;
190+ grid_right.valign = Gtk.Align.CENTER;
191+
192+ grid_left.attach (lock_suspend_label, 0, 0, 1, 1);
193+ grid_left.attach (timeout_label, 0, 1, 1, 1);
194+ grid_right.attach (lock_suspend_switch, 0, 0, 1, 1);
195+ grid_right.attach (screen_lock_combobox, 0, 1, 1, 1);
196+
197+ attach (grid_left, 0, 0, 1, 1);
198+ attach (grid_right, 1, 0, 1, 1);
199 }
200-}
201\ No newline at end of file
202+}

Subscribers

People subscribed via source and target branches

to all changes: