Skip to content

Commit 85abe5f

Browse files
committed
feat(OSD): add support for media volume
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
1 parent a49534d commit 85abe5f

7 files changed

Lines changed: 34 additions & 5 deletions

File tree

Assets/Translations/en-GB.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,8 @@
15741574
"types-lockkey-label": "Lock keys",
15751575
"types-media-description": "Show OSD when media playback state changes (play, pause, skip).",
15761576
"types-media-label": "Media playback",
1577+
"types-media-volume-description": "Show OSD when media volume changes.",
1578+
"types-media-volume-label": "Media volume",
15771579
"types-title": "OSD trigger events",
15781580
"types-volume-description": "Show OSD when audio output volume changes.",
15791581
"types-volume-label": "Output volume"

Assets/Translations/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,8 @@
15741574
"types-lockkey-label": "Lock keys",
15751575
"types-media-description": "Show OSD when media playback state changes (play, pause, skip).",
15761576
"types-media-label": "Media playback",
1577+
"types-media-volume-description": "Show OSD when media volume changes.",
1578+
"types-media-volume-label": "Media volume",
15771579
"types-title": "OSD trigger events",
15781580
"types-volume-description": "Show OSD when audio output volume changes.",
15791581
"types-volume-label": "Output volume"

Assets/settings-default.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,8 @@
478478
"enabledTypes": [
479479
0,
480480
1,
481-
2
481+
2,
482+
4
482483
],
483484
"monitors": []
484485
},

Commons/Settings.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ Singleton {
707707
property int autoHideMs: 2000
708708
property bool overlayLayer: true
709709
property real backgroundOpacity: 1.0
710-
property list<var> enabledTypes: [OSD.Type.Volume, OSD.Type.InputVolume, OSD.Type.Brightness]
710+
property list<var> enabledTypes: [OSD.Type.Volume, OSD.Type.InputVolume, OSD.Type.Brightness, OSD.Type.MediaVolume]
711711
property list<string> monitors: [] // holds osd visibility per monitor
712712
}
713713

Modules/OSD/OSD.qml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ Variants {
1919
Volume,
2020
InputVolume,
2121
Brightness,
22-
LockKey
22+
LockKey,
23+
MediaVolume
2324
}
2425

2526
model: Quickshell.screens.filter(screen => (Settings.data.osd.monitors.includes(screen.name) || Settings.data.osd.monitors.length === 0) && Settings.data.osd.enabled)
@@ -45,6 +46,7 @@ Variants {
4546
readonly property bool isMuted: AudioService.muted
4647
readonly property real currentInputVolume: AudioService.inputVolume
4748
readonly property bool isInputMuted: AudioService.inputMuted
49+
readonly property real currentMediaVolume: MediaService.volume
4850
readonly property real epsilon: 0.005
4951

5052
// LockKey OSD enabled state (reactive to settings)
@@ -72,6 +74,11 @@ Variants {
7274
return currentVolume <= 0.5 ? "volume-low" : "volume-high";
7375
case OSD.Type.InputVolume:
7476
return isInputMuted ? "microphone-off" : "microphone";
77+
case OSD.Type.MediaVolume:
78+
// Show volume-x icon when volume is effectively 0% (within rounding threshold)
79+
if (currentMediaVolume < root.epsilon)
80+
return "volume-x";
81+
return currentMediaVolume <= 0.5 ? "volume-low" : "volume-high";
7582
case OSD.Type.Brightness:
7683
// Show sun-off icon when brightness is effectively 0% (within rounding threshold)
7784
if (currentBrightness < root.epsilon)
@@ -90,6 +97,8 @@ Variants {
9097
return isMuted ? 0 : currentVolume;
9198
case OSD.Type.InputVolume:
9299
return isInputMuted ? 0 : currentInputVolume;
100+
case OSD.Type.MediaVolume:
101+
return currentMediaVolume;
93102
case OSD.Type.Brightness:
94103
return currentBrightness;
95104
case OSD.Type.LockKey:
@@ -124,7 +133,7 @@ Variants {
124133
}
125134

126135
function getProgressColor() {
127-
const isMutedState = (currentOSDType === OSD.Type.Volume && isMuted) || (currentOSDType === OSD.Type.InputVolume && isInputMuted);
136+
const isMutedState = (currentOSDType === OSD.Type.Volume && isMuted) || (currentOSDType === OSD.Type.InputVolume && isInputMuted) || (currentOSDType === OSD.Type.MediaVolume && currentMediaVolume < root.epsilon);
128137
if (isMutedState) {
129138
return Color.mError;
130139
}
@@ -150,7 +159,7 @@ Variants {
150159
}
151160

152161
function getIconColor() {
153-
const isMutedState = (currentOSDType === OSD.Type.Volume && isMuted) || (currentOSDType === OSD.Type.InputVolume && isInputMuted);
162+
const isMutedState = (currentOSDType === OSD.Type.Volume && isMuted) || (currentOSDType === OSD.Type.InputVolume && isInputMuted) || (currentOSDType === OSD.Type.MediaVolume && currentMediaVolume < root.epsilon);
154163
if (isMutedState)
155164
return Color.mError;
156165

@@ -313,6 +322,15 @@ Variants {
313322
}
314323
}
315324

325+
// MediaService monitoring
326+
Connections {
327+
target: MediaService
328+
329+
function onVolumeChanged() {
330+
showOSD(OSD.Type.MediaVolume);
331+
}
332+
}
333+
316334
// Brightness monitoring
317335
Connections {
318336
target: BrightnessService

Modules/Panels/Settings/Tabs/Osd/EventsSubTab.qml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ ColumnLayout {
3030
{
3131
type: OSD.Type.LockKey,
3232
key: "types-lockkey"
33+
},
34+
{
35+
type: OSD.Type.MediaVolume,
36+
key: "types-media-volume"
3337
}
3438
]
3539
delegate: NCheckbox {

Services/Media/MediaService.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Singleton {
4141
property bool canGoNext: currentPlayer ? currentPlayer.canGoNext : false
4242
property bool canGoPrevious: currentPlayer ? currentPlayer.canGoPrevious : false
4343
property bool canSeek: currentPlayer ? currentPlayer.canSeek : false
44+
property bool isMuted: currentPlayer ? currentPlayer.volume < root.epsilon : false
45+
property real volume: currentPlayer ? currentPlayer.volume : 0.0
4446
property string positionString: formatTime(currentPosition)
4547
property string lengthString: formatTime(trackLength)
4648
property real infiniteTrackLength: 922337203685

0 commit comments

Comments
 (0)