fix for fuzzytime nearing midnight crash

This commit is contained in:
Paul Wilde 2022-03-21 15:59:52 +00:00
parent 3e88ea16fa
commit 1549b8f368
9 changed files with 24 additions and 22 deletions

0
i3bar_base.nim Normal file → Executable file
View file

0
i3bar_brightness.nim Normal file → Executable file
View file

0
i3bar_date.nim Normal file → Executable file
View file

14
i3bar_fuzzytime.nim Normal file → Executable file
View file

@ -12,8 +12,11 @@ proc get_fuzzytime(): string =
var link = "past" var link = "past"
if min > 32 : if min > 32 :
link = "to" link = "to"
case hr:
of 23:
hr = 0
else:
hr = hr + 1 hr = hr + 1
if min >= 58 or min <= 02: if min >= 58 or min <= 02:
return get_hour(hr) & " " & get_minute(min) return get_hour(hr) & " " & get_minute(min)
else: else:
@ -68,11 +71,10 @@ proc get_minute(min: int): string =
return "error" return "error"
proc getObject(time: string): i3barData = proc getObject(time: string): i3barData =
let data = i3barData( var data = newi3barData()
full_text: time, data.full_text = time
color: foreground, #data.color = foreground
border: lightblue, data.border = lightblue
)
return data return data

13
i3bar_nic.nim Normal file → Executable file
View file

@ -4,7 +4,7 @@ import std/osproc
import std/threadpool import std/threadpool
import strutils 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 # /sys/class/net/*/operstate up or down if connected
@ -26,12 +26,9 @@ proc get_net(nic: string): (string, string) =
return (ip, state) return (ip, state)
proc getObject(conn: string): i3barData = proc getObject(conn: string): i3barData =
let data = i3barData( var data = newi3barData()
full_text: conn, data.full_text = conn
color: foreground, data.border = purple
border: purple,
background: black
)
return data return data
proc get_net_info(nic: string) = proc get_net_info(nic: string) =
@ -64,5 +61,7 @@ proc main() =
spawn get_net_info(mynic) spawn get_net_info(mynic)
spawn await_click_info() spawn await_click_info()
sync() sync()
else:
echo "No NIC"
main() main()

5
i3bar_pingclock.nim Normal file → Executable file
View file

@ -20,10 +20,11 @@ proc get_ping(): float =
if bounds.first > 0: if bounds.first > 0:
let png = ping_line[bounds.first+5..bounds.last] let png = ping_line[bounds.first+5..bounds.last]
ping = parseFloat(png) ping = parseFloat(png)
return round(ping,1) return ping
proc getObject(ping: float): i3barData = proc getObject(ping: float): i3barData =
var text = "🏓 " & $ping & " ms" let niceping = $round(ping,1)
var text = "🏓 " & niceping & " ms"
var col = foreground var col = foreground
if ping < 0: if ping < 0:
text = "❌ No Pong" text = "❌ No Pong"

0
i3bar_temperature.nim Normal file → Executable file
View file

0
i3bar_volume.nim Normal file → Executable file
View file

View file

@ -4,7 +4,7 @@ import std/osproc
import std/threadpool import std/threadpool
import strutils import strutils
const wlan_nic: string ="wlp2s0" const wlan_nic: string ="wlan0"
# /sys/class/net/wlp2s0/operstate up or down if connected # /sys/class/net/wlp2s0/operstate up or down if connected
@ -28,11 +28,9 @@ proc get_wifi(): (string, string) =
return (essid, quality) return (essid, quality)
proc getObject(conn: string): i3barData = proc getObject(conn: string): i3barData =
let data = i3barData( var data = newi3barData()
full_text: conn, data.full_text = conn
color: foreground, data.border = purple
border: purple,
)
return data return data
proc get_wifi_info() = proc get_wifi_info() =
@ -56,5 +54,7 @@ proc main() =
spawn get_wifi_info() spawn get_wifi_info()
spawn await_click_info() spawn await_click_info()
sync() sync()
else:
echo "No WLAN"
main() main()