I recently got into XMonad and unforunately I don't know much Haskell at all. I'm trying to configure my xmonad.hs file such that I can control the volume. However, right now, even though my xmonad.hs file compiles without errors, I cannot control the volume.
I got the volume control code from this link:http://dmwit.com/volume/
Here is my configuration file:
import XMonad
import XMonad.Util.Run(spawnPipe)
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Actions.Volume
import XMonad.Util.Dzen
import Data.Map (fromList)
import Data.Monoid (mappend)
import System.IO
alert = dzenConfig centered . show . round
centered =
onCurr (center 150 66)
>=> font "-*-helvetica-*-r-*-*-64-*-*-*-*-*-*-*"
>=> addArgs ["-fg", "#80c0ff"]
>=> addArgs ["-bg", "#000040"]
main = do
xmproc <- spawnPipe "xmobar /home/david/.xmobarrc"
xmonad $ defaultConfig
{
manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask
, keys =
keys defaultConfig `mappend`
\c -> fromList [
((0, xK_F6), lowerVolume 4 >>= alert),
((0, xK_F7), raiseVolume 4 >>= alert)
]
}
I have changed my code the following, however the volume has not changed:
main = do
xmproc <- spawnPipe "xmobar /home/luren/.xmobarrc"
xmonad $ defaultConfig
{
manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask
, keys =
keys defaultConfig `mappend`
\c -> fromList [
((0, 0x1008FF11), spawn "amixer -D pulse sset Master 4-"),
((0, 0x1008FF13), spawn "amixer -D pulse sset Master 4+")
]
}
(END)
Those keys are the codes for the volume media keys on my laptop.
I snooped around and saw some other configurations. I decided to do a little test and make the audio lower volume key print Hi ppl! when pressed. Unfortunately, this does not work.
main = do
xmproc <- spawnPipe "xmobar /home/luren/.xmobarrc"
xmonad $ defaultConfig
{
manageHook = manageDocks <+> manageHook defaultConfig
, layoutHook = avoidStruts $ layoutHook defaultConfig
, logHook = dynamicLogWithPP xmobarPP
{ ppOutput = hPutStrLn xmproc
, ppTitle = xmobarColor "green" "" . shorten 50
}
, modMask = mod4Mask
}
`additionalKeys`
[
((0, xF86XK_AudioLowerVolume), spawn "echo 'Hi ppl!'"),
((0, xF86XK_AudioRaiseVolume), spawn "amixer -D pulse sset Master 15%+")
]
amixer
has changed in an incompatible way since then. (I've moved from ALSA to pulse.) But, to check: if you bind some key togetVolume >>= alert
, does it show the correct answer? Does changing volumes on the command line withamixer
change your volume? What channel inalsamixer
(if any) actually controls your volume correctly? – Daniel Wagneramixer
command line by hand). You have a couple choices: copy the code from the module and fix it (the work of 10 seconds, but not usable by others); patchxmonad-extras
to add this functionality (a bit more work, but I will happily include your patch, and others will be able to benefit); usepacmd
instead of touchingamixer
at all (much more work if you want an on-screen volume display after you change it). Which do you want to hear more about? – Daniel Wagner-D pulse
in theamixer
command line should be very, very easy -- just copy the module and look for all instances ofamixer
and change them. You can callamixer
directly if you like; but then you might as well callpacmd
, since presumablyamixer -D pulse
means you are using pulseaudio. I'm happy to talk about either approach. – Daniel Wagner