feat: add some info about connected wifi (#354)

* feat: add some info about connected wifi

* feat: add some info about connected wifi

* fix: convert default label to empty string

* feat: add fallbacks

* feat: add wifi disconnect

* Update modules/menus/network/wifi/WirelessAPs.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update modules/menus/network/wifi/WirelessAPs.ts

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>

* Update modules/bar/network/index.ts

---------

Co-authored-by: Jas Singh <jaskiratpal.singh@outlook.com>
This commit is contained in:
Rubin Bhandari
2024-10-30 10:16:23 +05:45
committed by GitHub
parent 0bdaf461f6
commit b77f37c145
4 changed files with 87 additions and 27 deletions

View File

@@ -6,6 +6,15 @@ import { BarBoxChild } from 'lib/types/bar.js';
import Button from 'types/widgets/button.js';
import { Attribute, Child } from 'lib/types/widget.js';
import { runAsyncCommand, throttledScrollHandler } from 'customModules/utils.js';
import { Wifi } from 'types/service/network.js';
const formatFrequency = (frequency: number): string => {
return `${(frequency / 1000).toFixed(2)}MHz`;
};
const formatWifiInfo = (wifi: Wifi): string => {
return `Network: ${wifi.ssid === '' ? 'None' : wifi.ssid} \nSignal Strength: ${wifi.strength >= 0 ? wifi.strength : '--'}% \nFrequency: ${wifi.frequency >= 0 ? formatFrequency(wifi.frequency) : '--'}`;
};
const {
label: networkLabel,
@@ -15,6 +24,7 @@ const {
middleClick,
scrollDown,
scrollUp,
showWifiInfo,
} = options.bar.network;
const Network = (): BarBoxChild => {
@@ -55,8 +65,9 @@ const Network = (): BarBoxChild => {
networkLabel.bind('value'),
truncation.bind('value'),
truncation_size.bind('value'),
showWifiInfo.bind('value'),
],
(pmry, wfi, showLbl, trunc, tSize) => {
(pmry, wfi, showLbl, trunc, tSize, showWfiInfo) => {
if (!showLbl) {
return Widget.Box();
}
@@ -69,6 +80,7 @@ const Network = (): BarBoxChild => {
return Widget.Label({
class_name: 'bar-button-label network-label',
label: wfi.ssid ? `${trunc ? wfi.ssid.substring(0, tSize) : wfi.ssid}` : '--',
tooltipText: showWfiInfo ? formatWifiInfo(wfi) : '',
});
},
),