natask / gestures

Fluid gestures for Linux.
MIT License
66 stars 7 forks source link

Throws errors unless config file has a lot of empty keys #12

Closed ohthehugemanatee closed 2 years ago

ohthehugemanatee commented 2 years ago

Describe the bug If your config file only includes the gestures you want, gestures will throw errors because of keystrokes that aren't present.

The only way to avoid it is to use the full config file and empty out all the values you don't want.

To Reproduce

  1. Use this minimal configuration:
{
  'pinch_deadzone_enabled': 'False',
  'touchpad': {
    'pinch_deadzone_enabled': 'False',
    'pinch': {},
    'swipe': {
      '3': {
        't': [

        ],
        'l': {
          'start': [
            'evemu_do keydown leftmeta',
            'evemu_do keydown alt',
            "evemu_do key left"
          ],
          'end': [
            'evemu_do keyup alt',
            'evemu_do keyup leftmeta'
          ]
        },
        'r': {
          'start': [
            'evemu_do keydown leftmeta',
            'evemu_do keydown alt',
            "evemu_do key right"
          ],
          'end': [
            'evemu_do keyup alt',
            'evemu_do keyup leftmeta'
          ]
        }
      }
    }
  },
  'touchscreen': {
    'pinch_deadzone_enabled': 'False',
    'pinch': {},
    'swipe': {
      '3': {
        't': [    
        ],
        'l': {
          'start': [
            'evemu_do keydown leftmeta',
            'evemu_do keydown alt',
            "evemu_do key left"
          ],
          'end': [
            'evemu_do keyup alt',
            'evemu_do keyup leftmeta'
          ]
        },
        'r': {
          'start': [
            'evemu_do keydown leftmeta',
            'evemu_do keydown alt',
            "evemu_do key right"
          ],
          'end': [
            'evemu_do keyup alt',
            'evemu_do keyup leftmeta'
          ]
        }
      }
    }
  }
}
  1. Try pinching with two fingers
  2. observe error:
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib/python3.10/threading.py", line 1009, in _bootstrap_inner
    self.run()
  File "/usr/local/bin/gestures", line 96, in run
    self.__getattribute__(event["type"])(event);
  File "/usr/local/bin/gestures", line 192, in finger_update
    self.enqueue();
  File "/usr/local/bin/gestures", line 386, in enqueue
    self.gesture_queue.extend(map(lambda x: shlex.split(x), self.gestures[structure.type][structure.fingers][structure.direction][structure.event]));
KeyError: '2'

Expected behavior The lack of specific config should produce no output unless in debug mode.

Actual behavior Exception is produced in the thread.

Debugging Not relevant.

Additional context Not relevant.