Advertisement
cesarzeta

vol_bar.lua

Sep 13th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. require 'cairo'
  2. function conky_draw_lines()
  3. local updates=conky_parse('${updates}')
  4. update_num=tonumber(updates)
  5. if update_num > 5 then
  6. if conky_window==nil then return end
  7. local w=conky_window.width
  8. local h=conky_window.height
  9. local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
  10. cr=cairo_create(cs)
  11. cairo_select_font_face (cr, "DejaVuSans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
  12. cairo_set_font_size (cr, 12.0);
  13.  
  14. --Line 1 settings
  15. local a_arg=conky_parse('${exec $HOME/.conky/vol.sh}')
  16. local a_thick=10
  17. local a_red=1
  18. local a_green=0.5
  19. local a_blue=0
  20. local a_alpha=1
  21. local a_start=25
  22.  
  23. --line 1 settings end
  24. local a_num=tonumber(a_arg)
  25. --line 1 background
  26. cairo_set_source_rgba (cr, a_red, a_green, a_blue, 0.5);
  27. cairo_set_line_width (cr, a_thick);
  28. cairo_move_to (cr, a_start, a_start);
  29. cairo_rel_line_to (cr, 0 , 100);
  30. cairo_stroke (cr);
  31. --line 1 indicator
  32. cairo_set_source_rgba (cr, a_red, a_green, a_blue, a_alpha);
  33. cairo_set_line_width (cr, a_thick);
  34. cairo_move_to (cr, a_start, 125);
  35. cairo_rel_line_to (cr, 0 ,0-a_num);
  36. cairo_stroke (cr);
  37. --line 1 title
  38. cairo_set_source_rgba (cr, a_red, a_green, a_blue, a_alpha);
  39. cairo_move_to (cr, 0 , 140);
  40. cairo_show_text (cr, "Volumen");
  41. end
  42. end
  43. function conky_vol_bar()
  44.     conky_draw_lines()
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement