repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

brightness: solid-dark drag-to-set bar + active-preset highlight

09b9e5c6ca85dfd184d8060e5ca482360f5b1c97

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (1)

quickshell/nuguland/PopoutHost.qml

Modified
2554 2554 property var state: brightnessService ? Util.parseJson(brightnessService.stateJson(), {
2555 2555 "level": 0,
2556 2556 "compact": {
2557 - "label": "Bright"
2558 - },
2559 - "shader": {
2557 + "label": "Bright",
2558 + "role": "ui.accent"
2561 2560 }) : ({
2562 2561 "level": 0,
2563 2562 "compact": {
2564 - "label": "Bright"
2565 - },
2566 - "shader": {
2563 + "label": "Bright",
2564 + "role": "ui.accent"
2568 + readonly property real level: Math.max(0, Math.min(1, Number(root.state.level || 0)))
2569 + function roleColor(role) {
2570 + if (!root.theme)
2571 + return "white";
2572 + if (role === "warning")
2573 + return root.theme.warning;
2574 + if (role === "ui.minor")
2575 + return root.theme.ui.minor;
2576 + return root.theme.ui.accent;
2578 + function applyAt(x, width) {
2579 + root.state = Util.parseJson(root.brightnessService.setLevel(Math.max(0, Math.min(1, x / width))), root.state);
2570 2582 spacing: 12
2571 2583 padding: 14
2585 + // Drag/click anywhere on the bar to set level; fill is role-colored.
2573 2586 Rectangle {
2574 2587 width: Math.max(1, root.width - 28)
2575 - height: 36
2576 - radius: 10
2588 + height: 40
2589 + radius: 12
2577 2590 color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, 0.88) : "#242424"
2578 - border.width: 0
2579 - border.color: root.theme ? root.theme.ui.accent : "white"
2591 + border.width: 1
2592 + border.color: root.theme ? root.theme.withAlpha(root.theme.ui.minor, 0.45) : "white"
2581 2594 Rectangle {
2582 2595 anchors.left: parent.left
2583 2596 anchors.top: parent.top
2584 2597 anchors.bottom: parent.bottom
2585 - width: parent.width * Math.max(0, Math.min(1, Number(root.state.level || 0)))
2586 - radius: parent.radius
2587 - color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.55) : "white"
2598 + anchors.margins: 2
2599 + width: Math.max(0, (parent.width - 4) * root.level)
2600 + radius: parent.radius - 2
2601 + color: root.theme ? root.theme.withAlpha(root.roleColor(root.state.compact ? root.state.compact.role : "ui.accent"), 0.6) : "white"
2591 2605 anchors.centerIn: parent
2592 - text: `${Math.round(Number(root.state.level || 0) * 100)}%`
2606 + text: `${Math.round(root.level * 100)}%`
2593 2607 color: root.theme ? root.theme.content.normal : "white"
2594 2608 font.family: "IBM Plex Mono"
2595 - font.pixelSize: 14
2609 + font.pixelSize: 15
2612 + MouseArea {
2613 + anchors.fill: parent
2614 + onPressed: mouse => root.applyAt(mouse.x, width)
2615 + onPositionChanged: mouse => { if (pressed) root.applyAt(mouse.x, width); }
2604 2624 model: [0.25, 0.5, 0.75, 1]
2606 2626 delegate: Rectangle {
2627 + required property var modelData
2628 + readonly property bool active: Math.abs(root.level - modelData) < 0.02
2607 2630 width: 88
2608 - height: 30
2609 - radius: 8
2610 - color: root.theme ? root.theme.withAlpha(root.theme.ui.minor, 0.18) : "#333333"
2611 - border.width: 0
2612 - border.color: root.theme ? root.theme.ui.focus : "white"
2631 + height: 32
2632 + radius: 10
2633 + color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, active ? 0.82 : 0.55) : "#333333"
2634 + border.width: active ? 2 : 1
2635 + border.color: root.theme ? (active ? root.theme.ui.accent : root.theme.withAlpha(root.theme.ui.minor, 0.45)) : "white"
2615 2638 anchors.centerIn: parent
2616 - text: `${Math.round(modelData * 100)}%`
2639 + text: `${Math.round(parent.modelData * 100)}%`
2617 2640 color: root.theme ? root.theme.content.normal : "white"
2618 2641 font.family: "IBM Plex Sans"
2619 2642 font.pixelSize: 13
2622 2645 MouseArea {
2623 2646 anchors.fill: parent
2624 - onClicked: root.brightnessService.setLevel(modelData)
2647 + onClicked: root.state = Util.parseJson(root.brightnessService.setLevel(parent.modelData), root.state)