Closed funcrab closed 2 years ago
Unfortunately this is unsupported. keyd is completely ignorant of your mouse, so it can't resolve the timeout on click.
On Wed, Mar 23, 2022 at 7:41 AM Naoki Takahashi @.***> wrote:
It seems that space+click is not meta+click when space+click is used in the following configuration. I noticed this because I tried to move (meta+leftclick) and resize ( meta+rightclick) the swaywm window and could not.
$ keyd --version keyd v2.3.0-rc (6581f36) $
space = timeout(overload(meta, space), 1000, space)
keyd virtual device xxxx:xxxx space down keyd virtual device xxxx:xxxx space up
Due to a glitch in the AUR, I have not been able to update to the latest version. https://aur.archlinux.org/packages/keyd-git Sorry if this has been resolved.
— Reply to this email directly, view it on GitHub https://github.com/rvaiya/keyd/issues/162, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAOP7GPOMYM6NJYMKA7FRNDVBL7O3ANCNFSM5RNYG3HA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
I understand. Thanks. I just wanted the key repeat for the Pagedown and Pageup one-shot keys, set up with two keys to the left and right of the space, as in the configuration below, and I am fine without the key repeat for the space. (I expressed this in the form of meta,space when I requested the key repeat feature because it was easier to explain)
leftalt = timeout(overload( alt, pageup), 1000, pageup)
muhenkan = timeout(overload( control, pagedown), 1000, pagedown)
space = overload(meta,space)
henkan = timeout(overload( alt, pageup), 1000, pageup)
katakanahiragana = timeout(overload( shift, pagedown), 1000, pagedown)
You may close it.
I've added support for this in the latest commit. Let me know if it solves your problem.
Great. Thank you.
It may be difficult to understand, but it is as follows
keyd v2.3.1-rc (013f1e5)
space = timeout(overload(meta, space), 1000, space)
space+single click
Kensington Kensington Expert Mouse 047d:1020 leftmouse down
keyd virtual device 0fac:0ade leftmeta down
Kensington Kensington Expert Mouse 047d:1020 leftmouse up
-> It won't be meta+click.
space+double click
Kensington Kensington Expert Mouse 047d:1020 leftmouse down
keyd virtual device 0fac:0ade leftmeta down
Kensington Kensington Expert Mouse 047d:1020 leftmouse up
Kensington Kensington Expert Mouse 047d:1020 leftmouse down
-> result in meta+click behavior.
Ah, yes. The problem is that keyd is only passively monitoring your mouse, so it can't transpose the event order. This is not an issue in the case of oneshot keys, but won't properly break overload ties since the click event propagates independently from the meta event.
The only solution to this is to have keyd actually manage the mouse, but this potentially has other implications (e.g breaking common userspace tools/mouse specific config and potentially interfering with vendor specific libinput logic, etc). It might be possible to make something like this opt-in, but then we are going down the rabbit hole of turning keyd into moused.
I personally have little need for the timeout+overload+click functionality as I can currently fulfill my expectations without using the timeout (key repeat), but apart from that, you have the (I still don't understand) high scalability and consistency of this timeout functionality I imagine you are thinking about 🤔
At the moment I'm treating this as out of scope, since it involves multi-device coordination and would require keyd to get into the business of mouse management. I may revisit it at a later point if there is greater demand or I have some spare time. If you feel strongly about this, feel free to open another issue.
This should work now, though you will need to explicitly add the mouse to your config.
I added the relevant mouse in this way. I can't seem to do it yet in the form of using timeout. Am I doing something wrong?
# paru -Q keyd
keyd-git 2.4.0.r32.6064708-1
#
[ids]
04fe:0022 #HHKB-Hybrid_1 Keyboard
04fe:000d #PFU Limited HHKB Professional JP
047d:8019 #Expert Wireless TB Mouse
047d:1020 #Kensington Expert Mouse
[main]
#OK
#space = overload(meta, space)
#NG?
space = timeout(overload(meta, space), 1000, space)
From what I can see from that video, keyd is outputting the correct sequence, but click+drag fails in your window manger intermittently. Is this correct?
Certainly the output looks the same.
#1: space = overload(meta, space)
keyd virtual device 0fac:0ade leftmeta down
keyd virtual pointer 0fac:1ade leftmouse down
#2: space = timeout(overload(meta, space), 1000, space)
keyd virtual device 0fac:0ade leftmeta down
keyd virtual pointer 0fac:1ade leftmouse down
Sorry if I am wrong.
Just a naive guess, but could it be that #2
has a shorter interval after the leftmeta
is pressed?
My guess would be that your window manager is processing the button event before the key event. I've changed the behaviour to route both through the same virtual device to avoid the issue. Can you try the latest commit?
Unfortunately, it still doesn't seem to work.
What window manager are you using? Moving forward it might be better to omit KEYD_DEBUG
since the motion events makes the output harder to follow.
The window manager I use is sway. The settings that might be relevant are below, but I don't think they have been changed from their defaults.
~/.config/sway/config
# Resize them with right mouse button + $mod.
# Despite the name, also works for non-floating windows.
# Change normal to inverse to use left mouse button for resizing and right
# mouse button for dragging.
floating_modifier $mod normal
It may be more likely to occur in the terminal. I have had this problem with foot and kitty, but not with code (oss version of vscode).
For me, the need to repeat the space key (using timeout) is not serious, because I have little need for it. If I want to repeat a key, I can work around it by doing it on a different key layer. However, I will test if you feel the need.
Thanks for the second demo, I would appreciate your assistance in tracking down the bug. Oddly I can't seem to reproduce this. Your demo would suggest keyd is outputting the correct sequences even in the failure case. Can you post the output of libinput debug-events
alongside keyd -m
when reproducing the issue?
I would appreciate your assistance in tracking down the bug.
OK with pleasure👍
# space = timeout(overload(meta, space), 1000, space)
keyd virtual device 0fac:0ade leftmeta down
keyd virtual device 0fac:0ade leftmouse down
-event26 KEYBOARD_KEY +242.686s KEY_LEFTMETA (125) pressed
event26 POINTER_BUTTON +242.686s BTN_LEFT (272) pressed, seat count: 1
-> meta and click timing are simultaneous
# space = overload(meta, space)
keyd virtual device 0fac:0ade leftmeta down
keyd virtual device 0fac:0ade leftmouse down
event26 KEYBOARD_KEY +7.513s KEY_LEFTMETA (125) pressed
event26 POINTER_BUTTON +8.550s BTN_LEFT (272) pressed, seat count: 1
-> Click after meta
Hmm, that only leaves sway itself. Can you see if a more direct binding like grave = M-leftmouse
produces the same problem? What version of sway are you running?
Occurred in the following
# tab = M-leftmouse
event26 KEYBOARD_KEY +137.664s KEY_LEFTMETA (125) pressed
event26 POINTER_BUTTON +137.664s BTN_LEFT (272) pressed, seat count: 1
version
$ paru -Q sway cairo gdk-pixbuf2 libevdev.so=2-64 libinput libjson-c.so=5-64 libudev.so=1-64 libwayland-server.so=0-64 libwlroots.so=10-64 libxcb libxkbcommon.so=0-64 pango pcre ttf-font
sway 1:1.7-9
cairo 1.17.6-2
gdk-pixbuf2 2.42.8-1
libevdev 1.12.1-1
libinput 1.20.1-1
json-c 0.16-1
systemd-libs 251.2-1
wayland 1.20.0-2
wlroots 0.15.1-5
libxcb 1.15-1
libxkbcommon 1.4.1-1
pango 1:1.50.7-1
pcre 8.45-1
gnu-free-fonts 20120503-8
$
Note: I am the same person as @funcrab
I think there was a problem with my sway settings. I did the following and was able to move windows with the tab key. Sorry to bother you.
cd ~/.config/sway
mv config config.bk
reboot
No worries. I'm curious to know what the offending setting was. I assume the timeout()
binding also works now.
Sorry, I'm kind of having trouble reproducing the above. I will do some research.
I did a lot of research. I think I got the point, but I am guessing so sorry if I am off. It seems to be a problem in my environment, and it is not possible if the following settings are included.
/etc/enviroment
GTK2_RC_FILES=/usr/share/themes/base16-tomorrow-night/gtk-2.0/gtkrc
I think the problem may have been that Wayland could not use GTK2 but was forced to use it. https://wiki.archlinux.org/title/GTK#Wayland_backend
This problem occurred with foot and kitty, which are wayland compatible, and not with alacritty, which is an X11 app.
Sorry, my guess was off.
It seems that the behavior just changes every time swaymsg reload
.
I still can't seem to reproduce this. Can you post your sway config?
I renamed the ~/.config/sway
directory and rebooted the machine and it still occurred, so I don't think it has anything to do with that.
If it has anything to do with it, it might be environment variables, etc.
I'm running the following sway-run
with greetd-tuigreet-bin
I don't think it would make any difference if I started it directly from agetty
I can't take the time right now, but I'll take a look in a few days.
$ cat /usr/local/bin/sway-run
#!/bin/sh
#Xwayland disable
# Session
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_DESKTOP=sway
export XDG_CURRENT_DESKTOP=sway
export XDG_CURRENT_SESSION=sway #https://zenn.dev/haxibami/articles/wayland-sway-install
source /usr/local/bin/wayland_enablement.sh
# wayvnc
WLR_BACKENDS=headless
WLR_LIBINPUT_NO_DEVICES=1
systemd-cat --identifier=sway sway $@
$ cat /usr/local/bin/wayland_enablement.sh
#!/bin/sh
export MOZ_ENABLE_WAYLAND=1
export CLUTTER_BACKEND=wayland
#export QT_QPA_PLATFORM=wayland-egl
#export QT_QPA_PLATFORM=wayland
export QT_QPA_PLATFORM="wayland;xcb"
export ECORE_EVAS_ENGINE=wayland-egl
export ELM_ENGINE=wayland_egl
export SDL_VIDEODRIVER=wayland
export _JAVA_AWT_WM_NONREPARENTING=1
export NO_AT_BRIDGE=1
export WINIT_UNIX_BACKEND=x11
$ cat /etc/environment
#
# This file is parsed by pam_env module
#
# Syntax: simple "KEY=VAL" pairs on separate lines
#####
# uim
#####
#export GTK_IM_MODULE='uim'
#export QT_IM_MODULE='uim'
#uim-xim &
#export XMODIFIERS='@im=uim'
#######
# fcitx
#######
# To use kitty
GLFW_IM_MODULE=ibus
# Arch Wiki EN.
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
SDL_IM_MODULE=fcitx
# GTK
#GTK2_RC_FILES=/usr/share/themes/base16-tomorrow-night/gtk-2.0/gtkrc
$
To reduce the impact as much as I could think of, I did the following and checked again. Unfortunately, the operation did not seem to change.
Rename files and directories that may be related to this event
$ cat tmp/rename-20220617.txt | while read i ; do ls -ld $i ; done
ls: cannot access '/etc/environment': No such file or directory
ls: cannot access '/etc/locale.gen': No such file or directory
-rw-r--r-- 1 root root 75 Jun 3 03:32 /etc/locale.conf
ls: cannot access '/etc/profile.d': No such file or directory
ls: cannot access '/etc/bash.bashrc': No such file or directory
ls: cannot access '/usr/share/themes': No such file or directory
ls: cannot access '~/.profile': No such file or directory
ls: cannot access '~/.config/sway': No such file or directory
ls: cannot access '~/.zshrc': No such file or directory
ls: cannot access '~/.config/user-dirs.locale': No such file or directory
ls: cannot access '~/.config/foot': No such file or directory
ls: cannot access '~/.config/kitty': No such file or directory
ls: cannot access '~/.config/gtk-2.0': No such file or directory
ls: cannot access '~/.config/gtk-3.0': No such file or directory
gb1% cat /etc/locale.conf
# This is the fallback locale configuration provided by systemd.
LANG="C"
$
After rebooting the machine, login to agetty as a normal user (a) and perform the following
sway
User environment variables (printenv)
SHELL=/usr/bin/zsh
CLUTTER_BACKEND=wayland
I3SOCK=/run/user/1000/sway-ipc.1000.1445.sock
XDG_CURRENT_SESSION=sway
NO_AT_BRIDGE=1
XCURSOR_SIZE=24
XDG_SEAT=seat0
PWD=/home/a
XDG_SESSION_DESKTOP=sway
LOGNAME=a
XDG_SESSION_TYPE=wayland
ECORE_EVAS_ENGINE=wayland-egl
_=/usr/bin/printenv
MOTD_SHOWN=pam
HOME=/home/a
_JAVA_AWT_WM_NONREPARENTING=1
XDG_CURRENT_DESKTOP=sway
SWAYSOCK=/run/user/1000/sway-ipc.1000.1445.sock
WAYLAND_DISPLAY=wayland-1
WINIT_UNIX_BACKEND=x11
QT_QPA_PLATFORM=wayland;xcb
XDG_SESSION_CLASS=user
TERM=foot
USER=a
SDL_VIDEODRIVER=wayland
DISPLAY=:0
SHLVL=3
MOZ_ENABLE_WAYLAND=1
XDG_VTNR=2
XDG_SESSION_ID=3
XDG_RUNTIME_DIR=/run/user/1000
GREETD_SOCK=/run/greetd-1128.sock
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
ELM_ENGINE=wayland_egl
MAIL=/var/spool/mail/a
OLDPWD=/home/a
COLORTERM=truecolor
Environment variable for root (printenv)
SHELL=/bin/bash
PWD=/root
LOGNAME=root
HOME=/root
TERM=foot
USER=root
SHLVL=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin
_=/usr/bin/printenv
I still can't reproduce this. Can you see if the test branch makes a difference? I've added an artificial delay between the modifier and button press.
E.G
git fetch origin
git checkout origin/test
make
and compare it to the tip of master?
The best way to ensure it isn't a config issue it to create a new user on your machine and run sway with no config.
/etc/keyd/test.conf
[ids]
*
[main]
space = timeout(overload(meta, space), 1000, space)
Setting up a test version
$ paru -R keyd-git
$ mkdir ~/.cache/paru/clone/keyd-git_test
$ cp -p ~/.cache/paru/clone/keyd-git/PKGBUILD ~/.cache/paru/clone/keyd-git_test/
$ cd ~/.cache/paru/clone/keyd-git_test
$ $EDITOR PKGBUILD
$ grep "^\(source\|pkgver\)=" PKGBUILD
pkgver=2.4.1.r10.9fb7a1d
source=('git+https://github.com/rvaiya/keyd#branch=test')
$ makepkg -is
$ paru -Q keyd-git
keyd-git 2.4.1.r10.9fb7a1d-1
$ pgrep keyd
$ keyd --version
keyd v2.4.1 (9fb7a1d)
$ sudo systemctl start keyd
Add user, logout
sudo useradd -m newuser1
sudo passwd newuser1
swaymsg exit
I then logged into agetty as newuser1
and ran the sway
command.
Then run the usual operations. failure😿
Shall I check with a new OS installation on a virtual machine such as gnome-boxes?
Shall I check with a new OS installation on a virtual machine such as gnome-boxes?
This shouldn't be necessary for now, but thanks for offering.
Would you mind compiling directly from the git repo? I'm not really sure what magic paru is doing, but it seems to be creating its own commit hash.
If you are worried about polluting your system, you don't need to run make install
. You can do something like this:
git clone https://github.com/rvaiya/keyd
cd keyd
git checkout origin/test
make && sudo systemctl stop keyd && sudo ./bin/keyd
# Run tests..
# <C-c>
git checkout origin/master && make && sudo ./bin/keyd
# Run tests..
# <C-c>
# Restart your local version
sudo systemctl restart keyd
and test/post the output while it is running.
Thank you.
$ ./bin/keyd --version
keyd v2.4.1 (9fb7a1d)
$
OK with test version
NG with origin/master
@rvaiya Sorry if you have already noticed this. Presumably this issue appears to have been resolved as well as the status. https://github.com/rvaiya/keyd/commit/9fb7a1da6db9d4b2ab28c1ba711bb1bac3bc7ebb
Apologies for letting this languish. I haven't been able to reproduce the issue, but the fact that adding a delay solves the problem and that libinput seems to be seeing the correct output in both cases, would suggest it is a race condition higher up the input stack (i.e sway) potentially affected by something in your environment.
I am loath to add an artificial delay until I am convinced it is strictly necessary. Once I have some free time I will make another attempt, but if you can isolate the components necessary to reproduce it in the meantime, that would greatly help.
I understand. I will try a few things at the right time.
Can you try a40e3a489 (git fetch origin && git checkout a40e3a489
) and compare it to e749310df?
I tried it. The behavior seems to be the same for both. https://github.com/rvaiya/keyd/commit/e749310df486f00b97e97d5571ee142058a2a0be
https://github.com/rvaiya/keyd/commit/a40e3a489c0b362e6ad982cae7e6afe2a54acd0b
It looks like you haven't added your mouse id to your config file. I took a closer look at your earlier videos and looks like many of them have the same problem.
Sorry, I added the relevant mouse ID and checked again. The behavior does not seem to change. https://github.com/rvaiya/keyd/commit/e749310df486f00b97e97d5571ee142058a2a0be
https://github.com/rvaiya/keyd/commit/a40e3a489c0b362e6ad982cae7e6afe2a54acd0b
Thanks. Can you also include the libinput output?
KEY_LEFTMETA
and BTN_LEFT
appear to be entered simultaneously.
# e749310
-event31 KEYBOARD_KEY +3.549s KEY_LEFTMETA (125) pressed
-event256 POINTER_BUTTON +3.549s BTN_LEFT (272) pressed, seat count: 1
# a40e3a4
-event31 KEYBOARD_KEY +281.056s KEY_LEFTMETA (125) pressed
event31 POINTER_BUTTON +281.056s BTN_LEFT (272) pressed, seat count: 1
I uploaded my screencast to an external site because it seems that if the video file size is over 10 MB, it cannot be uploaded. https://github.com/rvaiya/keyd/commit/e749310df486f00b97e97d5571ee142058a2a0be https://streamable.com/s22x9l
https://github.com/rvaiya/keyd/commit/a40e3a489c0b362e6ad982cae7e6afe2a54acd0b https://streamable.com/r7ahdm
It seems that
space+click
is notmeta+click
whenspace+click
is used in the following configuration. I noticed this because I tried to move (meta+leftclick
) and resize (meta+rightclick
) the swaywm window and could not.Due to a glitch in the AUR, I have not been able to update to the latest version. https://aur.archlinux.org/packages/keyd-git Sorry if this has been resolved.