Created
March 8, 2014 13:14
-
-
Save miekg/9430422 to your computer and use it in GitHub Desktop.
add -lockaftersleep to xautolock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: Add -lockaftersleep | |
Lock the moment the machine comes out of sleep. | |
. | |
xautolock (1:2.2-4) unstable; urgency=low | |
. | |
* debian/control: | |
- Removed xautolock from Recommends since it was removed from Debian | |
- Standards-Version: 3.9.4 | |
- Depends: debhelper (>= 9) | |
* debian/compat: 9 | |
* debian/rules: | |
- Use hardening flags | |
- Use dh style rules | |
Author: Roland Stigge <stigge@antcom.de> | |
--- | |
The information above should follow the Patch Tagging Guidelines, please | |
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here | |
are templates for supplementary fields that you might want to add: | |
Origin: <vendor|upstream|other>, <url of original patch> | |
Bug: <url in upstream bugtracker> | |
Bug-Debian: http://bugs.debian.org/<bugnumber> | |
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber> | |
Forwarded: <no|not-needed|url proving that it has been forwarded> | |
Reviewed-By: <name and email of someone who approved the patch> | |
Last-Update: <YYYY-MM-DD> | |
--- xautolock-2.2.orig/include/options.h | |
+++ xautolock-2.2/include/options.h | |
@@ -52,7 +52,7 @@ extern time_t lockTime, killTime, | |
extern int bellPercent; | |
extern unsigned cornerSize; | |
extern Bool secure, notifyLock, useRedelay, resetSaver, | |
- noCloseOut, noCloseErr, detectSleep; | |
+ noCloseOut, noCloseErr, detectSleep, lockAfterSleep; | |
extern cornerAction corners[4]; | |
extern message messageToSend; | |
--- xautolock-2.2.orig/src/options.c | |
+++ xautolock-2.2/src/options.c | |
@@ -52,6 +52,7 @@ message messageToSend = msg_none; | |
Bool detectSleep = False; /* whether to reset the timers | |
after a (laptop) sleep, | |
i.e. after a big time jump */ | |
+Bool lockAfterSleep = False; | |
#ifdef VMS | |
struct dsc$descriptor lockerDescr; /* used to fire up the locker */ | |
@@ -231,6 +232,7 @@ BOOL_ACTION (resetSaver) | |
BOOL_ACTION (noCloseOut) | |
BOOL_ACTION (noCloseErr) | |
BOOL_ACTION (detectSleep) | |
+BOOL_ACTION (lockAfterSleep) | |
static Bool | |
noCloseAction (Display* d, const char* arg) | |
@@ -545,6 +547,8 @@ static struct | |
noCloseErrAction , (optChecker) 0 }, | |
{"detectsleep" , XrmoptionNoArg , (caddr_t) "", | |
detectSleepAction , (optChecker) 0 }, | |
+ {"lockaftersleep" , XrmoptionNoArg , (caddr_t) "", | |
+ lockAfterSleepAction , (optChecker) 0 }, | |
}; /* as it says, the order is important! */ | |
/* | |
@@ -576,7 +580,7 @@ usage (int exitCode) | |
error1 ("%s[-nocloseout][-nocloseerr][-noclose]\n", blanks); | |
error1 ("%s[-enable][-disable][-toggle][-exit][-secure]\n", blanks); | |
error1 ("%s[-locknow][-unlocknow][-nowlocker locker]\n", blanks); | |
- error1 ("%s[-restart][-resetsaver][-detectsleep]\n", blanks); | |
+ error1 ("%s[-restart][-resetsaver][-detectsleep][-lockaftersleep]\n", blanks); | |
error0 ("\n"); | |
error0 (" -help : print this message and exit.\n"); | |
@@ -612,6 +616,7 @@ usage (int exitCode) | |
error0 (" -resetsaver : reset the screensaver when starting " | |
"the locker.\n"); | |
error0 (" -detectsleep : reset timers when awaking from sleep.\n"); | |
+ error0 (" -lockaftersleep : lock immediately after waking up from sleep.\n"); | |
error0 ("\n"); | |
error0 ("Defaults :\n"); | |
--- xautolock-2.2.orig/src/xautolock.c | |
+++ xautolock-2.2/src/xautolock.c | |
@@ -165,6 +165,14 @@ main (int argc, char* argv[]) | |
if ((unsigned long) t1 - (unsigned long) t0 > 3) resetLockTrigger (); | |
t0 = t1; | |
} | |
+ | |
+ if (lockAfterSleep) | |
+ { | |
+ t1 = time (NULL); | |
+ if ((unsigned long) t1 - (unsigned long) t0 > 3) lockNow = True; | |
+ t0 = t1; | |
+ } | |
+ | |
} | |
return 0; /* Never reached! */ | |
--- xautolock-2.2.orig/xautolock.man | |
+++ xautolock-2.2/xautolock.man | |
@@ -23,7 +23,7 @@ This man page applies to xautolock versi | |
[\fB\-nocloseout\fR] [\fB\-nocloseerr\fR] [\fB\-noclose\fR] | |
[\fB\-disable\fR] [\fB\-enable\fR] [\fB\-toggle\fR] [\fB\-exit\fR] | |
[\fB\-locknow\fR] [\fB\-unlocknow\fR] [\fB\-nowlocker\fR \fIlocker\fR] | |
-[\fB\-restart\fR] [\fB\-detectsleep\fR] | |
+[\fB\-restart\fR] [\fB\-detectsleep\fR] [\fB-lockaftersleep\fR] | |
.SH DESCRIPTION | |
Xautolock monitors the user activity on an X Window display. If none is | |
@@ -213,6 +213,9 @@ When this occurs, the lock timer is rese | |
launched even if primary timeout has been reached. This option is | |
typically used to avoid locker program to be launched when awaking a | |
laptop computer. | |
+.TP | |
+\fB\-lockaftersleep\fR | |
++Lock immediately after awakening from sleep. | |
.TP | |
\fB\-secure\fR | |
Instructs xautolock to run in secure mode. In this mode, xautolock |
Agreed.
I think the lock should be before sleep. I do this using the sleep commend (hook with loginctl) in Slackware 15.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@miekg, this option interacts very counter-intuitively with
--detectsleep
: ff--detectsleep
is given, then--lockaftersleep
will never fire. This is certainly not obvious from the names of the options or from the man page. I tried to use this feature and was surprised that it never worked. Only after reading the source code did I find out that--detectsleep --lockaftersleep
is a non-sensical combination.IMHO,
xautolock
should abort with an error when both flags are given at the same time.