diff --git a/docs/index.md b/docs/index.md index 7ef35f9d..51ce7fc2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -136,10 +136,6 @@ for the step-by-step procedure for manual installation. - Sometimes the system tray icon does not show up. The cause of this is unknown. Either wait a while and try again or try with the `--window=hide` option. -- Running the command-line application while the GUI - application is also running *may* occasionally cause either of them to become - confused about the state of the devices. - - Some Linux drivers view or modify the setting Scroll Wheel Resolution to implement smooth scrolling. If Solaar changes this setting after the driver is set up scrolling can be either very fast or very slow. To fix this problem @@ -156,6 +152,8 @@ for the step-by-step procedure for manual installation. but this needs write permission on /dev/uinput. For more information see [the rules page](https://pwr-solaar.github.io/Solaar/rules). +- Sometimes bluetooth connections are not torn down correctly. + This can result in two entries in Solaar for the same device, with only one being active. ## Contributing to Solaar diff --git a/docs/installation.md b/docs/installation.md index 91c649f2..d95a6991 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -35,6 +35,13 @@ depending on your distribution). If you are running a version of Python different from the system version, you may need to use pip to install projects that provide the above Python packages. +Solaar runs best under X11 with the Xtest extension enabled so that Solaar rules can fake keyboard input using Xtest. +Solaar also uses the X11 library to access the XKB extension, +which requires installation of the X11 development package. +(In Fedora this is `libX11-devel`. In other distributions it may be `libX11-dev`.) +Solaar will run under Wayland but some parts of Solaar rules will not work. +For more information see [the rules page](https://pwr-solaar.github.io/Solaar/rules). + If desktop notifications bindings are also installed (`gir1.2-notify-0.7` for Debian/Ubuntu), you will also see desktop notifications when devices come online/go offline. diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py index 3d39f427..f0d0d493 100644 --- a/lib/logitech_receiver/diversion.py +++ b/lib/logitech_receiver/diversion.py @@ -80,25 +80,6 @@ try: NET_WM_PID = xdisplay.intern_atom('_NET_WM_PID') WM_CLASS = xdisplay.intern_atom('WM_CLASS') - # set up to get keyboard state using ctypes interface to libx11 - import ctypes - - class XkbDisplay(ctypes.Structure): - """ opaque struct """ - - class XkbStateRec(ctypes.Structure): - _fields_ = [('group', ctypes.c_ubyte), ('locked_group', ctypes.c_ubyte), ('base_group', ctypes.c_ushort), - ('latched_group', ctypes.c_ushort), ('mods', ctypes.c_ubyte), ('base_mods', ctypes.c_ubyte), - ('latched_mods', ctypes.c_ubyte), ('locked_mods', ctypes.c_ubyte), ('compat_state', ctypes.c_ubyte), - ('grab_mods', ctypes.c_ubyte), ('compat_grab_mods', ctypes.c_ubyte), ('lookup_mods', ctypes.c_ubyte), - ('compat_lookup_mods', ctypes.c_ubyte), - ('ptr_buttons', ctypes.c_ushort)] # something strange is happening here but it is not being used - - XkbUseCoreKbd = 0x100 - X11Lib = ctypes.cdll.LoadLibrary('libX11.so') - X11Lib.XOpenDisplay.restype = ctypes.POINTER(XkbDisplay) - X11Lib.XkbGetState.argtypes = [ctypes.POINTER(XkbDisplay), ctypes.c_uint, ctypes.POINTER(XkbStateRec)] - Xkbdisplay = X11Lib.XOpenDisplay(None) except Exception: _log.warn( 'X11 not available - rules cannot access current process, modifier keys, or keyboard group. %s', @@ -107,9 +88,35 @@ except Exception: modifier_keycodes = [] x11 = False +if x11: + try: + # set up to get keyboard state using ctypes interface to libx11 + import ctypes + + class XkbDisplay(ctypes.Structure): + """ opaque struct """ + + class XkbStateRec(ctypes.Structure): + _fields_ = [('group', ctypes.c_ubyte), ('locked_group', ctypes.c_ubyte), ('base_group', ctypes.c_ushort), + ('latched_group', ctypes.c_ushort), ('mods', ctypes.c_ubyte), ('base_mods', ctypes.c_ubyte), + ('latched_mods', ctypes.c_ubyte), ('locked_mods', ctypes.c_ubyte), ('compat_state', ctypes.c_ubyte), + ('grab_mods', ctypes.c_ubyte), ('compat_grab_mods', ctypes.c_ubyte), ('lookup_mods', ctypes.c_ubyte), + ('compat_lookup_mods', ctypes.c_ubyte), + ('ptr_buttons', ctypes.c_ushort)] # something strange is happening here but it is not being used + + XkbUseCoreKbd = 0x100 + X11Lib = ctypes.cdll.LoadLibrary('libX11.so') + X11Lib.XOpenDisplay.restype = ctypes.POINTER(XkbDisplay) + X11Lib.XkbGetState.argtypes = [ctypes.POINTER(XkbDisplay), ctypes.c_uint, ctypes.POINTER(XkbStateRec)] + Xkbdisplay = X11Lib.XOpenDisplay(None) + + except Exception: + _log.warn('X11 library not available - rules cannot access keyboard group. %s', exc_info=_sys.exc_info()) + Xkbdisplay = None + def kbdgroup(): - if x11: + if Xkbdisplay: state = XkbStateRec() X11Lib.XkbGetState(Xkbdisplay, XkbUseCoreKbd, ctypes.pointer(state)) return state.group