Compare commits
No commits in common. "5de09fd5e27273baf0a5971e9c5c2d65cfa68bfb" and "5f3864afbad3b2cf8571843d1b11d3535cb33a2d" have entirely different histories.
5de09fd5e2
...
5f3864afba
10 changed files with 5 additions and 28 deletions
|
|
@ -66,7 +66,6 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: root.percent + "%"
|
label: root.percent + "%"
|
||||||
minText: "100%"
|
|
||||||
color: M.Theme.base0A
|
color: M.Theme.base0A
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ Item {
|
||||||
anchors.fill: shadowSource
|
anchors.fill: shadowSource
|
||||||
shadowEnabled: true
|
shadowEnabled: true
|
||||||
shadowColor: root.borderColor
|
shadowColor: root.borderColor
|
||||||
shadowBlur: 1.0
|
shadowBlur: 0.6
|
||||||
shadowVerticalOffset: 0
|
shadowVerticalOffset: 0
|
||||||
shadowHorizontalOffset: 0
|
shadowHorizontalOffset: 0
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,17 +6,8 @@ Text {
|
||||||
id: root
|
id: root
|
||||||
property string label: ""
|
property string label: ""
|
||||||
property string tooltip: ""
|
property string tooltip: ""
|
||||||
property string minText: ""
|
|
||||||
|
|
||||||
text: label
|
text: label
|
||||||
width: minText ? Math.max(implicitWidth, _minMetrics.width) : implicitWidth
|
|
||||||
|
|
||||||
TextMetrics {
|
|
||||||
id: _minMetrics
|
|
||||||
text: root.minText
|
|
||||||
font.pixelSize: root.font.pixelSize
|
|
||||||
font.family: root.font.family
|
|
||||||
}
|
|
||||||
color: M.Theme.base05
|
color: M.Theme.base05
|
||||||
font.pixelSize: M.Theme.fontSize
|
font.pixelSize: M.Theme.fontSize
|
||||||
font.family: M.Theme.fontFamily
|
font.family: M.Theme.fontFamily
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,6 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: Math.round(root.pct) + "%"
|
label: Math.round(root.pct) + "%"
|
||||||
minText: "100%"
|
|
||||||
color: root._stateColor
|
color: root._stateColor
|
||||||
opacity: root._blinkOpacity
|
opacity: root._blinkOpacity
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
|
|
||||||
|
|
@ -10,31 +10,24 @@ M.BarSection {
|
||||||
if (root.state === "off")
|
if (root.state === "off")
|
||||||
return "Bluetooth: off";
|
return "Bluetooth: off";
|
||||||
if (root.state === "connected")
|
if (root.state === "connected")
|
||||||
return "Bluetooth: " + root.device + (root.batteryPct >= 0 ? "\nBattery: " + root.batteryPct + "%" : "");
|
return "Bluetooth: " + root.device;
|
||||||
return "Bluetooth: on";
|
return "Bluetooth: on";
|
||||||
}
|
}
|
||||||
|
|
||||||
property string state: "unavailable"
|
property string state: "unavailable"
|
||||||
property string device: ""
|
property string device: ""
|
||||||
property int batteryPct: -1
|
|
||||||
|
|
||||||
function _parse(text) {
|
function _parse(text) {
|
||||||
const lines = text.trim().split("\n");
|
const t = text.trim();
|
||||||
const t = lines[0] || "";
|
|
||||||
const sep = t.indexOf(":");
|
const sep = t.indexOf(":");
|
||||||
root.state = sep === -1 ? t : t.slice(0, sep);
|
root.state = sep === -1 ? t : t.slice(0, sep);
|
||||||
root.device = sep === -1 ? "" : t.slice(sep + 1);
|
root.device = sep === -1 ? "" : t.slice(sep + 1);
|
||||||
root.batteryPct = -1;
|
|
||||||
for (let i = 1; i < lines.length; i++) {
|
|
||||||
if (lines[i].startsWith("bat:"))
|
|
||||||
root.batteryPct = parseInt(lines[i].slice(4)) || -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: proc
|
id: proc
|
||||||
running: true
|
running: true
|
||||||
command: ["sh", "-c", "s=$(bluetoothctl show 2>/dev/null); " + "[ -z \"$s\" ] && echo unavailable && exit; " + "echo \"$s\" | grep -q 'Powered: yes' || { echo off:; exit; }; " + "info=$(bluetoothctl info 2>/dev/null); " + "d=$(echo \"$info\" | awk -F': ' '/\\tName:/{n=$2}/Connected: yes/{c=1}END{if(c)print n}'); " + "[ -n \"$d\" ] && echo \"connected:$d\" || { echo on:; exit; }; " + "bat=$(echo \"$info\" | awk -F': ' '/Battery Percentage.*\\(/{gsub(/[^0-9]/,\"\",$2);print $2}'); " + "[ -n \"$bat\" ] && echo \"bat:$bat\""]
|
command: ["sh", "-c", "s=$(bluetoothctl show 2>/dev/null); " + "[ -z \"$s\" ] && echo unavailable && exit; " + "echo \"$s\" | grep -q 'Powered: yes' || { echo off:; exit; }; " + "d=$(bluetoothctl info 2>/dev/null | awk -F': ' '/\\tName:/{n=$2}/Connected: yes/{c=1}END{if(c)print n}'); " + "[ -n \"$d\" ] && echo \"connected:$d\" || echo on:"]
|
||||||
stdout: StdioCollector {
|
stdout: StdioCollector {
|
||||||
onStreamFinished: root._parse(text)
|
onStreamFinished: root._parse(text)
|
||||||
}
|
}
|
||||||
|
|
@ -61,7 +54,7 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
visible: root.state === "connected"
|
visible: root.state === "connected"
|
||||||
label: root.device + (root.batteryPct >= 0 ? " " + root.batteryPct + "%" : "")
|
label: root.device
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,6 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: root.usage.toString().padStart(2) + "%@" + root.freqGhz.toFixed(2)
|
label: root.usage.toString().padStart(2) + "%@" + root.freqGhz.toFixed(2)
|
||||||
minText: "99%@9.99"
|
|
||||||
color: M.Theme.base08
|
color: M.Theme.base08
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: root.freePct + "% " + root.totalTb.toFixed(1)
|
label: root.freePct + "% " + root.totalTb.toFixed(1)
|
||||||
minText: "100% 9.9"
|
|
||||||
color: M.Theme.base08
|
color: M.Theme.base08
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,6 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: root.percent + "%"
|
label: root.percent + "%"
|
||||||
minText: "100%"
|
|
||||||
color: M.Theme.base08
|
color: M.Theme.base08
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,6 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: root.celsius + "\u00B0C"
|
label: root.celsius + "\u00B0C"
|
||||||
minText: "100\u00B0C"
|
|
||||||
color: root._stateColor
|
color: root._stateColor
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ M.BarSection {
|
||||||
}
|
}
|
||||||
M.BarLabel {
|
M.BarLabel {
|
||||||
label: Math.round(root.volume * 100) + "%"
|
label: Math.round(root.volume * 100) + "%"
|
||||||
minText: "100%"
|
|
||||||
color: root.muted ? M.Theme.base04 : M.Theme.base0E
|
color: root.muted ? M.Theme.base04 : M.Theme.base0E
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue