forked from Shinonome/dots-hyprland
Netwok bandwidth tracker
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import Network from "resource:///com/github/Aylur/ags/service/network.js";
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
@@ -56,6 +57,28 @@ const WifiNetwork = (accessPoint) => {
|
||||
})
|
||||
}
|
||||
|
||||
const NetResource = (icon, command) => {
|
||||
const resourceLabel = Label({
|
||||
className: `txt-smaller txt-subtext`,
|
||||
});
|
||||
const widget = Button({
|
||||
child: Box({
|
||||
hpack: 'start',
|
||||
className: `spacing-h-4`,
|
||||
children: [
|
||||
MaterialIcon(icon, 'very-small'),
|
||||
resourceLabel,
|
||||
],
|
||||
setup: (self) => self.poll(2000, () => execAsync(['bash', '-c', command])
|
||||
.then((output) => {
|
||||
resourceLabel.label = output;
|
||||
}).catch(print))
|
||||
,
|
||||
})
|
||||
});
|
||||
return widget;
|
||||
}
|
||||
|
||||
const CurrentNetwork = () => {
|
||||
let authLock = false;
|
||||
// console.log(Network.wifi);
|
||||
@@ -81,6 +104,16 @@ const CurrentNetwork = () => {
|
||||
}),
|
||||
]
|
||||
});
|
||||
const networkBandwidth = Box({
|
||||
vertical: true,
|
||||
hexpand: true,
|
||||
hpack: 'center',
|
||||
className: 'network-bandwidth',
|
||||
children: [
|
||||
NetResource('arrow_warm_up' , `${App.configDir}/scripts/network_scripts/network_bandwidth.py sent`),
|
||||
NetResource('arrow_cool_down', `${App.configDir}/scripts/network_scripts/network_bandwidth.py recv`),
|
||||
]
|
||||
});
|
||||
const networkStatus = Box({
|
||||
children: [Label({
|
||||
vpack: 'center',
|
||||
@@ -136,6 +169,7 @@ const CurrentNetwork = () => {
|
||||
children: [
|
||||
MaterialIcon('language', 'hugerass'),
|
||||
networkName,
|
||||
networkBandwidth,
|
||||
networkStatus,
|
||||
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user