commit f91e73ae451c1137da79019bb5a08daaca5f6323
parent 177f7d41a48363b9ee57e1871425bf667761beb2
Author: Christoph Lohmann <20h@r-36.net>
Date: Sat, 8 Dec 2012 22:31:19 +0100
Rename to xssstate and do it right.
Diffstat:
M | Makefile | | | 35 | +++++++++++++++++------------------ |
M | config.mk | | | 2 | +- |
D | xgetidle.1 | | | 27 | --------------------------- |
D | xgetidle.c | | | 68 | -------------------------------------------------------------------- |
4 files changed, 18 insertions(+), 114 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,15 +1,14 @@
-# xgetidle – display the X idle time
# See LICENSE file for copyright and license details.
include config.mk
-SRC = xgetidle.c
+SRC = xssstate.c
OBJ = ${SRC:.c=.o}
-all: options xgetidle
+all: options xssstate
options:
- @echo xgetidle build options:
+ @echo xssstate build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}"
@@ -20,37 +19,37 @@ options:
${OBJ}: config.mk
-xgetidle: xgetidle.o
+xssstate: xssstate.o
@echo CC -o $@
- @${CC} -o $@ xgetidle.o ${LDFLAGS}
+ @${CC} -o $@ xssstate.o ${LDFLAGS}
clean:
@echo cleaning
- @rm -f xgetidle ${OBJ} xgetidle-${VERSION}.tar.gz
+ @rm -f xssstate ${OBJ} xssstate-${VERSION}.tar.gz
dist: clean
@echo creating dist tarball
- @mkdir -p xgetidle-${VERSION}
+ @mkdir -p xssstate-${VERSION}
@cp -R LICENSE Makefile config.mk \
- xgetidle.1 arg.h ${SRC} xgetidle-${VERSION}
- @tar -cf xgetidle-${VERSION}.tar xgetidle-${VERSION}
- @gzip xgetidle-${VERSION}.tar
- @rm -rf xgetidle-${VERSION}
+ xssstate.1 arg.h ${SRC} xssstate-${VERSION}
+ @tar -cf xssstate-${VERSION}.tar xssstate-${VERSION}
+ @gzip xssstate-${VERSION}.tar
+ @rm -rf xssstate-${VERSION}
install: all
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
@mkdir -p ${DESTDIR}${PREFIX}/bin
- @cp -f xgetidle ${DESTDIR}${PREFIX}/bin
- @chmod 755 ${DESTDIR}${PREFIX}/bin/xgetidle
+ @cp -f xssstate ${DESTDIR}${PREFIX}/bin
+ @chmod 755 ${DESTDIR}${PREFIX}/bin/xssstate
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
@mkdir -p ${DESTDIR}${MANPREFIX}/man1
- @sed "s/VERSION/${VERSION}/g" < xgetidle.1 > ${DESTDIR}${MANPREFIX}/man1/xgetidle.1
- @chmod 644 ${DESTDIR}${MANPREFIX}/man1/xgetidle.1
+ @sed "s/VERSION/${VERSION}/g" < xssstate.1 > ${DESTDIR}${MANPREFIX}/man1/xssstate.1
+ @chmod 644 ${DESTDIR}${MANPREFIX}/man1/xssstate.1
uninstall:
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
- @rm -f ${DESTDIR}${PREFIX}/bin/xgetidle
+ @rm -f ${DESTDIR}${PREFIX}/bin/xssstate
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
- @rm -f ${DESTDIR}${MANPREFIX}/man1/xgetidle.1
+ @rm -f ${DESTDIR}${MANPREFIX}/man1/xssstate.1
.PHONY: all options clean dist install uninstall
diff --git a/config.mk b/config.mk
@@ -1,4 +1,4 @@
-# xgetidle version
+# xssstate version
VERSION = 1.0
# Customize below to fit your system
diff --git a/xgetidle.1 b/xgetidle.1
@@ -1,27 +0,0 @@
-.TH XGETIDLE 1 xgetidle\-VERSION
-.SH NAME
-xgetidle \- display the current X idle time
-.SH SYNOPSIS
-.B xgetidle
-.RB [ \-s ]
-.RB [ \-v ]
-.SH DESCRIPTION
-.B xgetidle
-will display the current idle time of X11 given the XScreenSaver extension.
-.SH OPTIONS
-.TP
-.B \-s
-display the result in seconds
-.TP
-.B \-v
-show version information
-.SH AUTHORS
-See the LICENSE file for the authors.
-.SH LICENSE
-See the LICENSE file for the terms of redistribution.
-.SH SEE ALSO
-.BR slock (1)
-.BR xlock (1)
-.SH BUGS
-Please report them.
-
diff --git a/xgetidle.c b/xgetidle.c
@@ -1,68 +0,0 @@
-/*
- * See LICENSE file for copyright and license details.
- */
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <libgen.h>
-#include <X11/extensions/scrnsaver.h>
-
-#include "arg.h"
-
-char *argv0;
-
-void
-die(const char *errstr, ...) {
- va_list ap;
-
- va_start(ap, errstr);
- vfprintf(stderr, errstr, ap);
- va_end(ap);
- exit(EXIT_FAILURE);
-}
-
-void
-usage(void)
-{
- die("usage: %s [-sv]\n", basename(argv0));
-}
-
-int
-main(int argc, char *argv[]) {
- XScreenSaverInfo *info;
- Display *dpy;
- int base, errbase;
- Bool inseconds;
-
- inseconds = False;
-
- ARGBEGIN {
- case 's':
- inseconds = true;
- break;
- case 'v':
- die("xgetidle-"VERSION", © 2008-2012 xgetidle engineers"
- ", see LICENSE for details.\n");
- default:
- usage();
- } ARGEND;
-
- if(!(dpy = XOpenDisplay(0)))
- die("Cannot open display.\n");
-
- if(!XScreenSaverQueryExtension(dpy, &base, &errbase))
- die("Screensaver extension not activated.\n");
-
- info = XScreenSaverAllocInfo();
- XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info);
-
- printf("%ld\n", info->idle / ((inseconds)? 1000 : 1));
-
- XCloseDisplay(dpy);
-
- return 0;
-}
-