ddcutil-service usage

This commit is contained in:
Zacharias-Brohn
2026-02-27 14:46:09 +01:00
parent afb736102d
commit 178375d861
9 changed files with 59 additions and 17 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ Text {
color: DynamicColors.palette.m3onSurface
font.family: Appearance.font.family.sans
font.pointSize: 12
font.pointSize: Appearance.font.size.normal
renderType: Text.NativeRendering
textFormat: Text.PlainText
+1
View File
@@ -236,6 +236,7 @@ Singleton {
return {
weatherLocation: services.weatherLocation,
useFahrenheit: services.useFahrenheit,
ddcutilService: services.ddcutilService,
useTwelveHourClock: services.useTwelveHourClock,
gpuType: services.gpuType,
audioIncrement: services.audioIncrement,
+1
View File
@@ -4,6 +4,7 @@ import QtQuick
JsonObject {
property real audioIncrement: 0.1
property real brightnessIncrement: 0.1
property bool ddcutilService: false
property string defaultPlayer: "Spotify"
property string gpuType: ""
property real maxVolume: 1.0
+8 -1
View File
@@ -1,6 +1,8 @@
import Quickshell
import QtQuick
import QtQuick.Shapes
import qs.Components
import qs.Config
import qs.Modules as Modules
import qs.Modules.Notifications as Notifications
import qs.Modules.Notifications.Sidebar as Sidebar
@@ -20,9 +22,14 @@ Shape {
anchors.fill: parent
// anchors.margins: 8
anchors.topMargin: bar.implicitHeight
anchors.topMargin: Config.barConfig.autoHide && !visibilities.bar ? 0 : bar.implicitHeight
preferredRendererType: Shape.CurveRenderer
Behavior on anchors.topMargin {
Anim {
}
}
Osd.Background {
startX: root.width - root.panels.sidebar.width
startY: (root.height - wrapper.height) / 2 - rounding
+40 -6
View File
@@ -12,6 +12,7 @@ Singleton {
property bool appleDisplayPresent: false
property list<var> ddcMonitors: []
property list<var> ddcServiceMon: []
readonly property list<Monitor> monitors: variants.instances
function decreaseBrightness(): void {
@@ -55,6 +56,8 @@ Singleton {
onMonitorsChanged: {
ddcMonitors = [];
ddcServiceMon = [];
ddcServiceProc.running = true;
ddcProc.running = true;
}
@@ -68,7 +71,7 @@ Singleton {
}
Process {
command: ["sh", "-c", "asdbctl get"] // To avoid warnings if asdbctl is not installed
command: ["sh", "-c", "asdbctl get"]
running: true
stdout: StdioCollector {
@@ -89,6 +92,26 @@ Singleton {
}
}
Process {
id: ddcServiceProc
command: ["ddcutil-client", "detect"]
// running: true
stdout: StdioCollector {
onStreamFinished: {
const t = text.replace(/\r\n/g, "\n").trim();
const output = ("\n" + t).split(/\n(?=display:\s*\d+\s*\n)/).filter(b => b.startsWith("display:")).map(b => ({
display: Number(b.match(/^display:\s*(\d+)/m)?.[1] ?? -1),
name: (b.match(/^\s*product_name:\s*(.*)$/m)?.[1] ?? "").trim()
})).filter(d => d.display > 0);
root.ddcServiceMon = output;
}
}
}
CustomShortcut {
description: "Increase brightness"
name: "brightnessUp"
@@ -161,10 +184,15 @@ Singleton {
property real brightness
readonly property string busNum: root.ddcMonitors.find(m => m.connector === modelData.name)?.busNum ?? ""
readonly property string displayNum: root.ddcServiceMon.find(m => m.name === modelData.model)?.display ?? ""
readonly property Process initProc: Process {
stdout: StdioCollector {
onStreamFinished: {
if (monitor.isAppleDisplay) {
if (monitor.isDdcService) {
const output = text.split("\n").filter(o => o.startsWith("vcp_current_value:"))[0].split(":")[1];
const val = parseInt(output.trim());
monitor.brightness = val / 100;
} else if (monitor.isAppleDisplay) {
const val = parseInt(text.trim());
monitor.brightness = val / 101;
} else {
@@ -176,6 +204,7 @@ Singleton {
}
readonly property bool isAppleDisplay: root.appleDisplayPresent && modelData.model.startsWith("StudioDisplay")
readonly property bool isDdc: root.ddcMonitors.some(m => m.connector === modelData.name)
readonly property bool isDdcService: Config.services.ddcutilService
required property ShellScreen modelData
property real queuedBrightness: NaN
readonly property Timer timer: Timer {
@@ -190,7 +219,9 @@ Singleton {
}
function initBrightness(): void {
if (isAppleDisplay)
if (isDdcService)
initProc.command = ["ddcutil-client", "-d", displayNum, "getvcp", "10"];
else if (isAppleDisplay)
initProc.command = ["asdbctl", "get"];
else if (isDdc)
initProc.command = ["ddcutil", "-b", busNum, "getvcp", "10", "--brief"];
@@ -206,25 +237,28 @@ Singleton {
if (Math.round(brightness * 100) === rounded)
return;
if (isDdc && timer.running) {
if ((isDdc || isDdcService) && timer.running) {
queuedBrightness = value;
return;
}
brightness = value;
if (isAppleDisplay)
if (isDdcService)
Quickshell.execDetached(["ddcutil-client", "-d", displayNum, "setvcp", "10", rounded]);
else if (isAppleDisplay)
Quickshell.execDetached(["asdbctl", "set", rounded]);
else if (isDdc)
Quickshell.execDetached(["ddcutil", "--disable-dynamic-sleep", "--sleep-multiplier", ".1", "--skip-ddc-checks", "-b", busNum, "setvcp", "10", rounded]);
else
Quickshell.execDetached(["brightnessctl", "s", `${rounded}%`]);
if (isDdc)
if (isDdc || isDdcService)
timer.restart();
}
Component.onCompleted: initBrightness()
onBusNumChanged: initBrightness()
onDisplayNumChanged: initBrightness()
}
}
+2 -5
View File
@@ -69,15 +69,12 @@ Singleton {
onLoaded: {
const up = parseInt(text().split(" ")[0] ?? 0);
const days = Math.floor(up / 86400);
const hours = Math.floor((up % 86400) / 3600);
const hours = Math.floor(up / 3600);
const minutes = Math.floor((up % 3600) / 60);
let str = "";
if (days > 0)
str += `${days} day${days === 1 ? "" : "s"}`;
if (hours > 0)
str += `${str ? ", " : ""}${hours} hour${hours === 1 ? "" : "s"}`;
str += `${hours} hour${hours === 1 ? "" : "s"}`;
if (minutes > 0 || !str)
str += `${str ? ", " : ""}${minutes} minute${minutes === 1 ? "" : "s"}`;
root.uptime = str;
+2
View File
@@ -43,6 +43,7 @@ Item {
MaterialIcon {
Layout.alignment: Qt.AlignVCenter
animate: true
color: Audio.muted ? DynamicColors.palette.m3error : root.textColor
font.pointSize: 14
text: Audio.muted ? "volume_off" : "volume_up"
@@ -71,6 +72,7 @@ Item {
MaterialIcon {
Layout.alignment: Qt.AlignVCenter
animate: true
color: (Audio.sourceMuted ?? false) ? DynamicColors.palette.m3error : root.textColor
font.pointSize: 14
text: Audio.sourceMuted ? "mic_off" : "mic"
+2 -2
View File
@@ -82,7 +82,7 @@ Row {
colour: DynamicColors.palette.m3tertiary
icon: "timer"
text: qsTr("up %1").arg(SystemInfo.uptime)
text: qsTr("%1").arg(SystemInfo.uptime)
}
}
@@ -113,7 +113,7 @@ Row {
anchors.left: icon.right
anchors.leftMargin: icon.anchors.leftMargin
anchors.verticalCenter: icon.verticalCenter
elide: Text.ElideRight
elide: Text.ElideNone
font.pointSize: 13
text: `: ${line.text}`
width: Config.dashboard.sizes.infoWidth
+2 -2
View File
@@ -5,8 +5,6 @@
# Stupid idea's from Daivin
- [ ] An on screen pencil to draw on your screen :).
- [ ] Audio module + cava / audio wave ;) ( Don't make it into minecraft blocks
but aan actual wave) -- Probably not planned
- [ ] Bluetooth device battery view -- Not planned ( Don't have a bluetooth
receiver )
@@ -21,3 +19,5 @@
- [x] Battery icon for Laptops. Broken?
- [x] Quick toggle for BT, WiFi (modules in the tray do this too)
- [x] Update module: When there is 1 package it still looks extremely off
- [x] Audio module + cava / audio wave ;) ( Don't make it into minecraft blocks
but aan actual wave) -- Probably not planned