You are not logged in.

#1 2006-08-30 05:52:26

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Gnome volume keybindings and default mixer device [SOLVED!]

I seem to have the same problem as this guy in the Gnome support forum. I was ecstatic when I discovered that the volume control keys on my new laptop were recognized in Gnome and I set them up in the keyboard shortcuts to control the volume up/down options. The problem is that, by default, it controls "headphones." This does me no good since all of the sound goes through PCM. I can mute headphones and leave PCM and still be listening to BMP or watching something in MPlayer without a change in volume. Is there a way to disable the headphones option, via alsa or anything else, or make PCM default?

I really hesitate to post in these forums in fear that my problem(s) have been addressed over and over again. I ritualistically search and search and search.. if I can't find it here, then I trying googling for a bit. Alas, here I am without my problem solved in hopes that one of you can help. Thanks in advance.


psearch - manipulate and refine pacman searches

Offline

#2 2006-08-31 04:54:09

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Gnome volume keybindings and default mixer device [SOLVED!]

OK, I've got it somewhat working. I can't get gconf to recognize the multimedia keys, but I was able to edit the keybinding preferences in apps->metacity->global_keybindings & keybinding_commands to execute a small script I wrote when I use <Shift>F2 or <Shift>F3.

The script just uses amixer from a prompt to set the volume. Something like:

amixer -q Front 40% unmute

...and there are, of course, conditionals in the script that determine the increments at which the volume will be increased or descreased.

Now, if I can just figure out how to use the multimedia keys in gconfs value fields. The keys are detected in xev, and Gnome's keyboard shortcuts program recognizes them as "0xb0" and "0xae". Unfortunately, typing "0xb0" or "0xae" into a value field in gconf won't work. Hm.


psearch - manipulate and refine pacman searches

Offline

#3 2006-09-01 02:59:49

wrythe
Member
From: Seattle, WA
Registered: 2006-08-15
Posts: 80

Re: Gnome volume keybindings and default mixer device [SOLVED!]

OK, after this I'll stop replying to myself. 8) I just wanted to post what I ultimately came up with just in case somebody else ran into the same problem.

First of all, I opened up 'xev' to find out which keys my volume keys registered as. They ended up being 174 and 176. I then created a file in my home directory called .Xmodmap with the following lines:

keycode 174 = F13
keycode 176 = F14

Since my laptop's function keys only go up to 12, F13 and F14 are arbitrary.

Next, I opened up Gnome's Configuartion Editor then went to apps -> metacity -> global_keybindings. I changed the values of run_command_1 and run_command_10 to "vol up" and "vol down" respectively (I'll explain "vol" in a minute). Then, right underneath global_keybindings is keybinding_commands. Again, looking at command_1 and command_10, I set the values to "F13" and "F14".

Lastly, I wrote a script named vol that uses amixer to change the volume. There's a mute option in the script too which should be pretty self explanitory if you choose to use it. Here's the script:

#!/bin/bash
i=5 # percent to increase or decrease
device="Front" # audio device to be controlled

# current audio level
current=`amixer sget $device | sed -n '6,6 p' | awk '{ print $5 }' | sed 's/%]//g' | sed 's/[//g'`

function goUp { 
    #percentages can become uneven
    if [ $current -le 100 -a $current -ge 95 ]; then
        amixer -q set $device 100%
        exit
    else
        level=$[$current+$i]
        amixer -q set $device $level%
        exit
    fi
}

function goDown { 
    #percentages can become uneven
    if [ $current -le 5 -a $current -ge 0 ]; then
        amixer -q set $device 0%
        exit
    else
        level=$[$current-$i]
        amixer -q set $device $level%
        exit
    fi
}

function mute { 
    sound=`amixer sget $device | sed -n '6,6 p' | awk '{ print $NF }'`
    if [ "$sound" == "[on]" ]; then
        amixer -q set $device mute
        exit
    else
        amixer -q set $device unmute
        exit
    fi
}

case $1 in
    up) goUp ;;
    down) goDown ;;
    mute) mute;;
    *) exit ;;
esac

Hope this helps. Maybe I'll write a wiki page that's a little more comprehensible. :twisted:


psearch - manipulate and refine pacman searches

Offline

Board footer

Powered by FluxBB