Hi, i searched for a replacement for the autolock feature of xscreensaver with slock. So i worked on an older piece of code, written by a friend of me. The result is sinac (simple inactive). Which can print out the inactive time of the X session or wait until the inactive timer has reached an specific value.
Sinac uses the xscreensaver x extention, so you have to install libxss-dev. You can compile the attached sinac.c file with: gcc sinac.c -L/usr/X11R6/lib -lX11 -lXss -lXext -o sinac And now lets build an autolocker with sinac & slock: while true; do ./sinac -w 300 && slock; done greetz didi -- No documentation is better than bad documentation
/*****************************************************************************
*
* xidletime
*
* derived from xautolock supplied by
* Authors: Michel Eyckmans (MCE) & Stefan De Troch (SDT)
*
* --------------------------------------------------------------------------
*
* Copyright 1990,1992-1999,2001-2002 by Stefan De Troch and Michel Eyckmans.
* Copyright 2005 by Stefan Siegl <[EMAIL PROTECTED]>
* Copyright 2007 by Christian Dietrich <[EMAIL PROTECTED]>
*
* Versions 2.0 and above of xautolock are available under version 2 of the
* GNU GPL.
*
*****************************************************************************/
#include <X11/Xos.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xresource.h>
#include <X11/extensions/scrnsaver.h>
#include <stdio.h>
#define VERSION "0.1"
static XScreenSaverInfo* xss_info = 0;
int
seconds_idle(Display *d)
{
if (! xss_info )
xss_info = XScreenSaverAllocInfo();
XScreenSaverQueryInfo(d, DefaultRootWindow(d), xss_info);
return xss_info->idle / 1000;
}
int
main (int argc, char* argv[])
{
Display* d;
Time idleTime;
if (!(d = XOpenDisplay (0))) {
fprintf (stderr, "Couldn't connect to %s\n", XDisplayName (0));
return 1;
}
(void) XSync (d, 0);
if (argc == 1)
fprintf(stdout, "%ld\n", seconds_idle(d));
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-w") == 0 && argv[i+1]) {
int wait = atoi(argv[++i]);
while (seconds_idle(d) < wait)
usleep(500000);
}
else if (strcmp(argv[i], "-s") == 0 && argv[i+1])
usleep(1000000 * atoi(argv[++i]));
else if (strcmp(argv[i], "-p") == 0)
fprintf(stdout, "%ld\n", seconds_idle(d));
else {
fprintf(stderr, "sinac - " VERSION ": %s [-w <seconds>] [-p] [-s
<seconds>]\n",
argv[0]);
return 1;
}
}
return 0;
}
pgpAmvSORcG6B.pgp
Description: PGP signature
