Rename to xssstate and do it right.

master
Christoph Lohmann 2012-12-08 22:31:19 +01:00
parent 177f7d41a4
commit f91e73ae45
4 changed files with 18 additions and 114 deletions

View File

@ -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

View File

@ -1,4 +1,4 @@
# xgetidle version
# xssstate version
VERSION = 1.0
# Customize below to fit your system

View File

@ -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.

View File

@ -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;
}