Brightness, fully working (at least on my machine)

This commit is contained in:
quadbyte 2025-08-17 08:03:09 -04:00
parent 593821e998
commit 4ed7324a99
10 changed files with 124 additions and 150 deletions

View file

@ -139,7 +139,6 @@ Variants {
// demoPanel.isLoaded = !demoPanel.isLoaded // demoPanel.isLoaded = !demoPanel.isLoaded
// } // }
// } // }
NIconButton { NIconButton {
id: sidePanelToggle id: sidePanelToggle
icon: "widgets" icon: "widgets"

View file

@ -17,7 +17,8 @@ Item {
function getIcon() { function getIcon() {
var brightness = BrightnessService.getMonitorForScreen(screen).brightness var brightness = BrightnessService.getMonitorForScreen(screen).brightness
return brightness <= 0 ? "brightness_1" : brightness < 0.33 ? "brightness_low" : brightness < 0.66 ? "brightness_medium" : "brightness_high" return brightness <= 0 ? "brightness_1" : brightness < 0.33 ? "brightness_low" : brightness
< 0.66 ? "brightness_medium" : "brightness_high"
} }
// Connection used to open the pill when brightness changes // Connection used to open the pill when brightness changes
@ -26,7 +27,7 @@ Item {
function onBrightnessUpdated() { function onBrightnessUpdated() {
Logger.log("Bar-Brightness", "OnBrightnessUpdated") Logger.log("Bar-Brightness", "OnBrightnessUpdated")
var monitor = BrightnessService.getMonitorForScreen(screen); var monitor = BrightnessService.getMonitorForScreen(screen)
var currentBrightness = monitor.brightness var currentBrightness = monitor.brightness
// Ignore if this is the first time or if brightness hasn't actually changed // Ignore if this is the first time or if brightness hasn't actually changed

View file

@ -130,7 +130,7 @@ NLoader {
"label": "Audio", "label": "Audio",
"icon": "volume_up", "icon": "volume_up",
"source": audioTab "source": audioTab
},{ }, {
"id": SettingsPanel.Tab.Display, "id": SettingsPanel.Tab.Display,
"label": "Display", "label": "Display",
"icon": "monitor", "icon": "monitor",

View file

@ -143,6 +143,8 @@ Item {
} }
// Single monitor display using the same data source as the bar icon // Single monitor display using the same data source as the bar icon
Repeater {
model: BrightnessService.monitors
Rectangle { Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
radius: Style.radiusMedium * scaling radius: Style.radiusMedium * scaling
@ -162,7 +164,7 @@ Item {
spacing: Style.marginMedium * scaling spacing: Style.marginMedium * scaling
NText { NText {
text: "Primary Monitor" text: `${model.modelData.name} [${model.modelData.model}]`
font.pointSize: Style.fontSizeLarge * scaling font.pointSize: Style.fontSizeLarge * scaling
font.weight: Style.fontWeightBold font.weight: Style.fontWeightBold
color: Color.mSecondary color: Color.mSecondary
@ -173,7 +175,7 @@ Item {
} }
NText { NText {
text: BrightnessService.currentMethod === "ddcutil" ? "External (DDC)" : "Internal" text: model.method
font.pointSize: Style.fontSizeSmall * scaling font.pointSize: Style.fontSizeSmall * scaling
color: Color.mOnSurfaceVariant color: Color.mOnSurfaceVariant
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
@ -193,53 +195,25 @@ Item {
NSlider { NSlider {
Layout.fillWidth: true Layout.fillWidth: true
from: 0 from: 0
to: 100 to: 1
value: BrightnessService.brightness value: model.brightness
stepSize: 1 stepSize: 0.05
enabled: BrightnessService.available
onPressedChanged: { onPressedChanged: {
if (!pressed && BrightnessService.available) { if (!pressed) {
BrightnessService.setBrightness(value) var monitor = BrightnessService.getMonitorForScreen(model.modelData)
monitor.setBrightness(value)
} }
} }
} }
NText { NText {
text: BrightnessService.available ? Math.round(BrightnessService.brightness) + "%" : "N/A" text: Math.round(model.brightness * 100) + "%"
font.pointSize: Style.fontSizeMedium * scaling font.pointSize: Style.fontSizeMedium * scaling
font.weight: Style.fontWeightBold font.weight: Style.fontWeightBold
color: BrightnessService.available ? Color.mPrimary : Color.mOnSurfaceVariant color: Color.mPrimary
Layout.alignment: Qt.AlignRight Layout.alignment: Qt.AlignRight
} }
} }
RowLayout {
Layout.fillWidth: true
spacing: Style.marginMedium * scaling
NText {
text: "Method:"
font.pointSize: Style.fontSizeSmall * scaling
color: Color.mOnSurfaceVariant
}
NText {
text: BrightnessService.currentMethod || "Unknown"
font.pointSize: Style.fontSizeSmall * scaling
color: Color.mOnSurface
Layout.alignment: Qt.AlignLeft
}
Item {
Layout.fillWidth: true
}
NText {
text: BrightnessService.available ? "Available" : "Unavailable"
font.pointSize: Style.fontSizeSmall * scaling
color: BrightnessService.available ? Color.mPrimary : Color.mError
Layout.alignment: Qt.AlignRight
}
} }
} }
} }

View file

@ -384,8 +384,6 @@ NPanel {
running: false running: false
} }
Process { Process {
id: logoutProcess id: logoutProcess

View file

@ -66,7 +66,6 @@ Singleton {
root.ddcMonitors = displays.map(d => { root.ddcMonitors = displays.map(d => {
var modelMatch = d.match(/Monitor:.*:(.*):.*/) var modelMatch = d.match(/Monitor:.*:(.*):.*/)
var busMatch = d.match(/I2C bus:[ ]*\/dev\/i2c-([0-9]+)/) var busMatch = d.match(/I2C bus:[ ]*\/dev\/i2c-([0-9]+)/)
console.log(modelMatch)
return { return {
"model": modelMatch ? modelMatch[1] : "", "model": modelMatch ? modelMatch[1] : "",
"busNum": busMatch ? busMatch[1] : "" "busNum": busMatch ? busMatch[1] : ""
@ -96,7 +95,7 @@ Singleton {
readonly property Process initProc: Process { readonly property Process initProc: Process {
stdout: StdioCollector { stdout: StdioCollector {
onStreamFinished: { onStreamFinished: {
var dataText = text.trim(); var dataText = text.trim()
if (dataText === "") { if (dataText === "") {
return return
} }

View file

@ -25,10 +25,10 @@ Singleton {
property bool inOverview: false property bool inOverview: false
// Generic events // Generic events
signal workspaceChanged() signal workspaceChanged
signal activeWindowChanged() signal activeWindowChanged
signal overviewStateChanged() signal overviewStateChanged
signal windowListChanged() signal windowListChanged
// Compositor detection // Compositor detection
Component.onCompleted: { Component.onCompleted: {
@ -54,8 +54,6 @@ Singleton {
} }
} }
function detectCompositor() { function detectCompositor() {
try { try {
// Try Hyprland first // Try Hyprland first
@ -67,6 +65,7 @@ Singleton {
return return
} }
} catch (e) { } catch (e) {
// Hyprland not available // Hyprland not available
} }
@ -98,12 +97,12 @@ Singleton {
} }
} }
function setupHyprlandConnections() { function setupHyprlandConnections() {// Connections are set up at the top level, this function just marks that Hyprland is ready
// Connections are set up at the top level, this function just marks that Hyprland is ready
} }
function updateHyprlandWorkspaces() { function updateHyprlandWorkspaces() {
if (!isHyprland) return if (!isHyprland)
return
workspaces.clear() workspaces.clear()
try { try {
@ -145,14 +144,16 @@ Singleton {
} }
function updateNiriWorkspaces() { function updateNiriWorkspaces() {
if (!isNiri) return if (!isNiri)
return
// Get workspaces from the Niri process // Get workspaces from the Niri process
niriWorkspaceProcess.running = true niriWorkspaceProcess.running = true
} }
function updateNiriWindows() { function updateNiriWindows() {
if (!isNiri) return if (!isNiri)
return
// Get windows from the Niri process // Get windows from the Niri process
niriWindowsProcess.running = true niriWindowsProcess.running = true

View file

@ -12,7 +12,9 @@ PanelWindow {
property bool showOverlay: Settings.data.general.dimDesktop property bool showOverlay: Settings.data.general.dimDesktop
property int topMargin: Style.barHeight * scaling property int topMargin: Style.barHeight * scaling
// Show dimming if this panel is opened OR if we're in a transition (to prevent flickering) // Show dimming if this panel is opened OR if we're in a transition (to prevent flickering)
property color overlayColor: (showOverlay && (PanelService.openedPanel === root || isTransitioning)) ? Color.applyOpacity(Color.mShadow, "AA") : Color.transparent property color overlayColor: (showOverlay && (PanelService.openedPanel === root
|| isTransitioning)) ? Color.applyOpacity(Color.mShadow,
"AA") : Color.transparent
property bool isTransitioning: false property bool isTransitioning: false
signal dismissed signal dismissed