2023-12-28 00:19:57 -05:00
|
|
|
import Network from 'resource:///com/github/Aylur/ags/service/network.js';
|
|
|
|
|
|
|
|
import { Label, Icon } from 'resource:///com/github/Aylur/ags/widget.js';
|
|
|
|
|
2024-01-13 23:38:31 -05:00
|
|
|
import HoverRevealer from './hover-revealer.ts';
|
2023-12-28 00:19:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
export default () => HoverRevealer({
|
|
|
|
class_name: 'network',
|
|
|
|
|
|
|
|
icon: Icon().hook(Network, (self) => {
|
|
|
|
if (Network.wifi.internet === 'connected' ||
|
|
|
|
Network.wifi.internet === 'connecting') {
|
|
|
|
self.icon = Network.wifi.icon_name;
|
|
|
|
}
|
|
|
|
else if (Network.wired.internet === 'connected' ||
|
|
|
|
Network.wired.internet === 'connecting') {
|
|
|
|
self.icon = Network.wired.icon_name;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
self.icon = Network.wifi.icon_name;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
label: Label().hook(Network, (self) => {
|
|
|
|
if (Network.wifi.internet === 'connected' ||
|
|
|
|
Network.wifi.internet === 'connecting') {
|
|
|
|
self.label = Network.wifi.ssid || 'Unknown';
|
|
|
|
}
|
|
|
|
else if (Network.wired.internet === 'connected' ||
|
|
|
|
Network.wired.internet === 'connecting') {
|
|
|
|
self.label = 'Connected';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
self.label = 'Disconnected';
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
});
|