swadhinbiswas Docker widget opens lazydocker on click, add lazydocker to packages · 8/22/2026
2416041
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import QtQuick
import Quickshell
import Quickshell.Io
import qs.Commons
import qs.Ui
BarWidget {
id: root
moduleName: "deomarchy.docker-status"
property int runningCount: 0
property int unhealthyCount: 0
property bool dockerAvailable: false
property string containerList: ""
visible: dockerAvailable
implicitWidth: label.implicitWidth + Style.spacing.controlPaddingX * 2
implicitHeight: barSize
function refresh() {
if (!dockerProc.running) dockerProc.running = true
}
function updateStatus(raw) {
var lines = String(raw || "").trim().split("\n")
var running = 0
var unhealthy = 0
var names = []
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim()
if (line === "") continue
var parts = line.split("|")
if (parts.length < 2) continue
var status = parts[1].toLowerCase()
if (status.indexOf("up") !== -1) {
running++
names.push(parts[0])
if (status.indexOf("unhealthy") !== -1) unhealthy++
}
}
runningCount = running
unhealthyCount = unhealthy
containerList = names.join(", ")
dockerAvailable = running > 0 || unhealthy > 0
}
Component.onCompleted: refresh()
Process {
id: dockerProc
command: ["docker", "ps", "--format", "{{.Names}}|{{.Status}}"]
onExited: function(exitCode) {
if (exitCode !== 0) root.dockerAvailable = false
}
stdout: StdioCollector {
waitForEnd: true
onStreamFinished: root.updateStatus(text)
}
}
Timer {
interval: 5000
running: true
repeat: true
onTriggered: root.refresh()
}
IpcHandler {
target: "deomarchy.docker-status"
function refresh(): void { root.refresh() }
}
Text {
id: label
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
text: root.unhealthyCount > 0
? "\uf308 " + root.runningCount + " \u26a0"
: "\uf308 " + root.runningCount
color: root.unhealthyCount > 0 ? Color.urgent : Color.foreground
font.family: root.bar ? root.bar.fontFamily : Style.font.family
font.pixelSize: Style.font.body
opacity: 0.85
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
// Launch lazydocker in a terminal
root.bar.run("uwsm-app -- kitty -e lazydocker")
}
onEntered: {
if (root.bar) root.bar.showTooltip(root, "Docker: " + root.runningCount + " running\n" + root.containerList + "\nClick to open lazydocker")
}
}
}