mirror of https://github.com/9wm/xss.git
Revert bad change, xss now has -w option for leaving out xsswin
This commit is contained in:
parent
1b568d19fd
commit
6c39cd126e
4
README
4
README
|
@ -42,6 +42,10 @@ Run like `xautolock`:
|
|||
|
||||
xss xlock -mode qix &
|
||||
|
||||
Just run a screen saver, don't lock
|
||||
|
||||
xss -w /usr/lib/xscreensaver/deco -window-id XSS_WINDOW
|
||||
|
||||
Launch a program called "screenlock" when you're idle:
|
||||
|
||||
xss screenlock
|
||||
|
|
52
xss.c
52
xss.c
|
@ -39,18 +39,28 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
Display *display = NULL;
|
||||
int screen;
|
||||
int bigwindow = 0;
|
||||
|
||||
if (argc < 2) {
|
||||
(void)fprintf(stderr, "Usage: %s PROGRAM [ARGUMENT ...]\n", argv[0]);
|
||||
if ((argc > 1) && (0 == (strcmp(argv[1], "-w")))) {
|
||||
bigwindow = 1;
|
||||
}
|
||||
if (argc - bigwindow < 2) {
|
||||
(void)fprintf(stderr, "Usage: %s [-w] PROGRAM [ARGUMENT ...]\n", argv[0]);
|
||||
(void)fprintf(stderr, "\n");
|
||||
(void)fprintf(stderr, "-w Map X server window, export $XSS_WINDOW. This window\n");
|
||||
(void)fprintf(stderr, " will be unmapped by any keypress or mouse movement.\n");
|
||||
return 64; /* EX_USAGE */
|
||||
}
|
||||
signal(SIGCHLD, sigchld);
|
||||
|
||||
try {
|
||||
int ss_event, ss_error;
|
||||
int screen;
|
||||
XEvent event;
|
||||
Window root;
|
||||
char *nargv[argc+1];
|
||||
char id[50];
|
||||
int i;
|
||||
|
||||
if (! (display = XOpenDisplay(NULL))) raise("cannot open display");
|
||||
screen = DefaultScreen(display);
|
||||
|
@ -63,21 +73,39 @@ main(int argc, char *argv[])
|
|||
root = RootWindow(display, screen);
|
||||
XScreenSaverSelectInput(display, root, ScreenSaverNotifyMask);
|
||||
|
||||
/* Tell X to show its provided window off the screen. We make our own. */
|
||||
{
|
||||
XSetWindowAttributes attr;
|
||||
XSetWindowAttributes wa;
|
||||
XScreenSaverInfo info;
|
||||
Pixmap pmap;
|
||||
XColor black;
|
||||
|
||||
attr.background_pixel = BlackPixel(display, screen);
|
||||
pmap = XCreateBitmapFromData(display, root, "\0", 1, 1);
|
||||
black.pixel = BlackPixel(display, screen);
|
||||
wa.cursor = XCreatePixmapCursor(display, pmap, pmap, &black, &black, 0, 0);
|
||||
wa.background_pixel = BlackPixel(display, screen);
|
||||
if (! (XFreePixmap(display, pmap))) break;
|
||||
XScreenSaverSetAttributes(display, root,
|
||||
-1, -1,
|
||||
1, 1,
|
||||
bigwindow?0:-1, bigwindow?0:-1,
|
||||
bigwindow?DisplayWidth(display, screen):1,
|
||||
bigwindow?DisplayHeight(display, screen):1,
|
||||
0,
|
||||
CopyFromParent, CopyFromParent,
|
||||
CopyFromParent,
|
||||
CWBackPixel,
|
||||
&attr);
|
||||
CWBackPixel | CWCursor,
|
||||
&wa);
|
||||
XScreenSaverQueryInfo(display, (Drawable)root, &info);
|
||||
(void)snprintf(id, sizeof(id), "0x%lx", (unsigned long)info.window);
|
||||
(void)setenv("XSS_WINDOW", id, 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < argc; i += 1) {
|
||||
if (bigwindow && (0 == strcmp(argv[i], "XSS_WINDOW"))) {
|
||||
nargv[i] = id;
|
||||
} else {
|
||||
nargv[i] = argv[i];
|
||||
}
|
||||
}
|
||||
nargv[argc] = NULL;
|
||||
|
||||
while (! XNextEvent(display, &event)) {
|
||||
if (ss_event == event.type) {
|
||||
|
@ -87,10 +115,11 @@ main(int argc, char *argv[])
|
|||
if (! child) {
|
||||
child = fork();
|
||||
if (0 == child) {
|
||||
(void)execvp(argv[1], argv + 1);
|
||||
(void)execvp(nargv[1+bigwindow], nargv+1+bigwindow);
|
||||
perror("exec");
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +127,7 @@ main(int argc, char *argv[])
|
|||
} while (0);
|
||||
|
||||
if (display) {
|
||||
(void)XScreenSaverUnregister(display, screen);
|
||||
(void)XCloseDisplay(display);
|
||||
}
|
||||
|
||||
|
|
26
xsswin.c
26
xsswin.c
|
@ -37,33 +37,33 @@ main(int argc, char * const argv[])
|
|||
|
||||
try {
|
||||
int screen;
|
||||
Cursor invisible;
|
||||
XSetWindowAttributes wa;
|
||||
Window root;
|
||||
XColor black;
|
||||
int i;
|
||||
char *nargv[argc + 1];
|
||||
char id[50];
|
||||
|
||||
zero(wa);
|
||||
zero(black);
|
||||
|
||||
if (! (display = XOpenDisplay(NULL))) raise("cannot open display");
|
||||
screen = DefaultScreen(display);
|
||||
root = RootWindow(display, screen);
|
||||
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixel = BlackPixel(display, screen);
|
||||
{
|
||||
Pixmap pmap;
|
||||
XColor black;
|
||||
|
||||
pmap = XCreateBitmapFromData(display, root, "\0", 1, 1);
|
||||
black.pixel = BlackPixel(display, screen);
|
||||
wa.cursor = XCreatePixmapCursor(display, pmap, pmap, &black, &black, 0, 0);
|
||||
if (! (XFreePixmap(display, pmap))) break;
|
||||
}
|
||||
w = XCreateWindow(display, root,
|
||||
0, 0,
|
||||
DisplayWidth(display, screen), DisplayHeight(display, screen), 0,
|
||||
CopyFromParent, CopyFromParent, CopyFromParent,
|
||||
CWOverrideRedirect | CWBackPixel,
|
||||
CWOverrideRedirect | CWBackPixel | CWCursor,
|
||||
&wa);
|
||||
pmap = XCreateBitmapFromData(display, w, "\0", 1, 1);
|
||||
black.pixel = BlackPixel(display, screen);
|
||||
invisible = XCreatePixmapCursor(display, pmap, pmap, &black, &black, 0, 0);
|
||||
XDefineCursor(display, w, invisible);
|
||||
XMapRaised(display, w);
|
||||
XSync(display, False);
|
||||
|
||||
|
@ -77,8 +77,14 @@ main(int argc, char * const argv[])
|
|||
}
|
||||
}
|
||||
nargv[argc] = NULL;
|
||||
|
||||
i = fork();
|
||||
if (0 == i) {
|
||||
(void)execvp(nargv[1], nargv + 1);
|
||||
perror("exec");
|
||||
return 1;
|
||||
}
|
||||
(void)waitpid(-1, NULL, 0);
|
||||
}
|
||||
|
||||
if (display) {
|
||||
|
|
Loading…
Reference in New Issue