Repository navigation
Fix nonfunctional brightness sliders on some DDC monitors #9876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Murderlon
wants to merge
13
commits into
omacom:quattro
Choose a base branch
from
Murderlon:fix/ddc-write-verification
base: quattro
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5e2338d
Verify external display brightness writes
Murderlon 85725ec
Report rejected DDC brightness writes without hiding the display
Murderlon db46f54
Show the wheel brightness OSD only after a verified write
Murderlon 35f6cb5
Snap the brightness slider back locally when a write is rejected
Murderlon f1617fa
Use ddcutil verified write retries
Murderlon 17f0fa4
Fix DDC compatibility and brightness write confirmation
Murderlon 9492cec
Merge quattro into DDC brightness fix
Murderlon d0158f3
Keep brightness state with its monitor
Murderlon a98eb81
Give monitor brightness transactions one owner
Murderlon d8994f1
Merge quattro into DDC brightness fix
Murderlon b81b7d6
Keep each display's brightness level current in the monitor panel
Murderlon fab9d45
Fold brightness panel tests into the monitor panel's test file
Murderlon 53ea914
Record each verified brightness write for its own display
Murderlon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import QtQuick | ||
| import Quickshell | ||
| import Quickshell.Io | ||
| import "BrightnessModel.js" as BrightnessModel | ||
|
|
||
| Item { | ||
| id: root | ||
|
|
||
| property var state: BrightnessModel.initial() | ||
| readonly property int percent: state.percent | ||
| readonly property bool available: state.available | ||
| signal verified(int percent) | ||
|
|
||
| function readGeneration() { | ||
| return BrightnessModel.readGeneration(state) | ||
| } | ||
|
|
||
| function acceptRead(monitor, raw, generation) { | ||
| var previousEpoch = state.epoch | ||
| state = BrightnessModel.acceptRead(state, monitor, raw, generation) | ||
| if (state.epoch !== previousEpoch) debounce.stop() | ||
| } | ||
|
|
||
| function request(value, osd = false) { | ||
| debounce.stop() | ||
| state = BrightnessModel.request(state, value, osd) | ||
| startLatest() | ||
| } | ||
|
|
||
| function preview(value) { | ||
| state = BrightnessModel.request(state, value, false) | ||
| debounce.restart() | ||
| } | ||
|
|
||
| function startLatest() { | ||
| if (writeProc.running || state.active || !state.latest) return | ||
| debounce.stop() | ||
| state = BrightnessModel.start(state) | ||
| writeProc.request = state.active | ||
| writeProc.command = ["omarchy-brightness-display", "--no-osd", "--monitor", state.active.epoch.monitor, state.active.target + "%"] | ||
| writeProc.running = true | ||
| } | ||
|
|
||
| function finish(request, success) { | ||
| var result = BrightnessModel.finish(state, request, success) | ||
| if (result.state === state) return | ||
| state = result.state | ||
| if (result.verified !== null) verified(result.verified) | ||
| if (state.latest) Qt.callLater(startLatest) | ||
| } | ||
|
|
||
| Timer { | ||
| id: debounce | ||
| interval: 180 | ||
| repeat: false | ||
| onTriggered: root.startLatest() | ||
| } | ||
|
|
||
| Process { | ||
| id: writeProc | ||
| property var request: null | ||
| stdout: StdioCollector { waitForEnd: true } | ||
| onExited: function(exitCode, exitStatus) { | ||
| root.finish(request, exitStatus === 0 && exitCode === 0) | ||
| } | ||
| onRunningChanged: { | ||
| if (running) return | ||
| // A failed start only changes running. Let a normal exit complete first. | ||
| var completedRequest = request | ||
| Qt.callLater(function() { | ||
| if (!writeProc.running) root.finish(completedRequest, false) | ||
| }) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| function initial() { | ||
| return { | ||
| epoch: { monitor: "" }, | ||
| percent: 0, | ||
| confirmed: 0, | ||
| available: false, | ||
| revision: 0, | ||
| active: null, | ||
| latest: null | ||
| } | ||
| } | ||
|
|
||
| function copy(state, changes) { | ||
| return Object.assign({}, state, changes) | ||
| } | ||
|
|
||
| function readGeneration(state) { | ||
| return state.active || state.latest ? -1 : state.revision | ||
| } | ||
|
|
||
| function acceptRead(state, monitor, raw, generation) { | ||
| var changedMonitor = monitor !== state.epoch.monitor | ||
| if (!changedMonitor && (state.active || state.latest || generation !== state.revision)) return state | ||
|
|
||
| var available = raw !== "unavailable" && raw !== "" | ||
| var parsed = parseInt(raw, 10) | ||
| var percent = available && isFinite(parsed) ? Math.max(0, Math.min(100, parsed)) : 0 | ||
| return copy(state, { | ||
| // A new identity also invalidates completions after switching away and back. | ||
| epoch: changedMonitor ? { monitor: monitor } : state.epoch, | ||
| percent: percent, | ||
| confirmed: available ? percent : changedMonitor ? 0 : state.confirmed, | ||
| available: available, | ||
| revision: state.revision + 1, | ||
| latest: null | ||
| }) | ||
| } | ||
|
|
||
| function request(state, value, osd) { | ||
| var number = Number(value) | ||
| var target = isFinite(number) ? Math.max(1, Math.min(100, Math.round(number))) : 1 | ||
| return copy(state, { | ||
| percent: target, | ||
| revision: state.revision + 1, | ||
| latest: { | ||
| epoch: state.epoch, | ||
| target: target, | ||
| osd: !!osd || !!(state.latest && state.latest.osd) | ||
| || !!(state.active && state.active.epoch === state.epoch && state.active.osd) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| function start(state) { | ||
| if (state.active || !state.latest) return state | ||
| return copy(state, { active: state.latest, latest: null }) | ||
| } | ||
|
|
||
| function finish(state, request, success) { | ||
| if (!request || state.active !== request) return { state: state, verified: null } | ||
|
|
||
| var current = request.epoch === state.epoch | ||
| var latest = state.latest | ||
| if (latest && latest.epoch === request.epoch && latest.target === request.target) latest = null | ||
| var confirmed = current && success ? request.target : state.confirmed | ||
| return { | ||
| state: copy(state, { | ||
| active: null, | ||
| latest: latest, | ||
| confirmed: confirmed, | ||
| percent: current && !latest && !success ? confirmed : state.percent, | ||
| revision: state.revision + 1 | ||
| }), | ||
| verified: current && success && !latest && (request.osd || (state.latest && state.latest.osd)) | ||
| ? request.target : null | ||
| } | ||
| } | ||
|
|
||
| if (typeof module !== "undefined") { | ||
| module.exports = { | ||
| initial: initial, | ||
| readGeneration: readGeneration, | ||
| acceptRead: acceptRead, | ||
| request: request, | ||
| start: start, | ||
| finish: finish | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.