dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Compare Notes Search feat(nuguland): sort bar widgets by persistent usage a5cf593e17b9bbaebdb72f313d753b1e0f2ad702
Oliver Jan Krylow <oliver@bugabinga.net > · 26 Jun 2026
unsigned
Browse files Compare with HEAD
Wire the usage tracker into the shell and drive the bar's widget order
from it. The two static chip groups collapse into one Repeater over the
usage-sorted layout order; chip label/width move into chipLabel()/
chipWidth() resolvers. Opening a widget records a use (close-toggle does
not). Order is snapshotted at load, so the bar stays put within a session
and re-sorts on next launch. Adds a 'usage' IPC target for inspection.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Changed files (3) quickshell/nuguland/Bar.qml Modified 24 24 required property
QtObject idleService
25 25 required property
QtObject lockService
26 26 required property
QtObject surfaces
27 + required property
QtObject usageService
29 + function chipLabel (name) {
30 + switch (
String (name)) {
32 + return root.timeService
? root.timeService.compact
: "--:--" ;
42 + return root.audioService
? root.audioService.privacyLabel().toLowerCase()
: "audio" ;
45 + case "connectivity" :
49 + case "notifications" :
52 + return root.trayService
&& root.trayService.attentionCount
> 0 ? `tray ${root.trayService.attentionCount}
` : "tray" ;
56 + return String (name);
59 + function chipWidth (name) {
60 + switch (
String (name)) {
72 + return root.audioService
&& root.audioService.privacyLabel()
=== "Mic Cam" ? 80 : 62 ;
75 + case "connectivity" :
79 + case "notifications" :
82 + return root.trayService
&& root.trayService.attentionCount
> 0 ? 66 : 54 ;
28 89 function itemRectInBar (item) {
57 118 const target
= String (name);
58 - if (root.surfaces.popoutOpen
&& root.surfaces.popoutName
=== target)
119 + if (root.surfaces.popoutOpen
&& root.surfaces.popoutName
=== target) {
59 120 root.surfaces.closePopout(
"bar-toggle" );
122 + if (root.usageService)
123 + root.usageService.record(target);
61 125 root.surfaces.openRegisteredPopout(target);
64 129 function refreshSurfaceGeometry () {
106 171 Layout .alignment:
Qt .AlignVCenter
110 - popoutName :
"clock" 111 - label : root.timeService
? root.timeService.compact
: "--:--" 175 + model : root.usageService
? root.usageService.layoutOrder
: []
116 - popoutName :
"launcher" 177 + delegate : BarChip {
178 + required property
var modelData
122 - popoutName :
"media" 180 + popoutName : modelData
181 + label : root.chipLabel(modelData)
182 + preferredWidth : root.chipWidth(modelData)
130 - Layout .alignment:
Qt .AlignVCenter
134 - popoutName :
"system" 140 - popoutName :
"clipboard" 146 - popoutName :
"audio" 147 - label : root.audioService
? root.audioService.privacyLabel().toLowerCase()
: "audio" 148 - preferredWidth : root.audioService
&& root.audioService.privacyLabel()
=== "Mic Cam" ? 80 : 62 152 - popoutName :
"brightness" 158 - popoutName :
"connectivity" 164 - popoutName :
"power" 170 - popoutName :
"notifications" 177 - label : root.trayService
&& root.trayService.attentionCount
> 0 ? `tray ${root.trayService.attentionCount}
` : "tray" 178 - preferredWidth : root.trayService
&& root.trayService.attentionCount
> 0 ? 66 : 54 quickshell/nuguland/Usage.qml Modified 13 13 readonly property var widgets: [
"clock" ,
"launcher" ,
"media" ,
"system" ,
"clipboard" ,
"audio" ,
"brightness" ,
"connectivity" ,
"power" ,
"notifications" ,
"tray" ,
"idle" ]
16 16 property
var layoutOrder: widgets
17 + property bool snapshotted:
false 19 + function snapshot () {
20 + if (root.snapshotted)
23 + root.snapshotted
= true ;
24 + root.layoutOrder
= root.ordered();
18 27 function countFor (name) {
19 28 const counts
= usageAdapter.counts
|| ({
65 76 path :
Quickshell .statePath(
"nuguland-widget-usage.json" )
67 - onFileChanged : reload()
68 77 onAdapterUpdated : writeAdapter()
69 - onLoaded : root.layoutOrder
= root.ordered()
70 - onLoadFailed : root.layoutOrder
= root.widgets
78 + onLoaded : root.snapshot()
79 + onLoadFailed : root.snapshot()
quickshell/nuguland/shell.qml Modified 110 110 id :
surfaceManager 114 118 model :
Quickshell .screens
334 338 idleService: idle
335 339 lockService: lock
336 340 surfaces: surfaceManager
341 + usageService: usage
408 413 target:
"brightness" 417 + function usageState () : string {
418 + return usage.stateJson();
421 + function record (name: string) : string {
422 + return usage.record(name);
412 429 function ping () : string {
413 430 return "nuguland" ;