internet widget

This commit is contained in:
Benjamin Palko 2025-04-04 09:49:27 -04:00
parent c1a1c5f869
commit 9f2db8d7e9

36
widget/Internet.tsx Normal file
View file

@ -0,0 +1,36 @@
import { bind } from "astal";
import Network from "gi://AstalNetwork";
function Internet() {
const network = Network.get_default();
const icon = (strength: number) => {
if (strength > 80) {
return "󰤨";
}
if (strength > 60) {
return "󰤥";
}
if (strength > 40) {
return "󰤢";
}
if (strength > 20) {
return "󰤟";
}
return "󰤯";
};
return (
<box>
<label
label={bind(network, "wifi").as(
(w) => `${icon(w.strength)} ${w.strength}%`,
)}
hasTooltip={true}
tooltip_text={bind(network, "wifi").as((w) => w.ssid)}
/>
</box>
);
}
export default Internet;