Bug 508929 - feature suggestion: playback streams shortcuts
Summary: feature suggestion: playback streams shortcuts
Status: CONFIRMED
Alias: None
Product: plasmashell
Classification: Plasma
Component: Audio Volume widget (other bugs)
Version First Reported In: 6.4.4
Platform: Bazzite Linux
: NOR wishlist
Target Milestone: 1.0
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-30 10:34 UTC by Simon99DE
Modified: 2025-11-30 16:53 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon99DE 2025-08-30 10:34:44 UTC
I would appreciate it if I could assign a shotkey to an application under shortcuts --> application xyz to control the volume, mute/unmute, etc. via shotkeys, as with playback streams.

Why?
This would allow me to build a DIY deck that sends shotkeys, which then changes the volume for only that one application and does not change the audio globally. This would be advantageous in various areas, such as streaming, as the system is already capable of this and does not require additional software that may become incompatible due to an update.

Additional changes:
It should be possible to set somewhere what the mute button mutes. Everything, only the source used, or the default device. Unfortunately, a script is currently required for this. The same applies to the volume, either the source used or the default device.
(This is important for devices such as the Roland Bridge Cast.)


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Bazzite 42 (Desktop)
KDE Plasma Version: 6.4.4
KDE Frameworks Version: 6.17.0
Qt Version: 6.9.1

ADDITIONAL INFORMATION
Comment 1 TraceyC 2025-09-03 19:45:39 UTC
For per-app shortcuts, it's up to each application to provide them.  If an application provides the ability to set shortcuts for certain actions, the controls will appear in the app in System Settings - Shortcuts under Applications as you suggest. For instance, the strawberry music player has shortcuts for Next, Previous, Play/Pause and Stop. 

If the application you're working with doesn't provide shortcuts, you'll need to reach out to the maintainers for it to request them to add this functionality. Plasma can only allow you to create shortcuts for applications that are developed to have them.

You mention a second, separate idea to have media controls be able to affect the current stream rather than the global stream, or the default device. This might be actionable for us, I'll pass this along to the developers to see what we might be able to do there.
Comment 2 Simon99DE 2025-09-03 19:53:12 UTC
(In reply to TraceyC from comment #1)
> For per-app shortcuts, it's up to each application to provide them.  If an
> application provides the ability to set shortcuts for certain actions, the
> controls will appear in the app in System Settings - Shortcuts under
> Applications as you suggest. For instance, the strawberry music player has
> shortcuts for Next, Previous, Play/Pause and Stop. 
> 
> If the application you're working with doesn't provide shortcuts, you'll
> need to reach out to the maintainers for it to request them to add this
> functionality. Plasma can only allow you to create shortcuts for
> applications that are developed to have them.
> 
> You mention a second, separate idea to have media controls be able to affect
> the current stream rather than the global stream, or the default device.
> This might be actionable for us, I'll pass this along to the developers to
> see what we might be able to do there.

I did not mean for the applications Play/Stop etc. I just meant for one source to turn the volume up/down/mute with one button/shotcut. This is currently already a function in KDE in the settings without shotcut
Comment 3 Simon99DE 2025-11-09 09:10:14 UTC
You could also add a new command for the streams to make the audio sources louder/quieter/mute.
In that case, you should not specify the ID, which changes, but the name. It would also be good if the volume display is shown when you activate it and display above/below it (text) what/which source is currently being changed.
Comment 4 Simon99DE 2025-11-30 16:53:47 UTC
I once had a script written by ki so that I could use it as I wanted. Unfortunately, it doesn't show that I'm changing the source (on the screen, as with the global volume) and what source I'm changing (I can't get it to work).
I don't know if it's possible to create a kind of folder for shortcuts/commands and then insert, for example, 3 commands for me there, as in other apps, e.g., system settings. It's slowly becoming confusing for me with 19 commands.

I would like a command so that I no longer need the script. :)

I currently use it in combination with my 17B06E Macropad: https://github.com/Simon99de/17B06E-Macropad


app_volume_control.sh

#!/usr/bin/env bash
# Controls the volume of an application or Bluetooth device in fixed increments.

# Usage:
#    ./app_volume_control.sh <appname|device> <up|down|mute>
#
# Settings:
#    - STEP: Step size in percent (e.g., 2, 5, 10)
#    - MAX / MIN: upper/lower volume limit
#
# CLI-Tip:
#     - Find out app names:
#         pw-cli ls Node



APP="$1"
ACTION="$2"

# ------------------- Settings -------------------
STEP=2        # Step size in %
MAX=100
MIN=2
# ------------------------------------------------

if [ -z "$APP" ] || [ -z "$ACTION" ]; then
    echo "Usage: $0 <appname> <up|down|mute>"
    exit 1
fi


# Find PipeWire nodes that match the app name
find_nodes() {
    pw-cli list-objects Node | awk -v app="$APP" '
        /id [0-9]+/ {id=$2; mc=""; an=""; nd=""}
        /media.class/ {mc=$0}
        /application.name/ {an=$0}
        /node.description/ {nd=$0}
        # Apps: APP without spaces -> match application.name
        (app !~ /[ _]/) {
            if (id && index(tolower(an), tolower(app))>0 && mc ~ /Stream\/Output\/Audio/) print id
        }
        # Devices: APP with space/underscore -> match node.description
        (app ~ /[ _]/) {
            if (id && index(tolower(nd), tolower(app))>0 && mc ~ /Stream\/(Output|Input)\/Audio/) print id
        }
    ' | sort -u | tr -d ',' | tr -d ' '
}

get_volume() {
    local node="$1"
    # Extract only the first number, remove all non-numbers
    vol=$(wpctl get-volume "$node" 2>/dev/null | grep -oE '[0-9]*\.[0-9]+' | head -n1)

    # Fallback if empty
    if [[ -z "$vol" ]]; then
        vol=0
    fi

    # convert to percent
    pct=$(awk -v v="$vol" 'BEGIN { printf "%.0f", v*100 }')
    echo "$pct"
}

set_volume() {
    local node="$1"
    local percent="$2"

    if [ "$percent" -lt "$MIN" ]; then percent=$MIN; fi
    if [ "$percent" -gt "$MAX" ]; then percent=$MAX; fi

    linear=$(echo "scale=3; $percent / 100" | bc -l)
    wpctl set-volume "$node" "$linear" >/dev/null 2>&1
}

adjust_volume() {
    local node="$1"

    if [ "$ACTION" = "mute" ]; then
        wpctl set-mute "$node" toggle
        echo "Node $node: mute toggled"
        return
    fi

    current=$(get_volume "$node")

    # Jump to the next STEP
    if [ "$ACTION" = "up" ]; then
        new=$((current + STEP))
    else
        new=$((current - STEP))
    fi

    set_volume "$node" "$new"
    final=$(get_volume "$node")
    echo "Node $node Volume: ${final}%"
}

# ---------------- MAIN ----------------

NODES=$(find_nodes)

if [ -z "$NODES" ]; then
    echo "No audio nodes found for: $APP"
    exit 1
fi

echo "Nodes found: $NODES"

for N in $NODES; do
    adjust_volume "$N"
done