You can use udev rules. For this, you'll need to find the device attributes that distinguish your USB headset once it is plugged in. This can be usually done in two steps:
Run udevadm monitor --udev
befor plugging the device. Then plug it in. There will be a bunch of output lines - just pick one and copy the device path from it - it is something like /devices/pci0000:00/0000:00:1d.7/usb1/1-5/1-5:1.0
.
With the headset still connected, use udevadm info --path=/your/device/path --attribute-walk
to find some attributes that distinguish your device from others (like ATTR{idVendor}
and ATTR{idProduct}
).
When you have that, you can construct a udev rule to be triggered on connecting the device. Look at the files under /etc/udev/rules.d/
for how these look like. The one you will probably be constructing will end with RUN+="some
command"
. Note that the identifiers (SUBSYSTEM=
, ATTRS=
etc.) used in such line must all come from the description of the same device - the same chunk of udevadm info --attribute-walk
output.
The second part of the task is to find amixer
settings that suits your needs for each scenario and wrap them in a command that you'll put in the RUN+=
part of udev rule. With that, I cannot help you as I don't have similar hardware.