SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-01-03 04:42:21

ShazbotMcNasty
Member
Registered: 2009-05-07
Posts: 11

How to bind volume keys with xbindkeys

1 - Installed xbindkeys and its gui configuration utility:
sudo apt-get install xbindkeys xbindkeys-config

2 - Execute this:
xbindkeys --defaults > ~/.xbindkeysrc

3 - Run xbindkeys and xbindkeys-config
xbindkeys
xbindkeys-config

4 - Press the button "New" to create a new keybinding, and on the right, you can name it, choose what key to use (use the Get Key button then press the combination of keys you want, and it will capture it for you), and choose the command to run.

Here are the basic ones: substitute "Master" with "PCM" if needed, or others

Name: Mute
Action: amixer sset Master toggle

Name: Increase volume
Action: amixer sset Master  1+ unmute

Name: Decrease volume
Action: amixer sset Master 1- unmute

5 - File -> Save to default File

6 - Add "xbindkeys &" to your autostart.sh so it always runs when you start up.

And that's it.

Last edited by ShazbotMcNasty (2010-07-14 21:01:24)


Yup....

Offline

Be excellent to each other!

#2 2010-01-03 12:09:27

ADcomp
Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 600
Website

Re: How to bind volume keys with xbindkeys

Hello,

why do you use xbindkeys when you can do the same thing in your rc.xml with openbox ?

I use something like this :

    <keybind key="W-Up">
      <action name="Execute">
        <execute>aumix -v +10</execute>
      </action>
    </keybind>

    <keybind key="W-Down">
      <action name="Execute">
        <execute>aumix -v -10</execute>
      </action>
    </keybind>

David [aka] ADcomp

Offline

#3 2010-01-04 15:28:13

jk26926
Member
Registered: 2008-12-12
Posts: 32

Re: How to bind volume keys with xbindkeys

some of us still like the GUI. I personally have borked my machine more than once by missing a keystroke while editing a .xml. Sure I backed up the file and was able to un-break it but not every one is that good from the command line.

Offline

#4 2010-01-04 15:33:04

ADcomp
Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 600
Website

Re: How to bind volume keys with xbindkeys

Hello jk26926,

I have a question .. What happen if you use a key bind with xbindkeys that is already in your rc.xml ?

and for keybind / openbox , you have obkey ( but I never use it .. )

Last edited by ADcomp (2010-01-04 15:34:38)


David [aka] ADcomp

Offline

#5 2010-01-04 16:27:41

paulsenior
#! CrunchBanger
From: Muenster, Germany
Registered: 2009-02-12
Posts: 100

Re: How to bind volume keys with xbindkeys

Hello there, did you tried

xbindkeys -k

?

That works very well, and then you just have to edit it into your xbindkeysrc
The result maybe looks something like this:

  "no command"
      m:0x10 + c:122
      NoSymbol

And now just edit it with your commands:

  "amixer sset toggle"
      m:0x10 + c:122
      NoSymbol

@ADcomp:
On my machine it starts both keybinds(from rc.xml and xbindkeysrc), veryusefull sometimes wink

Last edited by paulsenior (2010-01-04 16:29:09)


From Germany --> Bad English smile

Offline

#6 2010-01-04 16:43:14

ADcomp
Python Script Master
From: Belgium
Registered: 2008-12-22
Posts: 600
Website

Re: How to bind volume keys with xbindkeys

@ paulsenior :  ok .. Thanks  smile


David [aka] ADcomp

Offline

#7 2011-02-17 12:22:03

bozhkov
#! Junkie
Registered: 2009-12-29
Posts: 463

Re: How to bind volume keys with xbindkeys

Hello, xbindkeys is going away with segmentation fault if i try to specifi a key combination, also xev doesnt seems to be affected if I press the Fn key. How can I know whether its working?

Offline

#8 2011-10-09 13:51:39

bootstrap
Member
Registered: 2011-10-04
Posts: 29
Website

Re: How to bind volume keys with xbindkeys

ShazbotMcNasty wrote:

1 - Installed xbindkeys and its gui configuration utility:
sudo apt-get install xbindkeys xbindkeys-config

2 - Execute this:
xbindkeys --defaults > ~/.xbindkeysrc

3 - Run xbindkeys and xbindkeys-config
xbindkeys
xbindkeys-config

4 - Press the button "New" to create a new keybinding, and on the right, you can name it, choose what key to use (use the Get Key button then press the combination of keys you want, and it will capture it for you), and choose the command to run.

Here are the basic ones: substitute "Master" with "PCM" if needed, or others

Name: Mute
Action: amixer sset Master toggle

Name: Increase volume
Action: amixer sset Master  1+ unmute

Name: Decrease volume
Action: amixer sset Master 1- unmute

5 - File -> Save to default File

6 - Add "xbindkeys &" to your autostart.sh so it always runs when you start up.

And that's it.

Worked a treat for me. I have a Lenovo T61 laptop. After my switch to CrunchBang, the machine lost volume control with the "Mute", "Vol Down" and "Vol Down" buttons found on the top left, next to the Esc key. So for a few days, I was adjusting sound volume by moving the cursor on the volume icon on the task bar. I eventually got sick of doing that because I found myself habitually pressing the volume control buttons first to adjust sound volume. Thanks, ShazbotMcNasty! smile

Offline

#9 2011-10-09 14:49:29

thevdude
#! Junkie
From: Pittsburgh, PA
Registered: 2011-09-01
Posts: 469

Re: How to bind volume keys with xbindkeys

bozhkov wrote:

Hello, xbindkeys is going away with segmentation fault if i try to specifi a key combination, also xev doesnt seems to be affected if I press the Fn key. How can I know whether its working?

fn key alone doesn't do anything in XEV, use one of the fn keys on the keyboard and it'll show something from XEV. (My keyboard has volume up as fn + uparrow, so I have to hit that combo for xev to show)

Offline

#10 2011-10-25 01:40:49

Kevins4
Member
Registered: 2011-09-30
Posts: 24

Re: How to bind volume keys with xbindkeys

Thanks ShazbotMcNasty, et. al.  Been wanting to get volume working.

Can I please get some direction on where to look for other key actions, e.g. fn + [number keys] on my Dell D610 laptop?  Work with quite a few spreadsheets and would be faster with num_keys for data entry.

Thanks


sum ergo cogito ( i am therefore i think )

Offline

#11 2013-10-23 07:48:21

He_!
Member
Registered: 2013-05-19
Posts: 31

Re: How to bind volume keys with xbindkeys

With the help of  this trick, I was able to workaround a minor annoyance i had with the existing volume notification.
To me, the volume slide display stays too long on the screen after i adjust the volume so I often find myself closing this notification. I really tried to find out how to shorten the delay before automatic closing but failed to do so.

So, I disassociated the volume keyboard volume keys from alsa preferences via the volume icon and used xbindkeys instead to assign the volume keys to something else.

By itself, just using amixer sset Master  1%+/- unmute changes the volume but does not completely show any indication on the screen. So, I prepared a pair of scripts that at least shows me what the volume is while adjusting.

This one is for the volume UP button:

#!/bin/bash

pkill -15 xfce4-notifyd;

VOLUMENOW=`amixer get Master | grep "Front Left:" | awk '{print $5}'`

amixer sset Master 3%+ unmute;
 
#notify-send "$VOLUMENOW";

notify-send -i /usr/share/icons/elementaryXubuntu-dark/notifications/48/audio-volume-medium.svg Vol "<b>$VOLUMENOW</b>";


sleep 2;
pkill -15 xfce4-notifyd;

This is how it looks like:

changed volume notification

Last edited by He_! (2013-10-25 15:02:00)

Offline

#12 2013-10-23 11:55:25

He_!
Member
Registered: 2013-05-19
Posts: 31

Re: How to bind volume keys with xbindkeys

I just found that instead of using

 amixer sset Master 3%+ unmute 

this can be used instead:

pactl set-sink-volume 0 +3%

Its advantage and disadvantage is that it does not stop increasing at 100%

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo