mirror of https://github.com/9wm/xss.git
New program to report cursor position
This commit is contained in:
parent
f704d2b8a8
commit
76c992f8d7
4
Makefile
4
Makefile
|
@ -1,6 +1,8 @@
|
|||
CFLAGS = -Wall
|
||||
LDLIBS = -lX11
|
||||
|
||||
all: xss xsswin
|
||||
all: xss xsswin xcursorpos
|
||||
|
||||
xss: LDLIBS += -lXss
|
||||
|
||||
.PHONY: all
|
||||
|
|
6
README
6
README
|
@ -7,6 +7,7 @@ xsswin makes a full-screen black window and runs some other program,
|
|||
passing along the window ID in the environment ($XSS_WINDOW) and
|
||||
possibly as an argument (XSS_WINDOW gets replaced with the id).
|
||||
|
||||
xcursorpos prints out the x and y coordinates of the cursor.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
@ -26,9 +27,12 @@ Run like xscreensaver (no locking):
|
|||
xss xsswin /usr/lib/xscreensaver/flurry -window-id XSS_WINDOW
|
||||
|
||||
|
||||
Shell script to run an xscreensaver hack and xtrlock at the same time:
|
||||
Shell script to run an xscreensaver hack and xtrlock at the same time,
|
||||
but prevent locking if the cursor is in the upper-left corner:
|
||||
|
||||
#! /bin/sh
|
||||
|
||||
xcursorpos | (read x y; [ $x -lt 20 -a $y -lt 20 ]) && exit 0
|
||||
xsswin /usr/lib/xscreensaver/qix -window-id XSS_WINDOW &
|
||||
pid=$!
|
||||
xtrlock
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/* xcursorpos -- print current cursor coordinates
|
||||
* Copyright (C) 2008 Neale Pickett <neale@woozle.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "obj.h"
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
Display *display = NULL;
|
||||
|
||||
if (argc != 1) {
|
||||
fprintf(stderr, "Usage: %s\n", argv[0]);
|
||||
return 64; /* EX_USAGE */
|
||||
}
|
||||
|
||||
try {
|
||||
Window root, win;
|
||||
int x, y, win_x, win_y;
|
||||
unsigned int mask;
|
||||
|
||||
if (! (display = XOpenDisplay(NULL))) raise("cannot open display");
|
||||
root = DefaultRootWindow(display);
|
||||
if (! XQueryPointer(display, root, &root, &win, &x, &y, &win_x, &win_y, &mask)) {
|
||||
raise("unable to query pointer");
|
||||
}
|
||||
printf("%d %d\n", x, y);
|
||||
} while (0);
|
||||
|
||||
if (display) {
|
||||
(void)XCloseDisplay(display);
|
||||
}
|
||||
|
||||
except {
|
||||
fprintf(stderr, "Error: %s\n", exception);
|
||||
return 69; /* EX_UNAVAILABLE */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue