Janis Hutz 8a2180e120 [AGS] GTK 4 Migration: Done, Start adding QuickActions
Probably gonna abandon the QuickActions, as that is just way too much
effort for what it does. Will be providing keybinds for doing what I
wanted to do there in Hyprland
2025-04-22 15:30:41 +02:00

55 lines
1.3 KiB
TypeScript

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!' );
}
// Battery... acpi might be present, but potentially no bat
}
let enabled = false;
const availableFeatures = {
cpu: true,
ram: true,
bat: 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
}
}
}
const SystemInfo = () => {
return <box></box>
}
export default {
SystemInfo
}