Krolyxon
Commit af47ed6

Branches

Refs →

aurora.configquickshellauroraCatLoop.qml

42 lines · 1.3 KB · QML

1import QtQuick
2
3// catloop.sh, natively: frames A-E awake, G-N asleep. Faster with more CPU load,
4// falls asleep after 4 idle cycles. Needs the "Waycat" font you already use.
5Item {
6 id: cat
7 implicitWidth: Math.max(40, size * 2.6)
8 property int size: 14 // the bar uses 14; the home screen draws it big
9
10 property int idx: 0
11 property bool sleeping: false
12 property int low: 0
13 readonly property var awake: ["A", "B", "C", "D", "E"]
14 readonly property var asleep: ["G", "H", "I", "J", "K", "L", "M", "N"]
15 readonly property var frames: sleeping ? asleep : awake
16
17 Text {
18 anchors.centerIn: parent
19 text: cat.frames[cat.idx] || ""
20 color: Theme.fg
21 font.family: "Waycat"
22 font.pixelSize: cat.size
23 font.bold: true
24 }
25
26 Timer {
27 id: tick
28 running: true
29 repeat: true
30 interval: 250
31 onTriggered: {
32 var next = cat.idx + 1
33 if (next >= cat.frames.length) {
34 next = 0
35 cat.low = SysStats.cpu < 0.02 ? cat.low + 1 : 0
36 cat.sleeping = cat.low >= 4
37 }
38 cat.idx = next
39 tick.interval = Math.round(Math.max(0.03, 1 / (4 + SysStats.cpu * 100)) * 1000)
40 }
41 }
42}