this post was submitted on 08 Sep 2024
51 points (98.1% liked)

Linux

48328 readers
659 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

I sometimes play games and also open my music player, but the sound from the game drowns out the music, so I need to go into the sound mixer on KDE and manually lower the game's volume every time.
I was wondering, is there a way to do this process automatically? As in setting up conditions like "if music is playing (some MPRIS API?) then lower all other apps' volumes)", maybe even crazier "if some app is outputting voice then set its volume back up and lower music app's volume or pause its playback altogether for some specified timeout that keeps being refreshed for as long as voice is heard".
I imagine the latter is a bit of a dream, but maybe for the first, even some quick sound profile selector would go a long way, say switching from "normal profile" to "background music profile", etc. which specify preconfigured volumes for those apps.
Is that a thing?

you are viewing a single comment's thread
view the rest of the comments
[–] tetris11@lemmy.ml 4 points 2 months ago* (last edited 2 months ago)

Pulseaudio should have hooks

# cat /etc/pulse/default.pa
load-module module-switch-on-connect
load-module module-exec
load-module module-exec arguments="path/to/your/script.sh %s"    

(where %s resolves on trigger to the name of the sink added)

Your script.sh should then match the first argument to the name of the sink you want to control, and then run

# path/to/your/script.sh
if [ "$1" = "THESINKIWANT" ]; then
  pactl set-sink-volume $1 40%
fi