rules: only use X11 code when X11 is available

This commit is contained in:
Peter F. Patel-Schneider 2020-11-28 09:28:30 -05:00
parent 0427e5607e
commit 7d0402a97f
3 changed files with 35 additions and 35 deletions

View File

@ -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 <package>`
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

View File

@ -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,13 +83,15 @@ 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(
if x11:
display = Display()
context = display.record_create_context(
0, [record.AllClients], [{
'core_requests': (0, 0),
'core_replies': (0, 0),
@ -100,10 +103,9 @@ context = display.record_create_context(
'client_started': False,
'client_died': False,
}]
)
modifier_keycodes = display.get_modifier_mapping()
current_key_modifiers = 0
)
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):

View File

@ -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'],