Krolyxon
Commit 1904397

Branches

Refs →

aurora.configquickshellauroraCatLoop.qml

41 lines · 1.1 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: 40
8
9 property int idx: 0
10 property bool sleeping: false
11 property int low: 0
12 readonly property var awake: ["A", "B", "C", "D", "E"]
13 readonly property var asleep: ["G", "H", "I", "J", "K", "L", "M", "N"]
14 readonly property var frames: sleeping ? asleep : awake
15
16 Text {
17 anchors.centerIn: parent
18 text: cat.frames[cat.idx] || ""
19 color: Theme.fg
20 font.family: "Waycat"
21 font.pixelSize: 14
22 font.bold: true
23 }
24
25 Timer {
26 id: tick
27 running: true
28 repeat: true
29 interval: 250
30 onTriggered: {
31 var next = cat.idx + 1
32 if (next >= cat.frames.length) {
33 next = 0
34 cat.low = SysStats.cpu < 0.02 ? cat.low + 1 : 0
35 cat.sleeping = cat.low >= 4
36 }
37 cat.idx = next
38 tick.interval = Math.round(Math.max(0.03, 1 / (4 + SysStats.cpu * 100)) * 1000)
39 }
40 }
41}