mirror of https://github.com/9wm/xss.git
Add in all that stuff the last commit talked about
This commit is contained in:
parent
8b06b1ed2c
commit
2d75ef7bc3
10
Makefile
10
Makefile
|
@ -1,8 +1,14 @@
|
||||||
|
BINDIR = $(HOME)/bin
|
||||||
CFLAGS = -Wall
|
CFLAGS = -Wall
|
||||||
LDLIBS = -lX11
|
LDLIBS = -lX11
|
||||||
|
|
||||||
all: xss xsswin xcursorpos xkeygrab magic
|
BINARIES = xss xsswin xcursorpos xkeygrab xbell magic
|
||||||
|
|
||||||
|
all: $(BINARIES)
|
||||||
|
|
||||||
|
install: $(BINARIES)
|
||||||
|
cp $(BINARIES) $(BINDIR)
|
||||||
|
|
||||||
xss: LDLIBS += -lXss
|
xss: LDLIBS += -lXss
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all install
|
||||||
|
|
45
README
45
README
|
@ -1,6 +1,6 @@
|
||||||
== xss ==
|
== xss ==
|
||||||
|
|
||||||
`xss` uses the nearly 20-year-old MIT-SCREEN-SAVER extension to launch a
|
`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.
|
||||||
|
|
||||||
`xsswin` makes a full-screen black window and runs some other program,
|
`xsswin` makes a full-screen black window and runs some other program,
|
||||||
|
@ -12,6 +12,8 @@ stdout.
|
||||||
|
|
||||||
`xcursorpos` prints out the x and y coordinates of the cursor.
|
`xcursorpos` prints out the x and y coordinates of the cursor.
|
||||||
|
|
||||||
|
`xbell` sounds the X server's bell.
|
||||||
|
|
||||||
`magic` is a reimplementation of the "magic" screen saver from After
|
`magic` is a reimplementation of the "magic" screen saver from After
|
||||||
Dark. It probably doesn't work with an 8-bit color pallette.
|
Dark. It probably doesn't work with an 8-bit color pallette.
|
||||||
|
|
||||||
|
@ -28,18 +30,42 @@ Run like `xautolock`:
|
||||||
|
|
||||||
xss xlock -mode qix &
|
xss xlock -mode qix &
|
||||||
|
|
||||||
|
Launch a program called "screenlock" when you're idle:
|
||||||
|
|
||||||
Shell script to run `magic` while waiting for a pass word from the keybord. Won't
|
xss screenlock
|
||||||
do anything if the cursor is in the upper-left corner:
|
|
||||||
|
An simple "screenlock" script:
|
||||||
|
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
|
|
||||||
xcursorpos | (read x y; [ $x -lt 20 -a $y -lt 20 ]) && exit 0
|
xsswin magic XSS_WINDOW & pid=$!
|
||||||
xsswin magic XSS_WINDOW &
|
|
||||||
pid=$!
|
|
||||||
xkeygrab | (while read l; do [ "$l" != "secret" ] && break; done)
|
xkeygrab | (while read l; do [ "$l" != "secret" ] && break; done)
|
||||||
kill $pid
|
kill $pid
|
||||||
|
|
||||||
|
A more complex "screenlock" script which locks the screen awaiting a
|
||||||
|
pass phrase with the right md5 checksum. After 4 seconds of being
|
||||||
|
locked, it pauses mpd (iff it was playing). When the screen is
|
||||||
|
unlocked, mpd is resumed (iff it was playing beforehand). The script
|
||||||
|
won't lock if the cursor's at the top of the screen.
|
||||||
|
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
xcursorpos | (read x y; [ $y -lt 20 ]) && exit 0
|
||||||
|
mpc | fgrep -q '[playing]' && playing=1
|
||||||
|
xsswin magic XSS_WINDOW 2>/dev/null & xsswin=$!
|
||||||
|
(sleep 4; [ $playing ] && kill -0 $xsswin 2>/dev/null && mpc --no-status pause) &
|
||||||
|
xkeygrab | (
|
||||||
|
while read l; do
|
||||||
|
md5s=$(echo -n $l | md5sum | cut -d\ -f1)
|
||||||
|
if [ $md5s = 'a37c87558d98e9fe0484e09070268be1' ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
xbell
|
||||||
|
done
|
||||||
|
)
|
||||||
|
kill $xsswin
|
||||||
|
[ $playing ] && mpc --no-status play
|
||||||
|
|
||||||
|
|
||||||
Download
|
Download
|
||||||
--------
|
--------
|
||||||
|
@ -50,6 +76,13 @@ commit](http://woozle.org/~neale/repos/?p=xss;a=snapshot) or use git:
|
||||||
git clone http://woozle.org/~neale/repos/xss/
|
git clone http://woozle.org/~neale/repos/xss/
|
||||||
|
|
||||||
|
|
||||||
|
Bugs
|
||||||
|
----
|
||||||
|
|
||||||
|
* Sometimes xss quits launching anything. I suspect it's not getting
|
||||||
|
SIGCHLD for some reason.
|
||||||
|
|
||||||
|
|
||||||
History
|
History
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
34
xkeygrab.c
34
xkeygrab.c
|
@ -40,34 +40,34 @@ main(int argc, char *argv[])
|
||||||
char obuf[4096];
|
char obuf[4096];
|
||||||
int obuflen = 0;
|
int obuflen = 0;
|
||||||
struct pollfd fds[2];
|
struct pollfd fds[2];
|
||||||
int i;
|
|
||||||
|
|
||||||
if (! (display = XOpenDisplay(NULL))) raise("cannot open display");
|
if (! (display = XOpenDisplay(NULL))) raise("cannot open display");
|
||||||
root = DefaultRootWindow(display);
|
root = DefaultRootWindow(display);
|
||||||
for (i = 0; i < 3; ) {
|
|
||||||
if ((! (i & 1)) && (GrabSuccess == XGrabKeyboard(display, root,
|
|
||||||
True,
|
|
||||||
GrabModeAsync, GrabModeAsync,
|
|
||||||
CurrentTime))) {
|
|
||||||
i |= 1;
|
|
||||||
}
|
|
||||||
if ((! (i & 2)) && (GrabSuccess == XGrabPointer(display, root,
|
|
||||||
False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
|
|
||||||
GrabModeAsync, GrabModeAsync,
|
|
||||||
None, None, CurrentTime))) {
|
|
||||||
i |= 2;
|
|
||||||
}
|
|
||||||
(void)poll(NULL, 0, 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
fds[0].fd = STDOUT_FILENO;
|
fds[0].fd = STDOUT_FILENO;
|
||||||
fds[0].events = 0;
|
fds[0].events = 0;
|
||||||
fds[1].fd = ConnectionNumber(display);
|
fds[1].fd = ConnectionNumber(display);
|
||||||
fds[1].events = POLLIN;
|
fds[1].events = POLLIN;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
int tograb = 3;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = poll(fds, 2, -1);
|
if (tograb) {
|
||||||
|
if ((tograb & 1) && (GrabSuccess == XGrabKeyboard(display, root,
|
||||||
|
True,
|
||||||
|
GrabModeAsync, GrabModeAsync,
|
||||||
|
CurrentTime))) {
|
||||||
|
tograb |= 1;
|
||||||
|
}
|
||||||
|
if ((tograb & 2) && (GrabSuccess == XGrabPointer(display, root,
|
||||||
|
False, ButtonPressMask | ButtonReleaseMask | PointerMotionMask,
|
||||||
|
GrabModeAsync, GrabModeAsync,
|
||||||
|
None, None, CurrentTime))) {
|
||||||
|
tograb |= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = poll(fds, 2, (tograb?100:-1));
|
||||||
|
|
||||||
if (fds[0].revents & POLLERR) {
|
if (fds[0].revents & POLLERR) {
|
||||||
break;
|
break;
|
||||||
|
|
4
xss.c
4
xss.c
|
@ -63,9 +63,7 @@ main(int argc, char *argv[])
|
||||||
root = RootWindow(display, screen);
|
root = RootWindow(display, screen);
|
||||||
XScreenSaverSelectInput(display, root, ScreenSaverNotifyMask);
|
XScreenSaverSelectInput(display, root, ScreenSaverNotifyMask);
|
||||||
|
|
||||||
/* Tell X to make the screen saver window 1 pixel by 1 pixel and off
|
/* Tell X to show its provided window off the screen. We make our own. */
|
||||||
the visible area, since we'll be creating our own. I suspect jwz
|
|
||||||
is just blowing smoke. */
|
|
||||||
{
|
{
|
||||||
XSetWindowAttributes attr;
|
XSetWindowAttributes attr;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue