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

16
i3bar_fuzzytime.nim Normal file → Executable file
View file

@ -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

13
i3bar_nic.nim Normal file → Executable file
View file

@ -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()

5
i3bar_pingclock.nim Normal file → Executable file
View file

@ -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"

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 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()