9 set-xcursor-lock-and-run - Set X11 mouse pointer to a lock icon and run the given command
13 set-xcursor-lock-and-run <COMMAND> [<ARGS>]
27 gtk
.gdk
.threads_init()
45 " .X,,,,,,,,,,,,X. ",
46 " .X,,,,,,,,,,,,X. ",
47 " .X,,,,,,,,,,,,X. ",
48 " .X,,,,,,,,,,,,X. ",
49 " .X,,,,,XX,,,,,X. ",
50 " .X,,,,,XX,,,,,X. ",
51 " .X,,,,,XX,,,,,X. ",
52 " .X,,,,,,,,,,X. ",
60 #drawable = window.window
62 #white = gtk.gdk.Color('white')
63 #black = gtk.gdk.Color('black')
64 #green = gtk.gdk.Color('green')
66 #pixmap, X = gtk.gdk.pixmap_create_from_xpm_d(drawable, green, xpm_cursor, 1)
67 #mask, X = gtk.gdk.pixmap_create_from_xpm_d(drawable, green, xpm_mask, 1)
68 #pixmap = gtk.gdk.pixmap_create_from_data(drawable, xbm_cursor, 20, 20, 1, black, white)
69 #mask = gtk.gdk.pixmap_create_from_data(drawable, xbm_mask, 20, 20, 1, black, white)
70 pixbuf
= gtk
.gdk
.pixbuf_new_from_xpm_data(xpm_cursor
)
72 #cursor = gtk.gdk.Cursor(gtk.gdk.X_CURSOR)
73 #cursor = gtk.gdk.Cursor(pixmap, mask, black, white, 0, 0)
74 cursor
= gtk
.gdk
.Cursor(display
, pixbuf
, 0, 0)
75 window
.window
.set_cursor(cursor
)
77 Xscreen
, pointer_x
, pointer_y
, Xmods
= display
.get_pointer()
78 print pointer_x
, pointer_y
79 window
.move(pointer_x
- int(ww
/2), pointer_y
- int(wh
/2))
81 glib
.idle_add(run_external_prog
, priority
=glib
.PRIORITY_DEFAULT_IDLE
)
83 def run_external_prog(*X
):
84 subprocess
.call(sys
.argv
[1:])
88 window
.connect('leave-notify-event', on_blur
)
89 window
.connect('key-press-event', on_blur
)
91 os
.kill(parent
, signal
.SIGUSR1
)
98 def set_mouse_pointer(x
, y
):
99 from ctypes
import cdll
, c_int
, c_voidp
, byref
100 xlib
= cdll
.LoadLibrary('libX11.so')
101 display
= xlib
.XOpenDisplay(None)
102 root
= xlib
.XDefaultRootWindow(display
)
103 xlib
.XWarpPointer(display
, None, root
, 0, 0, 0, 0, c_int(x
), c_int(y
))
104 xlib
.XCloseDisplay(display
)
110 os
.closerange(3, 65535)
115 signal
.signal(signal
.SIGUSR1
, leave
)
116 while wait
: time
.sleep(86400)
120 set_mouse_pointer(0, 0)
123 display
= gtk
.gdk
.Display(None)
124 window
= gtk
.Window()
126 window
.set_default_size(ww
, wh
)
127 window
.set_geometry_hints(min_width
=ww
, min_height
=wh
)
128 window
.set_decorated(False)
129 window
.set_skip_taskbar_hint(True)
130 window
.connect('map-event', on_start
)
131 window
.connect('delete-event', lambda *X
: gtk
.main_quit())