# Buggy code
def process_notification(device, status, notification, feature):
    global keys_down, key_down
    key_down = None
    # need to keep track of keys that are down to find a new key down
    if feature == _F.REPROG_CONTROLS_V4 and notification.address == 0x00:
        new_keys_down = _unpack("!4H", notification.data[:8])
        for key in new_keys_down:
            if key and key not in keys_down:
                key_down = key
        keys_down = new_keys_down
    rules.evaluate(feature, notification, device, status, True)


# Traceback (ImportError)
Nov 19 16:49:15 xxx solaar.desktop[4106058]:  * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly
Nov 19 16:49:15 xxx solaar.desktop[4106058]: Try one of the following resolutions:
Nov 19 16:49:15 xxx solaar.desktop[4106058]: ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":0": b\'No protocol specifie>
Nov 19 16:49:15 xxx solaar.desktop[4106058]:     raise ImportError('this platform is not supported: {}'.format(
Nov 19 16:49:15 xxx solaar.desktop[4106058]:   File "/usr/local/lib/python3.8/dist-packages/pynput/_util/__init__.py", line 76, in backend
Nov 19 16:49:15 xxx solaar.desktop[4106058]:     backend = backend(__name__)
Nov 19 16:49:15 xxx solaar.desktop[4106058]:   File "/usr/local/lib/python3.8/dist-packages/pynput/keyboard/__init__.py", line 31, in <module>
Nov 19 16:49:15 xxx solaar.desktop[4106058]:     from . import keyboard
Nov 19 16:49:15 xxx solaar.desktop[4106058]:   File "/usr/local/lib/python3.8/dist-packages/pynput/__init__.py", line 40, in <module>
Nov 19 16:49:15 xxx solaar.desktop[4106058]:     from pynput import keyboard as _keyboard
Nov 19 16:49:15 xxx solaar.desktop[4106058]:   File "/usr/local/lib/python3.8/dist-packages/logitech_receiver/diversion.py", line 30, in <module>
Nov 19 16:49:15 xxx solaar.desktop[4106058]:     from . import diversion as _diversion
Nov 19 16:49:15 xxx solaar.desktop[4106058]:   File "/usr/local/lib/python3.8/dist-packages/logitech_receiver/notifications.py", line 30, in <module>
Nov 19 16:49:15 xxx solaar.desktop[4106058]:     from logitech_receiver import notifications as _notifications
Nov 19 16:49:15 xxx solaar.desktop[4106058]:   File "/usr/local/lib/python3.8/dist-packages/solaar/listener.py", line 32, in <module>
Nov 19 16:49:15 xxx solaar.desktop[4106058]:     import solaar.listener as listener
Nov 19 16:49:15 xxx solaar.desktop[4106058]:   File "/usr/local/lib/python3.8/dist-packages/solaar/gtk.py", line 153, in main
Nov 19 16:49:15 xxx solaar.desktop[4106058]: solaar: error: Traceback (most recent call last):

# Fixed code
def process_notification(device, status, notification, feature):
    if not x11:
        return
    global keys_down, key_down
    key_down = None
    # need to keep track of keys that are down to find a new key down
    if feature == _F.REPROG_CONTROLS_V4 and notification.address == 0x00:
        new_keys_down = _unpack("!4H", notification.data[:8])
        for key in new_keys_down:
            if key and key not in keys_down:
                key_down = key
        keys_down = new_keys_down
    rules.evaluate(feature, notification, device, status, True)