diff --git a/README.md b/README.md index e2e30f11..359ab250 100644 --- a/README.md +++ b/README.md @@ -38,15 +38,10 @@ delay of 10ms that can be configured in `~/.config/key-mapper/config`. ##### Names For a list of supported keystrokes and their names for the middle column, -check the output of `xmodmap -pke` +check the output of `key-mapper-service --names`. Examples: - Alphanumeric `a` to `z` and `0` to `9` - Modifiers `Alt_L` `Control_L` `Control_R` `Shift_L` `Shift_R` - -If you can't find what you need, consult -[linux/input-event-codes.h](https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h) -for KEY and BTN names - - Mouse buttons `BTN_LEFT` `BTN_RIGHT` `BTN_MIDDLE` `BTN_SIDE` ... - Multimedia keys `KEY_NEXTSONG` `KEY_PLAYPAUSE` ... diff --git a/bin/key-mapper-service b/bin/key-mapper-service index 4e8fa241..ad6d3525 100755 --- a/bin/key-mapper-service +++ b/bin/key-mapper-service @@ -34,6 +34,7 @@ from pydbus import SessionBus from keymapper.logger import update_verbosity, log_info, \ add_filehandler, logger from keymapper.daemon import Daemon, BUS_NAME +from keymapper.state import system_mapping from keymapper.dev.permissions import can_read_devices @@ -44,12 +45,23 @@ if __name__ == '__main__': help='Displays additional debug information', default=False ) + parser.add_argument( + '-n', '--names', action='store_true', dest='names', + help='Print all available names for the mapping', + default=False + ) options = parser.parse_args(sys.argv[1:]) + update_verbosity(options.debug) add_filehandler() log_info() + if options.names: + # TODO test + print('\n'.join(system_mapping.list_names())) + sys.exit(0) + can_read_devices() bus = SessionBus() diff --git a/data/key-mapper.glade b/data/key-mapper.glade index e46864d3..e456e716 100644 --- a/data/key-mapper.glade +++ b/data/key-mapper.glade @@ -684,12 +684,20 @@ True False - a-z, A-Z, 0-9 -"KP_0" - "KP_9" -"Shift_L", "Shift_R" -"Alt_L", "Alt_R" -"Control_R" -"BTN_LEFT" + a-z, A-Z, 0-9, "KP_0" - "KP_9" +"Shift_L", "Shift_R", "Alt_L", "Alt_R" +"Control_R", "BTN_LEFT", +"r(3, k(a).w(500))", "h(a).k(b)" +"m(Control_L, k(a).k(x))" + +Run `key-mapper-service --names` for more + +Macros: +- r: repeats the execution of the second parameter +- w: waits in milliseconds +- k: writes a single keystroke +- m: holds a modifier while executing the second parameter +- h: executes the parameter as long as the key is pressed down 5 5 Mapping diff --git a/keymapper/state.py b/keymapper/state.py index 455594a0..dd3b083a 100644 --- a/keymapper/state.py +++ b/keymapper/state.py @@ -41,6 +41,11 @@ class SystemMapping: self._mapping = {} self.populate() + def list_names(self): + """Return an array of all possible names in the mapping.""" + # TODO test + return self._mapping.keys() + def populate(self): """Get a mapping of all available names to their keycodes.""" self.clear() @@ -65,7 +70,8 @@ class SystemMapping: self._set(name, int(keycode) - XKB_KEYCODE_OFFSET) for name, ecode in evdev.ecodes.ecodes.items(): - self._set(name, ecode) + if name.startswith('KEY') or name.startswith('KEY'): + self._set(name, ecode) def _set(self, name, code): """Map name to code."""