mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-12 10:30:44 +02:00
added a systeminfo module to quickshell
This commit is contained in:
@@ -76,6 +76,7 @@
|
|||||||
(pkgs.callPackage ../../modules/scripts/manix.nix {})
|
(pkgs.callPackage ../../modules/scripts/manix.nix {})
|
||||||
(pkgs.callPackage ../../modules/scripts/man.nix {})
|
(pkgs.callPackage ../../modules/scripts/man.nix {})
|
||||||
(pkgs.callPackage ../../modules/scripts/trimmer.nix {})
|
(pkgs.callPackage ../../modules/scripts/trimmer.nix {})
|
||||||
|
(pkgs.callPackage ../../modules/scripts/QSsysinfo.nix {})
|
||||||
#pkgs
|
#pkgs
|
||||||
pkgs.gruvbox-gtk-theme
|
pkgs.gruvbox-gtk-theme
|
||||||
# # Adds the 'hello' command to your environment. It prints a friendly
|
# # Adds the 'hello' command to your environment. It prints a friendly
|
||||||
|
|||||||
@@ -30,6 +30,8 @@
|
|||||||
manix = "custom-manix";
|
manix = "custom-manix";
|
||||||
man = "custom-man";
|
man = "custom-man";
|
||||||
mplayer = "mplayer -volume 5";
|
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";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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\"}"
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import QtQuick.Effects
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import Quickshell.Wayland
|
import Quickshell.Wayland
|
||||||
|
import Quickshell.Io
|
||||||
import "mpris" as Mpris
|
import "mpris" as Mpris
|
||||||
import "systray" as SysTray
|
import "systray" as SysTray
|
||||||
import "../theme" as Theme
|
import "../theme" as Theme
|
||||||
@@ -14,23 +15,24 @@ PanelWindow {
|
|||||||
property var modelData
|
property var modelData
|
||||||
readonly property var tooltip: tooltip
|
readonly property var tooltip: tooltip
|
||||||
readonly property real tooltipYOffset: root.height + 2
|
readonly property real tooltipYOffset: root.height + 2
|
||||||
|
|
||||||
Tooltip {
|
Tooltip {
|
||||||
id: tooltip
|
id: tooltip
|
||||||
bar: root
|
bar: root
|
||||||
}
|
}
|
||||||
|
|
||||||
function boundedY(targetY: real, height: real): real {
|
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 {
|
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"
|
WlrLayershell.namespace: "shell:bar"
|
||||||
anchors {
|
anchors { top: true; left: true; right: true }
|
||||||
top: true
|
|
||||||
left: true
|
|
||||||
right: true
|
|
||||||
}
|
|
||||||
exclusiveZone: 48
|
exclusiveZone: 48
|
||||||
implicitHeight: 72
|
implicitHeight: 72
|
||||||
color: Theme.Colors.barColor1
|
color: Theme.Colors.barColor1
|
||||||
@@ -44,25 +46,16 @@ PanelWindow {
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: bar
|
id: bar
|
||||||
|
anchors { top: parent.top; left: parent.left; right: parent.right }
|
||||||
anchors {
|
|
||||||
top: parent.top
|
|
||||||
left: parent.left
|
|
||||||
right: parent.right
|
|
||||||
}
|
|
||||||
|
|
||||||
implicitHeight: 48
|
implicitHeight: 48
|
||||||
|
|
||||||
|
// ---------------- LEFT MODULE ----------------
|
||||||
Rectangle {
|
Rectangle {
|
||||||
anchors {
|
id: leftModule
|
||||||
top: parent.top
|
anchors { top: parent.top; bottom: parent.bottom; left: parent.left }
|
||||||
bottom: parent.bottom
|
|
||||||
left: parent.left
|
|
||||||
}
|
|
||||||
|
|
||||||
implicitWidth: left.width + left.anchors.leftMargin + left.anchors.rightMargin
|
|
||||||
implicitHeight: left.height
|
|
||||||
color: Theme.Colors.barColor2
|
color: Theme.Colors.barColor2
|
||||||
|
implicitWidth: left.childrenRect.width + 14
|
||||||
|
implicitHeight: left.childrenRect.height + 8
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
z: -1
|
z: -1
|
||||||
@@ -70,6 +63,7 @@ PanelWindow {
|
|||||||
color: Theme.Colors.barColor3
|
color: Theme.Colors.barColor3
|
||||||
anchors.margins: -4
|
anchors.margins: -4
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
width: 16 * 6
|
width: 16 * 6
|
||||||
height: 4 * 6
|
height: 4 * 6
|
||||||
@@ -81,39 +75,87 @@ PanelWindow {
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: left
|
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
|
spacing: 12
|
||||||
|
|
||||||
//Launcher {}
|
Workspaces { bar: root }
|
||||||
|
SysTray.SysTray { bar: root }
|
||||||
Workspaces {
|
}
|
||||||
bar: root
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SysTray.SysTray {
|
// ---------------- SYSINFO MODULE ----------------
|
||||||
bar: root
|
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 {
|
Rectangle {
|
||||||
anchors {
|
z: -1
|
||||||
top: parent.top
|
anchors.fill: parent
|
||||||
bottom: parent.bottom
|
color: Theme.Colors.barColor7
|
||||||
right: parent.right
|
anchors.margins: -4
|
||||||
}
|
}
|
||||||
|
|
||||||
implicitWidth: right.width + right.anchors.leftMargin + right.anchors.rightMargin
|
Image {
|
||||||
implicitHeight: right.height
|
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
|
color: Theme.Colors.barColor4
|
||||||
|
implicitWidth: right.childrenRect.width + 14
|
||||||
|
implicitHeight: right.childrenRect.height + 8
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
z: -1
|
z: -1
|
||||||
@@ -121,6 +163,7 @@ PanelWindow {
|
|||||||
color: Theme.Colors.barColor5
|
color: Theme.Colors.barColor5
|
||||||
anchors.margins: -4
|
anchors.margins: -4
|
||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
width: 16 * 6
|
width: 16 * 6
|
||||||
height: 4 * 6
|
height: 4 * 6
|
||||||
@@ -133,34 +176,13 @@ PanelWindow {
|
|||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: right
|
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
|
spacing: 12
|
||||||
|
|
||||||
Time {}
|
Time {}
|
||||||
|
Volume { bar: root }
|
||||||
Volume {
|
Mpris.Players { window: root; bar: root }
|
||||||
bar: root
|
Power { id: power; bar: root }
|
||||||
}
|
|
||||||
|
|
||||||
Mpris.Players {
|
|
||||||
window: root
|
|
||||||
bar: root
|
|
||||||
}
|
|
||||||
|
|
||||||
//Theme {}
|
|
||||||
|
|
||||||
Power {
|
|
||||||
id: power
|
|
||||||
bar: root
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ QtObject {
|
|||||||
readonly property color barColor3: border // Left block bar border original color: "#BE850E"
|
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 barColor4: background // Right block bar background original color: "#3B253F"
|
||||||
readonly property color barColor5: border // Right block bar border original color: "#BE850E"
|
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 powerColor1: black // Battery indicator empty color original color: "black"
|
||||||
readonly property color powerColor2: red // original color: "red"
|
readonly property color powerColor2: red // original color: "red"
|
||||||
readonly property color powerColor3: accentYellow // Battery indicator normal color original color: "#EEA939"
|
readonly property color powerColor3: accentYellow // Battery indicator normal color original color: "#EEA939"
|
||||||
|
|||||||
Reference in New Issue
Block a user