diff options
author | bernhard | 2015-08-18 22:55:56 +0200 |
---|---|---|
committer | bernhard | 2015-08-18 22:55:56 +0200 |
commit | 786e0cd843358671b7db38c9cfc6b6a421628f9b (patch) | |
tree | 51149de6fb77f3385e1e723069c2a53ac8419170 | |
download | aur-786e0cd843358671b7db38c9cfc6b6a421628f9b.tar.gz |
Initial import
-rw-r--r-- | .SRCINFO | 16 | ||||
-rw-r--r-- | PKGBUILD | 19 | ||||
-rw-r--r-- | sinac.c | 77 |
3 files changed, 112 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..6ee8a30a5999 --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,16 @@ +pkgbase = sinac + pkgdesc = A cleaner/simpler alternative to xautolock for screen locking. + pkgver = 0.1.2 + pkgrel = 4 + url = http://www.suckless.org/pipermail/dwm/2007-December/004691.html + arch = i686 + arch = x86_64 + license = GPL + makedepends = xproto + makedepends = scrnsaverproto + depends = libxss + source = sinac.c + md5sums = d7d3642a880636015bd507edf2f04ca2 + +pkgname = sinac + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..8267b581461a --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,19 @@ +# Contributor: Mathieu Boespflug <mboes@tweag.net> +# Maintainer: John Wallaby <drunken.wallaby@gmail.com> +pkgname=sinac +pkgver=0.1.2 +pkgrel=4 +pkgdesc="A cleaner/simpler alternative to xautolock for screen locking." +url="http://www.suckless.org/pipermail/dwm/2007-December/004691.html" +arch=('i686' 'x86_64') +license=('GPL') +depends=(libxss) +makedepends=(xproto scrnsaverproto) +source=(sinac.c) +md5sums=('d7d3642a880636015bd507edf2f04ca2') +package() { + cd $srcdir + gcc sinac.c -lX11 -lXss -lXext -o sinac + install -d $pkgdir/usr/bin/ + install sinac $pkgdir/usr/bin/ +} diff --git a/sinac.c b/sinac.c new file mode 100644 index 000000000000..c39d6b307de7 --- /dev/null +++ b/sinac.c @@ -0,0 +1,77 @@ +/***************************************************************************** + * + * 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 <stesie at brokenpipe.de> + * Copyright 2007 by Christian Dietrich <stettberger at dokucode.de> + * + * Versions 2.0 and above of xautolock are available under version 2 of the + * GNU GPL. + * + * sinac.c -L/usr/X11R6/lib -lX11 -lXss -lXext -o sinac + * + *****************************************************************************/ + +#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.2" + +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; + int wait = 0, i, idle; + + for (i = 1; i < argc; i++) { + if ((strcmp(argv[i], "-w") == 0) && (i+1 < argc)) + wait = atoi(argv[++i]), idle; + else if (strcmp(argv[i], "-p") == 0) + wait = 0; + else { + fprintf(stderr, "sinac - " VERSION ": %s [-w <seconds>] [-p]\n", + argv[0]); + return 1; + } + } + + if (!(d = XOpenDisplay (0))) { + fprintf (stderr, "Couldn't connect to %s\n", XDisplayName (0)); + return 1; + } + (void) XSync (d, 0); + + if (wait) + while ((idle = seconds_idle(d)) < wait) + sleep(wait - idle - 1); + else + fprintf(stdout, "%ld\n", seconds_idle(d)); + + return 0; +} + |