diff --git a/wmwifi/src/wmwifi.c b/wmwifi/src/wmwifi.c index 5bbb69d..bf95dc8 100644 --- a/wmwifi/src/wmwifi.c +++ b/wmwifi/src/wmwifi.c @@ -66,6 +66,8 @@ struct theme tcur; struct theme blgt; struct wifi lwfi; time_t last_update = 0; +time_t last_swap = 0; +time_t now = 0; /* prototypes */ static void update(struct wifi *wfi); @@ -201,6 +203,8 @@ static void update(struct wifi *wfi) //char *str = calloc(1, sizeof(wfi->ifname) + sizeof(wfi->essid) + 3); char str[512]; + now = time(NULL); + /* get current link level from /proc/net/wireless */ copy_wifi(&lwfi, wfi); get_wifi_info(wfi); @@ -260,12 +264,15 @@ static void update(struct wifi *wfi) if (count > (strlen(str) * 3)) count = 1; } else { - if (count < 50) - sw = 1; - if (count >= 50) - sw = 2; - if (count == 100) - count = -1; + int diff = now - last_swap; + /* swap between ifname and essid every 2 seconds */ + if (diff <= 2) + sw = 1; + else if ((diff > 2) && (diff <= 4)) + sw = 2; + else + last_swap = now; + switch (sw) { case 1: dockapp_copyarea(display_link, pixmap, 0, 0, 58, 12, 0, 0);