LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-20-2021, 12:24 PM   #1
NuttyJamie
LQ Newbie
 
Registered: Nov 2020
Location: South Korea
Distribution: Linuxfromscratch, Slackware 15
Posts: 20

Rep: Reputation: 0
Do I need to install an additional program to make multimedia keys available?


Hello all!
I was confused whether to post this question on the software forum or on the hardware forum and finally decided to post it here. So please forgive me if my decision is wrong.

I'm using Slackware64-current on Thinkpad T420 which has several multimedia key.
I have confirmed that these multimedia keys work well with KDE plasma or M$ Windows 10. I mean it's not broken.
But I want to use suckless's dwm, so I searched a lot and found some ways.

Since I had used xmodmap briefly before, I ran xev to modify the keycode. And pushed the mute button, then:
Code:
$ xev
...
KeyRelease event, serial 32, synthetic NO, window 0x4c00001,
    root 0x57a, subw 0x0, time 4661262, (584,345), root:(586,365),
    state 0x0, keycode 121 (keysym 0x1008ff12, XF86AudioMute), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False
The correct keysym was already specified.

Pasting "keycode 121 = XF86AudioMute" to ~/.Xmodmap and running "xmodmap ~/.Xmodmap" was nothing happend. No change. No error.

I also read about acpi, so I ran acpi_listen, then pushed those volume control keys, the results were as follows.
Code:
$ acpi_listen 
button/mute MUTE 00000080 00000000 K
button/volumedown VOLDN 00000080 00000000 K
button/volumeup VOLUP 00000080 00000000 K
button/f20 F20 00000080 00000000 K
^C
Isn't it being recognized? Or is there something wrong with it?
Should I install a program called xbindkey from Slackbuilds?

And I use the Colemak layout, can this be a hint for solving the problem?
Here's my .xinitrc:
Code:
$ cat ~/.xinitrc
#!/bin/sh

#Enable colemak layout
#https://colemak.com/Unix
setxkbmap us -variant colemak && xset r 66

#Change Caps_Lock(Backspace in colemak) to Ctrl
setxkbmap -option ctrl:nocaps

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
  xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
  xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
  xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
  xmodmap $usermodmap
fi

ibus-daemon &

export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus
export XIM_PROGRAM=/usr/bin/ibus

#Start X Window Manager
exec dwm
It is so uncomfortable to leave the spare terminal on and adjust the volume with the alsamixer every time.
Feel free to let me know if you need any information to solve the problem. I'll do my best to cooperate. Thank you for any help.
 
Old 02-20-2021, 01:05 PM   #2
nivieru
Member
 
Registered: Feb 2008
Posts: 78

Rep: Reputation: 14
I don't know how you do it in suckless, but using i3wm I need to tell i3 what to do with these keys. In i3 config file I have:
Code:
bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -q set Master 5%+ unmute && pkill -SIGRTMIN+10 i3blocks && paplay /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga
bindsym XF86AudioLowerVolume exec --no-startup-id amixer -q set Master 5%- unmute && pkill -SIGRTMIN+10 i3blocks && paplay /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga
bindsym XF86AudioMute exec --no-startup-id amixer -q set Master toggle && pkill -SIGRTMIN+10 i3blocks && paplay /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga
bindsym Shift+XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && pkill -SIGRTMIN+10 i3blocks && paplay /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga
bindsym Shift+XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && pkill -SIGRTMIN+10 i3blocks && paplay /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga
bindsym Shift+XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && pkill -SIGRTMIN+10 i3blocks && paplay /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga
You can see here two ways to do volume up and down - using amixer and using pactl. I added the ones with pactl because it goes above 100% which is useful when the volume is low. I don't remember why I have two versions for mute as well. The
Code:
&& pkill -SIGRTMIN+10 i3blocks
parts are to signal the change to i3bar to update the display, so probably not relevant for you, and the
Code:
&& paplay ...
is to play a sound when changing volume.
 
1 members found this post helpful.
Old 02-20-2021, 01:11 PM   #3
xor_ebx_ebx
Member
 
Registered: Mar 2019
Location: USA
Distribution: Slackware
Posts: 44

Rep: Reputation: Disabled
I don't actually use dwm, but IIRC it doesn't bind these keys by default and you're supposed to edit its source and re-compile to do so. From the Gentoo wiki (note that "re-emerge" involves recompiling)

You could also set up something like Xbindkeys
 
1 members found this post helpful.
Old 02-20-2021, 01:21 PM   #4
NuttyJamie
LQ Newbie
 
Registered: Nov 2020
Location: South Korea
Distribution: Linuxfromscratch, Slackware 15
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by nivieru View Post
I don't know how you do it in suckless, but using i3wm I need to tell i3 what to do with these keys.
...
Oh, Then is the dwm blocking the communication between me and the kernel? I don't know what to do right now, but I think it will be an important clue. I'll find a way to apply it to the dwm. Thank you very much.
 
Old 02-20-2021, 01:29 PM   #5
NuttyJamie
LQ Newbie
 
Registered: Nov 2020
Location: South Korea
Distribution: Linuxfromscratch, Slackware 15
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by xor_ebx_ebx View Post
I don't actually use dwm, but IIRC it doesn't bind these keys by default and you're supposed to edit its source and re-compile to do so. From the Gentoo wiki (note that "re-emerge" involves recompiling)

You could also set up something like Xbindkeys
Oh, those lovely Gentoo guys.
Thank you so much. I think the problem is almost solved.
It's late at night here, so I'll try tomorrow and report my progress.

Last edited by NuttyJamie; 02-20-2021 at 01:31 PM.
 
Old 02-20-2021, 01:43 PM   #6
Loomx
Member
 
Registered: Sep 2012
Distribution: Slackware
Posts: 184

Rep: Reputation: Disabled
Have a look in the dwm file config.def.h for how it links keys to actions. There are a couple of ways to do it.

Here is the normal way; you add the command then you add the key(s) to call it:
Code:
/* commands */
...
static const char *mutecmd[]      = { "amixer", "-D", "pulse", "-q", "set", "Master", "toggle", NULL };
...
static Key keys[] = {
...
        { 0,                   0x1008ff12,                spawn,          {.v = mutecmd } },
...
You can also use the SHCMD macro if you need to do something more complicated, e.g. a pipeline to parse output.
Here is an example from mine using the SHCMD macro which keeps the volume level in a /tmp/volume file which my status bar reads:
Code:
        { 0,                   0x1008ff11,                spawn,          SHCMD("amixer -D pulse set Master 5%- unmute | awk -F [][] 'END { print $2 }' >/tmp/volume") },
        { 0,                   0x1008ff13,                spawn,          SHCMD("amixer -D pulse set Master 5%+ unmute | awk -F [][] 'END { print $2 }' >/tmp/volume") },
Note that I have used the keysym instead of the key name for some reason, I can't remember why...
Also see the (quite old) tutorial in my signature.
 
1 members found this post helpful.
Old 02-20-2021, 02:19 PM   #7
NuttyJamie
LQ Newbie
 
Registered: Nov 2020
Location: South Korea
Distribution: Linuxfromscratch, Slackware 15
Posts: 20

Original Poster
Rep: Reputation: 0
I was just too curious about the results, so I kicked out the duvet and then just re-compiled the config.h source as I saw on Gentoo Wiki a few minutes ago, and it worked out perfectly.
Thank you so much, nivieru, xor_ebx_ebx, and Loomx. Thank you so much Gentoo guys.

Quote:
Originally Posted by Loomx View Post
Have a look in the dwm file config.def.h for how it links keys to actions. There are a couple of ways to do it.
...
Also see the (quite old) tutorial in my signature.
Not only did I get the idea I needed to solve the problem, I could even learn how to apply it in a complex way.
Thank you again
 
  


Reply

Tags
volume control, xmodmap



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
If web browsers are multimedia programs, why don't they have multimedia controls? hedron General 4 11-04-2020 03:48 AM
[SOLVED] How to make multimedia keys useful in KDE javascriptninja Linux - Desktop 5 02-13-2012 10:40 AM
How to download entire multimedia repository from debian-multimedia amrtuti Debian 4 02-20-2009 09:28 AM
LXer: Become a multimedia pro with the Vector Linux Multimedia Bonus Disc LXer Syndicated Linux News 0 10-08-2008 06:10 AM
Multimedia Keyboard, additional buttons don't work nykey Slackware 2 07-17-2006 11:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 02:01 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration