[AGS] SysInfo: Improve performance
This commit is contained in:
parent
2fd32da1b2
commit
b4b8d04e6a
@ -1,4 +1,4 @@
|
|||||||
import { exec, interval, Variable } from "astal";
|
import { exec, execAsync, interval, Variable } from "astal";
|
||||||
import { Gtk } from "astal/gtk4";
|
import { Gtk } from "astal/gtk4";
|
||||||
|
|
||||||
const FETCH_INTERVAL = 2000;
|
const FETCH_INTERVAL = 2000;
|
||||||
@ -109,7 +109,7 @@ Kernel: ${stats.kernel}`;
|
|||||||
></label>
|
></label>
|
||||||
<Gtk.Separator marginTop={10}></Gtk.Separator>
|
<Gtk.Separator marginTop={10}></Gtk.Separator>
|
||||||
<button
|
<button
|
||||||
onClicked={() => exec( `/bin/sh -c "kitty --hold fish -c 'fastfetch'"` )}
|
onClicked={() => exec(`/bin/sh -c "kitty --hold fish -c 'fastfetch'"`)}
|
||||||
child={
|
child={
|
||||||
<label label={"View FastFetch"}></label>
|
<label label={"View FastFetch"}></label>
|
||||||
}></button>
|
}></button>
|
||||||
@ -128,24 +128,23 @@ const SystemInformationPanel = () => {
|
|||||||
const sysInfoFetcher = () => {
|
const sysInfoFetcher = () => {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
if (availableFeatures.cpu) {
|
if (availableFeatures.cpu) {
|
||||||
cpuUtil.set(
|
execAsync(`/bin/fish -c cpu-utilization`).then(v => {
|
||||||
"" +
|
cpuUtil.set("" + Math.round(parseFloat(v)));
|
||||||
Math.round(
|
}).catch( e => {
|
||||||
parseFloat(exec(`/bin/fish -c cpu-utilization`)),
|
console.error( e );
|
||||||
),
|
} );
|
||||||
);
|
|
||||||
}
|
}
|
||||||
if (availableFeatures.ram) {
|
if (availableFeatures.ram) {
|
||||||
ramUtil.set(
|
execAsync(
|
||||||
"" +
|
`/bin/bash -c "free | awk '/Mem:/ {print $3 \\" \\" $2}'"`,
|
||||||
Math.round(
|
).then( v => {
|
||||||
parseFloat(
|
const util = parseInt( v.split( ' ' )[ 0 ] );
|
||||||
exec(
|
const available = parseInt( v.split( ' ' )[ 1 ] );
|
||||||
`/bin/bash -c "free | awk '/Mem/ { printf(\\"%.2f\\\\n\\", ($3/$2)*100) }'"`,
|
ramUtil.set( "" + Math.round( available / util ) );
|
||||||
),
|
ramUsed.set( `${Math.round( util / 1024 / 1024 )}MiB used of ${Math.round( available / 1024 / 1024 )}MiB` );
|
||||||
),
|
} ).catch( e => {
|
||||||
),
|
console.error( e );
|
||||||
);
|
} );
|
||||||
ramUsed.set(
|
ramUsed.set(
|
||||||
exec(
|
exec(
|
||||||
`/bin/bash -c \"free -h | awk '/^Mem:/ {print $3 \\" used of \\" $2}'\"`,
|
`/bin/bash -c \"free -h | awk '/^Mem:/ {print $3 \\" used of \\" $2}'\"`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user