Move mouse widget standalone, add RGB control widget, align peripherals
The mouse battery pill lived in Bar.qml, duplicated per-screen (it renders once per monitor) and invisible whenever taskbar mode hid the stats row entirely. Pulled into its own MouseWidget.qml, same standalone pattern as the theme widget - single instance, click opens DPI/poll-rate/idle-time/low-battery-threshold controls. mouse_battery.py folded into the new mouse.py (adds set-dpi-stage/set-poll-rate/ set-idle-time/set-low-battery-threshold on top of the old status-only script). New RGBWidget.qml + scripts/rgb.py: per-device mode/color/speed/ brightness for RAM/GPU/mainboard RGB via OpenRGB's SDK server (autostarted headless in hyprland.lua), plus a one-click "sync all to accent". Both RAM sticks are grouped into one card/one set of controls since they're the same model - rgb.py's commands take a comma-separated device-id list for exactly this. Found and worked around two real issues along the way: this server build mishandles openrgb-python's default protocol version (pinned to 3 instead), and set_color() doesn't reliably force Direct mode first on its own - a device left on a cycling effect can keep animating right through a color-set call despite it reporting success, worst on the GPU's own i2c adapter. Mitigated with an explicit mode switch + verify-and-retry. Also: hyprland.lua was missing accel_profile entirely, so libinput's default adaptive curve was always active - flat now, for the 1:1 response a gaming mouse is normally run with (found while chasing an unrelated OpenRazer DPI reset making it suddenly noticeable). Widget layout: all three corner widgets now align on a shared row height instead of each guessing the previous one's width. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dujsk9jYfxUVLtb5B8eC94
This commit is contained in:
48
README.md
48
README.md
@@ -21,7 +21,7 @@ bash /tmp/install.sh --deps # same, plus installs dependencies via pacman (Arc
|
||||
| Piece | Tool |
|
||||
|---|---|
|
||||
| Compositor | [Hyprland](https://hyprland.org/) |
|
||||
| Login screen | SDDM — stock theme, not customized/tracked here (config lives under `/etc`, outside this repo's scope) |
|
||||
| Login screen | SDDM — custom palette-driven theme ([`sddm/aether-rice/`](sddm/aether-rice/)), see Theming below |
|
||||
| Bar | Custom [Quickshell](https://quickshell.org/) shell (`quickshell/default/`) — replaces Waybar entirely |
|
||||
| Launcher | Rofi |
|
||||
| Terminal | Kitty |
|
||||
@@ -30,6 +30,8 @@ bash /tmp/install.sh --deps # same, plus installs dependencies via pacman (Arc
|
||||
| Theming | [`theme/`](theme/) — homegrown palette-driven theme generator (`render.py`), controlled from the Quickshell desktop widget or the CLI |
|
||||
| Qt/GTK theming | qt6ct, nwg-look |
|
||||
| File manager | Thunar (GTK3; themed via the same pipeline — see Theming below). Was Dolphin, dropped over an [unfixed upstream bug](https://discuss.kde.org/t/dolphin-how-can-i-override-the-new-highlight-color/38640) forcing Breeze's stock blue for selection outside a full Plasma session |
|
||||
| Mouse control | Standalone Quickshell widget ([`MouseWidget.qml`](quickshell/default/MouseWidget.qml)) — battery, DPI, poll rate, idle timeout, low-battery threshold, via [OpenRazer](https://openrazer.github.io/), optional/hardware-specific — see Peripheral widgets below |
|
||||
| RGB control | Standalone Quickshell widget ([`RGBWidget.qml`](quickshell/default/RGBWidget.qml)) — RAM/GPU/mainboard RGB, synced to the palette's accent in one click, via [OpenRGB](https://openrgb.org/), optional/hardware-specific — see Peripheral widgets below |
|
||||
|
||||
## The bar
|
||||
|
||||
@@ -114,6 +116,39 @@ A few icon colors in the bar are deliberately hardcoded rather than bound to the
|
||||
|
||||
It's a blue theme (`#1793d1` accent on a dark `#1a1b26` background) built around the stock default Hyprland wallpaper — the anime girl waiting at the train stop with the glowing blue Hyprland-logo cats. Every accent color across the bar, Rofi, Kitty, and the rest was picked to match that wallpaper's palette rather than the other way around.
|
||||
|
||||
## Peripheral widgets
|
||||
|
||||
Two more standalone Quickshell windows (same pattern as the theme widget: independent of `Bar.qml`, pinned to the top-left corner, Bottom wlr layer) control RGB/sensor peripherals over their own daemons instead of the palette. Both are entirely optional and hardware-specific — each hides itself (`visible: available`) if its daemon isn't reachable, so they're a no-op on a machine without this exact hardware, not an error.
|
||||
|
||||
**Mouse** ([`MouseWidget.qml`](quickshell/default/MouseWidget.qml) + [`scripts/mouse.py`](quickshell/default/scripts/mouse.py)) — battery, DPI (the device's own 5 stored stages), poll rate, wireless idle timeout, and low-battery warning threshold, for a Razer Viper V3 Pro over [OpenRazer](https://openrazer.github.io/). One-time setup, needs a real reboot after (not just logout/login — this machine's `sddm.conf` has `ReuseSession=true`, which reattaches to the old session instead of starting a fresh one, so group membership never actually refreshes without one):
|
||||
|
||||
```bash
|
||||
sudo pacman -S openrazer-daemon openrazer-driver-dkms python-openrazer
|
||||
sudo gpasswd -a "$USER" openrazer
|
||||
# then reboot
|
||||
```
|
||||
|
||||
Found the hard way:
|
||||
- **The mouse's USB product ID is different over its cable vs. its wireless dongle** (`1532:00C0` vs `1532:00C1` here) — openrazer-daemon only scans for devices at its *own* startup, not on hotplug, so switching cable↔dongle while it's already running goes completely unnoticed. `mouse.py` detects an empty device list and restarts `openrazer-daemon` once via `systemctl --user restart` before giving up, which picks the switch up within one call instead of needing a manual restart.
|
||||
- **The low-battery threshold is hardware-capped at 25%**, confirmed by testing every value 0-100 against the real device — asking for more just silently clamps to 25, undocumented anywhere. The widget's slider range reflects that cap instead of pretending 0-100 works.
|
||||
- **The DPI reset to a generic default (1800) the first time OpenRazer's daemon ever bound to the device**, overwriting whatever had been configured before (e.g. via Razer Synapse on a Windows dual-boot) — `restore_persistence` defaults to `false`, so the daemon doesn't restore anything on its own, it just starts the device off wherever its driver-level init leaves it. The device's 5 *stored* DPI stages survived this untouched, which is how the original value got found again (the stage list's reported "active index" still pointed at it, even though the single live `.dpi` reading didn't match any of them).
|
||||
- **A confirmed, still-open upstream SDDM bug** affects this mouse too, incidentally: see the keyboard-layout bullet in the SDDM section above — unrelated hardware, same "backend doesn't apply state until first input" shape.
|
||||
|
||||
Unrelated to OpenRazer, but found while setting it up: `hyprland.lua`'s `input` block never set `accel_profile`, so Hyprland/libinput were using their own default adaptive (accelerated) curve the whole time rather than the flat/linear response a gaming mouse is normally run with - only actually noticeable once the DPI reset above changed how it felt. Now `accel_profile = "flat"`.
|
||||
|
||||
**RGB** ([`RGBWidget.qml`](quickshell/default/RGBWidget.qml) + [`scripts/rgb.py`](quickshell/default/scripts/rgb.py)) — per-device mode (Direct/Rainbow/Breathing/…), color, speed, and brightness (wherever the active mode supports them) for RAM (Corsair Vengeance RGB Pro ×2, shown and controlled as *one* card since they're the same model - `rgb.py`'s commands all accept a comma-separated list of device IDs), GPU (Gigabyte RTX 3060 Gaming OC), and mainboard (ASUS ROG STRIX B550-F, Aura) — plus a "Sync all to accent" button that's the actual point of having this at all. All three go through [OpenRGB](https://openrgb.org/)'s SDK server, autostarted headless (`openrgb --server`, in `hyprland.lua`) so the widget's queries are fast — the plain CLI re-detects all hardware (~5s) on every single invocation, which is too slow to poll.
|
||||
|
||||
```bash
|
||||
sudo pacman -S openrgb i2c-tools
|
||||
sudo modprobe i2c-dev
|
||||
echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf # persist across reboots
|
||||
yay -S python-openrgb # AUR - the SDK client library rgb.py imports
|
||||
```
|
||||
|
||||
Found the hard way:
|
||||
- **This exact server build (`openrgb` 1.0-2, Arch `extra`) doesn't handle `openrgb-python`'s default SDK protocol version (4) correctly** — the plugin-list request it sends during connection setup just hangs until the client's socket times out. `rgb.py` connects with `protocol_version=3` explicitly, which skips that request and works.
|
||||
- **Setting a color doesn't reliably switch the device to Direct mode first** — a device left on a cycling mode (Rainbow Wave, Spectrum Cycle, …) can keep animating straight through a `set_color()` call, so the static color never actually sticks despite the API call succeeding and even reporting back the "right" state immediately after. Intermittent, not consistently reproducible - looks like SMBus/i2c timing flakiness, worst on the GPU specifically (its own NVIDIA i2c adapter, not the mainboard/RAM's shared SMBus one). `rgb.py`'s `set_color()` explicitly forces Direct mode first, waits, then re-reads the live state and retries once if it doesn't match what was asked for.
|
||||
|
||||
## Hotkeys
|
||||
|
||||
`Mod` = <kbd>Super</kbd>.
|
||||
@@ -182,7 +217,7 @@ It's a blue theme (`#1793d1` accent on a dark `#1a1b26` background) built around
|
||||
|
||||
## Requirements
|
||||
|
||||
Beyond Hyprland itself, the bar's scripts expect: `quickshell`, `nmcli`, `wpctl`, `nvidia-smi` (GPU stats — no-ops gracefully if absent), `sensors` (lm_sensors, for CPU temperature), `python3`, and `curl` (for the network widget's public-IP lookup). The theme widget's wallpaper picker additionally needs `zenity` (native file picker) and `swaybg`; an animated GIF wallpaper additionally needs `awww` (optional - only touched when the active wallpaper is a GIF).
|
||||
Beyond Hyprland itself, the bar's scripts expect: `quickshell`, `nmcli`, `wpctl`, `nvidia-smi` (GPU stats — no-ops gracefully if absent), `sensors` (lm_sensors, for CPU temperature), `python3`, and `curl` (for the network widget's public-IP lookup). The theme widget's wallpaper picker additionally needs `zenity` (native file picker) and `swaybg`; an animated GIF wallpaper additionally needs `awww` (optional - only touched when the active wallpaper is a GIF). The mouse and RGB widgets are both fully optional, hardware-specific, and need their own one-time setup beyond a package install — see Peripheral widgets above, not covered by `install.sh --deps`.
|
||||
|
||||
This is an Arch + Hyprland rice through and through, so the list below is Arch-authoritative — everything in the pacman column is a plain `extra`/`multilib` package on current Arch, nothing needs an AUR helper. `apt`/`dnf` columns are best-effort: Hyprland and its ecosystem (Hyprland itself, `quickshell`, `hyprcursor`) move fast and generally aren't in Debian/Ubuntu's or Fedora's stock repos, so those need a third-party repo (Fedora: the [`solopasha/hyprland` COPR](https://copr.fedorainfracloud.org/coprs/solopasha/hyprland/) covers most of it) or building from source — a blank cell means "no known repo package, check the project's own install docs". Snap has essentially no coverage here (this is all system/Wayland-level tooling, not the kind of app snap packages); where an optional app happens to have one, it's noted below the table instead.
|
||||
|
||||
@@ -219,6 +254,10 @@ This is an Arch + Hyprland rice through and through, so the list below is Arch-a
|
||||
| `materia-gtk-theme` | GTK theme | `materia-gtk-theme` | `materia-gtk-theme` | — (build) |
|
||||
| `papirus-icon-theme` | Icon theme | `papirus-icon-theme` | `papirus-icon-theme` | `papirus-icon-theme` |
|
||||
| `ttf-jetbrains-mono-nerd` | Bar/UI font | `ttf-jetbrains-mono-nerd` | — (manual install from [Nerd Fonts](https://www.nerdfonts.com/)) | — (manual install) |
|
||||
| `openrazer-daemon` + `openrazer-driver-dkms` | Mouse widget — optional, hardware-specific, needs more setup than just this (see Peripheral widgets above) | `openrazer-daemon openrazer-driver-dkms` | build from [source](https://openrazer.github.io/) | build from [source](https://openrazer.github.io/) |
|
||||
| `python-openrazer` | Python bindings `scripts/mouse.py` imports | `python-openrazer` | build from [source](https://openrazer.github.io/) | build from [source](https://openrazer.github.io/) |
|
||||
| `openrgb` + `i2c-tools` | RGB widget — optional, hardware-specific, needs more setup than just this (see Peripheral widgets above) | `openrgb i2c-tools` | build from [source](https://openrgb.org/) | build from [source](https://openrgb.org/) |
|
||||
| `python-openrgb` | Python bindings `scripts/rgb.py` imports | AUR (`yay -S python-openrgb`) | `pip install openrgb-python` | `pip install openrgb-python` |
|
||||
|
||||
```bash
|
||||
# Arch (pacman - every package below is in the extra/multilib repos already
|
||||
@@ -263,6 +302,8 @@ This config's software requirements (above) run on anything; a few specific sett
|
||||
| Monitors | 27" 2560×1440@144Hz (`DP-1`, desc `HKC OVERSEAS LIMITED 27E6QC`) + 23" 1680×1050@60Hz (`HDMI-A-1`, desc `LG Electronics L226W`) | `hl.monitor({...})` blocks and every `hl.workspace_rule({...})` in `hyprland.lua` match monitors by their exact EDID `desc:` string (find yours with `hyprctl monitors`) | With different monitors (or even the same models in a different plug order) these rules simply won't match anything — Hyprland falls back to its own defaults, so resolution/refresh-rate/position and the fixed per-monitor workspace assignments (1–4/9 on the main monitor, 5–8 on the second) silently stop applying. Update the `desc:` strings and positions to match `hyprctl monitors` output on the new setup |
|
||||
| Keyboard layout | German (`de`) | `kb_layout = "de"` in `hyprland.lua` | Not a crash, just the wrong layout — change it to your own (`kb_layout = "us"`, etc.) |
|
||||
| Motherboard / RAM / storage | ASUS ROG STRIX B550-F, 32 GB, NVMe SSDs (+ a USB stick) | Nothing — the disk pill enumerates real mounted filesystems and their device names live, nothing about specific drives is hardcoded | No changes needed regardless of storage layout |
|
||||
| Mouse | Razer Viper V3 Pro | `MouseWidget.qml`/`scripts/mouse.py` go through OpenRazer, which only knows this exact device | A different (or no) Razer mouse: the widget just hides itself (`available` goes false) - a non-Razer mouse has no OpenRazer support at all, Razer-but-different-model generally works as long as OpenRazer lists it |
|
||||
| RAM / GPU / mainboard RGB | Corsair Vengeance RGB Pro ×2, Gigabyte RTX 3060 Gaming OC, ASUS Aura | `RGBWidget.qml`/`scripts/rgb.py` show/control exactly whatever OpenRGB's SDK server detects, nothing about specific devices is hardcoded | Different RGB hardware: same widget, same code, whatever OpenRGB finds shows up instead - hides itself entirely if OpenRGB can't reach anything (no `--server` running, nothing it supports installed) |
|
||||
|
||||
None of this stops the config from *loading* on other hardware — Hyprland just silently falls back to sane defaults for anything that doesn't match, and the bar degrades gracefully (missing pills, `NA` values) rather than erroring. But if a monitor is misplaced/wrong-resolution, workspaces land on the wrong screen, or the GPU/CPU pill acts oddly, this table is where to look first before assuming something's broken.
|
||||
|
||||
@@ -270,7 +311,8 @@ None of this stops the config from *loading* on other hardware — Hyprland just
|
||||
|
||||
```
|
||||
hypr/ Hyprland config (hyprland.lua is active, .conf kept for reference) + wallpaper.png + cursor/ (cursor theme source)
|
||||
quickshell/ The bar (Bar.qml + helper QML components + scripts/) + ThemeWidget.qml (theming widget)
|
||||
quickshell/ The bar (Bar.qml + helper QML components + scripts/) + ThemeWidget.qml (theming
|
||||
widget) + MouseWidget.qml/RGBWidget.qml (peripheral widgets, see above)
|
||||
rofi/ Launcher config + theme
|
||||
kitty/ Terminal config + theme
|
||||
mako/ Notification daemon config (colors.ini generated by theme/render.py)
|
||||
|
||||
@@ -52,9 +52,9 @@ button:hover label {
|
||||
looks up these named colors directly instead (gtk_style_context_lookup_color).
|
||||
Redefining them is what actually recolors the selection there; .view:selected/
|
||||
*:selected below do nothing for it, only for widgets that DO use normal matching. */
|
||||
@define-color theme_selected_bg_color alpha(#7aa2f7, 0.5);
|
||||
@define-color theme_selected_bg_color alpha(#f7768e, 0.5);
|
||||
@define-color theme_selected_fg_color #c0caf5;
|
||||
@define-color theme_unfocused_selected_bg_color alpha(#7aa2f7, 0.5);
|
||||
@define-color theme_unfocused_selected_bg_color alpha(#f7768e, 0.5);
|
||||
@define-color theme_unfocused_selected_fg_color #c0caf5;
|
||||
|
||||
/* File-manager icon/list view (Thunar's grid, Materia's rounded selection pill) */
|
||||
@@ -68,6 +68,6 @@ button:hover label {
|
||||
}
|
||||
|
||||
*:selected {
|
||||
background-color: alpha(#7aa2f7, 0.5);
|
||||
background-color: alpha(#f7768e, 0.5);
|
||||
color: #c0caf5;
|
||||
}
|
||||
|
||||
@@ -617,6 +617,10 @@ hl.on("hyprland.start", function()
|
||||
hl.exec_cmd("quickshell -c default")
|
||||
hl.exec_cmd("mako")
|
||||
hl.exec_cmd("nm-applet --indicator")
|
||||
-- --server alone: headless SDK server, no GUI/tray window. Keeps RAM/GPU/mainboard
|
||||
-- RGB devices detected in memory so RGBWidget's queries are fast - the plain CLI
|
||||
-- re-detects all hardware (~5s) on every single invocation.
|
||||
hl.exec_cmd("openrgb --server")
|
||||
hl.exec_cmd("python3 ~/.config/theme/wallpaper.py start")
|
||||
hl.exec_cmd("wl-paste --type text --watch cliphist store")
|
||||
hl.exec_cmd("wl-paste --type image --watch cliphist store")
|
||||
|
||||
@@ -278,12 +278,6 @@ Variants {
|
||||
property string gpuMemTotal: "NA"
|
||||
readonly property bool gpuAvailable: gpuUtil !== "NA"
|
||||
|
||||
// ---- mouse battery (Razer, via openrazer - no-op if not installed/connected) ----
|
||||
property bool mouseBatteryAvailable: false
|
||||
property int mouseBatteryPct: 0
|
||||
property bool mouseBatteryCharging: false
|
||||
readonly property bool mouseBatteryLow: mouseBatteryAvailable && !mouseBatteryCharging && mouseBatteryPct <= 20
|
||||
|
||||
// ---- network ----
|
||||
property string connType: ""
|
||||
property string connName: ""
|
||||
@@ -357,30 +351,6 @@ Variants {
|
||||
Timer { interval: 100; running: true; repeat: false; onTriggered: statsProc.running = true }
|
||||
Timer { interval: 1000; running: true; repeat: true; onTriggered: statsProc.running = true }
|
||||
|
||||
Process {
|
||||
id: mouseBatteryProc
|
||||
command: ["python3", root.scriptsDir + "/mouse_battery.py"]
|
||||
stdout: StdioCollector { id: mouseBatteryCollector }
|
||||
onExited: {
|
||||
try {
|
||||
var d = JSON.parse(mouseBatteryCollector.text)
|
||||
bar.mouseBatteryAvailable = !!d.available
|
||||
if (d.available) {
|
||||
bar.mouseBatteryPct = d.pct
|
||||
bar.mouseBatteryCharging = !!d.charging
|
||||
}
|
||||
} catch (e) {
|
||||
bar.mouseBatteryAvailable = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 60s, not 1s like statsProc: querying openrazer's daemon over D-Bus is much
|
||||
// heavier than reading /proc, and a mouse's battery doesn't change fast enough
|
||||
// to need more than that anyway.
|
||||
Timer { interval: 200; running: true; repeat: false; onTriggered: mouseBatteryProc.running = true }
|
||||
Timer { interval: 60000; running: true; repeat: true; onTriggered: mouseBatteryProc.running = true }
|
||||
|
||||
Component {
|
||||
id: bellComp
|
||||
Rectangle {
|
||||
@@ -1256,40 +1226,6 @@ Variants {
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: mouseBatteryPill
|
||||
visible: !bar.taskbarMode && bar.mouseBatteryAvailable
|
||||
Layout.preferredWidth: mouseBatteryRow.implicitWidth + 14
|
||||
Layout.preferredHeight: 26
|
||||
radius: 10
|
||||
color: bar.hovered === "mouse" ? root.palette.accent : root.argb(root.palette.pill_color, root.pillOpacity)
|
||||
|
||||
Row {
|
||||
id: mouseBatteryRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
Text {
|
||||
text: ""
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 13
|
||||
color: bar.hovered === "mouse" ? "#0f111a" : (bar.mouseBatteryLow ? root.palette.color1 : root.palette.color2)
|
||||
}
|
||||
Text {
|
||||
text: bar.mouseBatteryPct + "%" + (bar.mouseBatteryCharging ? "" : "")
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 13
|
||||
color: bar.hovered === "mouse" ? "#0f111a" : root.palette.foreground
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: bar.hovered = "mouse"
|
||||
onExited: bar.hovered = ""
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
visible: bar.taskbarMode
|
||||
Layout.preferredWidth: visible ? 32 : 0
|
||||
@@ -1375,7 +1311,11 @@ Variants {
|
||||
// ================= POPUPS =================
|
||||
|
||||
LazyLoader {
|
||||
active: bar.hovered !== "" && bar.hovered !== "net"
|
||||
// Allowlist, not bar.hovered !== "" && bar.hovered !== "net": this tooltip
|
||||
// only has content for these five, so anything else hovered (help, mouse
|
||||
// battery, ...) showed it anyway - empty, since nothing here renders for
|
||||
// them, stacked right on top of their own dedicated tooltip if they have one.
|
||||
active: ["cpu", "mem", "disk", "gpu", "vol"].includes(bar.hovered)
|
||||
|
||||
PanelWindow {
|
||||
screen: bar.modelData
|
||||
|
||||
416
quickshell/default/MouseWidget.qml
Normal file
416
quickshell/default/MouseWidget.qml
Normal file
@@ -0,0 +1,416 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
|
||||
// Standalone widget (independent of Bar.qml, same pattern as ThemeWidget.qml), top-left
|
||||
// corner of the primary screen, right of ThemeWidget's icon row. Click opens Razer mouse
|
||||
// controls (DPI/poll rate/idle time/low-battery threshold) via openrazer - hidden
|
||||
// entirely if no Razer device is found, so it's a no-op for anyone without one.
|
||||
PanelWindow {
|
||||
id: widget
|
||||
screen: Quickshell.screens.find(function (s) { return s.name === "DP-1" }) || Quickshell.screens[0]
|
||||
anchors { top: true; left: true }
|
||||
// Stacked below ThemeWidget (own top:10, height 34) instead of next to it: these are
|
||||
// independent top-level components with no built-in cross-file layout binding, so a
|
||||
// side-by-side left offset would have to guess ThemeWidget's width instead of just
|
||||
// its height - which is fixed, so stacking by row is the one that stays aligned
|
||||
// regardless of how wide any of these ever get.
|
||||
margins { top: 50; left: 10 }
|
||||
implicitWidth: visible ? row.implicitWidth + 16 : 0
|
||||
implicitHeight: 34
|
||||
visible: available
|
||||
color: "transparent"
|
||||
WlrLayershell.namespace: "mouse-widget"
|
||||
WlrLayershell.layer: WlrLayer.Bottom
|
||||
|
||||
readonly property bool isGerman: Qt.locale().name.startsWith("de")
|
||||
readonly property string scriptsDir: Quickshell.shellDir + "/scripts"
|
||||
readonly property string themeDir: Quickshell.env("HOME") + "/.config/theme"
|
||||
|
||||
property bool settingsOpen: false
|
||||
|
||||
property bool available: false
|
||||
property string mouseName: ""
|
||||
property int batteryPct: 0
|
||||
property bool charging: false
|
||||
readonly property bool batteryLow: available && !charging && batteryPct <= 20
|
||||
property int dpi: 0
|
||||
property int dpiStage: 0
|
||||
property var dpiStages: []
|
||||
property int pollRate: 0
|
||||
property var supportedPollRates: []
|
||||
property int idleTime: 0
|
||||
// Hardware-capped at 25 regardless of what's asked for - confirmed by testing every
|
||||
// value 0-100 against the real device, not documented anywhere.
|
||||
property int lowBatteryThreshold: 0
|
||||
|
||||
// Matches Bar.qml's root.palette defaults - kept separate on purpose, these are two
|
||||
// independent top-level components (see margins comment above).
|
||||
property var palette: ({
|
||||
accent: "#1793d1", foreground: "#c0caf5", color1: "#f7768e", color2: "#a6e3a1",
|
||||
color8: "#565f89", popup_color: "#1a1b26",
|
||||
})
|
||||
property real popupOpacity: 0.90
|
||||
|
||||
function argb(hex, alpha) {
|
||||
var a = Math.round(Math.max(0, Math.min(1, alpha)) * 255).toString(16).padStart(2, "0")
|
||||
return "#" + a + hex.toString().replace("#", "")
|
||||
}
|
||||
|
||||
function applyStatus(d) {
|
||||
available = !!d.available
|
||||
if (!available) return
|
||||
mouseName = d.name
|
||||
batteryPct = d.pct
|
||||
charging = !!d.charging
|
||||
dpi = d.dpi
|
||||
dpiStage = d.dpi_stage
|
||||
dpiStages = d.dpi_stages
|
||||
pollRate = d.poll_rate
|
||||
supportedPollRates = d.supported_poll_rates
|
||||
idleTime = d.idle_time
|
||||
lowBatteryThreshold = d.low_battery_threshold
|
||||
}
|
||||
|
||||
function refreshPalette() { paletteDump.running = true }
|
||||
|
||||
Process {
|
||||
id: paletteDump
|
||||
command: ["python3", widget.themeDir + "/render.py", "--dump"]
|
||||
stdout: StdioCollector { id: paletteDumpCollector }
|
||||
onExited: {
|
||||
try {
|
||||
var c = JSON.parse(paletteDumpCollector.text)
|
||||
if ("popup_opacity" in c) widget.popupOpacity = c.popup_opacity
|
||||
var p = {}
|
||||
for (var key in widget.palette) p[key] = (key in c) ? c[key] : widget.palette[key]
|
||||
widget.palette = p
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: statusProc
|
||||
command: ["python3", widget.scriptsDir + "/mouse.py", "status"]
|
||||
stdout: StdioCollector { id: statusCollector }
|
||||
onExited: {
|
||||
try { widget.applyStatus(JSON.parse(statusCollector.text)) }
|
||||
catch (e) { widget.available = false }
|
||||
}
|
||||
}
|
||||
|
||||
// Re-run statusProc, then apply the fresh state - shared by every set-* control in
|
||||
// the popup, so each one's write is followed by a real read instead of just
|
||||
// assuming it took.
|
||||
Process {
|
||||
id: setProc
|
||||
stdout: StdioCollector { id: setCollector }
|
||||
onExited: {
|
||||
try { widget.applyStatus(JSON.parse(setCollector.text)) }
|
||||
catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
function set(args) {
|
||||
setProc.command = ["python3", widget.scriptsDir + "/mouse.py"].concat(args)
|
||||
setProc.running = true
|
||||
}
|
||||
|
||||
// 60s, not 1s: querying openrazer's daemon over D-Bus is much heavier than reading
|
||||
// /proc, and a mouse's battery doesn't change fast enough to need more than that.
|
||||
Timer { interval: 300; running: true; repeat: false; onTriggered: { widget.refreshPalette(); statusProc.running = true } }
|
||||
Timer { interval: 60000; running: true; repeat: true; onTriggered: statusProc.running = true }
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: 10
|
||||
// Same resting look as ThemeWidget's own icon row (subtle fill + border, not
|
||||
// just transparent-until-hover) - all these corner widgets should read as one
|
||||
// family at a glance, not as one themed button next to one plain-looking one.
|
||||
color: (mouseArea.containsMouse || widget.settingsOpen) ? widget.palette.accent : Qt.rgba(0.161, 0.204, 0.298, 0.14)
|
||||
border.width: 1
|
||||
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.4)
|
||||
|
||||
Row {
|
||||
id: row
|
||||
anchors.centerIn: parent
|
||||
spacing: 4
|
||||
leftPadding: 4
|
||||
rightPadding: 4
|
||||
|
||||
Text {
|
||||
text: ""
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 14
|
||||
color: (mouseArea.containsMouse || widget.settingsOpen) ? "#0f111a" : (widget.batteryLow ? widget.palette.color1 : widget.palette.color2)
|
||||
}
|
||||
Text {
|
||||
text: widget.batteryPct + "%" + (widget.charging ? "" : "")
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 13
|
||||
color: (mouseArea.containsMouse || widget.settingsOpen) ? "#0f111a" : widget.palette.foreground
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
widget.settingsOpen = !widget.settingsOpen
|
||||
if (widget.settingsOpen) widget.refreshPalette()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
active: widget.settingsOpen
|
||||
|
||||
PanelWindow {
|
||||
id: settingsWindow
|
||||
screen: widget.screen
|
||||
anchors { top: true; left: true }
|
||||
margins { top: 88; left: 10 }
|
||||
implicitWidth: 280
|
||||
implicitHeight: settingsCol.implicitHeight + 24
|
||||
color: "transparent"
|
||||
WlrLayershell.namespace: "mouse-widget-settings"
|
||||
WlrLayershell.layer: WlrLayer.Top
|
||||
|
||||
HyprlandFocusGrab {
|
||||
windows: [ settingsWindow ]
|
||||
active: true
|
||||
onCleared: widget.settingsOpen = false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: 12
|
||||
color: widget.argb(widget.palette.popup_color, widget.popupOpacity)
|
||||
border.width: 1
|
||||
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
|
||||
|
||||
ColumnLayout {
|
||||
id: settingsCol
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
spacing: 10
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: widget.mouseName
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 14
|
||||
font.bold: true
|
||||
color: widget.palette.foreground
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
// ---- DPI stages ----
|
||||
Text {
|
||||
text: "DPI (" + widget.dpi + ")"
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 12
|
||||
color: widget.palette.color8
|
||||
}
|
||||
|
||||
Flow {
|
||||
Layout.fillWidth: true
|
||||
spacing: 6
|
||||
|
||||
Repeater {
|
||||
model: widget.dpiStages
|
||||
|
||||
Rectangle {
|
||||
required property var modelData
|
||||
required property int index
|
||||
readonly property bool active: index === widget.dpiStage
|
||||
width: dpiLabel.implicitWidth + 14
|
||||
height: 24
|
||||
radius: 8
|
||||
color: active ? widget.palette.accent : (dpiArea.containsMouse ? widget.argb(widget.palette.color8, 0.35) : "transparent")
|
||||
border.width: 1
|
||||
border.color: active ? widget.palette.accent : widget.palette.color8
|
||||
|
||||
Text {
|
||||
id: dpiLabel
|
||||
anchors.centerIn: parent
|
||||
text: modelData
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 11
|
||||
color: active ? "#0f111a" : widget.palette.foreground
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: dpiArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: widget.set(["set-dpi-stage", index.toString()])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- poll rate ----
|
||||
Text {
|
||||
text: (widget.isGerman ? "Abfragerate" : "Poll rate") + " (" + widget.pollRate + " Hz)"
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 12
|
||||
color: widget.palette.color8
|
||||
}
|
||||
|
||||
Flow {
|
||||
Layout.fillWidth: true
|
||||
spacing: 6
|
||||
|
||||
Repeater {
|
||||
model: widget.supportedPollRates
|
||||
|
||||
Rectangle {
|
||||
required property var modelData
|
||||
readonly property bool active: modelData === widget.pollRate
|
||||
width: pollLabel.implicitWidth + 14
|
||||
height: 24
|
||||
radius: 8
|
||||
color: active ? widget.palette.accent : (pollArea.containsMouse ? widget.argb(widget.palette.color8, 0.35) : "transparent")
|
||||
border.width: 1
|
||||
border.color: active ? widget.palette.accent : widget.palette.color8
|
||||
|
||||
Text {
|
||||
id: pollLabel
|
||||
anchors.centerIn: parent
|
||||
text: modelData
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 11
|
||||
color: active ? "#0f111a" : widget.palette.foreground
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: pollArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: widget.set(["set-poll-rate", modelData.toString()])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- idle time (wireless sleep timeout, 60-900s) ----
|
||||
Text {
|
||||
text: (widget.isGerman ? "Ruhezustand nach" : "Sleep after") + " " + widget.idleTime + "s"
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 12
|
||||
color: widget.palette.color8
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 20
|
||||
|
||||
readonly property real shownValue: idleTrack.pressed ? idleDragValue : (widget.idleTime - 60) / (900 - 60)
|
||||
property real idleDragValue: 0
|
||||
|
||||
Rectangle {
|
||||
id: idleSliderTrack
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width
|
||||
height: 6
|
||||
radius: 3
|
||||
color: Qt.rgba(0.478, 0.635, 0.969, 0.15)
|
||||
}
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: idleSliderTrack.width * Math.max(0, Math.min(1, parent.shownValue))
|
||||
height: 6
|
||||
radius: 3
|
||||
color: widget.palette.accent
|
||||
}
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: Math.max(0, Math.min(idleSliderTrack.width, idleSliderTrack.width * parent.shownValue)) - width / 2
|
||||
width: 14; height: 14
|
||||
radius: 7
|
||||
color: widget.palette.foreground
|
||||
border.width: idleTrack.pressed ? 2 : 0
|
||||
border.color: widget.palette.accent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: idleTrack
|
||||
anchors.fill: parent
|
||||
preventStealing: true
|
||||
|
||||
function valueAt(mx) { return Math.max(0, Math.min(1, mx / width)) }
|
||||
onPressed: (mouse) => { parent.idleDragValue = valueAt(mouse.x) }
|
||||
onPositionChanged: (mouse) => { if (pressed) parent.idleDragValue = valueAt(mouse.x) }
|
||||
onReleased: {
|
||||
var seconds = Math.round(60 + parent.idleDragValue * (900 - 60))
|
||||
widget.set(["set-idle-time", seconds.toString()])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- low battery threshold (hardware-capped at 25%) ----
|
||||
Text {
|
||||
text: (widget.isGerman ? "Akku-Warnung bei" : "Low battery warning at") + " " + widget.lowBatteryThreshold + "%"
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 12
|
||||
color: widget.palette.color8
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 20
|
||||
|
||||
readonly property real shownValue: battTrack.pressed ? battDragValue : widget.lowBatteryThreshold / 25
|
||||
property real battDragValue: 0
|
||||
|
||||
Rectangle {
|
||||
id: battSliderTrack
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width
|
||||
height: 6
|
||||
radius: 3
|
||||
color: Qt.rgba(0.478, 0.635, 0.969, 0.15)
|
||||
}
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: battSliderTrack.width * Math.max(0, Math.min(1, parent.shownValue))
|
||||
height: 6
|
||||
radius: 3
|
||||
color: widget.palette.accent
|
||||
}
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: Math.max(0, Math.min(battSliderTrack.width, battSliderTrack.width * parent.shownValue)) - width / 2
|
||||
width: 14; height: 14
|
||||
radius: 7
|
||||
color: widget.palette.foreground
|
||||
border.width: battTrack.pressed ? 2 : 0
|
||||
border.color: widget.palette.accent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: battTrack
|
||||
anchors.fill: parent
|
||||
preventStealing: true
|
||||
|
||||
function valueAt(mx) { return Math.max(0, Math.min(1, mx / width)) }
|
||||
onPressed: (mouse) => { parent.battDragValue = valueAt(mouse.x) }
|
||||
onPositionChanged: (mouse) => { if (pressed) parent.battDragValue = valueAt(mouse.x) }
|
||||
onReleased: {
|
||||
var pct = Math.round(parent.battDragValue * 25)
|
||||
widget.set(["set-low-battery-threshold", pct.toString()])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
484
quickshell/default/RGBWidget.qml
Normal file
484
quickshell/default/RGBWidget.qml
Normal file
@@ -0,0 +1,484 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
|
||||
// Standalone widget (independent of Bar.qml, same pattern as ThemeWidget.qml/
|
||||
// MouseWidget.qml), top-left corner, right of MouseWidget's icon. Click opens RAM/GPU/
|
||||
// mainboard RGB controls (mode per device, one-click sync to the palette's accent) via
|
||||
// OpenRGB's SDK server - hidden entirely if that server isn't reachable, so it's a
|
||||
// no-op on a machine without these devices or without openrgb/openrgb-python installed.
|
||||
PanelWindow {
|
||||
id: widget
|
||||
screen: Quickshell.screens.find(function (s) { return s.name === "DP-1" }) || Quickshell.screens[0]
|
||||
anchors { top: true; left: true }
|
||||
// Same row as MouseWidget (own top:50), to its right - estimated past its icon +
|
||||
// up-to-3-digit percentage text (~80px) + a gap, not computed off it directly: two
|
||||
// independent top-level components, no built-in cross-file layout binding. Narrower
|
||||
// than MouseWidget's own content would leave a gap here instead of misaligning it.
|
||||
margins { top: 50; left: 76 }
|
||||
implicitWidth: visible ? 30 : 0
|
||||
implicitHeight: 34
|
||||
visible: available
|
||||
color: "transparent"
|
||||
WlrLayershell.namespace: "rgb-widget"
|
||||
WlrLayershell.layer: WlrLayer.Bottom
|
||||
|
||||
readonly property bool isGerman: Qt.locale().name.startsWith("de")
|
||||
readonly property string scriptsDir: Quickshell.shellDir + "/scripts"
|
||||
readonly property string themeDir: Quickshell.env("HOME") + "/.config/theme"
|
||||
|
||||
property bool settingsOpen: false
|
||||
property bool available: false
|
||||
property var devices: []
|
||||
// devices, but every DRAM entry (both RAM sticks, same model) collapsed into one -
|
||||
// one card, one set of controls, applied to both via set-*'s comma-separated ids.
|
||||
// Keyed by "ids" (always a list, even for a single device) instead of "id" from
|
||||
// here on, so the rest of the UI doesn't need two separate code paths.
|
||||
readonly property var groupedDevices: {
|
||||
var dram = devices.filter(function (d) { return d.type === "DRAM" })
|
||||
var rest = devices.filter(function (d) { return d.type !== "DRAM" })
|
||||
var out = rest.map(function (d) {
|
||||
var g = Object.assign({}, d); g.ids = [d.id]; return g
|
||||
})
|
||||
if (dram.length > 0) {
|
||||
var g = Object.assign({}, dram[0])
|
||||
g.ids = dram.map(function (d) { return d.id })
|
||||
if (dram.length > 1) g.name = g.name + " (×" + dram.length + ")"
|
||||
out.unshift(g)
|
||||
}
|
||||
return out
|
||||
}
|
||||
property string editingDeviceIds: ""
|
||||
property string hexInput: ""
|
||||
|
||||
// Matches Bar.qml's root.palette defaults - kept separate on purpose, see
|
||||
// MouseWidget.qml's identical property for why.
|
||||
property var palette: ({ accent: "#1793d1", foreground: "#c0caf5", color8: "#565f89", popup_color: "#1a1b26" })
|
||||
property real popupOpacity: 0.90
|
||||
|
||||
function argb(hex, alpha) {
|
||||
var a = Math.round(Math.max(0, Math.min(1, alpha)) * 255).toString(16).padStart(2, "0")
|
||||
return "#" + a + hex.toString().replace("#", "")
|
||||
}
|
||||
|
||||
function applyStatus(d) {
|
||||
available = !!d.available
|
||||
if (available) devices = d.devices
|
||||
}
|
||||
|
||||
function refreshPalette() { paletteDump.running = true }
|
||||
|
||||
Process {
|
||||
id: paletteDump
|
||||
command: ["python3", widget.themeDir + "/render.py", "--dump"]
|
||||
stdout: StdioCollector { id: paletteDumpCollector }
|
||||
onExited: {
|
||||
try {
|
||||
var c = JSON.parse(paletteDumpCollector.text)
|
||||
if ("popup_opacity" in c) widget.popupOpacity = c.popup_opacity
|
||||
var p = {}
|
||||
for (var key in widget.palette) p[key] = (key in c) ? c[key] : widget.palette[key]
|
||||
widget.palette = p
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: statusProc
|
||||
command: ["python3", widget.scriptsDir + "/rgb.py", "status"]
|
||||
stdout: StdioCollector { id: statusCollector }
|
||||
onExited: {
|
||||
try { widget.applyStatus(JSON.parse(statusCollector.text)) }
|
||||
catch (e) { widget.available = false }
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: setProc
|
||||
stdout: StdioCollector { id: setCollector }
|
||||
onExited: {
|
||||
try { widget.applyStatus(JSON.parse(setCollector.text)) }
|
||||
catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
function set(args) {
|
||||
setProc.command = ["python3", widget.scriptsDir + "/rgb.py"].concat(args)
|
||||
setProc.running = true
|
||||
}
|
||||
|
||||
// 60s: these devices don't change state on their own, this just keeps the widget in
|
||||
// sync if something else (e.g. OpenRGB's own GUI) changes it in the meantime.
|
||||
Timer { interval: 300; running: true; repeat: false; onTriggered: { widget.refreshPalette(); statusProc.running = true } }
|
||||
Timer { interval: 60000; running: true; repeat: true; onTriggered: statusProc.running = true }
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: 10
|
||||
color: (mouseArea.containsMouse || widget.settingsOpen) ? widget.palette.accent : Qt.rgba(0.161, 0.204, 0.298, 0.14)
|
||||
border.width: 1
|
||||
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.4)
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: ""
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 14
|
||||
color: (mouseArea.containsMouse || widget.settingsOpen) ? "#0f111a" : widget.palette.accent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
widget.settingsOpen = !widget.settingsOpen
|
||||
if (widget.settingsOpen) { widget.refreshPalette(); statusProc.running = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LazyLoader {
|
||||
active: widget.settingsOpen
|
||||
|
||||
PanelWindow {
|
||||
id: settingsWindow
|
||||
screen: widget.screen
|
||||
anchors { top: true; left: true }
|
||||
margins { top: 88; left: 10 }
|
||||
implicitWidth: 300
|
||||
implicitHeight: Math.min(settingsCol.implicitHeight + 24, widget.screen.height - 80)
|
||||
color: "transparent"
|
||||
WlrLayershell.namespace: "rgb-widget-settings"
|
||||
WlrLayershell.layer: WlrLayer.Top
|
||||
|
||||
HyprlandFocusGrab {
|
||||
windows: [ settingsWindow ]
|
||||
active: true
|
||||
onCleared: widget.settingsOpen = false
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: 12
|
||||
color: widget.argb(widget.palette.popup_color, widget.popupOpacity)
|
||||
border.width: 1
|
||||
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
|
||||
|
||||
Flickable {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
clip: true
|
||||
contentWidth: width
|
||||
contentHeight: settingsCol.implicitHeight
|
||||
boundsBehavior: Flickable.StopAtBounds
|
||||
|
||||
ColumnLayout {
|
||||
id: settingsCol
|
||||
width: parent.width
|
||||
spacing: 14
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 34
|
||||
radius: 8
|
||||
color: syncAllArea.containsMouse ? Qt.lighter(widget.palette.accent, 1.15) : widget.palette.accent
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: widget.isGerman ? "Alle auf Accent synchronisieren" : "Sync all to accent"
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.bold: true
|
||||
font.pixelSize: 13
|
||||
color: "#0f111a"
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: syncAllArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: widget.set(["sync-accent"])
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: widget.groupedDevices
|
||||
|
||||
ColumnLayout {
|
||||
id: deviceCol
|
||||
required property var modelData
|
||||
Layout.fillWidth: true
|
||||
spacing: 6
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 8
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: modelData.name
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 13
|
||||
font.bold: true
|
||||
color: widget.palette.foreground
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: 20; height: 20
|
||||
radius: 6
|
||||
color: Qt.rgba(modelData.color[0] / 255, modelData.color[1] / 255, modelData.color[2] / 255, 1)
|
||||
border.width: widget.editingDeviceIds === modelData.ids.join(",") ? 2 : 1
|
||||
border.color: widget.editingDeviceIds === modelData.ids.join(",") ? widget.palette.accent : Qt.rgba(1, 1, 1, 0.3)
|
||||
|
||||
MouseArea {
|
||||
id: swatchArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
if (widget.editingDeviceIds === modelData.ids.join(",")) {
|
||||
widget.editingDeviceIds = ""
|
||||
} else {
|
||||
widget.editingDeviceIds = modelData.ids.join(",")
|
||||
widget.hexInput = "#" + modelData.color.map(function (v) {
|
||||
return v.toString(16).padStart(2, "0")
|
||||
}).join("")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 8
|
||||
visible: widget.editingDeviceIds === deviceCol.modelData.ids.join(",")
|
||||
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 28
|
||||
radius: 6
|
||||
color: "#0f111a"
|
||||
border.width: 1
|
||||
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.3)
|
||||
|
||||
TextInput {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 6
|
||||
text: widget.hexInput
|
||||
onTextEdited: widget.hexInput = text
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 12
|
||||
color: widget.palette.foreground
|
||||
maximumLength: 7
|
||||
selectByMouse: true
|
||||
validator: RegularExpressionValidator { regularExpression: /#?[0-9a-fA-F]{0,6}/ }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
Layout.preferredWidth: 60
|
||||
Layout.preferredHeight: 28
|
||||
radius: 6
|
||||
readonly property bool valid: /^#[0-9a-fA-F]{6}$/.test(widget.hexInput)
|
||||
color: !valid ? Qt.rgba(1, 1, 1, 0.08) : (applyArea.containsMouse ? Qt.lighter(widget.palette.accent, 1.15) : widget.palette.accent)
|
||||
opacity: valid ? 1.0 : 0.5
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: widget.isGerman ? "OK" : "OK"
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 11
|
||||
color: "#0f111a"
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: applyArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
enabled: parent.valid
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
var h = widget.hexInput.replace("#", "")
|
||||
var r = parseInt(h.slice(0, 2), 16)
|
||||
var g = parseInt(h.slice(2, 4), 16)
|
||||
var b = parseInt(h.slice(4, 6), 16)
|
||||
widget.set(["set-color", deviceCol.modelData.ids.join(","), r.toString(), g.toString(), b.toString()])
|
||||
widget.editingDeviceIds = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Flow {
|
||||
Layout.fillWidth: true
|
||||
spacing: 6
|
||||
|
||||
Repeater {
|
||||
model: modelData.modes
|
||||
|
||||
Rectangle {
|
||||
// Named-id reference, not modelData.whatever: this delegate's own
|
||||
// `required property var modelData` (the mode) shadows the outer
|
||||
// ColumnLayout's identically-named one (the device) - deviceCol.modelData
|
||||
// reaches it by id instead, which shadowing doesn't affect.
|
||||
required property var modelData
|
||||
readonly property bool active: modelData.id === deviceCol.modelData.active_mode
|
||||
width: modeLabel.implicitWidth + 12
|
||||
height: 22
|
||||
radius: 7
|
||||
color: active ? widget.palette.accent : (modeArea.containsMouse ? widget.argb(widget.palette.color8, 0.35) : "transparent")
|
||||
border.width: 1
|
||||
border.color: active ? widget.palette.accent : widget.palette.color8
|
||||
|
||||
Text {
|
||||
id: modeLabel
|
||||
anchors.centerIn: parent
|
||||
text: modelData.name
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 10
|
||||
color: active ? "#0f111a" : widget.palette.foreground
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: modeArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: widget.set(["set-mode", deviceCol.modelData.ids.join(","), modelData.id.toString()])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Speed/brightness: only the device's *currently active* mode's
|
||||
// own range matters (most modes have both, Direct never does on
|
||||
// any of these three devices - see rgb.py's set_param()).
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 4
|
||||
visible: deviceCol.modelData.speed_min !== null && deviceCol.modelData.speed_max !== null
|
||||
|
||||
Text {
|
||||
text: widget.isGerman ? "Tempo" : "Speed"
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 10
|
||||
color: widget.palette.color8
|
||||
Layout.preferredWidth: 42
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 18
|
||||
|
||||
readonly property int vmin: deviceCol.modelData.speed_min || 0
|
||||
readonly property int vmax: deviceCol.modelData.speed_max || 1
|
||||
readonly property real shownValue: speedTrack.pressed ? speedDragValue : (deviceCol.modelData.speed - vmin) / Math.max(1, vmax - vmin)
|
||||
property real speedDragValue: 0
|
||||
|
||||
Rectangle {
|
||||
id: speedSliderTrack
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width; height: 5; radius: 2.5
|
||||
color: Qt.rgba(0.478, 0.635, 0.969, 0.15)
|
||||
}
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: speedSliderTrack.width * Math.max(0, Math.min(1, parent.shownValue))
|
||||
height: 5; radius: 2.5
|
||||
color: widget.palette.accent
|
||||
}
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: Math.max(0, Math.min(speedSliderTrack.width, speedSliderTrack.width * parent.shownValue)) - width / 2
|
||||
width: 12; height: 12; radius: 6
|
||||
color: widget.palette.foreground
|
||||
border.width: speedTrack.pressed ? 2 : 0
|
||||
border.color: widget.palette.accent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: speedTrack
|
||||
anchors.fill: parent
|
||||
preventStealing: true
|
||||
function valueAt(mx) { return Math.max(0, Math.min(1, mx / width)) }
|
||||
onPressed: (mouse) => { parent.speedDragValue = valueAt(mouse.x) }
|
||||
onPositionChanged: (mouse) => { if (pressed) parent.speedDragValue = valueAt(mouse.x) }
|
||||
onReleased: {
|
||||
var v = Math.round(parent.vmin + parent.speedDragValue * (parent.vmax - parent.vmin))
|
||||
widget.set(["set-speed", deviceCol.modelData.ids.join(","), v.toString()])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 4
|
||||
visible: deviceCol.modelData.brightness_min !== null && deviceCol.modelData.brightness_max !== null
|
||||
|
||||
Text {
|
||||
text: widget.isGerman ? "Helligk." : "Bright."
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: 10
|
||||
color: widget.palette.color8
|
||||
Layout.preferredWidth: 42
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: 18
|
||||
|
||||
readonly property int vmin: deviceCol.modelData.brightness_min || 0
|
||||
readonly property int vmax: deviceCol.modelData.brightness_max || 1
|
||||
readonly property real shownValue: brightTrack.pressed ? brightDragValue : (deviceCol.modelData.brightness - vmin) / Math.max(1, vmax - vmin)
|
||||
property real brightDragValue: 0
|
||||
|
||||
Rectangle {
|
||||
id: brightSliderTrack
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: parent.width; height: 5; radius: 2.5
|
||||
color: Qt.rgba(0.478, 0.635, 0.969, 0.15)
|
||||
}
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: brightSliderTrack.width * Math.max(0, Math.min(1, parent.shownValue))
|
||||
height: 5; radius: 2.5
|
||||
color: widget.palette.accent
|
||||
}
|
||||
Rectangle {
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
x: Math.max(0, Math.min(brightSliderTrack.width, brightSliderTrack.width * parent.shownValue)) - width / 2
|
||||
width: 12; height: 12; radius: 6
|
||||
color: widget.palette.foreground
|
||||
border.width: brightTrack.pressed ? 2 : 0
|
||||
border.color: widget.palette.accent
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: brightTrack
|
||||
anchors.fill: parent
|
||||
preventStealing: true
|
||||
function valueAt(mx) { return Math.max(0, Math.min(1, mx / width)) }
|
||||
onPressed: (mouse) => { parent.brightDragValue = valueAt(mouse.x) }
|
||||
onPositionChanged: (mouse) => { if (pressed) parent.brightDragValue = valueAt(mouse.x) }
|
||||
onReleased: {
|
||||
var v = Math.round(parent.vmin + parent.brightDragValue * (parent.vmax - parent.vmin))
|
||||
widget.set(["set-brightness", deviceCol.modelData.ids.join(","), v.toString()])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
84
quickshell/default/scripts/mouse.py
Normal file
84
quickshell/default/scripts/mouse.py
Normal file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Reads/controls the Razer mouse via openrazer.
|
||||
|
||||
mouse.py status JSON: battery + dpi + poll rate + idle time +
|
||||
low-battery threshold, or {"available": false}
|
||||
mouse.py set-dpi-stage N apply stored DPI stage N (0-4)
|
||||
mouse.py set-poll-rate HZ one of status's supported_poll_rates
|
||||
mouse.py set-idle-time SECONDS wireless sleep timeout, 60-900
|
||||
mouse.py set-low-battery-threshold PCT
|
||||
|
||||
Every command prints the same shape "status" does (the new state, after applying any
|
||||
change) - deliberately never raises, since a traceback on stdout would break the bar's
|
||||
JSON.parse of this output. {"available": false} covers openrazer not being installed,
|
||||
its daemon not being reachable, and no device being connected, alike.
|
||||
|
||||
openrazer-daemon only scans for devices at its own startup, not on USB hotplug - once
|
||||
it's running, switching the mouse between its USB cable and its wireless dongle (each
|
||||
a different USB product ID) goes completely unnoticed until something restarts it. So
|
||||
an empty device list gets one retry after doing exactly that, instead of just reporting
|
||||
unavailable until the next full daemon restart for an unrelated reason.
|
||||
"""
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
||||
def get_device():
|
||||
from openrazer.client import DeviceManager
|
||||
|
||||
def devices():
|
||||
return DeviceManager().devices
|
||||
|
||||
found = devices()
|
||||
if not found:
|
||||
subprocess.run(["systemctl", "--user", "restart", "openrazer-daemon"],
|
||||
check=False, capture_output=True, timeout=5)
|
||||
time.sleep(1.5)
|
||||
found = devices()
|
||||
if not found:
|
||||
raise RuntimeError("no device")
|
||||
return found[0]
|
||||
|
||||
|
||||
def status_json(d):
|
||||
stage_index, stages = d.dpi_stages
|
||||
return {
|
||||
"available": True,
|
||||
"name": d.name,
|
||||
"pct": d.battery_level,
|
||||
"charging": d.is_charging,
|
||||
"dpi": d.dpi[0],
|
||||
"dpi_stage": stage_index,
|
||||
"dpi_stages": [s[0] for s in stages],
|
||||
"poll_rate": d.poll_rate,
|
||||
"supported_poll_rates": d.supported_poll_rates,
|
||||
"idle_time": d.get_idle_time(),
|
||||
"low_battery_threshold": d.get_low_battery_threshold(),
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
try:
|
||||
d = get_device()
|
||||
if args[:1] == ["set-dpi-stage"]:
|
||||
_, stages = d.dpi_stages
|
||||
n = int(args[1])
|
||||
d.dpi = stages[n]
|
||||
elif args[:1] == ["set-poll-rate"]:
|
||||
d.poll_rate = int(args[1])
|
||||
elif args[:1] == ["set-idle-time"]:
|
||||
d.set_idle_time(int(args[1]))
|
||||
elif args[:1] == ["set-low-battery-threshold"]:
|
||||
d.set_low_battery_threshold(int(args[1]))
|
||||
elif args[:1] != ["status"] and args:
|
||||
sys.exit(__doc__)
|
||||
print(json.dumps(status_json(d)))
|
||||
except Exception:
|
||||
print(json.dumps({"available": False}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Prints the Razer mouse's battery as JSON: {"available": bool, "pct": int,
|
||||
"charging": bool, "name": str}. "available" is false (nothing else meaningful in the
|
||||
object) if openrazer isn't installed, its daemon isn't reachable, or no device is
|
||||
connected - deliberately never raises, since a traceback on stdout would break the
|
||||
bar's JSON.parse of this output.
|
||||
"""
|
||||
import json
|
||||
|
||||
try:
|
||||
from openrazer.client import DeviceManager
|
||||
devices = DeviceManager().devices
|
||||
if not devices:
|
||||
raise RuntimeError("no device")
|
||||
d = devices[0]
|
||||
print(json.dumps({"available": True, "pct": d.battery_level,
|
||||
"charging": d.is_charging, "name": d.name}))
|
||||
except Exception:
|
||||
print(json.dumps({"available": False}))
|
||||
138
quickshell/default/scripts/rgb.py
Normal file
138
quickshell/default/scripts/rgb.py
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Controls RAM/GPU/mainboard RGB (Corsair/Gigabyte/ASUS Aura, all via OpenRGB's SDK
|
||||
server - openrgb --server, autostarted in hyprland.lua) through openrgb-python.
|
||||
|
||||
rgb.py status JSON: {"available": bool, "devices": [...]} -
|
||||
each device is {id, name, type, active_mode,
|
||||
modes: [{id, name}], color: [r, g, b]}
|
||||
rgb.py set-color ID[,ID...] R G B Direct mode, that color, on every LED of
|
||||
each device
|
||||
rgb.py set-mode ID[,ID...] MODE_ID switch each device to one of its listed
|
||||
modes - by id, so this assumes they share
|
||||
the same mode list (true for same-model
|
||||
devices like a pair of RAM sticks, nothing
|
||||
else needs more than one ID here)
|
||||
rgb.py set-speed ID[,ID...] VALUE speed for each device's *currently active*
|
||||
mode - only if that mode's status has a
|
||||
non-null speed_min/speed_max (most do,
|
||||
Direct never does)
|
||||
rgb.py set-brightness ID[,ID...] VALUE same, for brightness
|
||||
rgb.py sync-accent set-color on every device using the palette's
|
||||
current accent (theme/colors.toml) - the point of
|
||||
having this at all: make the whole PC's RGB match
|
||||
the rest of the rice in one call
|
||||
|
||||
Every command prints the same shape "status" does (the new state, after applying any
|
||||
change) - deliberately never raises, since a traceback on stdout would break the bar's
|
||||
JSON.parse of this output. {"available": false} covers the SDK server not running and
|
||||
openrgb-python not being installed alike.
|
||||
|
||||
The server (openrgb 1.0-2, Arch extra) doesn't handle openrgb-python's default SDK
|
||||
protocol version (4) correctly - the plugin-list request it sends during connection
|
||||
setup just hangs until the socket times out. protocol_version=3 skips that and works.
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import tomllib
|
||||
|
||||
COLORS = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "..", "theme", "colors.toml")
|
||||
|
||||
|
||||
def get_client():
|
||||
from openrgb import OpenRGBClient
|
||||
return OpenRGBClient(protocol_version=3)
|
||||
|
||||
|
||||
def device_json(d):
|
||||
active = d.modes[d.active_mode]
|
||||
return {
|
||||
"id": d.id,
|
||||
"name": d.name,
|
||||
"type": d.type.name,
|
||||
"active_mode": d.active_mode,
|
||||
"modes": [{"id": m.id, "name": m.name} for m in d.modes],
|
||||
"color": [d.colors[0].red, d.colors[0].green, d.colors[0].blue] if d.colors else [0, 0, 0],
|
||||
# Only the *active* mode's params matter here - every mode has its own
|
||||
# independent speed/brightness, there's no single "device speed".
|
||||
"speed": active.speed, "speed_min": active.speed_min, "speed_max": active.speed_max,
|
||||
"brightness": active.brightness, "brightness_min": active.brightness_min, "brightness_max": active.brightness_max,
|
||||
}
|
||||
|
||||
|
||||
def status_json(c):
|
||||
return {"available": True, "devices": [device_json(d) for d in c.devices]}
|
||||
|
||||
|
||||
def set_color(d, r, g, b, _retry=True):
|
||||
from openrgb.utils import RGBColor
|
||||
# set_color() alone doesn't reliably force Direct first - caught live: a device left
|
||||
# on a cycling mode (Rainbow/Color Cycle) kept animating straight through it, so the
|
||||
# static color never actually stuck, even though querying it back claimed it had.
|
||||
direct = next((m for m in d.modes if m.name == "Direct"), None)
|
||||
if direct is not None and d.active_mode != direct.id:
|
||||
d.set_mode(direct.id)
|
||||
time.sleep(0.3) # the switch needs a moment before a color set reliably sticks
|
||||
d.set_color(RGBColor(r, g, b))
|
||||
if not _retry or direct is None:
|
||||
return
|
||||
# Also caught live, on the GPU specifically (its own i2c adapter, not the mainboard's
|
||||
# SMBus one that the RAM/mainboard share): intermittently, the mode switch above
|
||||
# silently doesn't take and the device is still cycling a few seconds later, despite
|
||||
# reporting Direct/the right color immediately after the calls above return. One
|
||||
# retry after actually re-reading the live state catches this without masking a
|
||||
# genuine failure as success.
|
||||
time.sleep(1.5)
|
||||
d.update()
|
||||
now = d.colors[0]
|
||||
if d.active_mode != direct.id or (now.red, now.green, now.blue) != (r, g, b):
|
||||
set_color(d, r, g, b, _retry=False)
|
||||
|
||||
|
||||
def set_param(d, **kwargs):
|
||||
# Mutate the *active* mode's ModeData in place, then push it back - set_mode() also
|
||||
# doubles as "apply these params to the mode I'm already in", there's no separate
|
||||
# set_speed()/set_brightness() in openrgb-python.
|
||||
m = d.modes[d.active_mode]
|
||||
for k, v in kwargs.items():
|
||||
setattr(m, k, v)
|
||||
d.set_mode(m)
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
try:
|
||||
c = get_client()
|
||||
if args[:1] == ["set-color"]:
|
||||
ids, r, g, b = [int(i) for i in args[1].split(",")], int(args[2]), int(args[3]), int(args[4])
|
||||
for device_id in ids:
|
||||
set_color(c.devices[device_id], r, g, b)
|
||||
elif args[:1] == ["set-mode"]:
|
||||
ids, mode_id = [int(i) for i in args[1].split(",")], int(args[2])
|
||||
for device_id in ids:
|
||||
c.devices[device_id].set_mode(mode_id)
|
||||
elif args[:1] == ["set-speed"]:
|
||||
ids, value = [int(i) for i in args[1].split(",")], int(args[2])
|
||||
for device_id in ids:
|
||||
set_param(c.devices[device_id], speed=value)
|
||||
elif args[:1] == ["set-brightness"]:
|
||||
ids, value = [int(i) for i in args[1].split(",")], int(args[2])
|
||||
for device_id in ids:
|
||||
set_param(c.devices[device_id], brightness=value)
|
||||
elif args[:1] == ["sync-accent"]:
|
||||
with open(COLORS, "rb") as f:
|
||||
accent = tomllib.load(f)["accent"].lstrip("#")
|
||||
r, g, b = (int(accent[i:i + 2], 16) for i in (0, 2, 4))
|
||||
for d in c.devices:
|
||||
set_color(d, r, g, b)
|
||||
elif args[:1] != ["status"] and args:
|
||||
sys.exit(__doc__)
|
||||
c2 = get_client() # re-fetch: the writes above don't update our local cache
|
||||
print(json.dumps(status_json(c2)))
|
||||
except Exception:
|
||||
print(json.dumps({"available": False}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -5,4 +5,6 @@ import Quickshell
|
||||
ShellRoot {
|
||||
Bar {}
|
||||
ThemeWidget {}
|
||||
MouseWidget {}
|
||||
RGBWidget {}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ popup_color = "#1a1b26"
|
||||
|
||||
# GTK file-selection highlight (Thunar's grid, etc.) - decoupled from `accent` so it can
|
||||
# be set independently, defaults to matching it.
|
||||
gtk_selection_color = "#7aa2f7"
|
||||
gtk_selection_color = "#f7768e"
|
||||
|
||||
# Opacity (0-1) for the bar itself, its pills, its popups, the terminal background, and
|
||||
# the GTK file-selection highlight above
|
||||
|
||||
Reference in New Issue
Block a user