LingSys
↓ 0 downloadsYour machine's memory, GPU, motherboard and network, drawn and played in the Ling design system: LingSys, a small build for USB liquid-cooler displays, LingNet for IPv4/IPv6, DNS and packets, and a LingOS edition. 64-bit and 32-bit Windows builds included.
Keywords system-monitor, visualization, network, ipv6, gpu, lcd, lingos, ling
lingfu install LingSysCode / Files (48)
src/70_main_screen.ling
# ───────────────────────────── MAIN screen ───────────────────────────────────
# Four rings in the middle (memory, GPU, CPU, network) and a card for each section on either side.
# A card shows that section's headline numbers; click it, or press its number, to open the section.
bind MAIN_HM = [4, 3, 1, 6]
fn card_rect(i, W, H) {
bind cw = clamp(W * 0.225, 220.0, 340.0)
bind top = 74.0
bind gap = 20.0
bind ch = (H - top - 14.0 - gap) / 2.0
bind x = 18.0
if i >= 2 { bind x = W - 18.0 - cw }
bind y = top
if i % 2 == 1 { bind y = top + ch + gap }
return [x, y, cw, ch]
}
# which card, if any, is under (mx, my)
fn card_hit(mx, my, W, H) {
bind i = 0
while i < 4 {
bind r = card_rect(i, W, H)
if mx >= r[0] {
if mx <= r[0] + r[2] {
if my >= r[1] {
if my <= r[1] + r[3] { return i }
}
}
}
bind i = i + 1
}
return 0 - 1
}
fn live_tag(l) {
if l == 1 { return "LIVE" }
if l == 2 { return "STALE" }
return "SIM"
}
fn card(Z, i, hov) {
bind sat = Z[Z_SAT]
bind hs = Z[Z_HS]
bind W = Z[Z_W]
bind H = Z[Z_H]
bind D = Z[Z_D]
bind hst = D[D_HS]
bind live = D[D_LIVE]
bind sec = i + 1
bind k = SEC_HUE[sec]
bind r = card_rect(i, W, H)
bind x = r[0]
bind y = r[1]
bind cw = r[2]
bind ch = r[3]
bind lit = 34.0 + 22.0 * hov
col(k, sat * 0.7, lit, hs)
brect(x, y, 1.0, 0.0, 0.0, cw, ch)
bind a = 14.0
col(k, sat, lit + 28.0, hs)
bline(x, y, 1.0, 0.0, a, 0.0, 0.0)
bline(x, y, 1.0, 0.0, 0.0, a, 0.0)
bline(x, y, 1.0, cw - a, 0.0, cw, 0.0)
bline(x, y, 1.0, cw, 0.0, cw, a)
bline(x, y, 1.0, cw, ch - a, cw, ch)
bline(x, y, 1.0, cw, ch, cw - a, ch)
bline(x, y, 1.0, a, ch, 0.0, ch)
bline(x, y, 1.0, 0.0, ch, 0.0, ch - a)
tile(str_slice(SEC_LET, sec, 1), x + 12.0, y + 12.0, 44.0, 56.0 + 24.0 * hov, k, sat, hs, 0.5 + hov)
col(k, sat, 78.0 + 12.0 * hov, hs)
daemon_text(SEC_NAME[sec], x + 68.0, y + 28.0, 17.0)
ink(52.0)
daemon_text(num_str(sec) + " " + live_tag(live[i]), x + 68.0, y + 50.0, 10.0)
bind frac = 0.0
bind big = ""
bind lines = []
bind sid = 0
if i == 0 {
bind mm = D[D_MEM]
bind cats = mm[0]
bind total = mm[1]
bind frac = mm[5]
bind big = pct(frac * 100.0) + "%"
bind lines = ["USED " + fmt_mb(frac * total) + " OF " + fmt_mb(total), "STANDBY " + fmt_mb(cats[1]) + " FREE " + fmt_mb(cats[6]), "READS " + fmt_rate(mm[2]) + "/S",
"WRITES " + fmt_rate(mm[3]) + "/S", "FAULTS " + fmt_rate(mm[4]) + "/S"]
bind sid = HS_MEM
}
if i == 1 {
bind gp = D[D_GPU]
bind n = gp[GP_N]
bind mx_ = 0.0
bind g = 0
bind lines = []
while g < n {
bind v = gp[GP_VEC][g]
bind mx_ = max(mx_, v[GV_UTIL])
if n <= 2 {
bind lines = list_push(lines, "G" + num_str(g) + " " + short_gpu(gp[GP_NAME][g]) + " " + pct(v[GV_UTIL]) + "%")
bind lines = list_push(lines, " " + fmt_mb(v[GV_VUSED]) + "/" + fmt_mb(v[GV_VTOTAL]) + " " + pct(v[GV_TEMP]) + "C " + pct(v[GV_POWER]) + "W")
} else {
if g < 5 {
bind lines = list_push(lines, "G" + num_str(g) + " " + pct(v[GV_UTIL]) + "% " + fmt_mb(v[GV_VUSED]) + " " + pct(v[GV_TEMP]) + "C " + pct(v[GV_POWER]) + "W")
}
}
bind g = g + 1
}
bind v0 = gp[GP_VEC][0]
if n <= 2 { bind lines = list_push(lines, "PCIE GEN" + pct(v0[GV_PGEN]) + " X" + pct(v0[GV_PW])) }
if n > 5 { bind lines = list_push(lines, "+ " + num_str(n - 5) + " MORE") }
bind frac = mx_ / 100.0
bind big = pct(mx_) + "%"
bind sid = HS_GPU
}
if i == 2 {
bind bp = D[D_BRD]
bind info = bp[BP_INFO]
bind bv = bp[BP_BV]
bind frac = bv[BV_UTIL] / 100.0
bind big = pct(bv[BV_UTIL]) + "%"
bind lines = [str_slice(info[BI_CPU], 0, 26), pct(info[BI_CORES]) + "C " + pct(info[BI_THR]) + "T " + num_str(round(bv[BV_MHZ] / 100.0) / 10.0) + " GHZ",
"ACPI " + num_str(round(bv[BV_TEMP] * 10.0) / 10.0) + "C UP " + fmt_up(bv[BV_UP]), "PROCS " + pct(bv[BV_PROCS]) + " THR " + fmt_rate(bv[BV_THR]),
"IRQ " + fmt_rate(bv[BV_INTR]) + "/S DPC " + fmt_rate(bv[BV_DPC]) + "/S"]
bind sid = HS_BRD
}
if i == 3 {
bind np = D[D_NET]
bind nv = np[NP_NV]
bind frac = lg(nv[NV_RX] + nv[NV_TX], 9.0)
bind big = fmt_bytes(nv[NV_RX] + nv[NV_TX])
bind rs = "---"
if nv[NV_RTT] > 0.0 { bind rs = num_str(round(nv[NV_RTT])) + "MS" }
bind lines = [str_slice(adapter_name(np), 0, 26), "IN " + fmt_bytes(nv[NV_RX]) + "/S OUT " + fmt_bytes(nv[NV_TX]) + "/S", "PKTS " + fmt_rate(nv[NV_PRX]) + " IN " + fmt_rate(nv[NV_PTX]) + " OUT",
"TCP " + fmt_rate(nv[NV_EST]) + " LISTEN " + fmt_rate(nv[NV_LISTEN]), "GATEWAY " + rs]
bind sid = HS_NET
}
bind bh = fit_h(big, cw * 0.3, 22.0)
col(k, sat, 84.0, hs)
daemon_text(big, x + cw - 14.0 - text_w(big, bh), y + 34.0, bh)
hbar(x + 12.0, y + 84.0, cw - 24.0, frac, k, sat, 56.0 + 24.0 * hov, hs)
bind lh = min(12.0, (cw - 24.0) / 24.0)
bind q = 0
while q < len(lines) {
ink(66.0 - 4.0 * q + 8.0 * hov)
daemon_text(lines[q], x + 12.0, y + 108.0 + q * 21.0, lh)
bind q = q + 1
}
spark(x + 12.0, y + ch - 52.0, cw - 24.0, 36.0, hst[sid], 100, k, sat, 62.0 + 20.0 * hov, hs)
}
fn view_main(Z) {
bind D = Z[Z_D]
bind bp = D[D_BRD]
bind bv = bp[BP_BV]
bind mm = D[D_MEM]
bind gp = D[D_GPU]
bind nv = D[D_NET][NP_NV]
bind fr = Z[Z_FRAC]
bind gmax = 0.0
bind g = 0
while g < gp[GP_N] {
bind gmax = max(gmax, gp[GP_VEC][g][GV_UTIL])
bind g = g + 1
}
bind labels = ["MEMORY " + pct(mm[5] * 100.0) + " ", "GPU " + pct(gmax) + " ", "CPU " + pct(bv[BV_UTIL]) + " ", "NETWORK " + fmt_bytes(nv[NV_RX] + nv[NV_TX]) + " "]
ring_stack(Z, 4, MAIN_HM, labels, fr, fmt_up(bv[BV_UP]), "SYSTEM UP", 2)
bind mx = Z[Z_MX]
bind my = Z[Z_MY]
bind hit = card_hit(mx, my, Z[Z_W], Z[Z_H])
bind i = 0
while i < 4 {
bind hv = 0.0
if hit == i { bind hv = 1.0 }
card(Z, i, hv)
bind i = i + 1
}
}