Closed Emeraudia closed 1 month ago
Done some debugging, on aquamarine 0.4.1, hyprland 9e356562446f44c471ae38a80506a9df039305d6.
When numlock by default is false - switchxkblayout
fails with "no device" until you press some mod key. Then it returns "ok" and layout is actually switched.
Same, when numlock by default is true, which is surprising, considering it should emit the same event that is emitted when you press some mod key (which I assume what you do with "save the file", e.g. Ctrl (mod) + S).
Testing hyprctl devices -j
yields interesting results - there is, indeed, no devices after hyprland's launch, until you press some mod key. That, I think, is the root of the problem.
The script, to demonstrate it:
#!/usr/bin/env bash
# seconds
timeout=20
hyprctl notify 1 $((timeout*1000)) 0 ' Trying to switch layout to 2nd'
# ❗WRITE YOURS
kbd=logitech-usb-keyboard
path="/tmp/devices-$(date "+%H:%M:%S")-${HYPRLAND_INSTANCE_SIGNATURE}"
mkdir -p "$path"
for i in $(seq 1 $((timeout*2))); do
res="$(hyprctl switchxkblayout "$kbd" 1)"
devices="$(hyprctl devices -j 2>&1)"
echo "$devices" > "${path}/${i}.json"
hyprctl notify 1 500 0 " switch res: $res"
if [[ "$res" == "ok" ]]; then
break
fi
sleep 0.5s
done
sleep 0.6s
hyprctl dismissnotify
(run with exec-once
)
Testing
hyprctl devices -j
yields interesting results - there is, indeed, no devices after hyprland's launch, until you press some mod key. That, I think, is the root of the problem.
I m using Waybar to display the current state of my keyboard with the "hyprland/language" module. The name is empty until I move my cursor or press any key. So as you said, I think there is no devices until any input is done, and not only some mod key in my case.
Done some more debugging.
Yeah, you're right.
Doesn't seem like this is even called before any key at all is pressed.
```log [ERR] rbo: glCheckFramebufferStatus failed [LOG] [22:58:04.541921677] Executing systemctl --user import-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME PATH XDG_DATA_DIRS && hash dbus-update-activation-environment 2>/dev/null && dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE QT_QPA_PLATFORMTHEME PATH XDG_DATA_DIRS [LOG] [22:58:04.553379220] Process Created with pid 156069 [LOG] [22:58:04.553489140] Executing systemctl --user start swaybg [LOG] [22:58:04.563710569] Process Created with pid 156072 ❗ Running the demo script, hands of keyboard [LOG] [22:58:04.563763039] Executing /home/witch/pick-2nd-layout.sh [LOG] [22:58:04.573608210] Process Created with pid 156075 ... [LOG] Shaders initialized successfully. ... [LOG] Hyprland init finished. [LOG] [22:58:04.583426562] Executing systemctl --user import-environment DISPLAY WAYLAND_DISPLAY HYPRLAND_INSTANCE_SIGNATURE XDG_CURRENT_DESKTOP QT_QPA_PLATFORMTHEME PATH XDG_DATA_DIRS && hash dbus-update-activation-environment 2>/dev/null && dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP HYPRLAND_INSTANCE_SIGNATURE QT_QPA_PLATFORMTHEME PATH XDG_DATA_DIRS ... [LOG] Hyprland is ready, running the event loop! ... [LOG] XWayland is ready [LOG] [22:58:04.784532869] xfixes version: 6.0 [LOG] [22:58:04.784607869] xres version: 1.2 [LOG] [22:58:04.785144906] XCursor scanning theme default ... ❗ Super+Enter pressed to launch foot, and finally, devices appear [LOG] [22:59:03.315793010] [AQ] libinput: New device Power Button: 0-1 [LOG] [22:59:03.315822629] New aquamarine keyboard with name Power Button [LOG] [22:59:03.315852989] ApplyConfigToKeyboard for "power-button", hasconfig: 0 [LOG] [22:59:03.315896839] Attempting to create a keymap for layout us,ru with variant (rules: , model: , options: caps:escape,grp:toggle) [LOG] [22:59:03.319055206] Updating keyboard 621938ddc800's translation state from a provided keymap ... [LOG] [22:59:03.324158974] [AQ] libinput: New device Logitech USB Keyboard: 1133-49960 [LOG] [22:59:03.324196204] New aquamarine keyboard with name Logitech USB Keyboard ```
And after that point we can switch layout.
probably same underlying issue as #7391
Reading the issue's description, seems like any typing would have fixed the symptoms, not just mouse, it if the cause was indeed the same.
It reads more like some bugged out focus than uninitialized device.
I'll try reverting 4fdc0d55e4b44bb5300679025d2378fb6de0cae4 from their initial description, still.
Reverting https://github.com/hyprwm/Hyprland/commit/4fdc0d55e4b44bb5300679025d2378fb6de0cae4 fixes it, making the devices complete and correctly setup on the first iteration of the first script.
Waybar doesn't pick up right layout until manually switching it, but activelayout
event is emitted as it should (and right characters are used when typing), so idk why is that, seems like waybar problem.
``` (layout is switched from the script) 00:06:52.262654850 ~ activelayout>>logitech-usb-keyboard,Russian (from other PR, ignore it) 00:06:52.264382215 ~ activelayoutv2>>logitech-usb-keyboard\,Russian 00:06:53.199555099 ~ openlayer>>wallpaper 00:06:53.624873563 ~ openlayer>>waybar (My first interaction with with the keyboard) 00:06:57.329259094 ~ windowtitle>>589db3cd3910 00:06:57.331082281 ~ windowtitlev2>>589db3cd3910,foot 00:06:57.372812492 ~ activewindow>>foot,foot 00:06:57.375081652 ~ activewindowv2>>589db3cd3910 00:06:57.377191550 ~ openwindow>>589db3cd3910,1,foot,foot 00:06:57.540006298 ~ windowtitle>>589db3cd3910 00:06:57.542459360 ~ windowtitlev2>>589db3cd3910,~ - zsh 00:06:57.544350837 ~ activewindow>>foot,~ - zsh 00:06:57.546165172 ~ activewindowv2>>589db3cd3910 00:06:58.646250324 ~ activelayout>>logitech-usb-keyboard,English (US) 00:06:58.648355892 ~ activelayoutv2>>logitech-usb-keyboard\,English (US) 00:07:00.264435004 ~ windowtitle>>589db3cd3910 00:07:00.266140019 ~ windowtitlev2>>589db3cd3910,~ - LF ```
The event script
```bash #!/usr/bin/env bash path="/tmp/devices-$(date "+%H:%M:%S")-${HYPRLAND_INSTANCE_SIGNATURE}" mkdir -p "$path" events="$path/events" touch "$events" socat - UNIX-CONNECT:"$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r event; do echo "$(date "+%H:%M:%S.%N") ~ $event" >> "$events" done ```
(run with exec-once
)
Also, adding
layout="$(hyprctl devices -j | jq -r '.keyboards | .[] | select(.name == "logitech-usb-keyboard") | .active_keymap')"
hyprctl notify 1 5000 0 " Layout is: $layout"
to the end of the first one, active_keymap
is also changed.
So, it works as it should with this commit reverted, basically.
@Emeraudia As we established the cause, could you rename the issue to something like
After 4fdc0d5 devices aren't initialized (hyprctl devices is empty) after Hyprland's launch until some user input
so it's more visible? There are other people running into it e.g. https://github.com/nwg-piotr/nwg-panel/pull/318
Because I don't know how to fix it without breaking BSD, and it seems like something relatively minor compared to not having a working compositor the commit in question fixed for FreeBSD.
Maybe someone else has ideas, other than reverting it.
I didn't take a look at the source code so I don't know if it is possible to set a default layout number (set at 0 by default), the same way numlock is activated by default or not
It's totally possible to add something like hyprctl switchxkblayout logic after numlock (group
is layout here).
Without any validation / index config etc it's basically
// 0, 0 as we don't want to consider mods as pressed,
// or have keys latched to modify next key during init / reload,
// locked to keep caps/num/etc state,
// 1 to set French, index from kb_layout.
updateModifiers(0, 0, modifiersState.locked, 1);
But that's not right solution, though. Devices should be available for hyprctl commands after start without you having to press some key or move a mouse. The initial problem would be solvable with your exec-once = hyprctl ...
command, if devices behaved at start as they used to (and should).
I think we should make aq dispatch libinput once on launch as a proper fix
Like this?
```diff diff --git a/src/Compositor.cpp b/src/Compositor.cpp index 232ba4a6..cef7894e 100644 --- a/src/Compositor.cpp +++ b/src/Compositor.cpp @@ -314,6 +314,16 @@ void CCompositor::initServer(std::string socketName, int socketFd) { initManagers(STAGE_LATE); + if (m_pAqBackend->hasSession()) { + // m_pAqBackend->session->dispatchLibinputEvents(); - private + m_pAqBackend->session->dispatchPendingEventsAsync(); // public, includes dispatchLibinputEvents + + // this is just for me to see if it worked or not + Debug::log(LOG, "FIX 7855: dispatchPendingEventsAsync() on start"); + } else { + Debug::log(LOG, "FIX 7855: no Aquamarine session"); + } + for (auto const& o : pendingOutputs) { onNewMonitor(o); } ````
Seems to fix it.
``` ❯ rg 'Executing /home/witch/events-pick-2nd-layout.sh|FIX|New aquamarine keyboard' hyprland.log 849:[LOG] [02:11:49.014359566] New aquamarine keyboard with name Power Button 870:[LOG] [02:11:49.018794009] New aquamarine keyboard with name Power Button 896:[LOG] [02:11:49.023012784] New aquamarine keyboard with name Logitech USB Keyboard 916:[LOG] [02:11:49.027199269] New aquamarine keyboard with name Logitech USB Keyboard Consumer Control 942:[LOG] [02:11:49.031517203] New aquamarine keyboard with name Logitech USB Keyboard System Control 962:[LOG] [02:11:49.035710748] New aquamarine keyboard with name Eee PC WMI hotkeys 981:[LOG] FIX 7855: dispatchPendingEventsAsync() on start 1080:[LOG] [02:11:49.128613912] Executing /home/witch/events-pick-2nd-layout.sh ```
So devices are ready before exec-once
.
Events are fired correctly
``` 02:11:49.264771949 ~ activelayout>>logitech-usb-keyboard,Russian 02:11:49.266594703 ~ activelayoutv2>>logitech-usb-keyboard\,Russian 02:11:49.537953761 ~ openlayer>>waybar 02:11:50.216375038 ~ openlayer>>wallpaper (first keyboard interaction) 02:11:53.442506127 ~ windowtitle>>5aab8386a830 02:11:53.444300771 ~ windowtitlev2>>5aab8386a830,foot 02:11:53.486799308 ~ activewindow>>foot,foot 02:11:53.489036810 ~ activewindowv2>>5aab8386a830 02:11:53.491260402 ~ openwindow>>5aab8386a830,1,foot,foot ```
and layout is changed on the first try
❯ jq -r '.keyboards.[] | select(.main == true) | .active_keymap'< 1.json
Russian
(checked with typing too)
aquamarine itself should do it IMO
Already reported ? *
Regression?
No
System Info and Version
System/Version info
```sh Hyprland, built from branch at commit 0f594732b063a90d44df8c5d402d658f27471dfe (props: bump version to 0.43.0). Date: Sun Sep 8 16:48:21 2024 Tag: v0.43.0, commits: 5196 flags: (if any) System Information: System name: Linux Node name: asus Release: 6.10.10-zen1-1-zen Version: #1 ZEN SMP PREEMPT_DYNAMIC Thu, 12 Sep 2024 17:17:51 +0000 GPU information: 00:02.0 VGA compatible controller [0300]: Intel Corporation Skylake GT2 [HD Graphics 520] [8086:1916] (rev 07) (prog-if 00 [VGA controller]) os-release: NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinux.org/" DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=archlinux-logo plugins: ======Config-Start====== Config File: /home/emeraud/.config/hypr/hyprland.conf: Read Succeeded # https://wiki.hyprland.org/Configuring/Configuring-Hyprland/ # Please note not all available settings / options are set here. # For a full list, see the wiki # source = ~/.config/hypr/myColors.conf ################ ### MONITORS ### ################ # https://wiki.hyprland.org/Configuring/Monitors/ monitor=,1920x1080,0x0,1 ################### ### MY PROGRAMS ### ################### # https://wiki.hyprland.org/Configuring/Keywords/ # Set programs that you use $terminal = kitty $fileManager = thunar $menu = wofi --show drun ################# ### AUTOSTART ### ################# # Autostart necessary processes (like notifications daemons, status bars, etc.) # Or execute your favorite apps at launch like this: # exec-once = $terminal # exec-once = nm-applet & exec-once = waybar # Top bar exec-once = hyprpaper # Wallpapers ############################# ### ENVIRONMENT VARIABLES ### ############################# # See https://wiki.hyprland.org/Configuring/Environment-variables/ env = XCURSOR_SIZE,12 env = HYPRCURSOR_SIZE,12 ##################### ### LOOK AND FEEL ### ##################### # Refer to https://wiki.hyprland.org/Configuring/Variables/ # General source=./hyprland/general.conf # https://wiki.hyprland.org/Configuring/Variables/#decoration decoration { rounding = 5 # Change transparency of focused and unfocused windows active_opacity = 0.9 inactive_opacity = 0.9 drop_shadow = true shadow_range = 4 shadow_render_power = 3 col.shadow = rgba(1a1a1aee) # https://wiki.hyprland.org/Configuring/Variables/#blur blur { enabled = true size = 3 passes = 1 vibrancy = 0.1696 } } # https://wiki.hyprland.org/Configuring/Variables/#animations animations { enabled = true # Default animations, see https://wiki.hyprland.org/Configuring/Animations/ for more bezier = myBezier, 0.05, 0.9, 0.1, 1.05 animation = windows, 1, 7, myBezier animation = windowsOut, 1, 7, default, popin 80% animation = border, 1, 10, default animation = borderangle, 1, 8, default animation = fade, 1, 7, default animation = workspaces, 1, 6, default } # See https://wiki.hyprland.org/Configuring/Dwindle-Layout/ for more dwindle { pseudotile = true # Master switch for pseudotiling. Enabling is bound to mainMod + P in the keybinds section below preserve_split = true # You probably want this } # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more master { new_status = master } # https://wiki.hyprland.org/Configuring/Variables/#misc misc { force_default_wallpaper = -1 # Set to 0 or 1 to disable the anime mascot wallpapers disable_hyprland_logo = true disable_splash_rendering = true } # Input source=./hyprland/input.conf # https://wiki.hyprland.org/Configuring/Variables/#gestures gestures { workspace_swipe = false } # Example per-device config # See https://wiki.hyprland.org/Configuring/Keywords/#per-device-input-configs for more device { name = epic-mouse-v1 sensitivity = -0.5 } ################### ### KEYBINDINGS ### ################### source=./hyprland/keybindings.conf ############################## ### WINDOWS AND WORKSPACES ### ############################## # See https://wiki.hyprland.org/Configuring/Window-Rules/ for more # See https://wiki.hyprland.org/Configuring/Workspace-Rules/ for workspace rules # Example windowrule v1 # windowrule = float, ^(kitty)$ # Example windowrule v2 # windowrulev2 = float,class:^(kitty)$,title:^(kitty)$ windowrulev2 = suppressevent maximize, class:.* # You'll probably like this. Config File: /home/emeraud/.config/hypr/hyprland/general.conf: Read Succeeded # https://wiki.hyprland.org/Configuring/Variables/#general general { gaps_in = 2 gaps_out = 5 border_size = 2 # https://wiki.hyprland.org/Configuring/Variables/#variable-types for info about colors col.active_border = rgba(33ccffee) rgba(00ff99ee) 45deg col.inactive_border = rgba(595959aa) # Set to true enable resizing windows by clicking and dragging on borders and gaps resize_on_border = false # Please see https://wiki.hyprland.org/Configuring/Tearing/ before you turn this on allow_tearing = false layout = dwindle } Config File: /home/emeraud/.config/hypr/hyprland/input.conf: Read Succeeded # https://wiki.hyprland.org/Configuring/Variables/#input input { kb_layout = us, fr kb_variant = kb_model = kb_options = kb_rules = numlock_by_default = true follow_mouse = 1 sensitivity = 0 # -1.0 - 1.0, 0 means no modification. touchpad { natural_scroll = false } } # Default keyboard # exec=hyprctl keyword input:kb_layout fr exec=hyprctl switchxkblayout at-translated-set-2-keyboard 1m Config File: /home/emeraud/.config/hypr/hyprland/keybindings.conf: Read Succeeded # See https://wiki.hyprland.org/Configuring/Keywords/ $mainMod = SUPER # Sets "Windows" key as main modifier # Example binds, see https://wiki.hyprland.org/Configuring/Binds/ for more bind = $mainMod, Q, exec, $terminal bind = $mainMod, A, killactive, bind = $mainMod, M, exit, bind = $mainMod, E, exec, $fileManager bind = $mainMod, V, togglefloating, bind = $mainMod, D, exec, $menu bind = $mainMod, P, pseudo, # dwindle bind = $mainMod, J, togglesplit, # dwindle # Move focus with mainMod + arrow keys bind = $mainMod, left, movefocus, l bind = $mainMod, right, movefocus, r bind = $mainMod, up, movefocus, u bind = $mainMod, down, movefocus, d # Switch workspaces with mainMod + [0-9] bind = $mainMod, 1, workspace, 1 bind = $mainMod, 2, workspace, 2 bind = $mainMod, 3, workspace, 3 bind = $mainMod, 4, workspace, 4 bind = $mainMod, 5, workspace, 5 bind = $mainMod, 6, workspace, 6 bind = $mainMod, 7, workspace, 7 bind = $mainMod, 8, workspace, 8 bind = $mainMod, 9, workspace, 9 bind = $mainMod, 0, workspace, 10 # Move active window to a workspace with mainMod + SHIFT + [0-9] bind = $mainMod SHIFT, 1, movetoworkspace, 1 bind = $mainMod SHIFT, 2, movetoworkspace, 2 bind = $mainMod SHIFT, 3, movetoworkspace, 3 bind = $mainMod SHIFT, 4, movetoworkspace, 4 bind = $mainMod SHIFT, 5, movetoworkspace, 5 bind = $mainMod SHIFT, 6, movetoworkspace, 6 bind = $mainMod SHIFT, 7, movetoworkspace, 7 bind = $mainMod SHIFT, 8, movetoworkspace, 8 bind = $mainMod SHIFT, 9, movetoworkspace, 9 bind = $mainMod SHIFT, 0, movetoworkspace, 10 # Example special workspace (scratchpad) bind = $mainMod, S, togglespecialworkspace, magic bind = $mainMod SHIFT, S, movetoworkspace, special:magic # Scroll through existing workspaces with mainMod + scroll bind = $mainMod, mouse_down, workspace, e+1 bind = $mainMod, mouse_up, workspace, e-1 # Move/resize windows with mainMod + LMB/RMB and dragging bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow # Laptop multimedia keys for volume and LCD brightness bindel = ,XF86AudioRaiseVolume, exec, pactl set-sink-volume 0 +5% bindel = ,XF86AudioLowerVolume, exec, pactl set-sink-volume 0 -5% bindel = ,XF86AudioMute, exec, pactl set-sink-mute 0 toggle bindel = ,XF86MonBrightnessUp, exec, brightnessctl s 10%+ bindel = ,XF86MonBrightnessDown, exec, brightnessctl s 10%- ======Config-End======== ```Description
I want to use the english (us) keyboard layout to do my keybindings and use the french one to type.
I can't set the default keyboard on startup. I know I can switch between keyboard layouts with a key but I don't want to do it on every startup.
How to reproduce
exec=hyprctl switchxkblayout at-translated-set-2-keyboard 1
Crash reports, logs, images, videos
No response