diff --git a/src/components/bar/modules/network/helpers.ts b/src/components/bar/modules/network/helpers.ts index ff56a22..7b43821 100644 --- a/src/components/bar/modules/network/helpers.ts +++ b/src/components/bar/modules/network/helpers.ts @@ -64,21 +64,16 @@ const formatFrequency = (frequency: number): string => { * Formats the WiFi information for display. * * This function takes a WiFi object and formats its SSID, signal strength, and frequency for display. - * If any of these values are not available, it provides default values. * * @param wifi The WiFi object containing SSID, signal strength, and frequency information. * * @returns A formatted string containing the WiFi information. */ -export const formatWifiInfo = (wifi: AstalNetwork.Wifi | null): string => { - const netSsid = wifi?.ssid ? wifi.ssid : 'None'; - const wifiStrength = wifi?.strength ? wifi.strength : '--'; - const wifiFreq = wifi?.frequency ? formatFrequency(wifi.frequency) : '--'; - - return `Network: ${netSsid} \nSignal Strength: ${wifiStrength}% \nFrequency: ${wifiFreq}`; +export const formatWifiInfo = (wifi: AstalNetwork.Wifi): string => { + return `Network: ${wifi.ssid} \nSignal Strength: ${wifi.strength}% \nFrequency: ${formatFrequency(wifi.frequency)}`; }; -Variable.derive([bind(networkService, 'wifi')], () => { +Variable.derive([bind(networkService, 'state'), bind(networkService, 'connectivity')], () => { handleWiredIcon(); handleWirelessIcon(); }); diff --git a/src/components/bar/modules/network/index.tsx b/src/components/bar/modules/network/index.tsx index 269fe57..335bc71 100644 --- a/src/components/bar/modules/network/index.tsx +++ b/src/components/bar/modules/network/index.tsx @@ -16,10 +16,7 @@ const Network = (): BarBoxChild => { const iconBinding = Variable.derive( [bind(networkService, 'primary'), bind(wiredIcon), bind(wirelessIcon)], (primaryNetwork, wiredIcon, wifiIcon) => { - const isWired = primaryNetwork === AstalNetwork.Primary.WIRED; - const iconName = isWired ? wiredIcon : wifiIcon; - - return iconName; + return primaryNetwork === AstalNetwork.Primary.WIRED ? wiredIcon : wifiIcon; }, ); @@ -28,28 +25,44 @@ const Network = (): BarBoxChild => { const networkLabel = Variable.derive( [ bind(networkService, 'primary'), - bind(networkService, 'wifi'), bind(label), bind(truncation), bind(truncation_size), bind(showWifiInfo), + + bind(networkService, 'state'), + bind(networkService, 'connectivity'), + ...(networkService.wifi ? [bind(networkService.wifi, 'enabled')] : []), ], - (primaryNetwork, networkWifi, showLabel, trunc, tSize, showWifiInfo) => { + (primaryNetwork, showLabel, trunc, tSize, showWifiInfo) => { if (!showLabel) { return ; } if (primaryNetwork === AstalNetwork.Primary.WIRED) { return