Bug 462117

Summary: Add DBus function to adjust volume directly
Product: [Applications] kmix Reporter: em2cEYhqFfLon
Component: generalAssignee: Christian Esken <esken>
Status: RESOLVED WORKSFORME    
Severity: wishlist CC: jjm
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description em2cEYhqFfLon 2022-11-22 08:26:37 UTC
SUMMARY

Hello KMix developers,

Currently there are some functions for adjusting volumes, as described here: https://userbase.kde.org/KDE_Connect/Tutorials/Useful_commands#Volume_control

However, I need to set volume to a specific level, such as 50%, 30%... For current supported functions, I need to do these:

- In GUI settings, set step to 5%.
- Call `decrease_volume` 20 times, to make sure it reaches 0%.
- Then, for a specific level, calculate number of calls, and call `increase_volume`. For example, to make 50%, call it 10 times.

In my use case, I want to set my volume to 20% at 9 p.m, and set it to 50% at 6 a.m. A cron job does that. But it's really inconvenient.

Thank you,
Comment 1 Jonathan Marten 2023-06-10 13:03:19 UTC
There is already a DBus interface to set the absolute volume of any channel.  It is not obvious how to set a read/write value via qdbusviewer (use "Set value" in the context menu) but it can be accessed via the command line, for example:

# read the current absolute volume
$ qdbus org.kde.kmix /Mixers/ALSA__HDA_ATI_SB_1/Master_0 absoluteVolume
27
# ses the current absolute volume
$ qdbus org.kde.kmix /Mixers/ALSA__HDA_ATI_SB_1/Master_0 absoluteVolume 16
# read the max/min values if required to calculate from/to a percentage
$ qdbus org.kde.kmix /Mixers/ALSA__HDA_ATI_SB_1/Master_0 absoluteVolumeMax
31
$ qdbus org.kde.kmix /Mixers/ALSA__HDA_ATI_SB_1/Master_0 absoluteVolumeMin
0

You can also read the current master card and control if you don't have them already (replace all colons in the control name with underscores to derive the DBus path used above):

$ qdbus org.kde.kmix /Mixers currentMasterMixer
ALSA::HDA_ATI_SB:1
$ qdbus org.kde.kmix /Mixers currentMasterControl
Master:0
Comment 2 em2cEYhqFfLon 2023-08-11 07:12:49 UTC
(In reply to Jonathan Marten from comment #1)
> There is already a DBus interface to set the absolute volume of any channel.
> It is not obvious how to set a read/write value via qdbusviewer (use "Set
> value" in the context menu) but it can be accessed via the command line, for
> example:
> 
> # read the current absolute volume
> $ qdbus org.kde.kmix /Mixers/ALSA__HDA_ATI_SB_1/Master_0 absoluteVolume
> 27
> # ses the current absolute volume
> $ qdbus org.kde.kmix /Mixers/ALSA__HDA_ATI_SB_1/Master_0 absoluteVolume 16
> # read the max/min values if required to calculate from/to a percentage
> $ qdbus org.kde.kmix /Mixers/ALSA__HDA_ATI_SB_1/Master_0 absoluteVolumeMax
> 31
> $ qdbus org.kde.kmix /Mixers/ALSA__HDA_ATI_SB_1/Master_0 absoluteVolumeMin
> 0
> 
> You can also read the current master card and control if you don't have them
> already (replace all colons in the control name with underscores to derive
> the DBus path used above):
> 
> $ qdbus org.kde.kmix /Mixers currentMasterMixer
> ALSA::HDA_ATI_SB:1
> $ qdbus org.kde.kmix /Mixers currentMasterControl
> Master:0

Thank you very much Mr.,