fix: poll disk data, clipboard persist, fix disk display type

This commit is contained in:
2025-06-24 20:19:47 -07:00
parent 66eda1d7cc
commit 142f4f0dab
4 changed files with 25 additions and 9 deletions

View File

@@ -92,10 +92,10 @@ function Ram() {
</box> </box>
} }
let disk_space = Variable(get_disk_space()) let disk_space = Variable(get_disk_space()).poll(5000, () => get_disk_space())
function Disk() { function Disk() {
return <box className="status-box"> return <box className="status-box">
<label label={bind(disk_space).as((s) => `${s}GiB`)} /> <label label={bind(disk_space).as((s) => `${s}`)} />
</box> </box>
} }
@@ -106,7 +106,7 @@ function Battery() {
if (charging) { if (charging) {
return { label: `${full_percentage == 100 ? "FULL" : "CHR"}: ${full_percentage}%` } return { label: `${full_percentage == 100 ? "FULL" : "CHR"}: ${full_percentage}%` }
} }
return { label: `${full_percentage == 100 ? "FULL" : "BAT"}: ${full_percentage}` } return { label: `${full_percentage == 100 ? "FULL" : "BAT"}: ${full_percentage}%` }
}) })
return <box className="status-box"> return <box className="status-box">

View File

@@ -1,5 +1,6 @@
import { GLib, Variable } from "astal"; import { GLib, Variable } from "astal";
import GTop from "gi://GTop"; import GTop from "gi://GTop";
import Wp05 from "gi://Wp";
type Snapshot = { type Snapshot = {
total: number; total: number;
@@ -35,12 +36,23 @@ export function get_ram_info() {
}; };
} }
function format_bytes(bytes: number) {
let units = ["B", "KiB", "MiB", "GiB", "TiB"];
let i = 0;
let num: number = bytes;
while (num >= 1024 && i < units.length - 1) {
num /= 1024;
i++;
}
return `${num.toFixed(2)}${units[i]}`;
}
export function get_disk_space() { export function get_disk_space() {
const usage = new GTop.glibtop_fsusage(); const usage = new GTop.glibtop_fsusage();
GTop.glibtop_get_fsusage(usage, "/"); GTop.glibtop_get_fsusage(usage, "/");
const free_bytes = usage.bavail * usage.block_size; const free_bytes = usage.bavail * usage.block_size;
const free_gib = free_bytes / 1024 ** 3;
return free_gib.toFixed(2); return format_bytes(free_bytes);
} }

6
nix/flake.lock generated
View File

@@ -83,11 +83,11 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1750650158, "lastModified": 1750798083,
"narHash": "sha256-cGdpDr/OUjS5rfl0lH7CjnIFWtpOFQOcRkvBu9CV+Cs=", "narHash": "sha256-DTCCcp6WCFaYXWKFRA6fiI2zlvOLCf5Vwx8+/0R8Wc4=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "3bd646138a9c71f244a9293dde6f59ae1c6875ab", "rev": "ff31a4677c1a8ae506aa7e003a3dba08cb203f82",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -35,6 +35,8 @@
adwaita-icon-theme adwaita-icon-theme
swaybg swaybg
gnome-themes-extra gnome-themes-extra
wl-clipboard
wl-clip-persist
]; ];
programs.thunar.enable = true; programs.thunar.enable = true;
programs.hyprland.enable = true; programs.hyprland.enable = true;
@@ -67,7 +69,7 @@
configFile = ../../custom/dunst/dunstrc; configFile = ../../custom/dunst/dunstrc;
}; };
services.hyprpolkitagent.enable = true; services.hyprpolkitagent.enable = true;
services.copyq.enable = true; services.cliphist.enable = true;
gtk = { gtk = {
enable = true; enable = true;
theme.name = "Adwaita-dark"; theme.name = "Adwaita-dark";
@@ -102,6 +104,7 @@
"$mod, 0, workspace, 10" "$mod, 0, workspace, 10"
"$mod SHIFT, 0, movetoworkspacesilent, 10" "$mod SHIFT, 0, movetoworkspacesilent, 10"
"$mod, f, fullscreen"
] ]
++ (builtins.concatLists ( ++ (builtins.concatLists (
builtins.genList ( builtins.genList (
@@ -144,6 +147,7 @@
exec-once = [ exec-once = [
"swaybg -i ~/.config/wallpaper/bg.jpg" "swaybg -i ~/.config/wallpaper/bg.jpg"
"status-bar" "status-bar"
"wl-clip-persist --clipboard regular"
]; ];
monitor = [ monitor = [
"eDP-1, 1920x1080, 0x0, 1" "eDP-1, 1920x1080, 0x0, 1"