more help on mapping names and macros

pull/14/head
sezanzeb 4 years ago
parent 5e4dccb6d9
commit c0f5e8ff58

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

@ -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()

@ -684,12 +684,20 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">a-z, A-Z, 0-9
"KP_0" - "KP_9"
"Shift_L", "Shift_R"
"Alt_L", "Alt_R"
"Control_R"
"BTN_LEFT"</property>
<property name="tooltip_text" translatable="yes">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</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Mapping</property>

@ -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."""

Loading…
Cancel
Save