Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Keyboard shortcuts don't work in Wayland #125

Closed
OoDeLally opened this issue Jul 22, 2022 · 9 comments
Closed

[BUG] Keyboard shortcuts don't work in Wayland #125

OoDeLally opened this issue Jul 22, 2022 · 9 comments
Labels

Comments

@OoDeLally
Copy link

Describe the bug

On a fresh install of Ubuntu 22.04 LTS.

I've set shortcut to output device ports. They do not work. I've tested various keyboard combinations and none of them work.
When switching sound from the graphical menu, it works flawlessly.

I used to use Linux Mint before Ubuntu, and it was working fine. It stopped working on a fresh Ubuntu (vanilla) install.

To this day I do not know whether the issue is from the SoundSwitch, or Ubuntu which may not let the keystroke event go through.

To Reproduce
On Ubuntu 22.04 LTS, set some shortcuts, and strike them. It does nothing.

Expected behavior
Sound output should be switched.

Desktop (please complete the following information):

  • OS: Ubuntu 22.04 LTS
  • Desktop environment Gnome 42.2
  • Sound Switcher Indicator version: 2.3.9
  • Installation source: PPA

Indicator config:

{
    "devices": {
        "alsa_card.pci-0000_03_00.1": {
            "ports": {
                "hdmi-output-0": {
                    "visible": false
                },
                "hdmi-output-1": {},
                "hdmi-output-2": {},
                "hdmi-output-3": {},
                "hdmi-output-4": {},
                "hdmi-output-5": {
                    "visible": false
                }
            }
        },
        "alsa_card.usb-Microsoft_Microsoft___LifeCam_Cinema_TM_-02": {
            "ports": {
                "analog-input-mic": {
                    "visible": false
                }
            }
        },
        "alsa_card.pci-0000_00_1f.3": {
            "ports": {
                "analog-input-front-mic": {},
                "analog-input-rear-mic": {},
                "analog-input-linein": {},
                "analog-output-lineout": {},
                "analog-output-headphones": {
                    "shortcut": "<Primary>F8"
                },
                "iec958-stereo-output": {
                    "shortcut": "<Primary>F9"
                }
            }
        }
    },
    "show_inputs": false
}

Indicator log:

** (indicator-sound-switcher:9024): WARNING **: 11:45:09.507: Binding '<Primary>F8' failed!
WARNING  Failed to bind keyboard shortcut `<Primary>F8` to `[('alsa_card.pci-0000_00_1f.3', 'analog-output-headphones')]`

** (indicator-sound-switcher:9024): WARNING **: 11:45:09.507: Binding '<Primary>F9' failed!
WARNING  Failed to bind keyboard shortcut `<Primary>F9` to `[('alsa_card.pci-0000_00_1f.3', 'iec958-stereo-output')]`
@OoDeLally OoDeLally added the bug label Jul 22, 2022
@yktoo
Copy link
Owner

yktoo commented Jul 22, 2022

I'm on 22.04 LTS and all shortcuts work just fine. Must be a libkeybinder problem.

@finsterwalder
Copy link

Same problem here... Binding fails.
Log shows:
DEBUG .on_refresh()
DEBUG KeyboardManager.bind_keys()
DEBUG - Unbound keyboard shortcut <Primary><Alt>1
DEBUG - Unbound keyboard shortcut <Primary><Alt>2
DEBUG - Unbound keyboard shortcut <Primary><Alt>3

** (indicator-sound-switcher:212752): WARNING **: 09:53:40.814: Binding '1' failed!
WARNING Failed to bind keyboard shortcut <Primary><Alt>1 to [('alsa_card.pci-0000_00_1f.3', 'analog-output-speaker')]

** (indicator-sound-switcher:212752): WARNING **: 09:53:40.814: Binding '2' failed!
WARNING Failed to bind keyboard shortcut <Primary><Alt>2 to [('alsa_card.pci-0000_00_1f.3', 'analog-output-headphones')]

** (indicator-sound-switcher:212752): WARNING **: 09:53:40.814: Binding '3' failed!
WARNING Failed to bind keyboard shortcut <Primary><Alt>3 to [('alsa_card.pci-0000_00_1f.3', 'hdmi-output-0')]

@yktoo
Copy link
Owner

yktoo commented Aug 9, 2022

Unfortunately, libkeybinder doesn't seem to report the cause of the failure for bind(), so I'm not sure how this can be debugged (considering I'm unable to reproduce that). The only thing I can think of is trying to pry in the system logs.

You can also try to figure out if the binding isn't working in general or only for specific key combinations.

@finsterwalder
Copy link

finsterwalder commented Aug 9, 2022

Which window manager are you using? Wayland or X11? After a quick search it seams that libkeybinder and Wayland don't work well together?

@OoDeLally
Copy link
Author

OoDeLally commented Aug 9, 2022

I've installed Cinnamon on my Ubuntu, and it works

▶ indicator-sound-switcher -vv
INFO     Starting indicator application
INFO     Loaded configuration file /home/user/.config/indicator-sound-switcher.json
DEBUG    KeyboardManager.bind_keys()
DEBUG      - Bound keyboard shortcut `<Primary>F8` to `[('alsa_card.pci-0000_00_1f.3', 'analog-output-headphones')]`
DEBUG      - Bound keyboard shortcut `<Primary>F9` to `[('alsa_card.pci-0000_00_1f.3', 'iec958-stereo-output')]`

Then tried Ubuntu with xorg, it works
@yktoo is it possible that you're using xorg and not wayland?

▶ indicator-sound-switcher -vv
INFO     Starting indicator application
INFO     Loaded configuration file /home/user/.config/indicator-sound-switcher.json
DEBUG    KeyboardManager.bind_keys()
DEBUG      - Bound keyboard shortcut `<Primary>F8` to `[('alsa_card.pci-0000_00_1f.3', 'analog-output-headphones')]`
DEBUG      - Bound keyboard shortcut `<Primary>F9` to `[('alsa_card.pci-0000_00_1f.3', 'iec958-stereo-output')]`

Then Ubuntu (I assume Wayland), it doesnt work:

▶ indicator-sound-switcher -vv
INFO     Starting indicator application
INFO     Loaded configuration file /home/user/.config/indicator-sound-switcher.json
DEBUG    KeyboardManager.bind_keys()

** (indicator-sound-switcher:26509): WARNING **: 11:48:21.731: Binding '<Primary>F8' failed!
WARNING  Failed to bind keyboard shortcut `<Primary>F8` to `[('alsa_card.pci-0000_00_1f.3', 'analog-output-headphones')]`

** (indicator-sound-switcher:26509): WARNING **: 11:48:21.731: Binding '<Primary>F9' failed!
WARNING  Failed to bind keyboard shortcut `<Primary>F9` to `[('alsa_card.pci-0000_00_1f.3', 'iec958-stereo-output')]`

This guy seems to have exactly the same issue kupferlauncher/keybinder#17

It is extremely likely that the issue comes from upstream, e.g. from libkeybinder as @yktoo suggested.
So should we close this issue and pray for a answer to the 3-year-old kupferlauncher/keybinder#17 ?

@finsterwalder
Copy link

As a workaround: You can run indicator-sound-switcher with X11 Backend and then it works:
env GDK_BACKEND=x11 indicator-sound-switcher

A real fix could be to use a GAction instead of libkeybinder, when on Wayland. :-/

@yktoo
Copy link
Owner

yktoo commented Aug 9, 2022

Indeed, it does work in a X11 session but fails on Wayland.

@finsterwalder can GAction be used for making a global shortcut?

@OoDeLally
Copy link
Author

OoDeLally commented Aug 9, 2022

As a workaround: You can run indicator-sound-switcher with X11 Backend and then it works: env GDK_BACKEND=x11 indicator-sound-switcher

Wow it does work, even with Wayland. Thanks!

@yktoo yktoo changed the title [BUG] [Ubuntu] Keyboard shortcut do not work [BUG] Keyboard shortcuts don't work in Wayland Aug 9, 2022
@yktoo
Copy link
Owner

yktoo commented Aug 9, 2022

Conclusion: the error is caused by kupferlauncher/keybinder#17 and appears to only affect Wayland session.

The current workarounds are:

  • Log into Xorg session instead of Wayland (select it on the login screen after clicking the username), or
  • Start the indicator using env GDK_BACKEND=x11 indicator-sound-switcher

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants