internet widget
This commit is contained in:
parent
c1a1c5f869
commit
9f2db8d7e9
1 changed files with 36 additions and 0 deletions
36
widget/Internet.tsx
Normal file
36
widget/Internet.tsx
Normal 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;
|
||||
Loading…
Add table
Reference in a new issue