sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.79k stars 156 forks source link

Not running when starting via GUI #7

Closed clausbertels closed 3 years ago

clausbertels commented 3 years ago

Hi, I'd like to quickly say that this is great! I reckon many people have been waiting for this and it will advance many distros in becoming more user friendly. Great work!

I'm on Elementary OS 5.1. I've been fiddling with xbindkeys and logiops to get my MX Keys and MX Master 3 to play nicely with my system. It's a lot of work to get things to function well. Today I discovered your app and hoped it could bring some ease to my headaches.

The Issue

I couldn't install the 0.4.0.deb with Eddy, so I tried directly from source. This seemed to install fine, but when I launch via applications, it pops up in the Dock for 5 seconds and then quits. No GUI. I ran sudo key-mapper-gtk -d

Loaded config from "/home/claus/.config/key-mapper/config.json"
Writing "/home/claus/.config/key-mapper/xmodmap.json"
INFO: logger.py, line 114, key-mapper 0.4.0
WARNING: logger.py, line 121, Debug level will log all your keystrokes! Do not post this output in the internet if you typed in sensitive or private information with your device!
DEBUG: logger.py, line 126, pid 11336
DEBUG: data.py, line 86, Found data at "/usr/share/key-mapper"

(key-mapper-gtk:11336): IBUS-WARNING **: 15:47:40.554: The owner of /home/claus/.config/ibus/bus is not root!

(key-mapper-gtk:11336): IBUS-WARNING **: 15:47:40.584: Unable to connect to ibus: Unexpected lack of content trying to read a line
DEBUG: getdevices.py, line 93, Discovering device paths
SPAM: getdevices.py, line 116, Found "LogiOps Virtual Input", /dev/input/event4, 
SPAM: getdevices.py, line 116, Found "Logitech MX Keys Mac", /dev/input/event3, usb-0000:02:00.0-4
SPAM: getdevices.py, line 116, Found "Logitech MX Master 3", /dev/input/event2, usb-0000:02:00.0-4
INFO: getdevices.py, line 179, Found "LogiOps Virtual Input", "Logitech MX Keys Mac"
DEBUG: presets.py, line 144, The newest preset is "Logitech MX Keys Mac", "new preset"
DEBUG: window.py, line 422, Selecting device "Logitech MX Keys Mac"
DEBUG: window.py, line 241, "Logitech MX Keys Mac" presets: "new preset"
DEBUG: window.py, line 469, Selecting preset "new preset"
INFO: mapping.py, line 139, Loading preset from "/home/claus/.config/key-mapper/presets/Logitech MX Keys Mac/new preset.json"
DEBUG: getdevices.py, line 93, Discovering device paths
SPAM: getdevices.py, line 116, Found "LogiOps Virtual Input", /dev/input/event4, 
SPAM: getdevices.py, line 116, Found "Logitech MX Keys Mac", /dev/input/event3, usb-0000:02:00.0-4
SPAM: getdevices.py, line 116, Found "Logitech MX Master 3", /dev/input/event2, usb-0000:02:00.0-4
INFO: getdevices.py, line 179, Found "LogiOps Virtual Input", "Logitech MX Keys Mac"
DEBUG: reader.py, line 119, Starting reading keycodes from "Logitech MX Keys Mac", "Logitech MX Master 3"

This did pop open the GUI, but I wasn't able to make any changes. Not sure how to proceed.

sezanzeb commented 3 years ago

Thanks a lot!

Sounds like a problem with polkit. I think I'll have to get an Elementary OS vm running to try it out myself.

Try to click right below "Key" and hit a key on the selected device:

image

hitting keys on your device (Your Logitech MX Keys) should

Do those three things happen?

I have added more info into usage.md and the UI now shows where to click and what to do. I think that's certainly an improved user experience.

sezanzeb commented 3 years ago

what happens when you execute for example pkexec mousepad? (or leafpad, gedit, some random application that is installed and safe to grant root rights to)

clausbertels commented 3 years ago

I'm not sure what that command is for, but it throws an error.

claus@Clarinet:~$ pkexec firefox
Error: no DISPLAY environment variable specified

Do those three things happen?

Yes. But after I create an entry for a custom key remap (I just did a simple Q -> A to test), my pc seems to lose all keyboard input and I have to reboot. I'll be using xmodmap for now. Do you have big plans for key-mapper? Would love to see it on some package managers in the future with a full graphical keyboard and mouse representation.

sezanzeb commented 3 years ago

Unplugging and replugging the devices usb cable, or using the mouse on the "Restore Defaults" button, should also work to stop the injection.

I just pushed a fix to support launching it via the start menu of elementary os, and it includes some style fixes for it as well. If it still doesn't work, please post the output of key-mapper-gtk-pkexec (without sudo).

To debug your keyboard problem I would have to see some debug output of the injection. First, stop the key-mapper service (sudo systemctl stop key-mapper) and then start sudo key-mapper-gtk -d. Apply your test preset and hit a small number of random keys on the keyboard. Use the mouse to hit the "Restore Defaults" button to make your keyboard work again (or unplug and replug your keyboard). Then post it please. But first, please make sure python3-evdev is up to date

Graphical keyboard and mouse representation would be nice. But first I need to get it to install properly on everyones distro. There is also always the option of people helping out and making pull requests for stuff like that.

I'm not sure what that command is for

It's like sudo, but it pops up a graphical user interface to enter the password instead.

clausbertels commented 3 years ago

Reinstalled with your fixes. Launching via Applications works very well. Also seems to recognize my mouse now.

I was gonna debug but then saw that opening via terminal shows me previous presets from before I installed your fixes. Is there a way to completely remove key-mapper? Then I can clean reinstall.

sezanzeb commented 3 years ago

Good to read! Presets from before the fixes should be allright.

sudo apt purge key-mapper, and to remove all of your configurations and logs you can run rm ~/.config/key-mapper ~/.log/key-mapper -r

clausbertels commented 3 years ago

Python3-evdev was up to date. Debugging output:

claus@Clarinet:~$ sudo key-mapper-gtk -d
Loaded config from "/home/claus/.config/key-mapper/config.json"
Writing "/home/claus/.config/key-mapper/xmodmap.json"
INFO: logger.py, line 114, key-mapper 0.4.0
INFO: logger.py, line 117, python-evdev 0.7.0
WARNING: logger.py, line 124, Debug level will log all your keystrokes! Do not post this output in the internet if you typed in sensitive or private information with your device!
DEBUG: logger.py, line 129, pid 20389
WARNING: daemon.py, line 73, The daemon "key-mapper-service" is not running, mapping keys only works as long as the window is open.
DEBUG: daemon.py, line 131, Creating daemon
DEBUG: data.py, line 86, Found data at "/usr/share/key-mapper"

(key-mapper-gtk:20389): IBUS-WARNING **: 16:19:23.084: The owner of /home/claus/.config/ibus/bus is not root!
DEBUG: getdevices.py, line 93, Discovering device paths
SPAM: getdevices.py, line 119, Found "bus: 0000, vendor 0000, product 0000, version 0000", "/dev/input/event4", "LogiOps Virtual Input"
SPAM: getdevices.py, line 119, Found "bus: 0003, vendor 046d, product 4092, version 0111", "/dev/input/event3", "Logitech MX Keys Mac"
SPAM: getdevices.py, line 119, Found "bus: 0003, vendor 046d, product 4082, version 0111", "/dev/input/event2", "Logitech MX Master 3"
INFO: getdevices.py, line 182, Found "LogiOps Virtual Input", "Logitech MX Keys Mac", "Logitech MX Master 3"
DEBUG: presets.py, line 144, The newest preset is "Logitech MX Keys Mac", "new preset"
DEBUG: window.py, line 486, Selecting device "Logitech MX Keys Mac"
DEBUG: window.py, line 295, "Logitech MX Keys Mac" presets: "new preset"
DEBUG: window.py, line 535, Selecting preset "new preset"
INFO: mapping.py, line 150, Loading preset from "/home/claus/.config/key-mapper/presets/Logitech MX Keys Mac/new preset.json"
SPAM: mapping.py, line 186, (1, 16, 1) maps to a
DEBUG: getdevices.py, line 93, Discovering device paths
SPAM: getdevices.py, line 119, Found "bus: 0000, vendor 0000, product 0000, version 0000", "/dev/input/event4", "LogiOps Virtual Input"
SPAM: getdevices.py, line 119, Found "bus: 0003, vendor 046d, product 4092, version 0111", "/dev/input/event3", "Logitech MX Keys Mac"
SPAM: getdevices.py, line 119, Found "bus: 0003, vendor 046d, product 4082, version 0111", "/dev/input/event2", "Logitech MX Master 3"
INFO: getdevices.py, line 182, Found "LogiOps Virtual Input", "Logitech MX Keys Mac", "Logitech MX Master 3"
DEBUG: reader.py, line 119, Starting reading keycodes from "Logitech MX Keys Mac"
DEBUG: window.py, line 441, Applying preset "new preset" for "Logitech MX Keys Mac"
INFO: config.py, line 228, Loaded config from "/home/claus/.config/key-mapper/config.json"
INFO: mapping.py, line 150, Loading preset from "/home/claus/.config/key-mapper/presets/Logitech MX Keys Mac/new preset.json"
SPAM: mapping.py, line 186, (1, 16, 1) maps to a
DEBUG: daemon.py, line 189, Using keycodes from "/home/claus/.config/key-mapper/xmodmap.json"
DEBUG: reader.py, line 79, Sending close msg to reader
DEBUG: pid 20400, reader.py, line 171, Reader stopped
INFO: pid 20401, injector.py, line 309, Starting injecting the mapping for "Logitech MX Keys Mac"
DEBUG: pid 20401, injector.py, line 200, Grab /dev/input/event3
DEBUG: pid 20401, injector.py, line 320, Parsing macros for /dev/input/event3
DEBUG: getdevices.py, line 93, Discovering device paths
SPAM: getdevices.py, line 119, Found "bus: 0003, vendor 0001, product 0001, version 0001", "/dev/input/event17", "key-mapper Logitech MX Keys Mac"
SPAM: getdevices.py, line 119, Found "bus: 0000, vendor 0000, product 0000, version 0000", "/dev/input/event4", "LogiOps Virtual Input"
SPAM: getdevices.py, line 119, Found "bus: 0003, vendor 046d, product 4092, version 0111", "/dev/input/event3", "Logitech MX Keys Mac"
SPAM: getdevices.py, line 119, Found "bus: 0003, vendor 046d, product 4082, version 0111", "/dev/input/event2", "Logitech MX Master 3"
INFO: getdevices.py, line 182, Found "key-mapper Logitech MX Keys Mac", "LogiOps Virtual Input", "Logitech MX Keys Mac", "Logitech MX Master 3"
DEBUG: reader.py, line 119, Starting reading keycodes from "Logitech MX Keys Mac"
SPAM: pid 20401, injector.py, line 341, Injected capabilities for "/dev/input/event3": {('EV_SYN', 0): [('SYN_REPORT', 0), ('SYN_CONFIG', 1), ('SYN_MT_REPORT', 2), ('SYN_DROPPED', 3), ('?', 4), ('?', 17)], ('EV_KEY', 1): [('KEY_ESC', 1), ('KEY_1', 2), ('KEY_2', 3), ('KEY_3', 4), ('KEY_4', 5), ('KEY_5', 6), ('KEY_6', 7), ('KEY_7', 8), ('KEY_8', 9), ('KEY_9', 10), ('KEY_0', 11), ('KEY_MINUS', 12), ('KEY_EQUAL', 13), ('KEY_BACKSPACE', 14), ('KEY_TAB', 15), ('KEY_Q', 16), ('KEY_W', 17), ('KEY_E', 18), ('KEY_R', 19), ('KEY_T', 20), ('KEY_Y', 21), ('KEY_U', 22), ('KEY_I', 23), ('KEY_O', 24), ('KEY_P', 25), ('KEY_LEFTBRACE', 26), ('KEY_RIGHTBRACE', 27), ('KEY_ENTER', 28), ('KEY_LEFTCTRL', 29), ('KEY_A', 30), ('KEY_S', 31), ('KEY_D', 32), ('KEY_F', 33), ('KEY_G', 34), ('KEY_H', 35), ('KEY_J', 36), ('KEY_K', 37), ('KEY_L', 38), ('KEY_SEMICOLON', 39), ('KEY_APOSTROPHE', 40), ('KEY_GRAVE', 41), ('KEY_LEFTSHIFT', 42), ('KEY_BACKSLASH', 43), ('KEY_Z', 44), ('KEY_X', 45), ('KEY_C', 46), ('KEY_V', 47), ('KEY_B', 48), ('KEY_N', 49), ('KEY_M', 50), ('KEY_COMMA', 51), ('KEY_DOT', 52), ('KEY_SLASH', 53), ('KEY_RIGHTSHIFT', 54), ('KEY_KPASTERISK', 55), ('KEY_LEFTALT', 56), ('KEY_SPACE', 57), ('KEY_CAPSLOCK', 58), ('KEY_F1', 59), ('KEY_F2', 60), ('KEY_F3', 61), ('KEY_F4', 62), ('KEY_F5', 63), ('KEY_F6', 64), ('KEY_F7', 65), ('KEY_F8', 66), ('KEY_F9', 67), ('KEY_F10', 68), ('KEY_NUMLOCK', 69), ('KEY_SCROLLLOCK', 70), ('KEY_KP7', 71), ('KEY_KP8', 72), ('KEY_KP9', 73), ('KEY_KPMINUS', 74), ('KEY_KP4', 75), ('KEY_KP5', 76), ('KEY_KP6', 77), ('KEY_KPPLUS', 78), ('KEY_KP1', 79), ('KEY_KP2', 80), ('KEY_KP3', 81), ('KEY_KP0', 82), ('KEY_KPDOT', 83), ('KEY_ZENKAKUHANKAKU', 85), ('KEY_102ND', 86), ('KEY_F11', 87), ('KEY_F12', 88), ('KEY_RO', 89), ('KEY_KATAKANA', 90), ('KEY_HIRAGANA', 91), ('KEY_HENKAN', 92), ('KEY_KATAKANAHIRAGANA', 93), ('KEY_MUHENKAN', 94), ('KEY_KPJPCOMMA', 95), ('KEY_KPENTER', 96), ('KEY_RIGHTCTRL', 97), ('KEY_KPSLASH', 98), ('KEY_SYSRQ', 99), ('KEY_RIGHTALT', 100), ('KEY_HOME', 102), ('KEY_UP', 103), ('KEY_PAGEUP', 104), ('KEY_LEFT', 105), ('KEY_RIGHT', 106), ('KEY_END', 107), ('KEY_DOWN', 108), ('KEY_PAGEDOWN', 109), ('KEY_INSERT', 110), ('KEY_DELETE', 111), (['KEY_MIN_INTERESTING', 'KEY_MUTE'], 113), ('KEY_VOLUMEDOWN', 114), ('KEY_VOLUMEUP', 115), ('KEY_POWER', 116), ('KEY_KPEQUAL', 117), ('KEY_PAUSE', 119), ('KEY_SCALE', 120), ('KEY_KPCOMMA', 121), (['KEY_HANGEUL', 'KEY_HANGUEL'], 122), ('KEY_HANJA', 123), ('KEY_YEN', 124), ('KEY_LEFTMETA', 125), ('KEY_RIGHTMETA', 126), ('KEY_COMPOSE', 127), ('KEY_STOP', 128), ('KEY_AGAIN', 129), ('KEY_PROPS', 130), ('KEY_UNDO', 131), ('KEY_FRONT', 132), ('KEY_COPY', 133), ('KEY_OPEN', 134), ('KEY_PASTE', 135), ('KEY_FIND', 136), ('KEY_CUT', 137), ('KEY_HELP', 138), ('KEY_MENU', 139), ('KEY_CALC', 140), ('KEY_SLEEP', 142), ('KEY_WAKEUP', 143), ('KEY_FILE', 144), ('KEY_WWW', 150), (['KEY_COFFEE', 'KEY_SCREENLOCK'], 152), ('KEY_MAIL', 155), ('KEY_BOOKMARKS', 156), ('KEY_BACK', 158), ('KEY_FORWARD', 159), ('KEY_EJECTCD', 161), ('KEY_NEXTSONG', 163), ('KEY_PLAYPAUSE', 164), ('KEY_PREVIOUSSONG', 165), ('KEY_STOPCD', 166), ('KEY_RECORD', 167), ('KEY_REWIND', 168), ('KEY_PHONE', 169), ('KEY_CONFIG', 171), ('KEY_HOMEPAGE', 172), ('KEY_REFRESH', 173), ('KEY_EXIT', 174), ('KEY_EDIT', 176), ('KEY_SCROLLUP', 177), ('KEY_SCROLLDOWN', 178), ('KEY_KPLEFTPAREN', 179), ('KEY_KPRIGHTPAREN', 180), ('KEY_NEW', 181), ('KEY_REDO', 182), ('KEY_F13', 183), ('KEY_F14', 184), ('KEY_F15', 185), ('KEY_F16', 186), ('KEY_F17', 187), ('KEY_F18', 188), ('KEY_F19', 189), ('KEY_F20', 190), ('KEY_F21', 191), ('KEY_F22', 192), ('KEY_F23', 193), ('KEY_F24', 194), ('KEY_CLOSE', 206), ('KEY_PLAY', 207), ('KEY_FASTFORWARD', 208), ('KEY_BASSBOOST', 209), ('KEY_PRINT', 210), ('KEY_CAMERA', 212), ('KEY_CHAT', 216), ('KEY_SEARCH', 217), ('KEY_FINANCE', 219), ('KEY_CANCEL', 223), ('KEY_BRIGHTNESSDOWN', 224), ('KEY_BRIGHTNESSUP', 225), ('KEY_KBDILLUMTOGGLE', 228), ('KEY_KBDILLUMDOWN', 229), ('KEY_KBDILLUMUP', 230), ('KEY_SEND', 231), ('KEY_REPLY', 232), ('KEY_FORWARDMAIL', 233), ('KEY_SAVE', 234), ('KEY_DOCUMENTS', 235), ('KEY_UNKNOWN', 240), ('KEY_VIDEO_NEXT', 241), (['KEY_BRIGHTNESS_AUTO', 'KEY_BRIGHTNESS_ZERO'], 244), (['BTN_0', 'BTN_MISC'], 256), (['BTN_LEFT', 'BTN_MOUSE'], 272), ('BTN_RIGHT', 273), ('BTN_MIDDLE', 274), ('BTN_SIDE', 275), ('BTN_EXTRA', 276), ('BTN_FORWARD', 277), ('BTN_BACK', 278), ('BTN_TASK', 279), ('?', 280), ('?', 281), ('?', 282), ('?', 283), ('?', 284), ('?', 285), ('?', 286), ('?', 287), ('KEY_SELECT', 353), ('KEY_GOTO', 354), ('KEY_INFO', 358), ('KEY_PROGRAM', 362), ('KEY_PVR', 366), ('KEY_SUBTITLE', 370), ('KEY_ZOOM', 372), ('KEY_KEYBOARD', 374), ('KEY_SCREEN', 375), ('KEY_PC', 376), ('KEY_TV', 377), ('KEY_TV2', 378), ('KEY_VCR', 379), ('KEY_VCR2', 380), ('KEY_SAT', 381), ('KEY_CD', 383), ('KEY_TAPE', 384), ('KEY_TUNER', 386), ('KEY_PLAYER', 387), ('KEY_DVD', 389), ('KEY_AUDIO', 392), ('KEY_VIDEO', 393), ('KEY_MEMO', 396), ('KEY_CALENDAR', 397), ('KEY_RED', 398), ('KEY_GREEN', 399), ('KEY_YELLOW', 400), ('KEY_BLUE', 401), ('KEY_CHANNELUP', 402), ('KEY_CHANNELDOWN', 403), ('KEY_LAST', 405), ('KEY_NEXT', 407), ('KEY_RESTART', 408), ('KEY_SLOW', 409), ('KEY_SHUFFLE', 410), ('KEY_PREVIOUS', 412), ('KEY_VIDEOPHONE', 416), ('KEY_GAMES', 417), ('KEY_ZOOMIN', 418), ('KEY_ZOOMOUT', 419), ('KEY_ZOOMRESET', 420), ('KEY_WORDPROCESSOR', 421), ('KEY_EDITOR', 422), ('KEY_SPREADSHEET', 423), ('KEY_GRAPHICSEDITOR', 424), ('KEY_PRESENTATION', 425), ('KEY_DATABASE', 426), ('KEY_NEWS', 427), ('KEY_VOICEMAIL', 428), ('KEY_ADDRESSBOOK', 429), ('KEY_MESSENGER', 430), (['KEY_BRIGHTNESS_TOGGLE', 'KEY_DISPLAYTOGGLE'], 431), ('KEY_SPELLCHECK', 432), ('KEY_LOGOFF', 433), ('KEY_MEDIA_REPEAT', 439), ('KEY_IMAGES', 442), ('KEY_BUTTONCONFIG', 576), ('KEY_TASKMANAGER', 577), ('KEY_JOURNAL', 578), ('KEY_CONTROLPANEL', 579), ('KEY_APPSELECT', 580), ('KEY_SCREENSAVER', 581), ('KEY_VOICECOMMAND', 582), ('KEY_ASSISTANT', 583), ('?', 584), ('KEY_BRIGHTNESS_MIN', 592), ('KEY_BRIGHTNESS_MAX', 593), ('KEY_KBDINPUTASSIST_PREV', 608), ('KEY_KBDINPUTASSIST_NEXT', 609), ('KEY_KBDINPUTASSIST_PREVGROUP', 610), ('KEY_KBDINPUTASSIST_NEXTGROUP', 611), ('KEY_KBDINPUTASSIST_ACCEPT', 612), ('KEY_KBDINPUTASSIST_CANCEL', 613)], ('EV_REL', 2): [('REL_X', 0), ('REL_Y', 1), ('REL_HWHEEL', 6), ('REL_WHEEL', 8), ('?', 11), ('?', 12)], ('EV_ABS', 3): [(('ABS_VOLUME', 32), AbsInfo(value=0, min=0, max=0, fuzz=0, flat=0, resolution=0))], ('EV_MSC', 4): [('MSC_SCAN', 4)], ('EV_LED', 17): [('LED_NUML', 0), ('LED_CAPSL', 1), ('LED_SCROLLL', 2), ('LED_COMPOSE', 3), ('LED_KANA', 4)]}
INFO: window.py, line 499, This device is currently mapped.
DEBUG: pid 20401, injector.py, line 413, Started injecting into /dev/input/event17, fd 23
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 35, 1), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 35, 0), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 32, 1), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 32, 0), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 34, 1), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 34, 0), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 31, 1), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 31, 0), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 21, 1), unmapped
SPAM: pid 20401, keycode_mapper.py, line 157, (1, 21, 0), unmapped
INFO: injector.py, line 444, Stopping injecting keycodes for device "Logitech MX Keys Mac"
DEBUG: pid 20401, injector.py, line 285, Received close signal
DEBUG: pid 20401, injector.py, line 387, asyncio coroutines ended
sezanzeb commented 3 years ago

I was able to reproduce it (by copying your generated capabilities over to me) and just pushed a fix for this. Thanks.

Please let me know if everything works now. Does changing the volume with your multimedia keys still work?

clausbertels commented 3 years ago

I really appreciate your hard work, If there's any way I can help with anything related to either graphic design or interface design, let me know.

So now my keyboard (and volume buttons) is still working after applying the preset, but sadly the preset seems to have no effect now. No matter what keys I try to remap, save to the preset and apply, no changes are made to the input. Could this have anything to do with my custom configs of xbindkeys/logiops?

sezanzeb commented 3 years ago

thanks! I'll keep that in mind if the UI ever has to be redesigned. You can also always just post your ideas to improve the usability or layout in a new issue, or propose an improved icon and such in a pull request.

as long as the second column shows your desired output in the dropdown list, xkb stuff won't cause any trouble.

I don't know how logiops works so I can't judge that. But I don't think it causes trouble.

If mapping q to a won't do anything and q still writes q, then the injection doesn't work. Can you please generate injection debug output again like you did in https://github.com/sezanzeb/key-mapper/issues/7#issuecomment-751479868?

clausbertels commented 3 years ago

I think we're close. When running sudo key-mapper-gtk via Terminal, everything works as expected! I only get issues starting the app via app menu.

Simple remappings work well this way, but I see now that the app doesn't entirely work as I expected. Some keys, like the one to the right of Left Shift and the one directly below Escape are acting strangely. I also can't remap from a second level key, since it will immediately select LEFTSHIFT.

Does it not grab the absolute keycode in the background?

sezanzeb commented 3 years ago

When started via the app menu it won't map your keyboard? Can you try to run key-mapper-gtk-pkexec in a terminal, does that work? This is what the app menu entry is calling.

With absolute keycode, do you mean for example an "E" as opposed to an "e"? The kernel doesn't know key combinations, it just reports the events (like shift-down, e-down, e-up, shift-up), and it's xkb's job to understand this as "E". key-mapper reads those events and maps single events to something different. It kinda sits between the kernel and xkb. So it has no knowledge of shift+key combinations. Mapping arbitrary combinations of buttons is part of the todo and it would be very nice to have this at some point in the future. key-mapper would have to keep track of buttons that are pressed down and then check if a key combination is triggered. For now I'll focus on fixing bugs and such though

sezanzeb commented 3 years ago

I'm able to reproduce it in my virtual machine, hold on

clausbertels commented 3 years ago

With absolute keycode, do you mean for example an "E" as opposed to an "e"?

I imagine that each key event sends a specific code to the computer that doesn't ever change. So, for example, pressing the button that is three buttons to the right of the left shift key would be 'hardwired' to some specific code. And then the software interprets that code and translates it into a character or system event.

I don't really know what I'm talking about. I need to learn more about how input works first. It's quite a bit more complicated, I reckon. Especially with media keys and keys for opening software, etc.

sezanzeb commented 3 years ago

I just pushed another fix.

The root of all evil of the current problem is probably ubuntu/elementaryos not being able to handle os.getlogin(). I have seen and fixed this before on a different device, but that was for sudo and did not cover pkexec yet.

sounds right. The actions of those special keys are most likely just executed by some software that listens on the device (just like what key-mapper does). Key-mapper could also be programmed to execute bash scripts on key events (for example causing a volume to change, or an application to open), but I'm too concerned with the security implications, especially since the service has root rights.

clausbertels commented 3 years ago

Seems like everything is fixed regarding this issue!

There's some deeper problems I have, but those have more to do with my OS and my keyboard specifically. Some xf86 commands not working, some buttons coded to a key combination, etc.

If you ever need someone to do some testing with Elementary OS and MX Keys / MX Master 3, hit me up.

Best of luck on further development. Linux is in terrible need of a good, fully featured GUI keyboard manager. I keep thinking of Ukelele on MacOS. Could be interesting to check out.

Can I buy you a coffee somewhere?

sezanzeb commented 3 years ago

I can't make any promises when I will be able to do the visualization thing, but it sounds quite cool. The easiest solution would be to only visualize, without interactivity.

It could be programmed in three major steps:

Where would you place it? Is it another window that can be dragged around next to key-mapper, or is it something that pops out of the bottom and is part of the main window with some scrollbars to not make the window jump to enormous sizes? With something like a dropdown on the bottom. Where would you put a button for that? I'm afraid that the window will get quite complex over time.

I don't have anything public where people can send me money, but thanks!

sezanzeb commented 3 years ago

Seems like everything is fixed regarding this issue!

I'll close it then. You can still comment here

sezanzeb commented 3 years ago

if you would map a combination of keys, for example a + b + c, would you expect b + a + c to trigger the same mapping? Or to be something different?