diff --git a/assets/volume-click.wav b/assets/volume-click.wav new file mode 100644 index 0000000..3247e2d Binary files /dev/null and b/assets/volume-click.wav differ diff --git a/lucidosd/Osd.qml b/lucidosd/Osd.qml index de2020f..6eef0fc 100644 --- a/lucidosd/Osd.qml +++ b/lucidosd/Osd.qml @@ -26,6 +26,8 @@ PanelWindow { property bool capsLock: false property bool numLock: false property bool kbInitialized: false + readonly property string clickSound: Qt.resolvedUrl("../assets/volume-click.wav").toString().replace("file://", "") + property double lastClickAt: 0 // m3 shape, spacing and slider metrics, shared with lucidbar/System.qml readonly property int cardPadX: 16 @@ -146,6 +148,18 @@ PanelWindow { nudgeAnim.restart(); } + // a click on every step, like the notches of a dial: each press, each + // repeat of a held key, and a drag no more often than every 35 ms, so it + // stays a ratchet rather than a buzz + function volumeClick() { + const now = Date.now(); + if (now - osdWindow.lastClickAt < 35) + return ; + + osdWindow.lastClickAt = now; + Quickshell.execDetached(["pw-play", osdWindow.clickSound]); + } + function showVolume() { osdWindow.oscType = "volume"; osdWindow.levelValue = osdWindow.volumePercent; @@ -198,7 +212,7 @@ PanelWindow { return ; if (Prefs.soundVolumeFeedback && !osdWindow.volMuted) - volumeTick.restart(); + osdWindow.volumeClick(); osdWindow.showVolume(); } @@ -230,15 +244,6 @@ PanelWindow { objects: [osdWindow.sink, osdWindow.source] } - // waits for the level to settle, so a held key or a drag ticks once at the - // end rather than in a burst - Timer { - id: volumeTick - - interval: 140 - onTriggered: Quickshell.execDetached(["paplay", "/usr/share/sounds/freedesktop/stereo/audio-volume-change.oga"]) - } - Timer { interval: 800 running: true diff --git a/lucidprefs/AudioPage.qml b/lucidprefs/AudioPage.qml index 86d9a9c..0618099 100644 --- a/lucidprefs/AudioPage.qml +++ b/lucidprefs/AudioPage.qml @@ -179,7 +179,7 @@ Column { SettingRow { title: "Play a sound when the volume changes" resetKey: "soundVolumeFeedback" - description: "A short tick once the output volume settles, from the keys, the bar or anywhere else, so you can hear the new level." + description: "A click on every step, like turning a dial, from the keys, the bar or anywhere else, so you can hear the new level." M3Switch { checked: Prefs.soundVolumeFeedback