From f4b259dd1341c6f09af6771ac57a7dc7ac44c1b9 Mon Sep 17 00:00:00 2001 From: Janis Hutz Date: Mon, 21 Apr 2025 12:44:41 +0200 Subject: [PATCH] [AGS] Bar: Start sysinfo --- .../components/bar/ui/modules/SystemInfo.tsx | 56 +++++++++++++++++++ notes.md | 1 + 2 files changed, 57 insertions(+) diff --git a/config/astal/components/bar/ui/modules/SystemInfo.tsx b/config/astal/components/bar/ui/modules/SystemInfo.tsx index e69de29..2d91d04 100644 --- a/config/astal/components/bar/ui/modules/SystemInfo.tsx +++ b/config/astal/components/bar/ui/modules/SystemInfo.tsx @@ -0,0 +1,56 @@ +import { exec, GLib } from "astal" + +const featureTest = () => { + // Check if awk is available + try { + exec( 'awk -V' ); + exec( 'sed --version' ); + enabled = true; + } catch ( e ) { + printerr( '[ SysInfo ] AWK or SED missing! No system info will be available' ); + enabled = false; + return; + } + try { + exec( 'mpstat' ); + } catch ( e ) { + availableFeatures.cpu = false; + printerr( '[ SysInfo ] Feature Test for CPU info failed. mpstat from the sysstat package missing!' ); + } +} + +let enabled = false; + +const availableFeatures = { + cpu: true, + ram: true, + bat: true, + net: false, + brightness: true, +} + +const sysInfoFetcher = () => { + if ( enabled ) { + if ( availableFeatures.cpu ) { + const cpuUtil = exec( 'mpstat | awk "/all/ {print(100 - $NF)"}' ); + } + if ( availableFeatures.ram ) { + const ramUtil = exec( `free | awk '/Mem/ { printf("%.2f\\n", ($3/$2)*100) }'` ); + } + if ( availableFeatures.bat ) { + const acpi = exec( `acpi -i | grep 'Battery'` ); + // TODO: Parse acpi output + } + // if ( availableFeatures.net ) { + // // Using ifstat or vnstat probably, get current network de + // } + if ( availableFeatures.brightness ) { + + } + } +} + +const SystemInfo = () => { + + +} diff --git a/notes.md b/notes.md index 5436dab..fe05c76 100644 --- a/notes.md +++ b/notes.md @@ -16,6 +16,7 @@ - [ ] Media controls - [ ] AppLauncher (possibly, if anyrun is no good) - [ ] OSD (see [here](https://github.com/Aylur/astal/tree/main/examples/gtk3/js)) + - [ ] Open Window List for bar when hovering over window title and per-workspace when hovering over workspace - [ ] Text recognition - [ ] Theming - [ ] Vivado dark mode