Guest User

conkyrc-lua

a guest
Mar 6th, 2019
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.77 KB | None | 0 0
  1. settings_table = {
  2. {
  3. -- Edit this table to customise your rings.
  4. -- You can create more rings simply by adding more elements to settings_table.
  5. -- "name" is the type of stat to display; you can choose from 'cpu', 'memperc', 'fs_used_perc', 'battery_used_perc'.
  6. name='time',
  7. -- "arg" is the argument to the stat type, e.g. if in Conky you would write ${cpu cpu0}, 'cpu0' would be the argument. If you would not use an argument in the Conky variable, use ''.
  8. arg='%I.%M',
  9. -- "max" is the maximum value of the ring. If the Conky variable outputs a percentage, use 100.
  10. max=12,
  11. -- "bg_colour" is the colour of the base ring.
  12. bg_colour=0xFFFFFF,
  13. -- "bg_alpha" is the alpha value of the base ring.
  14. bg_alpha=0.1,
  15. -- "fg_colour" is the colour of the indicator part of the ring.
  16. fg_colour=0xFFFFFF,
  17. -- "fg_alpha" is the alpha value of the indicator part of the ring.
  18. fg_alpha=0.2,
  19. -- "x" and "y" are the x and y coordinates of the centre of the ring, relative to the top left corner of the Conky window.
  20. x=100, y=150,
  21. -- "radius" is the radius of the ring.
  22. radius=30,
  23. -- "thickness" is the thickness of the ring, centred around the radius.
  24. thickness=5,
  25. -- "start_angle" is the starting angle of the ring, in degrees, clockwise from top. Value can be either positive or negative.
  26. start_angle=0,
  27. -- "end_angle" is the ending angle of the ring, in degrees, clockwise from top. Value can be either positive or negative, but must be larger than start_angle.
  28. end_angle=360
  29. },
  30.  
  31. -- circle graph for time
  32. {
  33. name='time',
  34. arg='%M.%S',
  35. max=60,
  36. bg_colour=0xFFFFFF,
  37. bg_alpha=0.1,
  38. fg_colour=0xFFFFFF,
  39. fg_alpha=0.4,
  40. x=100, y=150,
  41. radius=36,
  42. thickness=5,
  43. start_angle=0,
  44. end_angle=360
  45. },
  46. {
  47. name='time',
  48. arg='%S',
  49. max=60,
  50. bg_colour=0xFFFFFF,
  51. bg_alpha=0.1,
  52. fg_colour=0xFFFFFF,
  53. fg_alpha=0.6,
  54. x=100, y=150,
  55. radius=42,
  56. thickness=5,
  57. start_angle=0,
  58. end_angle=360
  59. },
  60. {
  61. name='time',
  62. arg='%d',
  63. max=31,
  64. bg_colour=0xFFFFFF,
  65. bg_alpha=0.4,
  66. fg_colour=0xFFFFFF,
  67. fg_alpha=0.8,
  68. x=100, y=150,
  69. radius=50,
  70. thickness=5,
  71. start_angle=-150,
  72. end_angle=90
  73. },
  74. {
  75. name='time',
  76. arg='%m',
  77. max=12,
  78. bg_colour=0xFFFFFF,
  79. bg_alpha=0.4,
  80. fg_colour=0xFFFFFF,
  81. fg_alpha=1,
  82. x=100, y=150,
  83. radius=56,
  84. thickness=5,
  85. start_angle=-90,
  86. end_angle=150
  87. },
  88.  
  89. -- circle graph for cpu
  90. {
  91. name='cpu',
  92. arg='cpu0',
  93. max=100,
  94. bg_colour=0xFFFFFF,
  95. bg_alpha=0.4,
  96. fg_colour=0xFFFFFF,
  97. fg_alpha=0.8,
  98. x=100, y=310,
  99. radius=50,
  100. thickness=10,
  101. start_angle=-90,
  102. end_angle=270
  103. },
  104. {
  105. name='cpu',
  106. arg='hwmon temp 1',
  107. max=100,
  108. bg_colour=0xFFFFFF,
  109. bg_alpha=0.4,
  110. fg_colour=0xFFFFFF,
  111. fg_alpha=0.8,
  112. x=100, y=310,
  113. radius=59,
  114. thickness=5,
  115. start_angle=-110,
  116. end_angle=40
  117. },
  118.  
  119. --individual core monitors
  120. {
  121. name='cpu',
  122. arg='cpu1',
  123. max=100,
  124. bg_colour=0xFFFFFF,
  125. bg_alpha=0.4,
  126. fg_colour=0xFFFFFF,
  127. fg_alpha=0.8,
  128. x=100, y=310,
  129. radius=60,
  130. thickness=5,
  131. start_angle=45,
  132. end_angle=90
  133. },
  134.  
  135. {
  136. name='cpu',
  137. arg='cpu2',
  138. max=100,
  139. bg_colour=0xFFFFFF,
  140. bg_alpha=0.4,
  141. fg_colour=0xFFFFFF,
  142. fg_alpha=0.8,
  143. x=100, y=310,
  144. radius=68,
  145. thickness=5,
  146. start_angle=45,
  147. end_angle=90
  148. },
  149. {
  150. name='cpu',
  151. arg='cpu3',
  152. max=100,
  153. bg_colour=0xFFFFFF,
  154. bg_alpha=0.4,
  155. fg_colour=0xFFFFFF,
  156. fg_alpha=0.8,
  157. x=100, y=310,
  158. radius=76,
  159. thickness=5,
  160. start_angle=45,
  161. end_angle=90
  162. },
  163. {
  164. name='cpu',
  165. arg='cpu4',
  166. max=100,
  167. bg_colour=0xFFFFFF,
  168. bg_alpha=0.4,
  169. fg_colour=0xFFFFFF,
  170. fg_alpha=0.8,
  171. x=100, y=310,
  172. radius=84,
  173. thickness=5,
  174. start_angle=45,
  175. end_angle=90
  176. },
  177. --[[memory]]
  178. {
  179. name='memperc',
  180. arg='',
  181. max=100,
  182. bg_colour=0xFFFFFF,
  183. bg_alpha=0.4,
  184. fg_colour=0xFFFFFF,
  185. fg_alpha=0.8,
  186. x=330, y=385,
  187. radius=60,
  188. thickness=10,
  189. start_angle=-90,
  190. end_angle=270
  191. },
  192.  
  193. {
  194. name='fs_used_perc',
  195. arg='/',
  196. max=100,
  197. bg_colour=0xFFFFFF,
  198. bg_alpha=0.4,
  199. fg_colour=0xFFFFFF,
  200. fg_alpha=0.8,
  201. x=50, y=850,
  202. radius=40,
  203. thickness=10,
  204. start_angle=-90,
  205. end_angle=180
  206. },
  207. {
  208. name='fs_used_perc',
  209. arg='/home',
  210. max=100,
  211. bg_colour=0xFFFFFF,
  212. bg_alpha=0.3,
  213. fg_colour=0xFFFFFF,
  214. fg_alpha=0.0,
  215. x=50, y=850,
  216. radius=40,
  217. thickness=5,
  218. start_angle=180,
  219. end_angle=270
  220. },
  221. {
  222. name='downspeedf',
  223. arg='enx3c18a0d1c5e4',
  224. max=100,
  225. bg_colour=0xFFFFFF,
  226. bg_alpha=0.5,
  227. fg_colour=0xFFFFFF,
  228. fg_alpha=0.8,
  229. x=120, y=980,
  230. radius=38,
  231. thickness=10,
  232. start_angle=105,
  233. end_angle=195
  234. },
  235. {
  236. name='upspeedf',
  237. arg='enx3c18a0d1c5e4',
  238. max=100,
  239. bg_colour=0xFFFFFF,
  240. bg_alpha=0.5,
  241. fg_colour=0xFFFFFF,
  242. fg_alpha=0.8,
  243. x=120, y=980,
  244. radius=38,
  245. thickness=10,
  246. start_angle=-75,
  247. end_angle=15
  248. },
  249. {
  250. name='upspeedf',
  251. arg='enx3c18a0d1c5e4',
  252. max=100,
  253. bg_colour=0xFFFFFF,
  254. bg_alpha=0.5,
  255. fg_colour=0xFFFFFF,
  256. fg_alpha=0.0,
  257. x=120, y=980,
  258. radius=30,
  259. thickness=6,
  260. start_angle=0,
  261. end_angle=360
  262. },
  263. }
  264.  
  265. -- Use these settings to define the origin and extent of your clock.
  266.  
  267. clock_r=65
  268.  
  269. -- "clock_x" and "clock_y" are the coordinates of the centre of the clock, in pixels, from the top left of the Conky window.
  270.  
  271. clock_x=100
  272. clock_y=150
  273.  
  274. show_seconds=true
  275.  
  276. require 'cairo'
  277.  
  278. function rgb_to_r_g_b(colour,alpha)
  279. return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
  280. end
  281.  
  282. function draw_ring(cr,t,pt)
  283. local w,h=conky_window.width,conky_window.height
  284.  
  285. local xc,yc,ring_r,ring_w,sa,ea=pt['x'],pt['y'],pt['radius'],pt['thickness'],pt['start_angle'],pt['end_angle']
  286. local bgc, bga, fgc, fga=pt['bg_colour'], pt['bg_alpha'], pt['fg_colour'], pt['fg_alpha']
  287.  
  288. local angle_0=sa*(2*math.pi/360)-math.pi/2
  289. local angle_f=ea*(2*math.pi/360)-math.pi/2
  290. local t_arc=t*(angle_f-angle_0)
  291.  
  292. -- Draw background ring
  293.  
  294. cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
  295. cairo_set_source_rgba(cr,rgb_to_r_g_b(bgc,bga))
  296. cairo_set_line_width(cr,ring_w)
  297. cairo_stroke(cr)
  298.  
  299. -- Draw indicator ring
  300.  
  301. cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
  302. cairo_set_source_rgba(cr,rgb_to_r_g_b(fgc,fga))
  303. cairo_stroke(cr)
  304. end
  305.  
  306. function draw_clock_hands(cr,xc,yc)
  307. local secs,mins,hours,secs_arc,mins_arc,hours_arc
  308. local xh,yh,xm,ym,xs,ys
  309.  
  310. secs=os.date("%S")
  311. mins=os.date("%M")
  312. hours=os.date("%I")
  313.  
  314. secs_arc=(2*math.pi/60)*secs
  315. mins_arc=(2*math.pi/60)*mins+secs_arc/60
  316. hours_arc=(2*math.pi/12)*hours+mins_arc/12
  317.  
  318. -- Draw hour hand
  319.  
  320. xh=xc+0.7*clock_r*math.sin(hours_arc)
  321. yh=yc-0.7*clock_r*math.cos(hours_arc)
  322. cairo_move_to(cr,xc,yc)
  323. cairo_line_to(cr,xh,yh)
  324.  
  325. cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
  326. cairo_set_line_width(cr,5)
  327. cairo_set_source_rgba(cr,1.0,1.0,1.0,1.0)
  328. cairo_stroke(cr)
  329.  
  330. -- Draw minute hand
  331.  
  332. xm=xc+clock_r*math.sin(mins_arc)
  333. ym=yc-clock_r*math.cos(mins_arc)
  334. cairo_move_to(cr,xc,yc)
  335. cairo_line_to(cr,xm,ym)
  336.  
  337. cairo_set_line_width(cr,3)
  338. cairo_stroke(cr)
  339.  
  340. -- Draw seconds hand
  341.  
  342. if show_seconds then
  343. xs=xc+clock_r*math.sin(secs_arc)
  344. ys=yc-clock_r*math.cos(secs_arc)
  345. cairo_move_to(cr,xc,yc)
  346. cairo_line_to(cr,xs,ys)
  347.  
  348. cairo_set_line_width(cr,1)
  349. cairo_stroke(cr)
  350. end
  351. end
  352.  
  353. function conky_clock_rings()
  354. local function setup_rings(cr,pt)
  355. local str=''
  356. local value=0
  357.  
  358. str=string.format('${%s %s}',pt['name'],pt['arg'])
  359. str=conky_parse(str)
  360.  
  361. value=tonumber(str)
  362. pct=(value or 0)/pt['max']
  363.  
  364. draw_ring(cr,pct,pt)
  365. end
  366.  
  367. -- Check that Conky has been running for at least 5s
  368.  
  369. if conky_window==nil then return end
  370. local cs=cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width,conky_window.height)
  371.  
  372. local cr=cairo_create(cs)
  373. --test
  374. cairo_surface_destroy(cs)
  375.  
  376. local updates=conky_parse('${updates}')
  377. update_num=tonumber(updates)
  378.  
  379. if update_num>5 then
  380. for i in pairs(settings_table) do
  381. setup_rings(cr,settings_table[i])
  382. end
  383. end
  384.  
  385. draw_clock_hands(cr,clock_x,clock_y)
  386. --test
  387. cairo_destroy(cr)
  388. end
Add Comment
Please, Sign In to add comment