-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpu_details.lua
More file actions
executable file
·131 lines (112 loc) · 4.35 KB
/
cpu_details.lua
File metadata and controls
executable file
·131 lines (112 loc) · 4.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---------------------------------
-- Network Interfaces
---------------------------------
function initNets()
local netstatio = io.popen("ip link show | awk '{print substr($2, 1, length($2)-1)}'")
local netstatout = netstatio:read("*all")
function string.starts(String,Start)
return string.sub(String,1,string.len(Start))==Start
end
local outstr = ""
for line in string.gmatch(netstatout,"[^\r\n]*") do
if string.starts(line, "wl") or
string.starts(line, "enp") or
string.starts(line, "eth") then
local addr=conky_parse('${addr '..line..'}')
if addr ~= "No Address" then
outstr = outstr.."\n${voffset -5}${font ADELE:bold:size=15}${color1}${alignc}Interface "..line.."${font}\n"
outstr = outstr.."Internal: ${font ADELE:bold:14}${alignr}"..addr.."\n"
outstr = outstr.."${color1}${font ADELE:bold:size=9}UP : ${upspeed "..line.."} | DOWN : ${downspeed "..line.."}${alignr}${totalup "..line.."} / ${totaldown "..line.."}\n"
outstr = outstr.."${color2}${upspeedgraph "..line.." 25,240 66241C FF5A45 0 -l}\n"
outstr = outstr.."${color2}${voffset -10}${downspeedgraph "..line.." 25,240 66241C FF5A45 0 -l}\n"
end
end
end
return outstr
end
local output = ""
function conky_listNets()
if output == "" then
output = initNets()
end
return output
end
---------------------------------
-- Mounts
---------------------------------
function round(exact, quantum)
local quant,frac = math.modf(exact/quantum)
return quantum * (quant + (frac > 0.5 and 1 or 0))
end
function toGBFromB(num, pow)
local gb = num / 1000 / 1000 / 1000
return round(gb, pow)
end
function toGBFromK(num, pow)
local gb = num / 1000 / 1000
return round(gb, pow)
end
function decode (s)
return (string.gsub(s, '\\x[0-9][0-9]', function (x)
x = string.gsub(x,"\\","0")
return string.char(tonumber(x))
end))
end
function column(s,n)
local p=string.rep("%s+.-",n-1).."(%S+)"
return s:match(p)
end
json = require "json"
function conky_listMounts()
local file_df = io.popen("df -B 1000 | grep -e '^/dev'")
local dftext = file_df:read("*all")
file_df:close()
local file_devs = io.popen("lsblk --json --output NAME,MODEL,MOUNTPOINT,LABEL,SIZE --noheadings --bytes")
local text = file_devs:read("*all")
file_devs:close()
local objline = json.decode(text).blockdevices
local output = ""
for rowCount = 1, #objline do
local found_mount = false
local model = objline[rowCount].model
local childs = objline[rowCount].children
if childs ~= nil then
for partCount = 1, #childs do
local partdevid = childs[partCount].name
local mountpoint = childs[partCount].mountpoint
local label = childs[partCount].label
local size = childs[partCount].size
size = toGBFromB(size, 1)
if label == nil and mountpoint == "/" then
label = "Root"
elseif label == nil then
label = size.." GB Volume"
end
if mountpoint ~= nil and mountpoint ~= "[SWAP]" and mountpoint ~= "System\\x20Reserved" and mountpoint ~= "/boot/efi" then
local perused = "?%"
local used = ""
for word in string.gmatch(dftext, "/dev/"..partdevid.."([^\n]*)") do
perused = column(word,5)
used = column(word,3)
used = toGBFromK(used,0.1)
end
if found_mount ~= true then
output = output.."${color1}${voffset -10}${hr 1}\n"
output = output.."${color1}${font ADELE:bold:size=11}"..model.."\n"
output = output.."${voffset 10}"
found_mount = true
else
output = output.."${voffset -5}"
end
output = output.."${color1}${offset 5}${font ADELE:bold:size=12}"..label.."${font}\n"
output = output.."${color1}${offset 5}${voffset -10}${font :size=7}"..mountpoint.." ${alignr}${offset -5}${font ADELE:bold:size=9}${color1}"..used.." / "..size.." ("..perused..")\n"
output = output.."${color2}${offset 5}${voffset -2}${fs_bar 5,230 "..mountpoint.."}\n"
output = output.."${color1}${offset 5}${font ADELE:bold:size=9}READ : ${diskio_read "..partdevid.."}/s | WRITE : ${diskio_write "..partdevid.."}/s${alignr}${font ADELE:bold:size=9}${offset -5}["..partdevid.."]${font}\n"
output = output.."${color2}${offset 5}${voffset -10}${diskiograph_read "..partdevid.." 20,230 66241C FF5A45 0 -t}\n"
output = output.."${color2}${offset 5}${voffset -15}${diskiograph_write "..partdevid.." 20,230 66241C FF5A45 0 -t}\n"
end
end
end
end
return output
end