How do I auto set different volume levels for different devices?

How do I set, for example, 50% volume for speakers, but then automatically raise to 100% volume when a headset is connected?

Using Plasma 6.0.5

Perhaps with a keyboard shortcut you could do a dirty fix.

I have mine mapped with Vol+ and Vol-.
I also have KAlarm adjust my volume for morning/alarms etc.

amixer -q set Master 100%;
amixer | rg 'Front Left: Playback' | cut -c 15-

This will set, then display, volume at 100%.

So instead of Vol+ you should set a new shortcut for AltVol+

Then instead of Vol-, you should define your ‘low’ volume (mine is 30% for quiet speakers) and map that to another.

Depending on the keyboard, you could use any key for this - remember, there’s not only Ctrl, Alt, but also Meta, Shift, and combinations…

So then you’d press your shortcut before switching. I’m not sure how to do this automatically…

I think udev rules are an answer, though I didn’t try this:


# Get the current card number and device number
card=$(aplay -l | grep -oP '(?<=card )\d')
device=$(aplay -l | grep -oP '(?<=device )\d')

# Create a udev rule file for headphone connection
echo 'SUBSYSTEM=="input", KERNEL=="event[0-9]*", ACTION=="add", ATTRS{name}=="*Headphone*", RUN+="/usr/bin/amixer -c '$card' -q sset Master 100%"' | sudo tee /etc/udev/rules.d/99-headphones-connect.rules > /dev/null

# Create a udev rule file for headphone disconnection
echo 'SUBSYSTEM=="input", KERNEL=="event[0-9]*", ACTION=="remove", ATTRS{name}=="*Headphone*", RUN+="/usr/bin/amixer -c '$card' -q sset Master 50%"' | sudo tee /etc/udev/rules.d/99-headphones-disconnect.rules > /dev/null

# Reload udev rules
sudo udevadm control --reload-rules
sudo udevadm trigger

Replace "*Headphone*" with the actual name of your headphone device. You can find this by looking at the output of cat /proc/asound/cards or aplay -l when your headphones are connected.

Hopefully some proper clever person can give us a clue… and it will depend greatly on what devices are and how they connect.

For my case, with Bluetooth headphones, the volume levels are not changed - so if I set my volume to 100%, and LINE OUT at 50%, the values persist without doing anything… The level of amplification for the speakers is set on my amplifier.

1 Like

- select sound device with F6
- raise PCM volume to full (or 84% to avoid distortion)

1 Like

Is amixer -q set Master 100% not simpler for a ‘dirty’ fix?

OP actually asked about AUTOMATIC - and for that, Udev is the way to go

However, it seems OP has abandoned the thread…

1 Like

So there’s not a default/vanilla solution for it on Plasma itself?

I cannot say, as I have no wired headphones to test, my audio goes via LINE OUT or Bluetooth and I don’t face this issue.

I always assumed that volume set for specific devices would be remembered…

My amplifier is actually wired, but has bluetooth - if I switch to connect via bluetooth, the volume can be set to 100%.

When I disconnect Bluetooth, it goes back to 50% which is my normal listening volume.

When I switch devices, this is the case:

Via bluetooth, my Class-D amplifier has a completely separate volume level, labelled ‘Headset’ which has persistent volume - so connecting that way .

My headphones show up as T.Monitor, and they also have their own volume which persists… so it’s the same if they’re reconnected and my LINE OUT level is still set at 50% so that nobody gets a shock when they’re disconnected and the system switches back to the default (LINE OUT).

1 Like

you can just use the volume icon in the system tray… but alsamixer gives you pcm control which i found no dial for in plasma.

Safe to assume there’s no native solution, so I added to the wishlist. (488214)

Most likely you’re on a setup where the headphones and speakers share the same sink? (img 1) When they are split it works as @ben2talk describes, they show as separate devices with their own volumes. (img 2)



To split them into separate sinks you can try a guide I wrote GitHub - luisbocanegra/linux-guide-split-audio-ports: Split jack(headphones)/speakers outputs into individual sinks on Linux to allow simultaneous playback (listen to different audio streams on each port)