I often use a headset, to select if using the headset or the normal soundcard I use a environment variable thanks to this code in ~/.asound.rc:
@args.CARD {
type string
default {
@func getenv
vars {
0 ALSA_CARD
}
default {
@func refer
name 'defaults.pcm.card'
}
}
}
Unfortunately the new headset (hw:Set) has reversed channels so I created a pcm to fix, adding those lines to ~/.asoundrc:
pcm.swapped {
type route
slave {
pcm "hw:Set"
}
ttable.0.1 1
ttable.1.0 1
}
pcm.HeadsetSwapped {
type plug
slave {
pcm "pcm.swapped"
}
}
The pcm works, but how can I decide to use it via environment variable? At the moment the env variable only accepts card names. It is probably something around the -- name 'defaults.pcm.card' -- line, but I cannot fix it.
I know I can change pcm.HeadsetSwapped to pcm.!default, but I would like to avoid to edit the file each time I want to start a program...