Merge branch 'main' of github.com:noctalia-dev/noctalia-shell

This commit is contained in:
LemmyCook 2025-08-28 12:22:43 -04:00
commit 8ebcfa4bc6
4 changed files with 112 additions and 0 deletions

View file

@ -99,6 +99,24 @@ Item {
}
}
IpcHandler {
target: "volume"
function increase() {
AudioService.increaseVolume()
}
function decrease() {
AudioService.decreaseVolume()
}
function muteOutput() {
AudioService.setMuted(!AudioService.muted)
}
function muteInput() {
if (AudioService.source?.ready && AudioService.source?.audio) {
AudioService.source.audio.muted = !AudioService.source.audio.muted
}
}
}
IpcHandler {
target: "powerPanel"
function toggle() {

View file

@ -81,6 +81,54 @@ ColumnLayout {
}
}
// Input Volume
ColumnLayout {
spacing: Style.marginS * scaling
Layout.fillWidth: true
Layout.topMargin: Style.marginM * scaling
NLabel {
label: "Input Volume"
description: "Microphone input volume level."
}
RowLayout {
NSlider {
Layout.fillWidth: true
from: 0
to: 1.0
value: AudioService.inputVolume
stepSize: 0.01
onMoved: {
AudioService.setInputVolume(value)
}
}
NText {
text: Math.floor(AudioService.inputVolume * 100) + "%"
Layout.alignment: Qt.AlignVCenter
Layout.leftMargin: Style.marginS * scaling
color: Color.mOnSurface
}
}
}
// Input Mute Toggle
ColumnLayout {
spacing: Style.marginS * scaling
Layout.fillWidth: true
Layout.topMargin: Style.marginM * scaling
NToggle {
label: "Mute Audio Input"
description: "Mute or unmute the default audio input (microphone)."
checked: AudioService.inputMuted
onToggled: checked => {
AudioService.setInputMuted(checked)
}
}
}
// Volume Step Size
ColumnLayout {
spacing: Style.marginS * scaling

View file

@ -194,6 +194,10 @@ The following commands apply to the Nix flake and also the AUR package installat
| Open Calculator | `noctalia-shell ipc call launcher calculator` |
| Increase Brightness | `noctalia-shell ipc call brightness increase` |
| Decrease Brightness | `noctalia-shell ipc call brightness decrease` |
| Increase Output Volume | `noctalia-shell ipc call volume increase` |
| Decrease Output Volume | `noctalia-shell ipc call volume decrease` |
| Toggle Mute Audio Output | `noctalia-shell ipc call volume muteOutput` |
| Toggle Mute Audio Input | `noctalia-shell ipc call volume muteInput` |
| Toggle Power Panel | `noctalia-shell ipc call powerPanel toggle` |
| Toggle Idle Inhibitor | `noctalia-shell ipc call idleInhibitor toggle` |
| Toggle Settings Window | `noctalia-shell ipc call settings toggle` |

View file

@ -35,6 +35,13 @@ Singleton {
readonly property alias muted: root._muted
property bool _muted: !!sink?.audio?.muted
// Input volume [0..1] is readonly from outside
readonly property alias inputVolume: root._inputVolume
property real _inputVolume: source?.audio?.volume ?? 0
readonly property alias inputMuted: root._inputMuted
property bool _inputMuted: !!source?.audio?.muted
readonly property real stepVolume: Settings.data.audio.volumeStep / 100.0
PwObjectTracker {
@ -58,6 +65,23 @@ Singleton {
}
}
Connections {
target: source?.audio ? source?.audio : null
function onVolumeChanged() {
var vol = (source?.audio.volume ?? 0)
if (isNaN(vol)) {
vol = 0
}
root._inputVolume = vol
}
function onMutedChanged() {
root._inputMuted = (source?.audio.muted ?? true)
Logger.log("AudioService", "OnInputMuteChanged:", root._inputMuted)
}
}
function increaseVolume() {
setVolume(volume + stepVolume)
}
@ -85,6 +109,24 @@ Singleton {
}
}
function setInputVolume(newVolume: real) {
if (source?.ready && source?.audio) {
// Clamp it accordingly
source.audio.muted = false
source.audio.volume = Math.max(0, Math.min(1, newVolume))
} else {
Logger.warn("AudioService", "No source available")
}
}
function setInputMuted(muted: bool) {
if (source?.ready && source?.audio) {
source.audio.muted = muted
} else {
Logger.warn("AudioService", "No source available")
}
}
function setAudioSink(newSink: PwNode): void {
Pipewire.preferredDefaultAudioSink = newSink
}