At Tue, 24 Apr 2012 03:22:01 -0300,
Diogo F. S. Ramos wrote:
> 
> I've been using a *very* primitive code to interact with pulseaudio and
> I decided to pack it as a "module" [0].
> 
> This way, I can create symbols outside stumpwm package.
> 
> Unfortunately, by doing all this, I couldn't directly access a function
> called `bar', which is not exported by stumpwm, so I had to use `::'. It
> looks like a good symbol to export to me.

stumpwm export list is IMHO stale, and its impossible to extend it
well without using internal symbols, so I see absolutely no problem with that.
> 
> Also, because the procedure `define-key' only accepts commands, to make
> the life of the user easier, I decided to define three of them. To do
> it, I had to use `(in-package #:stumpwm)' inside my package. I don't
> know if this is OK or not.

Same as above, OK in my book, but I'm just a user like you not a
maintainer :-)

For whatever its worth, I had the same hack for over a year, rather
then go all lispy I thrown together a zsh script.. IMHO it is
extremely useful to have an "input" parameter that chooses input based
on name. This way I have bound super-W and super-R to control amarok
volume, s-S and s-F to control master volume, and s-X and s-V to
control Alsa volume, which is what firefox/chrome uses.

My script is attached, example usage:

pavol master +1
pavol Amarok -5
pavol ALSA +5

#!/bin/zsh

emulate -L zsh

local input_num index vol new_vol cur found voln setcmd

if [[ -z $1 ]] ; then
    print "Usage: pavol <input-number> [[+|-]<volume percent>"
    return 0
fi

input_num=$1
new_vol=$2

index=
vol=
cur=1

if [[ $input_num != master ]] ; then
    pacmd list-sink-inputs | while read one two three ; do
        case $one ; in
            (index:)
                index=$two
                ;;
            (volume:)
                vol=${three%%%*}
                ;;
            (application.name)
                if [[ $three == *${input_num}* ]] ; then
                    found=1
                    break
                fi
            ;;
        esac
    done
    setcmd=set-sink-input-volume
else
    pacmd list-sinks | while read one two three four ; do
        case $one ; in
            (volume:)
                vol=${three%*%}
                ;;
        esac
        if [[ -n $vol ]] ; then
            found=1
            break
        fi
    done
    setcmd=set-sink-volume
    index=0
fi

if [[ $found == 1 ]] ; then
    integer voln

    (( voln = vol*(65535/100)))
    if [[ -n $new_vol ]] ; then
        if [[ $new_vol[1] == '+' ]] ; then
            (( voln = voln + (new_vol[2,-1] * 65536/100)))
        elif [[ $new_vol[1] == '-' ]] ; then
            (( voln = voln - (new_vol[2,-1] * 65536/100)))
        else
            (( voln = new_vol * (65536/100)))
        fi
        if [[ $voln -gt 65535 ]] ; then
            voln=65535
        fi
        if [[ $voln -lt 0 ]] ; then
            voln=0
        fi
        print "Running pacmd $setcmd $index $voln"
        pacmd $setcmd $index $voln >/dev/null 2>&1
    fi
    print "$vol"
else
    print "Not found"
fi

_______________________________________________
Stumpwm-devel mailing list
Stumpwm-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/stumpwm-devel

Reply via email to