From c094e542d9e5e6f102cef393eaf14b6b0840e8d3 Mon Sep 17 00:00:00 2001 From: Venelin Dechkov Date: Thu, 22 Aug 2024 18:35:56 +0300 Subject: [PATCH] status wifi not connected --- dwm.c | 4 ---- vene.cpp | 29 +++++++++++++++++++---------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/dwm.c b/dwm.c index 0e45c0d..520a150 100644 --- a/dwm.c +++ b/dwm.c @@ -2155,10 +2155,6 @@ main(int argc, char *argv[]) die("dwm: cannot open display"); checkotherwm(); setup(); -#ifdef __OpenBSD__ - if (pledge("stdio rpath proc exec", NULL) == -1) - die("pledge"); -#endif /* __OpenBSD__ */ scan(); run(); cleanup(); diff --git a/vene.cpp b/vene.cpp index dc63569..6dfd7d0 100644 --- a/vene.cpp +++ b/vene.cpp @@ -127,19 +127,27 @@ extern "C" new_stat += "🌐 "; break; case 'w': // 'w' means wifi - ifstream(dir_entry.path() / "operstate") >> interface_state; - if(interface_state == "up") + if(const char* ssid = wifi_essid(interface.c_str()); ssid) // Connected { + // State new_stat += "🛜"; - if(const char* ssid = wifi_essid(interface.c_str()); ssid) - new_stat += ssid; + new_stat += ssid; new_stat += ' '; + + // Quality percent if(const char* perc = wifi_perc(interface.c_str()); perc) { new_stat += perc; new_stat += "% "; } } + else // Disconnected + { + string wifi_state; + ifstream(dir_entry.path() / "flags") >> wifi_state; + if( wifi_state == "0x1003") + new_stat += "📡 "; + } break; } } @@ -148,12 +156,13 @@ extern "C" { new_stat += "🛜"; new_stat += ssid; - } - new_stat += ' '; - if(const char* perc = wifi_perc("iwn0"); perc) - { - new_stat += perc; - new_stat += "% "; + new_stat += ' '; + + if(const char* perc = wifi_perc("iwn0"); perc) + { + new_stat += perc; + new_stat += "% "; + } } #endif