1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-09 23:15:38 -05:00

add brightness and micmute OSDs, fix audio tab bug

This commit is contained in:
bbedward
2025-08-06 17:33:12 -04:00
parent 6b74d109dc
commit abed2e1e3c
9 changed files with 420 additions and 8 deletions

View File

@@ -13,6 +13,7 @@ Singleton {
readonly property PwNode source: Pipewire.defaultAudioSource
signal volumeChanged()
signal micMuteChanged()
function displayName(node) {
if (!node) return ""
@@ -137,7 +138,9 @@ Singleton {
}
function mute(): string {
return root.toggleMute();
const result = root.toggleMute();
root.volumeChanged();
return result;
}
function setmic(percentage: string): string {
@@ -145,7 +148,9 @@ Singleton {
}
function micmute(): string {
return root.toggleMicMute();
const result = root.toggleMicMute();
root.micMuteChanged();
return result;
}
function status(): string {

View File

@@ -16,7 +16,9 @@ Singleton {
property int currentRawBrightness: 0
property bool brightnessInitialized: false
function setBrightness(percentage) {
signal brightnessChanged()
function setBrightnessInternal(percentage) {
brightnessLevel = Math.max(1, Math.min(100, percentage));
if (laptopBacklightAvailable) {
@@ -28,6 +30,11 @@ Singleton {
}
}
function setBrightness(percentage) {
setBrightnessInternal(percentage);
brightnessChanged();
}
Component.onCompleted: {
ddcAvailabilityChecker.running = true;
laptopBacklightChecker.running = true;
@@ -143,4 +150,51 @@ Singleton {
}
}
}
// IPC Handler for external control
IpcHandler {
target: "brightness"
function set(percentage: string): string {
if (!root.brightnessAvailable) {
return "Brightness control not available";
}
const value = parseInt(percentage);
const clampedValue = Math.max(1, Math.min(100, value));
root.setBrightness(clampedValue);
return "Brightness set to " + clampedValue + "%";
}
function increment(step: string): string {
if (!root.brightnessAvailable) {
return "Brightness control not available";
}
const currentLevel = root.brightnessLevel;
const newLevel = Math.max(1, Math.min(100, currentLevel + parseInt(step || "10")));
root.setBrightness(newLevel);
return "Brightness increased to " + newLevel + "%";
}
function decrement(step: string): string {
if (!root.brightnessAvailable) {
return "Brightness control not available";
}
const currentLevel = root.brightnessLevel;
const newLevel = Math.max(1, Math.min(100, currentLevel - parseInt(step || "10")));
root.setBrightness(newLevel);
return "Brightness decreased to " + newLevel + "%";
}
function status(): string {
if (!root.brightnessAvailable) {
return "Brightness control not available";
}
return "Brightness: " + root.brightnessLevel + "% (" +
(root.laptopBacklightAvailable ? "laptop backlight" : "DDC") + ")";
}
}
}