From 1549b8f368a6468b83c6f3a96fa2f9ea98978add Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 21 Mar 2022 15:59:52 +0000 Subject: [PATCH] fix for fuzzytime nearing midnight crash --- i3bar_base.nim | 0 i3bar_brightness.nim | 0 i3bar_date.nim | 0 i3bar_fuzzytime.nim | 16 +++++++++------- i3bar_nic.nim | 13 ++++++------- i3bar_pingclock.nim | 5 +++-- i3bar_temperature.nim | 0 i3bar_volume.nim | 0 i3bar_wlan.nim | 12 ++++++------ 9 files changed, 24 insertions(+), 22 deletions(-) mode change 100644 => 100755 i3bar_base.nim mode change 100644 => 100755 i3bar_brightness.nim mode change 100644 => 100755 i3bar_date.nim mode change 100644 => 100755 i3bar_fuzzytime.nim mode change 100644 => 100755 i3bar_nic.nim mode change 100644 => 100755 i3bar_pingclock.nim mode change 100644 => 100755 i3bar_temperature.nim mode change 100644 => 100755 i3bar_volume.nim diff --git a/i3bar_base.nim b/i3bar_base.nim old mode 100644 new mode 100755 diff --git a/i3bar_brightness.nim b/i3bar_brightness.nim old mode 100644 new mode 100755 diff --git a/i3bar_date.nim b/i3bar_date.nim old mode 100644 new mode 100755 diff --git a/i3bar_fuzzytime.nim b/i3bar_fuzzytime.nim old mode 100644 new mode 100755 index 6a0ea81..d4d196c --- a/i3bar_fuzzytime.nim +++ b/i3bar_fuzzytime.nim @@ -12,8 +12,11 @@ proc get_fuzzytime(): string = var link = "past" if min > 32 : link = "to" - hr = hr + 1 - + case hr: + of 23: + hr = 0 + else: + hr = hr + 1 if min >= 58 or min <= 02: return get_hour(hr) & " " & get_minute(min) else: @@ -68,11 +71,10 @@ proc get_minute(min: int): string = return "error" proc getObject(time: string): i3barData = - let data = i3barData( - full_text: time, - color: foreground, - border: lightblue, - ) + var data = newi3barData() + data.full_text = time + #data.color = foreground + data.border = lightblue return data diff --git a/i3bar_nic.nim b/i3bar_nic.nim old mode 100644 new mode 100755 index dd71b11..924fe09 --- a/i3bar_nic.nim +++ b/i3bar_nic.nim @@ -4,7 +4,7 @@ import std/osproc import std/threadpool import strutils -const nics: seq[string] = @["enp3s0","wlp2s0","enp0s20f0u3"] +const nics: seq[string] = @["wlan0", "enp3s0","wlp2s0","enp0s20f0u3"] # /sys/class/net/*/operstate up or down if connected @@ -26,12 +26,9 @@ proc get_net(nic: string): (string, string) = return (ip, state) proc getObject(conn: string): i3barData = - let data = i3barData( - full_text: conn, - color: foreground, - border: purple, - background: black - ) + var data = newi3barData() + data.full_text = conn + data.border = purple return data proc get_net_info(nic: string) = @@ -64,5 +61,7 @@ proc main() = spawn get_net_info(mynic) spawn await_click_info() sync() + else: + echo "No NIC" main() diff --git a/i3bar_pingclock.nim b/i3bar_pingclock.nim old mode 100644 new mode 100755 index b196b4c..4eaf898 --- a/i3bar_pingclock.nim +++ b/i3bar_pingclock.nim @@ -20,10 +20,11 @@ proc get_ping(): float = if bounds.first > 0: let png = ping_line[bounds.first+5..bounds.last] ping = parseFloat(png) - return round(ping,1) + return ping proc getObject(ping: float): i3barData = - var text = "🏓 " & $ping & " ms" + let niceping = $round(ping,1) + var text = "🏓 " & niceping & " ms" var col = foreground if ping < 0: text = "❌ No Pong" diff --git a/i3bar_temperature.nim b/i3bar_temperature.nim old mode 100644 new mode 100755 diff --git a/i3bar_volume.nim b/i3bar_volume.nim old mode 100644 new mode 100755 diff --git a/i3bar_wlan.nim b/i3bar_wlan.nim index 3411484..d799b7c 100755 --- a/i3bar_wlan.nim +++ b/i3bar_wlan.nim @@ -4,7 +4,7 @@ import std/osproc import std/threadpool import strutils -const wlan_nic: string ="wlp2s0" +const wlan_nic: string ="wlan0" # /sys/class/net/wlp2s0/operstate up or down if connected @@ -28,11 +28,9 @@ proc get_wifi(): (string, string) = return (essid, quality) proc getObject(conn: string): i3barData = - let data = i3barData( - full_text: conn, - color: foreground, - border: purple, - ) + var data = newi3barData() + data.full_text = conn + data.border = purple return data proc get_wifi_info() = @@ -56,5 +54,7 @@ proc main() = spawn get_wifi_info() spawn await_click_info() sync() + else: + echo "No WLAN" main()