added a systeminfo module to quickshell

This commit is contained in:
Tomas Rivera
2026-03-11 16:58:03 +01:00
parent a8568872bf
commit 587eb6179e
5 changed files with 128 additions and 69 deletions
+1
View File
@@ -76,6 +76,7 @@
(pkgs.callPackage ../../modules/scripts/manix.nix {})
(pkgs.callPackage ../../modules/scripts/man.nix {})
(pkgs.callPackage ../../modules/scripts/trimmer.nix {})
(pkgs.callPackage ../../modules/scripts/QSsysinfo.nix {})
#pkgs
pkgs.gruvbox-gtk-theme
# # Adds the 'hello' command to your environment. It prints a friendly
+2
View File
@@ -30,6 +30,8 @@
manix = "custom-manix";
man = "custom-man";
mplayer = "mplayer -volume 5";
snrt = "git add -A && sudo nixos-rebuild test --flake ~/nixos/#laptop";
snrs = "git add -A && sudo nixos-rebuild switch --flake ~/nixos/#laptop";
};
};
}
+31
View File
@@ -0,0 +1,31 @@
{
writeShellApplication,
ripgrep,
gawkInteractive,
...
}:
writeShellApplication {
name = "QS-sysinfo";
runtimeInputs = [
ripgrep
gawkInteractive
];
text = ''
Pad CPU, MEM, DISK to 2 chars (right-aligned)
cpu=$(awk '/^cpu /{printf("%.0f", ($2+$4)*100/($2+$4+$5))}' /proc/stat)
cpu=$(printf "%2s" "$cpu")
mem=$(free | awk '/Mem:/ {printf("%.0f",$3/$2*100)}')
mem=$(printf "%2s" "$mem")
disk=$(df / | awk 'NR==2 {gsub("%",""); print $5}')
disk=$(printf "%2s" "$disk")
# Pad POWER to 5 chars (XX.XX)
power=$(upower -b | awk -F: '/energy-rate/ {gsub(/^[ \t]+/, "", $2); split($2,a," "); printf("%.2f", a[1])}')
power=$(printf "%5s" "$power")
# Output JSON
echo "{\"cpu\":\"$cpu\",\"mem\":\"$mem\",\"disk\":\"$disk\",\"power\":\"$power\"}"
'';
}
+93 -71
View File
@@ -3,6 +3,7 @@ import QtQuick.Effects
import Quickshell
import QtQuick.Layouts
import Quickshell.Wayland
import Quickshell.Io
import "mpris" as Mpris
import "systray" as SysTray
import "../theme" as Theme
@@ -14,23 +15,24 @@ PanelWindow {
property var modelData
readonly property var tooltip: tooltip
readonly property real tooltipYOffset: root.height + 2
Tooltip {
id: tooltip
bar: root
}
function boundedY(targetY: real, height: real): real {
return Math.max(bar.anchors.topMargin + height, Math.min(bar.height + bar.anchors.topMargin - height, targetY));
return Math.max(bar.anchors.topMargin + height,
Math.min(bar.height + bar.anchors.topMargin - height, targetY));
}
function boundedX(targetX: real, width: real): real {
return Math.max(bar.anchors.leftMargin + width, Math.min(bar.width + bar.anchors.leftMargin - width, targetX));
return Math.max(bar.anchors.leftMargin + width,
Math.min(bar.width + bar.anchors.leftMargin - width, targetX));
}
WlrLayershell.namespace: "shell:bar"
anchors {
top: true
left: true
right: true
}
anchors { top: true; left: true; right: true }
exclusiveZone: 48
implicitHeight: 72
color: Theme.Colors.barColor1
@@ -44,25 +46,16 @@ PanelWindow {
Item {
id: bar
anchors {
top: parent.top
left: parent.left
right: parent.right
}
anchors { top: parent.top; left: parent.left; right: parent.right }
implicitHeight: 48
// ---------------- LEFT MODULE ----------------
Rectangle {
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
}
implicitWidth: left.width + left.anchors.leftMargin + left.anchors.rightMargin
implicitHeight: left.height
id: leftModule
anchors { top: parent.top; bottom: parent.bottom; left: parent.left }
color: Theme.Colors.barColor2
implicitWidth: left.childrenRect.width + 14
implicitHeight: left.childrenRect.height + 8
Rectangle {
z: -1
@@ -70,6 +63,7 @@ PanelWindow {
color: Theme.Colors.barColor3
anchors.margins: -4
}
Image {
width: 16 * 6
height: 4 * 6
@@ -81,39 +75,87 @@ PanelWindow {
RowLayout {
id: left
anchors {
top: parent.top
bottom: parent.bottom
left: parent.left
leftMargin: 7
rightMargin: 7
}
anchors { top: parent.top; bottom: parent.bottom; left: parent.left; leftMargin: 7; rightMargin: 7 }
spacing: 12
//Launcher {}
Workspaces {
bar: root
Workspaces { bar: root }
SysTray.SysTray { bar: root }
}
}
SysTray.SysTray {
bar: root
}
}
}
// ---------------- SYSINFO MODULE ----------------
Rectangle {
id: leftCenterModule
anchors { top: parent.top; bottom: parent.bottom; left: leftModule.right; leftMargin: 30 }
color: Theme.Colors.barColor6
implicitWidth: sysinfo.childrenRect.width + 16
implicitHeight: sysinfo.childrenRect.height + 8
Rectangle {
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
z: -1
anchors.fill: parent
color: Theme.Colors.barColor7
anchors.margins: -4
}
implicitWidth: right.width + right.anchors.leftMargin + right.anchors.rightMargin
implicitHeight: right.height
Image {
width: 16 * 6
height: 4 * 6
anchors.top: parent.bottom
anchors.left: parent.left
source: "../assets/bar-decor.png"
smooth: false
}
RowLayout {
id: sysinfo
spacing: 10
property int cpu: 0
property int mem: 0
property int disk: 0
property real power: 0
Timer {
interval: 2000
running: true
repeat: true
onTriggered: sysProcess.running = true
}
Process {
id: sysProcess
command: ["QS-sysinfo"]
stdout: SplitParser {
onRead: function(line) {
try {
var data = JSON.parse(line)
sysinfo.cpu = data.cpu
sysinfo.mem = data.mem
sysinfo.disk = data.disk
sysinfo.power = data.power
} catch(e) {}
}
}
}
Text {
id: infoText
text: "CPU " + sysinfo.cpu + "% MEM " + sysinfo.mem + "% DSK " + sysinfo.disk + "% PWR " + sysinfo.power + "W"
font.pixelSize: 18
color: Theme.Colors.barColor8
}
}
}
// ---------------- RIGHT MODULE ----------------
Rectangle {
id: rightCenterModule
anchors { top: parent.top; bottom: parent.bottom; right: parent.right }
color: Theme.Colors.barColor4
implicitWidth: right.childrenRect.width + 14
implicitHeight: right.childrenRect.height + 8
Rectangle {
z: -1
@@ -121,6 +163,7 @@ PanelWindow {
color: Theme.Colors.barColor5
anchors.margins: -4
}
Image {
width: 16 * 6
height: 4 * 6
@@ -133,34 +176,13 @@ PanelWindow {
RowLayout {
id: right
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
leftMargin: 7
rightMargin: 7
}
anchors { top: parent.top; bottom: parent.bottom; right: parent.right; leftMargin: 7; rightMargin: 7 }
spacing: 12
Time {}
Volume {
bar: root
}
Mpris.Players {
window: root
bar: root
}
//Theme {}
Power {
id: power
bar: root
}
Volume { bar: root }
Mpris.Players { window: root; bar: root }
Power { id: power; bar: root }
}
}
}
+3
View File
@@ -51,6 +51,9 @@ QtObject {
readonly property color barColor3: border // Left block bar border original color: "#BE850E"
readonly property color barColor4: background // Right block bar background original color: "#3B253F"
readonly property color barColor5: border // Right block bar border original color: "#BE850E"
readonly property color barColor6: background // left center block bar background
readonly property color barColor7: border // left center block bar border
readonly property color barColor8: text // left center block bar text color
readonly property color powerColor1: black // Battery indicator empty color original color: "black"
readonly property color powerColor2: red // original color: "red"
readonly property color powerColor3: accentYellow // Battery indicator normal color original color: "#EEA939"