2222# Not very much unlike the xmacrorec2 program in the xmacro package.
2323
2424
25+ # Python 2/3 compatibility.
26+ from __future__ import print_function
27+
2528import sys
2629import os
2730
@@ -45,7 +48,7 @@ def record_callback(reply):
4548 if reply .category != record .FromServer :
4649 return
4750 if reply .client_swapped :
48- print "* received swapped protocol data, cowardly ignored"
51+ print ( "* received swapped protocol data, cowardly ignored" )
4952 return
5053 if not len (reply .data ) or ord (reply .data [0 ]) < 2 :
5154 # not an event
@@ -60,28 +63,28 @@ def record_callback(reply):
6063
6164 keysym = local_dpy .keycode_to_keysym (event .detail , 0 )
6265 if not keysym :
63- print "KeyCode%s" % pr , event .detail
66+ print ( "KeyCode%s" % pr , event .detail )
6467 else :
65- print "KeyStr%s" % pr , lookup_keysym (keysym )
68+ print ( "KeyStr%s" % pr , lookup_keysym (keysym ) )
6669
6770 if event .type == X .KeyPress and keysym == XK .XK_Escape :
6871 local_dpy .record_disable_context (ctx )
6972 local_dpy .flush ()
7073 return
7174 elif event .type == X .ButtonPress :
72- print "ButtonPress" , event .detail
75+ print ( "ButtonPress" , event .detail )
7376 elif event .type == X .ButtonRelease :
74- print "ButtonRelease" , event .detail
77+ print ( "ButtonRelease" , event .detail )
7578 elif event .type == X .MotionNotify :
76- print "MotionNotify" , event .root_x , event .root_y
79+ print ( "MotionNotify" , event .root_x , event .root_y )
7780
7881
7982# Check if the extension is present
8083if not record_dpy .has_extension ("RECORD" ):
81- print "RECORD extension not found"
84+ print ( "RECORD extension not found" )
8285 sys .exit (1 )
8386r = record_dpy .record_get_version (0 , 0 )
84- print "RECORD extension version %d.%d" % (r .major_version , r .minor_version )
87+ print ( "RECORD extension version %d.%d" % (r .major_version , r .minor_version ) )
8588
8689# Create a recording context; we only want key and mouse events
8790ctx = record_dpy .record_create_context (
0 commit comments