mirror of https://github.com/9wm/xss.git
A couple little tweaks
* magic now looks for the XSS_WINDOW environment variable * xsswin doesn't bother forking before execing now * README provides a little introduction
This commit is contained in:
parent
6e5a49de25
commit
1b568d19fd
14
README
14
README
|
@ -1,7 +1,19 @@
|
|||
== xss ==
|
||||
|
||||
[xss](http://woozle.org/~neale/src/xss) is a suite of X screensaver
|
||||
utilities. With them, you can use shell scripts to glue the tools
|
||||
together to build your own screen saver and/or locker. You can use any
|
||||
`xscreensaver` hack instead of the built-in `magic` hack, or you can use
|
||||
`xlock` if you prefer.
|
||||
|
||||
|
||||
The programs
|
||||
------------
|
||||
|
||||
`xss` uses the decades-old MIT-SCREEN-SAVER extension to launch a
|
||||
program when the X server turns on the built-in screen saver.
|
||||
program when the X server turns on the built-in screen saver. Unlike
|
||||
`xautolock`, `xss` blocks until the X server says it's time to do
|
||||
something.
|
||||
|
||||
`xsswin` makes a full-screen black window and runs some other program,
|
||||
passing along the window ID in the environment (`$XSS_WINDOW`) and
|
||||
|
|
16
magic.c
16
magic.c
|
@ -53,26 +53,30 @@ main(int argc, char * const argv[])
|
|||
Window w = (Window)0;
|
||||
GC egc = (GC)0;
|
||||
XSegment *lines = NULL;
|
||||
char *winstr = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i += 1) {
|
||||
if (0 == strcmp(argv[i], "-window-id")) {
|
||||
/* For compatibility reasons, just ignore */
|
||||
} else if (w) {
|
||||
} else if (winstr) {
|
||||
w = (Window)-1;
|
||||
break;
|
||||
} else {
|
||||
winstr = argv[i];
|
||||
}
|
||||
}
|
||||
if (! winstr) winstr = getenv("XSS_WINDOW");
|
||||
if (winstr) {
|
||||
char *end;
|
||||
|
||||
if (argv[i][0] == '0' && argv[i][1] == 'x') {
|
||||
w = (Window)strtol(argv[i] + 2, &end, 16);
|
||||
if (winstr[0] == '0' && winstr[1] == 'x') {
|
||||
w = (Window)strtol(winstr + 2, &end, 16);
|
||||
} else {
|
||||
w = (Window)strtol(argv[i], &end, 10);
|
||||
w = (Window)strtol(winstr, &end, 10);
|
||||
}
|
||||
if ('\0' != *end) {
|
||||
w = (Window)-1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((Window)-1 == w) {
|
||||
|
|
17
xsswin.c
17
xsswin.c
|
@ -41,7 +41,9 @@ main(int argc, char * const argv[])
|
|||
XSetWindowAttributes wa;
|
||||
Window root;
|
||||
XColor black;
|
||||
int child;
|
||||
int i;
|
||||
char *nargv[argc + 1];
|
||||
char id[50];
|
||||
|
||||
zero(wa);
|
||||
zero(black);
|
||||
|
@ -55,7 +57,7 @@ main(int argc, char * const argv[])
|
|||
w = XCreateWindow(display, root,
|
||||
0, 0,
|
||||
DisplayWidth(display, screen), DisplayHeight(display, screen), 0,
|
||||
CopyFromParent, InputOutput, CopyFromParent,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel,
|
||||
&wa);
|
||||
pmap = XCreateBitmapFromData(display, w, "\0", 1, 1);
|
||||
|
@ -65,12 +67,6 @@ main(int argc, char * const argv[])
|
|||
XMapRaised(display, w);
|
||||
XSync(display, False);
|
||||
|
||||
child = fork();
|
||||
if (0 == child) {
|
||||
char *nargv[argc + 1];
|
||||
char id[50];
|
||||
int i;
|
||||
|
||||
(void)snprintf(id, sizeof(id), "0x%lx", (unsigned long)w);
|
||||
(void)setenv("XSS_WINDOW", id, 1);
|
||||
for (i = 0; i < argc; i += 1) {
|
||||
|
@ -83,11 +79,6 @@ main(int argc, char * const argv[])
|
|||
nargv[argc] = NULL;
|
||||
(void)execvp(nargv[1], nargv + 1);
|
||||
perror("exec");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* XXX: maybe important to also watch for X events? */
|
||||
(void)waitpid(-1, NULL, 0);
|
||||
}
|
||||
|
||||
if (display) {
|
||||
|
|
Loading…
Reference in New Issue