diff --git a/docs/installation.md b/docs/installation.md index a90ec8df..3dcefc06 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -20,20 +20,17 @@ and `hid-logitech-hidpp` loaded. Also, the `udev` package must be installed and its daemon running. If you have a recent Linux distribution, you are most likely good to go. -Solaar requires Python 3.6+ -and the `python3-pyudev` package. -To run the GUI Solaar also requires Gtk3, its GObject -introspection bindings. +Solaar requires Python 3.6+ and the +`python3-pyudev` package. +The Solaar GUI requires the +`python3-psutil`, `python3-xlib`, and `python3-pyyaml` packages. +To run the GUI Solaar also requires Gtk3 and its GObject introspection bindings. The Debian/Ubuntu packages that need to be installed are `python3-gi` and `gir1.2-gtk-3.0`; in Fedora you need `gtk3` and `python3-gobject`; if you're using another distribution the required packages are most likely named something similar. -The Solaar GUI also requires Python packages -`PyYAML` (>= 5.1), `python-xlib` (>= 0.27), and `psutil` (>= 5.7.3). -These are best installed using `pip` via `pip install --user ` -if they are not already available. -You may have to install the `gcc` and the Python development package (`python3-dev` or `python3-devel`, +You may have to install `gcc` and the Python development package (`python3-dev` or `python3-devel`, depending on your distribution). If desktop notifications bindings are also installed diff --git a/lib/logitech_receiver/diversion.py b/lib/logitech_receiver/diversion.py index e9fc7cc0..47145a30 100644 --- a/lib/logitech_receiver/diversion.py +++ b/lib/logitech_receiver/diversion.py @@ -53,13 +53,14 @@ except Exception: XK_KEYS = {} x11 = False -# determine name of active process +if x11: + # determine name of active process + disp_prog = Display() + NET_ACTIVE_WINDOW = disp_prog.intern_atom('_NET_ACTIVE_WINDOW') + NET_WM_PID = disp_prog.intern_atom('_NET_WM_PID') + root2 = disp_prog.screen().root + root2.change_attributes(event_mask=Xlib.X.PropertyChangeMask) -disp_prog = Display() -NET_ACTIVE_WINDOW = disp_prog.intern_atom('_NET_ACTIVE_WINDOW') -NET_WM_PID = disp_prog.intern_atom('_NET_WM_PID') -root2 = disp_prog.screen().root -root2.change_attributes(event_mask=Xlib.X.PropertyChangeMask) active_process_name = None @@ -82,28 +83,29 @@ def determine_active_program(): active_process_name = active_program() -_thread.start_new_thread(determine_active_program, ()) +if x11: + _thread.start_new_thread(determine_active_program, ()) # determine current key modifiers # there must be a better way to do this -display = Display() -context = display.record_create_context( - 0, [record.AllClients], [{ - 'core_requests': (0, 0), - 'core_replies': (0, 0), - 'ext_requests': (0, 0, 0, 0), - 'ext_replies': (0, 0, 0, 0), - 'delivered_events': (0, 0), - 'device_events': (X.KeyPress, X.KeyRelease), - 'errors': (0, 0), - 'client_started': False, - 'client_died': False, - }] -) - -modifier_keycodes = display.get_modifier_mapping() -current_key_modifiers = 0 +if x11: + display = Display() + context = display.record_create_context( + 0, [record.AllClients], [{ + 'core_requests': (0, 0), + 'core_replies': (0, 0), + 'ext_requests': (0, 0, 0, 0), + 'ext_replies': (0, 0, 0, 0), + 'delivered_events': (0, 0), + 'device_events': (X.KeyPress, X.KeyRelease), + 'errors': (0, 0), + 'client_started': False, + 'client_died': False, + }] + ) + modifier_keycodes = display.get_modifier_mapping() + current_key_modifiers = 0 def modifier_code(keycode): @@ -162,7 +164,8 @@ TESTS = { COMPONENTS = {} -displayt = Display() +if x11: + displayt = Display() class RuleComponent(object): diff --git a/setup.py b/setup.py index a7adeb02..48b27eef 100755 --- a/setup.py +++ b/setup.py @@ -63,7 +63,7 @@ battery status, and show and modify some of the modifiable features of devices. 'pyudev (>= 0.13)', 'PyYAML (>= 5.1)', 'python-xlib (>= 0.27)', - 'psutil (>= 5.7.3)', + 'psutil (>= 5.6.0)', ], package_dir={'': 'lib'}, packages=['hidapi', 'logitech_receiver', 'solaar', 'solaar.ui', 'solaar.cli'],