8 set-xcursor-lock-and-run - Set X11 cursor to a padlock and run a command
24 gtk
.gdk
.threads_init()
42 " .X,,,,,,,,,,,,X. ",
43 " .X,,,,,,,,,,,,X. ",
44 " .X,,,,,,,,,,,,X. ",
45 " .X,,,,,,,,,,,,X. ",
46 " .X,,,,,XX,,,,,X. ",
47 " .X,,,,,XX,,,,,X. ",
48 " .X,,,,,XX,,,,,X. ",
49 " .X,,,,,,,,,,X. ",
57 #drawable = window.window
59 #white = gtk.gdk.Color('white')
60 #black = gtk.gdk.Color('black')
61 #green = gtk.gdk.Color('green')
63 #pixmap, X = gtk.gdk.pixmap_create_from_xpm_d(drawable, green, xpm_cursor, 1)
64 #mask, X = gtk.gdk.pixmap_create_from_xpm_d(drawable, green, xpm_mask, 1)
65 #pixmap = gtk.gdk.pixmap_create_from_data(drawable, xbm_cursor, 20, 20, 1, black, white)
66 #mask = gtk.gdk.pixmap_create_from_data(drawable, xbm_mask, 20, 20, 1, black, white)
67 pixbuf
= gtk
.gdk
.pixbuf_new_from_xpm_data(xpm_cursor
)
69 #cursor = gtk.gdk.Cursor(gtk.gdk.X_CURSOR)
70 #cursor = gtk.gdk.Cursor(pixmap, mask, black, white, 0, 0)
71 cursor
= gtk
.gdk
.Cursor(display
, pixbuf
, 0, 0)
72 window
.window
.set_cursor(cursor
)
74 Xscreen
, pointer_x
, pointer_y
, Xmods
= display
.get_pointer()
75 print pointer_x
, pointer_y
76 window
.move(pointer_x
- int(ww
/2), pointer_y
- int(wh
/2))
78 glib
.idle_add(run_external_prog
, priority
=glib
.PRIORITY_DEFAULT_IDLE
)
80 def run_external_prog(*X
):
81 subprocess
.call(sys
.argv
[1:])
85 window
.connect('leave-notify-event', on_blur
)
86 window
.connect('key-press-event', on_blur
)
88 os
.kill(parent
, signal
.SIGUSR1
)
95 def set_mouse_pointer(x
, y
):
96 from ctypes
import cdll
, c_int
, c_voidp
, byref
97 xlib
= cdll
.LoadLibrary('libX11.so')
98 display
= xlib
.XOpenDisplay(None)
99 root
= xlib
.XDefaultRootWindow(display
)
100 xlib
.XWarpPointer(display
, None, root
, 0, 0, 0, 0, c_int(x
), c_int(y
))
101 xlib
.XCloseDisplay(display
)
107 os
.closerange(3, 65535)
112 signal
.signal(signal
.SIGUSR1
, leave
)
113 while wait
: time
.sleep(86400)
117 set_mouse_pointer(0, 0)
120 display
= gtk
.gdk
.Display(None)
121 window
= gtk
.Window()
123 window
.set_default_size(ww
, wh
)
124 window
.set_geometry_hints(min_width
=ww
, min_height
=wh
)
125 window
.set_decorated(False)
126 window
.set_skip_taskbar_hint(True)
127 window
.set_keep_above(True)
128 window
.connect('map-event', on_start
)
129 window
.connect('delete-event', lambda *X
: gtk
.main_quit())