Worked on quickshell finalized module sysinfo

This commit is contained in:
Tomas Rivera
2026-03-12 10:05:27 +01:00
parent 587eb6179e
commit ddd474d0d9
5 changed files with 127 additions and 58 deletions
+3 -1
View File
@@ -22,7 +22,9 @@
documentation.man.generateCaches = true; # used for the man script documentation.man.generateCaches = true; # used for the man script
qt.enable = true; hardware.bluetooth.enable = true;
qt.enable = true;
# grub theme # grub theme
boot.loader.grub = { boot.loader.grub = {
+1 -1
View File
@@ -21,7 +21,7 @@
../../modules/home-manager/neovim.nix # dont use nixvim. broken ../../modules/home-manager/neovim.nix # dont use nixvim. broken
#../../modules/home-manager/neovim2.nix # ./neovim2.nix uses vim plug instead of the nix repository as with ./neovim.nix see the begining of neovim2 for an explanation #../../modules/home-manager/neovim2.nix # ./neovim2.nix uses vim plug instead of the nix repository as with ./neovim.nix see the begining of neovim2 for an explanation
../../modules/home-manager/rclone.nix ../../modules/home-manager/rclone.nix
#../../modules/home-manager/waybar.nix ../../modules/home-manager/waybar.nix
../../modules/home-manager/quickshell.nix # used for widgets, waybar and notifications ../../modules/home-manager/quickshell.nix # used for widgets, waybar and notifications
#../../modules/home-manager/oh-my-posh.nix # zsh customizer #../../modules/home-manager/oh-my-posh.nix # zsh customizer
../../modules/home-manager/oh-my-zsh.nix # another zsh customizer ../../modules/home-manager/oh-my-zsh.nix # another zsh customizer
+62 -13
View File
@@ -1,20 +1,55 @@
{ {
writeShellApplication, writeShellApplication,
ripgrep, ripgrep,
gawkInteractive, gawkInteractive,
... iproute2,
coreutils,
procps,
upower,
...
}: }:
writeShellApplication { writeShellApplication {
name = "QS-sysinfo"; name = "QS-sysinfo";
runtimeInputs = [ runtimeInputs = [
ripgrep ripgrep
gawkInteractive gawkInteractive
]; iproute2
text = '' coreutils
Pad CPU, MEM, DISK to 2 chars (right-aligned) procps
upower
];
text = ''
# Pad CPU, MEM, DISK to 2 chars (right-aligned)
cpu=$(awk '/^cpu /{printf("%.0f", ($2+$4)*100/($2+$4+$5))}' /proc/stat) cpu=$(awk '/^cpu /{printf("%.0f", ($2+$4)*100/($2+$4+$5))}' /proc/stat)
cpu=$(printf "%2s" "$cpu") cpu=$(printf "%2s" "$cpu")
sum=0
count=0
for f in /sys/class/hwmon/hwmon*/temp*_input; do
if [ -r "$f" ]; then
val=$(cat "$f" 2>/dev/null) || continue
sum=$((sum + val))
count=$((count + 1))
fi
done
temp=$(( sum / count / 1000 ))
sum=0
count=0
for f in /sys/class/hwmon/hwmon*/fan*_input; do
if [ -r "$f" ]; then
val=$(cat "$f" 2>/dev/null) || continue
sum=$((sum + val))
count=$((count + 1))
fi
done
fan=$(( sum / count / 1000 ))
fan=$(printf "%4s" "$fan")
mem=$(free | awk '/Mem:/ {printf("%.0f",$3/$2*100)}') mem=$(free | awk '/Mem:/ {printf("%.0f",$3/$2*100)}')
mem=$(printf "%2s" "$mem") mem=$(printf "%2s" "$mem")
@@ -25,7 +60,21 @@ disk=$(printf "%2s" "$disk")
power=$(upower -b | awk -F: '/energy-rate/ {gsub(/^[ \t]+/, "", $2); split($2,a," "); printf("%.2f", a[1])}') power=$(upower -b | awk -F: '/energy-rate/ {gsub(/^[ \t]+/, "", $2); split($2,a," "); printf("%.2f", a[1])}')
power=$(printf "%5s" "$power") power=$(printf "%5s" "$power")
# network calculations
iface=$(ip route get 1.1.1.1 | awk '{print $5; exit}')
rx1=$(cat "/sys/class/net/$iface/statistics/rx_bytes")
tx1=$(cat "/sys/class/net/$iface/statistics/tx_bytes")
sleep 1
rx2=$(cat "/sys/class/net/$iface/statistics/rx_bytes")
tx2=$(cat "/sys/class/net/$iface/statistics/tx_bytes")
down_speed=$(( (rx2 - rx1) / 1024 ))
up_speed=$(( (tx2 - tx1) / 1024 ))
# Output JSON # Output JSON
echo "{\"cpu\":\"$cpu\",\"mem\":\"$mem\",\"disk\":\"$disk\",\"power\":\"$power\"}" echo "{\"cpu\":\"$cpu\",\"temp\":\"$temp\",\"fan\":\"$fan\",\"mem\":\"$mem\",\"disk\":\"$disk\",\"power\":\"$power\",\"down\":\"$down_speed\",\"up\":\"$up_speed\"}"
''; '';
} }
+54 -35
View File
@@ -107,46 +107,65 @@ PanelWindow {
smooth: false smooth: false
} }
RowLayout { RowLayout {
id: sysinfo id: sysinfo
spacing: 10 spacing: 10
property int cpu: 0 property int cpu: 0
property int mem: 0 property int mem: 0
property int disk: 0 property int disk: 0
property real power: 0 property real power: 0
property int temp: 0
property int fan: 0
property int down: 0
property int up: 0
Timer { Timer {
interval: 2000 interval: 2000
running: true running: true
repeat: true repeat: true
onTriggered: sysProcess.running = true onTriggered: sysProcess.running = true
} }
Process { Process {
id: sysProcess id: sysProcess
command: ["QS-sysinfo"] command: ["QS-sysinfo"]
stdout: SplitParser { stdout: SplitParser {
onRead: function(line) { onRead: function(line) {
try { try {
var data = JSON.parse(line) var data = JSON.parse(line)
sysinfo.cpu = data.cpu
sysinfo.mem = data.mem
sysinfo.disk = data.disk
sysinfo.power = data.power
} catch(e) {}
}
}
}
Text { sysinfo.cpu = parseInt(data.cpu)
id: infoText sysinfo.mem = parseInt(data.mem)
text: "CPU " + sysinfo.cpu + "% MEM " + sysinfo.mem + "% DSK " + sysinfo.disk + "% PWR " + sysinfo.power + "W" sysinfo.disk = parseInt(data.disk)
font.pixelSize: 18 sysinfo.power = parseFloat(data.power)
color: Theme.Colors.barColor8 sysinfo.temp = parseInt(data.temp)
} sysinfo.fan = parseInt(data.fan)
} sysinfo.down = parseInt(data.down)
sysinfo.up = parseInt(data.up)
} catch(e) {}
}
}
}
Column {
spacing: 2
Text {
text: "CPU " + sysinfo.cpu + "% | MEM " + sysinfo.mem + "% | PWR " + sysinfo.power.toFixed(1) + "W | UP " + sysinfo.up
font.pixelSize: 18
color: Theme.Colors.barColor8
}
Text {
text: "TMP " + sysinfo.temp + "°C | DSK " + sysinfo.disk + "% | FAN " + sysinfo.fan + " | DOWN " + sysinfo.down
font.pixelSize: 18
color: Theme.Colors.barColor8
}
}
}
} }
// ---------------- RIGHT MODULE ---------------- // ---------------- RIGHT MODULE ----------------
+2 -3
View File
@@ -27,17 +27,16 @@ with quickshell:
see all thoses waarnings and errors see all thoses waarnings and errors
set keybinds. for screenshot set keybinds. for screenshot
fix screenshot (copy, write, etc.) fix screenshot (copy, write, etc.)
fix battery icon
fix player control icons fix player control icons
remove unnecessary stuff remove unnecessary stuff
give battery percentage
maybe modify some of the images (like the notification body) maybe modify some of the images (like the notification body)
do a full bar (no ugly empty space at top) do a full bar (no ugly empty space at top)
add brightness slider add brightness slider
maybe change sound icon by volume level maybe change sound icon by volume level
maybe incorpore the fast fourier transform code maybe incorpore the fast fourier transform code
add some modules to see system stats
maybe write some notification center maybe write some notification center