Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'cairo'
- function conky_main()
- if conky_window == nil then return end
- local cs = cairo_xlib_surface_create(conky_window.display,conky_window.drawable,conky_window.visual, conky_window.width, conky_window.height)
- cr = cairo_create(cs)
- local updates=tonumber(conky_parse('${updates}'))
- if updates>5 then
- conky_image_func()
- conky_name_func()
- conky_cname_func()
- conky_time_func()
- conky_fs_func()
- conky_net_func()
- conky_resource_func()
- end-- if updates>5
- cairo_surface_destroy (image);
- cairo_destroy(cr)
- cairo_surface_destroy(cs)
- cr=nil
- end-- end main function
- --Image
- --###################
- function conky_image_func()
- image = cairo_image_surface_create_from_png ("archtuxsm.png");
- cairo_set_source_surface (cr, image, 0, 0);
- cairo_paint (cr);
- end
- function conky_name_func()
- --Title
- --###################
- red=88/255
- green=155/255
- blue=200/255
- cairo_select_font_face (cr, "Trade Winds", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size (cr, 26);
- cairo_set_source_rgba (cr,.8,.8,.8,1);
- cairo_move_to (cr,47,25);
- cairo_show_text (cr,"Scarlett's Computer");
- cairo_set_source_rgba (cr,red,green,blue,1);
- cairo_move_to (cr,49,26);
- cairo_show_text (cr,"Scarlett's Computer");
- cairo_stroke (cr)
- end
- function conky_cname_func()
- --Computer Name
- --##################
- red=88/255
- green=155/255
- blue=200/255
- cairo_select_font_face (cr, "Droid Serif", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size (cr, 16);
- cairo_set_source_rgba (cr,red,green,blue,1);
- local Cnamehandle = io.popen("uname -smr");
- local Cname = Cnamehandle:read("*a");
- Cnamehandle:close();
- cairo_move_to (cr, 75,70);
- cairo_show_text (cr, Cname);
- --##################
- cairo_set_line_width (cr,5);
- cairo_set_line_cap (cr,CAIRO_LINE_CAP_ROUND);
- cairo_set_source_rgba (cr,.8,.8,.8,1);
- cairo_move_to (cr,0,90);
- cairo_rel_line_to (cr,350,0);
- cairo_stroke (cr);
- --##################
- end
- function conky_time_func()
- --Time
- --##################
- local mytime = os.date("%D %I:%M:%S");
- cairo_move_to (cr,75,120);
- cairo_show_text (cr, mytime);
- --##################
- cairo_set_line_width (cr,5);
- cairo_set_line_cap (cr,CAIRO_LINE_CAP_ROUND);
- cairo_set_source_rgba (cr,.8,.8,.8,1);
- cairo_move_to (cr,0,135);
- cairo_rel_line_to (cr,350,0);
- cairo_stroke (cr);
- --##################
- end
- function conky_uptime_func()
- --Uptime
- --##################
- local uptimehandle = io.popen("uptime | awk '{print substr($3,1,length($3)-1)}'");
- local uptime = uptimehandle:read("*a");
- uptimehandle:close();
- cairo_move_to (cr, 25,170);
- cairo_show_text (cr, "Uptime");
- cairo_move_to (cr,100,170);
- cairo_show_text (cr,uptime);
- cairo_move_to (cr,155,170);
- cairo_show_text (cr,"hours");
- --##################
- cairo_set_line_width (cr,5);
- cairo_set_line_cap (cr,CAIRO_LINE_CAP_ROUND);
- cairo_set_source_rgba (cr,0.5,0.5,0.5,1);
- cairo_move_to (cr,25,180);
- cairo_rel_line_to (cr,250,0);
- cairo_stroke (cr);
- --##################
- end
- --CPU
- --##################
- function conky_fs_func()
- --##################
- cairo_set_line_width (cr,5);
- cairo_set_line_cap (cr,CAIRO_LINE_CAP_ROUND);
- cairo_set_source_rgba (cr,.8,.8,.8,1);
- cairo_move_to (cr,0,375);
- cairo_rel_line_to (cr,350,0);
- cairo_stroke (cr);
- --##################
- --section
- red=88/255
- green=155/255
- blue=200/255
- cairo_select_font_face (cr, "Trade Winds", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size (cr, 26);
- cairo_set_source_rgba (cr,red,green,blue,1);
- cairo_move_to (cr,05,400);
- cairo_show_text (cr,"Filesystem:");
- cairo_select_font_face (cr, "Droid Serif", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size (cr, 12);
- cairo_set_source_rgba (cr,red,green,blue,1);
- cairo_move_to (cr,0,428);
- cairo_show_text (cr,"Root /");
- cairo_move_to (cr,0,458);
- cairo_show_text (cr,"Home /home");
- --Settings
- ind_red=245/255
- ind_green=248/255
- ind_blue=196/255
- bar_bottom_left_X=100
- bar_bottom_left_Y=415
- bar_W=100
- bar_H=15
- max_value=100
- --disk size
- local fshandle = io.popen("df /dev/sda6 | awk 'NR==2 {print $2}'");
- local fstotal = tonumber(fshandle:read("*a"));
- fshandle:close();
- --used
- local fshandle = io.popen("df /dev/sda6 | awk 'NR==2 {print $3}'");
- local fsused = tonumber(fshandle:read("*a"));
- fshandle:close();
- --draw
- cairo_set_source_rgba (cr,0.5,0.5,0.5,1);
- cairo_rectangle (cr, bar_bottom_left_X, bar_bottom_left_Y, bar_W, bar_H);
- cairo_fill (cr);
- value = fsused/fstotal;
- scale = bar_W/max_value
- indicator_width=scale*(value*100)
- cairo_set_source_rgba (cr,ind_red,ind_green,ind_blue,1);
- cairo_rectangle (cr, bar_bottom_left_X,bar_bottom_left_Y,indicator_width,bar_H)
- cairo_fill(cr)
- --##Second disk
- --settings
- bar_bottom_left_X2=100
- bar_bottom_left_Y2=445
- bar_W2=100
- bar_H2=15
- --disk size
- local fshandle = io.popen("df /dev/sda3 | awk 'NR==2 {print $2}'");
- local fstotal2 = tonumber(fshandle:read("*a"));
- fshandle:close();
- --used
- local fshandle = io.popen("df /dev/sda3 | awk 'NR==2 {print $3}'");
- local fsused2 = tonumber(fshandle:read("*a"));
- fshandle:close();
- --draw
- cairo_set_source_rgba (cr,0.5,0.5,0.5,1);
- cairo_rectangle (cr, bar_bottom_left_X2, bar_bottom_left_Y2, bar_W2, bar_H2);
- cairo_fill (cr);
- value2 = fsused2/fstotal2;
- scale = bar_W2/max_value
- indicator_width2=scale*(value2*100)
- cairo_set_source_rgba (cr,ind_red,ind_green,ind_blue,1);
- cairo_rectangle (cr, bar_bottom_left_X2,bar_bottom_left_Y2,indicator_width2,bar_H2)
- cairo_fill(cr)
- end
- function conky_net_func()
- --##################
- cairo_set_line_width (cr,5);
- cairo_set_line_cap (cr,CAIRO_LINE_CAP_ROUND);
- cairo_set_source_rgba (cr,.8,.8,.8,1);
- cairo_move_to (cr,0,475);
- cairo_rel_line_to (cr,350,0);
- cairo_stroke (cr);
- --##################
- --section
- red=88/255
- green=155/255
- blue=200/255
- cairo_select_font_face (cr, "Trade Winds", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size (cr, 26);
- cairo_set_source_rgba (cr,red,green,blue,1);
- cairo_move_to (cr,05,500);
- cairo_show_text (cr,"Network:");
- --#### TODO
- end
- function conky_resource_func()
- --##################
- cairo_set_line_width (cr,5);
- cairo_set_line_cap (cr,CAIRO_LINE_CAP_ROUND);
- cairo_set_source_rgba (cr,.8,.8,.8,1);
- cairo_move_to (cr,0,600);
- cairo_rel_line_to (cr,350,0);
- cairo_stroke (cr);
- --##################
- --section
- red=88/255
- green=155/255
- blue=200/255
- cairo_select_font_face (cr, "Trade Winds", CAIRO_FONT_SLANT_ITALIC, CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size (cr, 26);
- cairo_set_source_rgba (cr,red,green,blue,1);
- cairo_move_to (cr,05,630);
- cairo_show_text (cr,"Top Resource Hogs:");
- --#### TODO
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement