Skip to main content
Topic solved
This topic has been marked as solved and requires no further attention.
Topic: [SOLVED] ThinkPad X220 volume buttons (Read 2301 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

[SOLVED] ThinkPad X220 volume buttons

Hi everyone,

I am running Artix with LARBS by Luke Smith and the mute/volume/toggle microphone buttons in the upper left of my keyboard are not working as they should be. The mute and toggle mic buttons both have an orange led on them which turns on as soon as I boot into the system, but if I press them nothing happens. I managed to toggle the mute with:

pactl set-sink-mute @DEFAULT_SINK@ toggle

But I still cannot control the volume and mic through the physical byttons. After googling for a while I imagine the key is re-mapping such buttons with commands such as:

pactl set-sink-volume @DEFAULT_SINK@ -10%
pactl set-sink-volume @DEFAULT_SINK@ +10%
pactl set-source-mute @DEFAULT_SOURCE@ toggle


But I am a newbie and don't know which files I should edit to do so. Any help? :)

Thanks in advance!

Re: ThinkPad X220 volume buttons

Reply #1
I sometimes want to type a £ symbol on a US keyboard that doesn't have this, so I just put this command in my desktop "startup applications" (possibly this would need the keycode changing to work on other hw)
Code: [Select]
xmodmap -e 'keycode 118 = Insert sterling Insert'
Simplistic but functional  :D
So if you can figure out a command to do what you want then that's one way, perhaps you might find something neater.

/usr/lib/udev/hwdb.d/60-keyboard.hwdb
contains udev rules for various hardware control buttons, you could create something like that and perhaps even submit it upstream to add general support for your hardware if it was missing, see the Arch Wiki page as a start point:
https://wiki.archlinux.org/title/libinput

And another alternative is adding a volume control mixer applet to a desktop panel if you have one. I think pactl is pulse audio specific so that's not what the buttons would normally  send btw.

Re: ThinkPad X220 volume buttons

Reply #2
Hi everyone,

I am running Artix with LARBS by Luke Smith and the mute/volume/toggle microphone buttons in the upper left of my keyboard are not working as they should be. The mute and toggle mic buttons both have an orange led on them which turns on as soon as I boot into the system, but if I press them nothing happens. I managed to toggle the mute with:

pactl set-sink-mute @DEFAULT_SINK@ toggle

But I still cannot control the volume and mic through the physical byttons. After googling for a while I imagine the key is re-mapping such buttons with commands such as:

pactl set-sink-volume @DEFAULT_SINK@ -10%
pactl set-sink-volume @DEFAULT_SINK@ +10%
pactl set-source-mute @DEFAULT_SOURCE@ toggle


But I am a newbie and don't know which files I should edit to do so. Any help? :)

Thanks in advance!

LARBS uses dwm so you need to edit the keybinding in config.h, which from memory is in ~/.local/bin/dwm (?) I haven't really used LARBS so I don't recall exactly where.

Regardless, looking at the repo for his dwm build, the volume keys  are already bound to pamixer, it's possible that pamixer was not correctly installed by LARBS.

Try installing pamixer with:

Code: [Select]
sudo pacman -S pamixer

Then try the keys again.

Re: ThinkPad X220 volume buttons

Reply #3
Thanks @Krellnus! I'll try that as soon as possible and let you know if it'll do it  :)

@####### If the other solution won't work, I think I'll have to do what you suggested. Thank you for your reply :)

Re: ThinkPad X220 volume buttons

Reply #4
Apparently I misspelled something. Both sudo pacman -S pamixer and sudo yay -S pamixer give me error: target not found: pamixer. Maybe it currently has another name?


Re: ThinkPad X220 volume buttons

Reply #6
@SGOrava yup, that was it! Thanks a lot.  Although it only solved the volume and mute buttons issue, the "disable mic" button still doesn't respond and its orange led is always turned on. Any suggestion? :)

Re: ThinkPad X220 volume buttons

Reply #7
To be honest I do not know why the button with led is misbehaving.

Re: ThinkPad X220 volume buttons

Reply #8
I finally figured this out.

I added these lines in config.def.h in my dwm folder under /* appearence */:

Code: [Select]
static const char *mutemic[] = {"/usr/bin/pactl", "set-source-mute", "@DEFAULT_SOURCE@", "toggle", NULL };
static const char *upvol[] = {"/usr/bin/pactl", "set-sink-volume", "0", "+5%", NULL };
static const char *downvol[] = {"/usr/bin/pactl", "set-sink-volume", "0", "-5%", NULL };
static const char *mutevol[] = {"/usr/bin/pactl", "set-sink-mute", "0", "toggle", NULL };

And then, under /* commands */:
Code: [Select]
{ 0, XF86XK_AudioMicMute, spawn, {.v = mutemic } },
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol} },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevol } },

And each button just works as intended! Marking this as solved, hoping that it'll be useful to someone else. Thanks everyone!

Re: [SOLVED] ThinkPad X220 volume buttons

Reply #9
I am having the same issue, and am completely new to linux/artix. I am having trouble finding the dwm folder. I found dwm in usr/local/bin but cannot find the directories specified above. Any insight is appreciated.  Thank you

Re: [SOLVED] ThinkPad X220 volume buttons

Reply #10
I am having the same issue, and am completely new to linux/artix. I am having trouble finding the dwm folder. I found dwm in usr/local/bin but cannot find the directories specified above. Any insight is appreciated.  Thank you

Did you compile and install dwm from source or did you install it through pacman?

 

Re: [SOLVED] ThinkPad X220 volume buttons

Reply #11
Looking at the larbs script, appears to be through pacman. Appreciate the response.