Media buttons not working

I’m running Gentoo with Sway as window manager.

My keyboard is generally working but I don’t seem to be able to get special keys like media buttons to work.

My configuration:

# localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us
       X11 Model: pc105+inet
     X11 Options: terminate:ctrl_alt_bksp

Apart from the system locale, I did not actively choose that configuration, it just showed up like this after installation.

I also added section

### Keyboard configuration
input type:keyboard {
    xkb_layout us
    xkb_model pc105+inet
    xkb_options terminate:ctrl_alt_bksp
}

in file ~/.config/sway/config, reloaded the configuration, but it doesn’t seem to have any effect or might just be the wrong configuration.

Can someone with a fully working keyboard please share his output of localectl status with me? If you are using Sway as window manager, did it require any input configuration for the keyboard? Thanks.

Some more information; the Fn+F1..F6 events are working as expected:

# acpi_listen
button/mute MUTE 00000080 00000000 K
button/volumedown VOLDN 00000080 00000000 K
button/volumeup VOLUP 00000080 00000000 K
cd/prev CDPREV 00000080 00000000 K
cd/play CDPLAY 00000080 00000000 K
cd/next CDNEXT 00000080 00000000 K

However there are not events triggered for Fn+F7..F12.

This is my output

   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us

Media keys work fine for me but I run neither sway nor Gentoo. Fedora KDE.

1 Like

Thanks @GhostLegion, that helped in the sense that I now know that my key map configuration is not completely off.

Also the blacklist hid-sensor-hub workaround allowed me to get events for Fn+F7..F8:

# acpi_listen
video/brightnessdown BRTDN 00000087 00000000 K
video/brightnessup BRTUP 00000086 00000000 K

Now I’m down to no events triggered for Fn+F9..F12.

Hmm, something I just realized, are you on 12th or 11th gen? I’m on 11th gen.

It seems that if acpi_listen doesn’t list an event does not necessarily mean the key is not working:

# rfkill list all
0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
1: phy0: Wireless LAN
        Soft blocked: no
        Hard blocked: no

Now hitting Fn+F10.

# rfkill list all
0: hci0: Bluetooth
        Soft blocked: yes
        Hard blocked: no
1: phy0: Wireless LAN
        Soft blocked: yes
        Hard blocked: no

Seems like I’m down to Fn+F9, Fn+F11, and Fn+F12, what is the purpose of Fn+F12 anyway?

I’m on 12th gen.

The Fn+F12 is XF86AudioMedia. You can assign anything.

For your Sway config, you can see [TRACKING] Sway / i3 WM on Framework - #17 by junaruga . Here is a list of the Fn keys symbols: Framework Laptop - function keys - ArchWiki

1 Like

I understand, just wondering what the intention was by the frame.work guys.

@junaruga - What is your output of localectl status?

This. Right now I am running the i3 not Sway. I run i3 or sway in the case. Why do you want to know it? Do you still have a problem on your environment?

$ localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us

~/.config/sway/config keyboard part.

input "1:1:AT_Translated_Set_2_keyboard" {
    xkb_layout us

    # The following files manage the symbols.
    # /usr/share/X11/xkb/rules/evdev
    # /usr/share/X11/xkb/rules/evdev.xml
    # /usr/share/X11/xkb/symbols/*
    #
    # You can set the own custom symbol loading the following files.
    # ~/.xkb/rules/evdev
    # ~/.xkb/symbols/*
    # https://github.com/swaywm/sway/wiki#keyboard-layout
    #
    # The caps:escape_shifted_compose is available on xkeyboard-config >= 2.35.
    # https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/commit/8018e2982d1067fc79195e518546fee191b63b6d
    xkb_options "caps:escape_shifted_compose,custom:compose_shifted_escape"
    # Set Shift + Esc as Compose key.
    # https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/-/merge_requests/418
    # xkb_options "caps:escape_shifted_compose,compose:shifted_escape"
}
1 Like

No, no problems really, I just wanted to avoid to have to configure each individual function+key to work in console mode and in Sway. I was hoping there is an existing X11 Model one could define that already has those key mappings defined.

I see. Thanks for sharing the intent. I don’t know what the X11 Model is. Below is the result by setxkbmap -query on “i3” (not “sway”). I am setting a custom layout to use my custom key binding that is not defined in the xkeyboard-config application. But I didn’t touch “model”. If you configure something to work in the console mode, I am curious to see the outcome. :wink:

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     custom
variant:    ,
options:    caps:escape_shifted_compose

Sure, I will post my results here when I’m done.

2 Likes

Looking forward to it!

OK, my setup is still work in progress, I have few applications installed so far, but here is what I got, I think you get the idea.

Any X11 configuration done via localectl will only update /etc/X11/xorg.conf.d/00-keyboard.conf which won’t have any impact on the Wayland compositor, therefore limiting it to its minimum:

$ localectl status
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us

Not doing any key mappings in .config/sway.config for the time being:

### Basic key bindings
bindsym --to-code {
  # Fn+F01: KEY_MUTE (113) > /etc/acpi/events/FnF01-mute
  # Fn+F02: KEY_VOLUMEDOWN (114) > /etc/acpi/events/FnF02-voldn
  # Fn+F03: KEY_VOLUMEUP (115) > /etc/acpi/events/FnF03-volup
  # Fn+F04: KEY_PREVIOUSSONG (165) - TODO
  # Fn+F05: KEY_PLAYPAUSE (164) - TODO
  # Fn+F06: KEY_NEXTSONG (163) - TODO
  # Fn+F07: KEY_BRIGHTNESSDOWN (224) > /etc/acpi/events/FnF07-brtdn
  # Fn+F08: KEY_BRIGHTNESSUP (225) > /etc/acpi/events/FnF08-brtup
  # Fn+F09: Super_L + p
  # Fn+F10: KEY_RFKILL (247) - works as is
  # Fn+F11: KEY_SYSRQ (99) - TODO
  # Fn+F12: KEY_MEDIA (226) - TODO
  # Fn+Del: KEY_INSERT (110) - TODO
  # Fn+Space: Controls the keyboard backlight - works as is
  # Fn+Left: KEY_HOME (102) - works as is
  # Fn+Right: KEY_END (107) - works as is
  # Fn+Up: KEY_PAGEUP (104) - works as is
  # Fn+Down: KEY_PAGEDOWN (109) - works as is
}

Instead delegating mappings for Fn+F[1-3,7,8] to the acpid so that they work on the console as well:

$ ls /etc/acpi/events/FnF0?-*
FnF01-mute  FnF02-voldn  FnF03-volup  FnF07-brtdn  FnF08-brtup
$ cat /etc/acpi/events/FnF0?-*
#Fn+F1 button/mute MUTE 00000080 00000000 K
event=button/mute
action=/etc/acpi/actions/audio.sh toggle
#Fn+F2 button/volumedown VOLDN 00000080 00000000 K
event=button/volumedown
action=/etc/acpi/actions/audio.sh 3dB- unmute
#Fn+F3 button/volumeup VOLUP 00000080 00000000 K
event=button/volumeup
action=/etc/acpi/actions/audio.sh 3dB+ unmute
#Fn+F7 video/brightnessdown BRTDN 00000087 00000000 K
event=video/brightnessdown
action=light -U 4
#Fn+F8 video/brightnessup BRTUP 00000086 00000000 K
event=video/brightnessup
action=light -A 4
$ cat /etc/acpi/actions/audio.sh
#!/bin/sh
[ -d /dev/snd ] && alsa=true || alsa=false
amixer="amixer -q set Master"
$alsa && $amixer $1 $2

After that enabling and starting the daemon:

$ systemctl enable acpid.service
$ systemctl start acpid.service

The only concern I’m having right now is Fn+Del, libinput debug-events lists the mapping as KEY_INSERT (110), but it doesn’t behave like an old fashioned insert key.

2 Likes

Interesting. Keep me posted, this is very interesting indeed! I realize it’s not ideal, but this is an interesting workaround.