Greetings!
My main machine has been running Ubuntu 10.10 for several months now and a few weeks ago I discovered Conky. I have had a great time playing with Conky, Lua and the shell to get system vitals onto my desktop, so in the spirit of Conky, attached herewith are my files with a screenshot. Sorry for the length of the post.
Conky is divided into four sections (clock, calendar, sysmon and weather) so that I could have different update intervals and window locations. Major parts of most scripts were liberated from other sources and to their creators I am grateful. But many parts are unique and may act as a resource for others.
The clock started as a ring with text and I combined that with the hands function. Hands can be modified in size and made to move proportionately if desired. The negative start value is what begins the hands on the other side of center. The UTC hour hand was included just for fun but now I use it a lot.
Since I often want to know days and dates in the current month as well as into the next few weeks, the calendar is a bit different in that the current date is always in the week displayed at the middle row with weeks floating upward as time goes by. The code is a bit inelegant but all of it is there to manage colors and names of months in ways that change with the line involved. It all seems to work as intended well past the end of time in December of next year. The update interval is set to 2000. I tried to make it longer but it caused some kind of error loop even though the calendar would seemingly display just fine.
The system monitor section keeps track of temperature, resources and network/storage. The rings can be set to change color when things warm up to make them more noticeable. When not catering to my whims, the cores are searching for ET or folding proteins so they are always near 100%. This means I have little need to know about processes since the top several are always the same.
The weather section is fairly simple and lightweight, I believe, for what it displays. I was looking for just a bit more chat than an icon and temperature and could look out the window to get accurate current info. The data source I finally chose is from Wunderground. The icons are ConkyWeather font and a bit of a shell script and Lua pulls it together. The data source format is not formalized so every now and then the text may get out of alignment but it seems to work fine almost all of the time. This variability also leads to the length of the display changing to accommodate greater or lesser data. Go to Wunderground.com, enter your location, click the v button in the menu area to the right and copy the link to the iCal file. Put this in the conky_weather.sh wget statement. You will also need the ConkyWeather.ttf font in your ~/.fonts/ folder. The weather stuff is in its own folder under .conky, so change the path if needed.
My Conky is not fancy like so many of the incredible examples displayed here but it has its charm in a functional sort of way. I seldom see my full desktop so I just have a simple dark gradient and the light text works fine. I have 1200 pixels to work with so one may need to squeeze things up a bit or cut out part of the weather to make it all fit. Finally, these things have worked only from days to weeks. There may be obscure bugs as there always are, so I apologize if you discover them. Thank you to everyone contributing vast insight and experience in this forum but especially to slk, londonali, teo and tirabassi, who were my primary sources. (The screenshot shows the Conky area in two parts to get the whole thing into the image limits at full resolution.)
startstopconky.sh (startup script)
Code:
#!/bin/sh
# click to start, click to stop
if pidof conky | grep [0-9] > /dev/null
then
exec killall conky
else
conky -c ~/.conky/conkyrc_clock &
conky -c ~/.conky/conkyrc_calendar &
conky -c ~/.conky/conkyrc_sysmon &
conky -c ~/.conky/weather/conkyrc_weather
# test conkys
#sleep 3
#conky -c ~/.conky/sandbox/conkyrc_clock &
exit
fi
conyrc_clock
Code:
#==============================================================================
# conkyrc_clock
#
# by mjjohanson based on work from SLK
#
#==============================================================================
background yes
update_interval 1
cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius
double_buffer yes
no_buffers yes
text_buffer_size 2048
gap_x 10
gap_y 30
minimum_size 220 200
maximum_width 228
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment tr
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
override_utf8_locale yes
use_xft yes
xftfont ubuntu:size=8
xftalpha 0.5
uppercase 20
default_color FFFFFF
color1 DDDDDD
color2 AAAAAA
color3 888888
color4 666666
color5 444444
lua_load ~/.conky/conky_clock.lua
lua_draw_hook_post main
TEXT
#${voffset 48}
#${color3}${font ubuntu:size=22}${alignc}${time %e}
#${color2}${font ubuntu:size=12}${voffset -12}$alignc${time %B}
#${color5}${font ubuntu:size=22}${voffset -2}$alignc${time %Y}
#${color1}${font ubuntu:size=10}${voffset -38}$alignc${time %A}
conky_clock.lua
Code:
--==============================================================================
-- conky_clock.lua
--
-- by mjjohanson based on work from SLK and londonali
--
--==============================================================================
require 'cairo'
--------------------------------------------------------------------------------
-- clock DATA
-- HOURS
clock_h = {
{
name='time', arg='%H', max_value=12,
x=114, y=110,
graph_radius=72,
graph_thickness=3,
graph_unit_angle=30, graph_unit_thickness=30,
graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.3,
txt_radius=48,
txt_weight=1, txt_size=14.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.6,
graduation_radius=72,
graduation_thickness=6, graduation_mark_thickness=2,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
hand_start=-10, hand_end=40,
hand_thickness=6, hand_line_cap=1,
hand_colour=0xffffff, hand_alpha=0.4,
hand_proportion='hours',
},
}
-- MINUTES
clock_m = {
{
name='time', arg='%M', max_value=60,
x=114, y=110,
graph_radius=78,
graph_thickness=2,
graph_unit_angle=6, graph_unit_thickness=5,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.3,
txt_radius=90,
txt_weight=0, txt_size=12.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.6,
graduation_radius=78,
graduation_thickness=0, graduation_mark_thickness=2,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.8,
hand_start=-10, hand_end=76,
hand_thickness=3, hand_line_cap=2,
hand_colour=0xffffff, hand_alpha=0.4,
hand_proportion='minutes',
},
}
-- SECONDS
clock_s = {
{
name='time', arg='%S', max_value=60,
x=114, y=110,
graph_radius=66,
graph_thickness=2,
graph_unit_angle=6, graph_unit_thickness=1,
graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.3,
txt_radius=59,
txt_weight=1, txt_size=11.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.3,
graduation_radius=0,
graduation_thickness=0, graduation_mark_thickness=0,
graduation_unit_angle=0,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.0,
hand_start=-20, hand_end=50,
hand_thickness=1, hand_line_cap=2,
hand_colour=0xffffff, hand_alpha=0.4,
hand_proportion='',
},
}
-- UTC HOURS
clock_u = {
{
name='utime', arg='%H', max_value=12,
x=114, y=110,
graph_radius=36,
graph_thickness=1,
graph_unit_angle=30, graph_unit_thickness=30,
graph_bg_colour=0xffffff, graph_bg_alpha=0.0,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.3,
txt_radius=42,
txt_weight=1, txt_size=12.0,
txt_fg_colour=0xaaddaa, txt_fg_alpha=0.6,
graduation_radius=72,
graduation_thickness=0, graduation_mark_thickness=0,
graduation_unit_angle=30,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
hand_start=0, hand_end=30,
hand_thickness=6, hand_line_cap=1,
hand_colour=0xaaffaa, hand_alpha=0.3,
hand_proportion='hours',
},
}
-------------------------------------------------------------------------------
-- rgb_to_r_g_b
-- converts color in hexa to decimal
--
function rgb_to_r_g_b(colour, alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
-------------------------------------------------------------------------------
-- angle_to_position
-- convert degree to rad and rotate (0 degree is top/north)
--
function angle_to_position(start_angle, current_angle)
local pos = current_angle + start_angle
return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
end
-------------------------------------------------------------------------------
-- draw_clock_ring
-- displays clock
--
function draw_clock_ring(display, data, value)
local max_value = data['max_value']
local x, y = data['x'], data['y']
local graph_radius = data['graph_radius']
local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
local graph_unit_angle = data['graph_unit_angle']
local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
-- background ring
cairo_arc(display, x, y, graph_radius, 0, 2 * math.pi)
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
cairo_set_line_width(display, graph_thickness)
cairo_stroke(display)
-- arc of value
local val = (value % max_value)
local i = 1
while i <= val do
cairo_arc(display, x, y, graph_radius,( ((graph_unit_angle * i) - graph_unit_thickness)*(2*math.pi/360) )-(math.pi/2),((graph_unit_angle * i) * (2*math.pi/360))-(math.pi/2))
cairo_set_source_rgba(display,rgb_to_r_g_b(graph_fg_colour,graph_fg_alpha))
cairo_stroke(display)
i = i + 1
end
local angle = (graph_unit_angle * i) - graph_unit_thickness
-- graduations marks
local graduation_radius = data['graduation_radius']
local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
local graduation_unit_angle = data['graduation_unit_angle']
local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
local nb_graduation = 360 / graduation_unit_angle
local i = 1
while i <= nb_graduation do
cairo_set_line_width(display, graduation_thickness)
cairo_arc(display, x, y, graduation_radius, (((graduation_unit_angle * i)-(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2),(((graduation_unit_angle * i)+(graduation_mark_thickness/2))*(2*math.pi/360))-(math.pi/2))
cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
cairo_stroke(display)
cairo_set_line_width(display, graph_thickness)
i = i + 1
end
end
-- text
local txt_radius = data['txt_radius']
local txt_weight, txt_size = data['txt_weight'], data['txt_size']
local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
local movex = txt_radius * (math.cos((angle * 2 * math.pi / 360)-(math.pi/2)))
local movey = txt_radius * (math.sin((angle * 2 * math.pi / 360)-(math.pi/2)))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight);
cairo_set_font_size (display, txt_size);
cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha));
cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3);
cairo_show_text (display, value);
cairo_stroke (display);
-- hands
local hand_start, hand_end = data['hand_start'], data['hand_end']
local hand_thickness = data['hand_thickness']
local hand_colour, hand_alpha = data['hand_colour'], data['hand_alpha']
local hand_line_cap = data['hand_line_cap']
local hand_proportion = data['hand_proportion']
if hand_proportion == 'hours' then
value = value + (tonumber(conky_parse('${time %M}') / 60))
end
if hand_proportion == 'minutes' then
value = value + (tonumber(conky_parse('${time %S}') / 60))
end
local xs = x + (hand_start * math.sin(2*math.pi*value/max_value))
local ys = y - (hand_start * math.cos(2*math.pi*value/max_value))
local xe = x + (hand_end * math.sin(2*math.pi*value/max_value))
local ye = y - (hand_end * math.cos(2*math.pi*value/max_value))
cairo_move_to (display, xs, ys);
cairo_line_to (display, xe, ye);
cairo_set_line_width(display, hand_thickness);
cairo_set_line_cap(display, hand_line_cap);
cairo_set_source_rgba(display,rgb_to_r_g_b(hand_colour, hand_alpha));
cairo_stroke(display);
end
-------------------------------------------------------------------------------
-- go_clock_rings
-- loads data and displays clock
--
function go_clock_rings(display)
local function load_clock_rings(display, data)
local str, value = '', 0
str = string.format('${%s %s}',data['name'], data['arg'])
str = conky_parse(str)
value = tonumber(str)
draw_clock_ring(display, data, value)
end
for i in pairs(clock_h) do
load_clock_rings(display, clock_h[i])
end
for i in pairs(clock_m) do
load_clock_rings(display, clock_m[i])
end
for i in pairs(clock_s) do
load_clock_rings(display, clock_s[i])
end
for i in pairs(clock_u) do
load_clock_rings(display, clock_u[i])
end
end
-------------------------------------------------------------------------------
-- MAIN
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)
local display = cairo_create(cs)
local updates = conky_parse('${updates}')
update_num = tonumber(updates)
if update_num > 5 then
go_clock_rings(display)
end
end
conkyrc_calendar
Code:
#==============================================================================
# conkyrc_calendar
#
# by mjjohanson based on work by Tirabassi
#
#==============================================================================
background yes
update_interval 2000
double_buffer yes
no_buffers yes
text_buffer_size 2048
gap_x 48
gap_y 240
minimum_size 180 40
maximum_width 180
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 1
border_outer_margin 1
alignment tr
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
override_utf8_locale yes
use_xft yes
xftfont monospace:size=8
xftalpha 0.5
uppercase 20
default_color 505050 #days
color1 bbbbbb #current month
color2 00732A #today
color3 888888 #heading
color4 666666
color5 444444
lua_load ~/.conky/conky_calendar.lua
TEXT
${lua_parse calendar}
conky_calendar.lua
Code:
-- calendar ====================================================================
-- Conky calendar
--
-- By mjjohanson based on work by Cesare Tirabassi and others
--[[ calendar is arrayed thus in a block of nine lines with the current date
in the fifth line
current day is 13 March
S M T W T F S
February 13 14 15 16 17 18 19
20 21 22 23 24 25 26
March 27 28 1 2 3 4 5 (current month in separate color)
6 7 8 9 10 11 12
|March| 13 14|15|16 17 18 19 (March and 15 are highlighted)
20 21 22 23 24 25 26
April 27 28 29 30 31 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16 (previous and next month in separate color)
The month appears in the left column when the first day of the month
is in the line.
]]
-- Return a calendar for display
function conky_calendar()
if conky_window == nil then return end
-- Some useful arrays
local day_per_month = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
local name_of_month = { " January ", " February ", " March ", " April ",
" May ", " June ", " July ", " August ",
"September ", " October ", " November ", " December ", " January " }
-- Retrieve current date information
local dtable = os.date("*t")
local to_year = dtable.year
local to_month = dtable.month
local to_day = dtable.day
local to_wday = dtable.wday
-- Adjust number of days for February if it is a leap year
if (to_year % 4 == 0) and (to_year % 100 ~= 0) or (to_year % 400 == 0) then
day_per_month[2] = day_per_month[2] + 1
end
-- Determine start date (upper left)
local day = to_day - to_wday - 27
local month = to_month
if day < 1 then
month = to_month - 1
if month == 0 then month = 12 end
day = day_per_month[month] + day
end
if day < 1 then
month = to_month - 2
if month == 0 then month = 12 end
day = day_per_month[month] + day
end
-- Format and print header
local calendar = "\n ${color2}" .. to_year .. " ${color3}Su Mo Tu We Th Fr Sa${color}\n"
-- Build first four weeks
for i = 1, 4, 1 do
if i == 1 then
if day <= day_per_month[month] - 6 then
if day == 1 then
if month == to_month then
calendar = calendar .. "${color1}" .. name_of_month[month]
else
calendar = calendar .. "${color}" .. name_of_month[month]
end
else
if month == to_month then
calendar = calendar .. "${color1}" .. name_of_month[month]
else
calendar = calendar .. "${color}" .. name_of_month[month]
end
end
else
if name_of_month[month + 1] == name_of_month[to_month] then
calendar = calendar .. "${color1}" .. name_of_month[month + 1] .. "${color}"
else
calendar = calendar .. name_of_month[month + 1]
end
end
else
if day <= day_per_month[month] - 6 then
if day == 1 then
if month == to_month then
calendar = calendar .. "${color1}" .. name_of_month[month]
else
calendar = calendar .. "${color}" .. name_of_month[month]
end
else
calendar = calendar .. " "
end
else
calendar = calendar .. "${color1}" .. name_of_month[month + 1] .. "${color}"
end
end
for j = 1, 7, 1 do
if day < 10 then
calendar = calendar .. " "
end
calendar = calendar .. day .. " "
day = day + 1
if day > day_per_month[month] then
day = 1
month = month + 1
if month > 12 then month = 1 end
if month == to_month then calendar = calendar .. "${color1}" end
end
end
calendar = calendar .. "\n"
end
-- Build current week
calendar = calendar .. "${color2}".. name_of_month[to_month] .. "${color}"
if month == to_month then calendar = calendar .. "${color1}" end
for j = 1, 7, 1 do
if day < 10 then
calendar = calendar .. " "
end
if day == to_day then
calendar = calendar .. "${color2}"
calendar = calendar .. day .. " "
calendar = calendar .. "${color1}"
else
calendar = calendar .. day .. " "
end
day = day + 1
if day > day_per_month[month] then
day = 1
month = month + 1
if month > 12 then month = 1 end
if month == to_month then
calendar = calendar .. "${color1}"
else
calendar = calendar .. "${color}"
end
end
end
calendar = calendar .. "\n"
-- Build last four weeks
for i = 1, 4, 1 do
if day <= day_per_month[month] - 6 then
if day == 1 then
calendar = calendar .. "${color}" .. name_of_month[month]
else
if i == 1 and day < 7 and month ~= to_month then
calendar = calendar .. name_of_month[month]
else
calendar = calendar .. " "
end
end
else
if month == to_month then
calendar = calendar .. "${color}" .. name_of_month[month +1] .. "${color1}"
else
calendar = calendar .. name_of_month[month +1]
end
end
for j = 1, 7, 1 do
if day < 10 then calendar = calendar .. " " end
calendar = calendar .. day .. " "
day = day + 1
if day > day_per_month[month] then
day = 1
month = month + 1
if month > 12 then month = 1 end
calendar = calendar .. "${color}"
end
end
calendar = calendar .. "\n"
end
-- Return the calendar
return calendar
end
conkyrc_sysmon
Code:
#==============================================================================
# conkyrc_sysmon
#
# by mjjohanson based on work from SLK
#
#==============================================================================
background yes
update_interval 2
cpu_avg_samples 2
net_avg_samples 2
temperature_unit celsius
double_buffer yes
no_buffers yes
text_buffer_size 2048
gap_x 44
gap_y 390
minimum_size 212 240
maximum_width 212
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 0
border_outer_margin 0
alignment tr
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
override_utf8_locale yes
use_xft yes
xftfont caviar dreams:size=8
xftalpha 0.5
uppercase no
default_color FFFFFF
color1 DDDDDD
color2 AAAAAA
color3 888888
color4 666666
hddtemp_host 127.0.0.1
hddtemp_port 7634
lua_load ~/.conky/conky_sysmon.lua
lua_draw_hook_post main
TEXT
${voffset -2}
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}board ${hwmon 0 temp 1}\u00b0C
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}video1 ${nvidia temp}\u00b0C
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}/dev/sda ${lua_parse resolve_hddtemp /dev/sda}\u00b0C
${voffset -12}
${goto 90}${font Ubuntu:size=7,weight:bold}${color}temperature
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}core0${alignr}${hwmon 1 temp 1}\u00b0C
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}core1${alignr}${hwmon 2 temp 1}\u00b0C
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}core2${alignr}${hwmon 3 temp 1}\u00b0C
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}core3${alignr}${hwmon 4 temp 1}\u00b0C
${voffset -12}
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}memory ${mem}
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}cycles ${cpu cpu0}%
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}loadavg 1 min ${loadavg 1}
${voffset -12}
${goto 90}${font Ubuntu:size=7,weight:bold}${color}resources
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}uptime${alignr}${uptime}
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}processes${alignr}${processes}
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}running processes${alignr} ${running_processes}
#floating space above to resolve single digit bug
${goto 90}${font Ubuntu:size=7,weight:normal}${color2}entropy ${alignr}${entropy_avail}
${voffset -12}
${goto 90}${downspeedgraph eth3 30,130 222222 aaaaaa -l}${voffset -39}
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}download ${downspeedf eth3} KiB/s
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}upload ${upspeedf eth3}KiB/s
${goto 90}${font Ubuntu:size=5,weight:bold}${color2}ethernet ${addr eth3}
${voffset -12}
${goto 90}${font Ubuntu:size=7,weight:bold}${color}network/storage
${goto 90}${diskiograph 30,130 222222 aaaaaa}${voffset -42}
${goto 90}${font Ubuntu:size=7,weight:normal}${color2} /home${alignr}${fs_used /home} of ${fs_size /home}
${goto 90}${font Ubuntu:size=7,weight:normal}${color2} /${alignr}${fs_used /} of ${fs_size /}
${goto 90}${font Ubuntu:size=7,weight:normal}${color2} /var${alignr}${fs_used /var} of ${fs_size /var}
conky_sysmon.lua
Code:
--==============================================================================
-- conky_sysmon.lua
--
-- by mjjohanson based on work from SLK and londonali
--==============================================================================
require 'cairo'
--------------------------------------------------------------------------------
-- gauge DATA
gauge = {
{
name='hwmon', arg='0 temp 1', max_value=60,
x=85, y=68,
graph_radius=34,
graph_thickness=6,
graph_start_angle=180,
graph_unit_angle=3.0, graph_unit_thickness=3.0,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.5,
gradient_display=1,
hand_fg_colour=0xEF5A29, hand_fg_alpha=0.0,
txt_radius=40,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=28,
graduation_thickness=0, graduation_mark_thickness=1,
graduation_unit_angle=27,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.3,
},
{
name='nvidia', arg='temp', max_value=80,
x=85, y=68,
graph_radius=26,
graph_thickness=6,
graph_start_angle=180,
graph_unit_angle=2.25, graph_unit_thickness=2.25,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.5,
gradient_display=1,
hand_fg_colour=0xEF5A29, hand_fg_alpha=0.0,
txt_radius=24,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=28,
graduation_thickness=0, graduation_mark_thickness=1,
graduation_unit_angle=27,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.3,
},
{
name='hddtemp', arg='/dev/sda', max_value=60,
x=85, y=68,
graph_radius=18,
graph_thickness=6,
graph_start_angle=180,
graph_unit_angle=3.0, graph_unit_thickness=3.0,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.5,
gradient_display=1,
hand_fg_colour=0xEF5A29, hand_fg_alpha=0.0,
txt_radius=10,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=28,
graduation_thickness=0, graduation_mark_thickness=1,
graduation_unit_angle=27,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.3,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.3,
},
{
name='memperc', arg='', max_value=100,
x=85, y=168,
graph_radius=34,
graph_thickness=6,
graph_start_angle=180,
graph_unit_angle=1.8, graph_unit_thickness=1.8,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.5,
gradient_display=1,
hand_fg_colour=0xEF5A29, hand_fg_alpha=0.0,
txt_radius=40,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=34,
graduation_thickness=6, graduation_mark_thickness=2,
graduation_unit_angle=15,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.3,
},
{
name='cpu', arg='cpu0', max_value=100,
x=85, y=168,
graph_radius=26,
graph_thickness=6,
graph_start_angle=180,
graph_unit_angle=1.8, graph_unit_thickness=1.8,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.5,
gradient_display=0,
hand_fg_colour=0xEF5A29, hand_fg_alpha=0.0,
txt_radius=18,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=23,
graduation_thickness=0, graduation_mark_thickness=2,
graduation_unit_angle=27,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.3,
},
{
name='loadavg', arg='1', max_value=18,
x=85, y=168,
graph_radius=18,
graph_thickness=6,
graph_start_angle=180,
graph_unit_angle=10, graph_unit_thickness=10,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.5,
gradient_display=1,
hand_fg_colour=0xEF5A29, hand_fg_alpha=0.0,
txt_radius=10,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=23,
graduation_thickness=0, graduation_mark_thickness=2,
graduation_unit_angle=27,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.3,
},
{
name='downspeedf', arg='eth3', max_value=400,
x=85, y=268,
graph_radius=34,
graph_thickness=6,
graph_start_angle=180,
graph_unit_angle=0.45, graph_unit_thickness=0.45,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.5,
gradient_display=0,
hand_fg_colour=0xEF5A29, hand_fg_alpha=0.0,
txt_radius=10,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=23,
graduation_thickness=0, graduation_mark_thickness=2,
graduation_unit_angle=27,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.3,
},
{
name='upspeedf', arg='eth3', max_value=40,
x=85, y=268,
graph_radius=26,
graph_thickness=6,
graph_start_angle=180,
graph_unit_angle=4.5, graph_unit_thickness=4.5,
graph_bg_colour=0xffffff, graph_bg_alpha=0.1,
graph_fg_colour=0xFFFFFF, graph_fg_alpha=0.5,
gradient_display=0,
hand_fg_colour=0xEF5A29, hand_fg_alpha=0.0,
txt_radius=10,
txt_weight=0, txt_size=8.0,
txt_fg_colour=0xFFFFFF, txt_fg_alpha=0.0,
graduation_radius=23,
graduation_thickness=0, graduation_mark_thickness=2,
graduation_unit_angle=27,
graduation_fg_colour=0xFFFFFF, graduation_fg_alpha=0.5,
caption='',
caption_weight=1, caption_size=8.0,
caption_fg_colour=0xFFFFFF, caption_fg_alpha=0.3,
}
}
-------------------------------------------------------------------------------
-- rgb_to_r_g_b
-- converts color in hexa to decimal
--
function rgb_to_r_g_b(colour, alpha)
return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
-------------------------------------------------------------------------------
-- angle_to_position
-- convert degree to rad and rotate (0 degree is top/north)
--
function angle_to_position(start_angle, current_angle)
local pos = current_angle + start_angle
return ( ( pos * (2 * math.pi / 360) ) - (math.pi / 2) )
end
-------------------------------------------------------------------------------
-- draw_gauge_ring
-- displays gauges
--
function draw_gauge_ring(display, data, value)
local max_value = data['max_value']
local x, y = data['x'], data['y']
local graph_radius = data['graph_radius']
local graph_thickness, graph_unit_thickness = data['graph_thickness'], data['graph_unit_thickness']
local graph_start_angle = data['graph_start_angle']
local graph_unit_angle = data['graph_unit_angle']
local graph_bg_colour, graph_bg_alpha = data['graph_bg_colour'], data['graph_bg_alpha']
local graph_fg_colour, graph_fg_alpha = data['graph_fg_colour'], data['graph_fg_alpha']
local gradient = data['gradient_display']
local hand_fg_colour, hand_fg_alpha = data['hand_fg_colour'], data['hand_fg_alpha']
local graph_end_angle = (max_value * graph_unit_angle) % 360
-- background ring
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, 0), angle_to_position(graph_start_angle, graph_end_angle))
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_bg_colour, graph_bg_alpha))
cairo_set_line_width(display, graph_thickness)
cairo_stroke(display)
-- arc of value
local val = value % (max_value + 1)
if gradient > 0 then
if value / max_value > 0.6 then graph_fg_colour = 0xFFFF66 end
if value / max_value > 0.7 then graph_fg_colour = 0xFFCC33 end
if value / max_value > 0.8 then graph_fg_colour = 0xFF9900 end
if value / max_value > 0.9 then graph_fg_colour = 0xFF3300 end
end
local start_arc = 0
local stop_arc = 0
local i = 1
while i <= val do
start_arc = (graph_unit_angle * i) - graph_unit_thickness
stop_arc = (graph_unit_angle * i)
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display, rgb_to_r_g_b(graph_fg_colour, graph_fg_alpha))
cairo_stroke(display)
i = i + 1
end
local angle = start_arc
-- hand
start_arc = (graph_unit_angle * val) - (graph_unit_thickness * 2)
stop_arc = (graph_unit_angle * val)
cairo_arc(display, x, y, graph_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display, rgb_to_r_g_b(hand_fg_colour, hand_fg_alpha))
cairo_stroke(display)
-- graduations marks
local graduation_radius = data['graduation_radius']
local graduation_thickness, graduation_mark_thickness = data['graduation_thickness'], data['graduation_mark_thickness']
local graduation_unit_angle = data['graduation_unit_angle']
local graduation_fg_colour, graduation_fg_alpha = data['graduation_fg_colour'], data['graduation_fg_alpha']
if graduation_radius > 0 and graduation_thickness > 0 and graduation_unit_angle > 0 then
local nb_graduation = graph_end_angle / graduation_unit_angle
local i = 0
while i < nb_graduation do
cairo_set_line_width(display, graduation_thickness)
start_arc = (graduation_unit_angle * i) - (graduation_mark_thickness / 2)
stop_arc = (graduation_unit_angle * i) + (graduation_mark_thickness / 2)
cairo_arc(display, x, y, graduation_radius, angle_to_position(graph_start_angle, start_arc), angle_to_position(graph_start_angle, stop_arc))
cairo_set_source_rgba(display,rgb_to_r_g_b(graduation_fg_colour,graduation_fg_alpha))
cairo_stroke(display)
cairo_set_line_width(display, graph_thickness)
i = i + 1
end
end
-- text
local txt_radius = data['txt_radius']
local txt_weight, txt_size = data['txt_weight'], data['txt_size']
local txt_fg_colour, txt_fg_alpha = data['txt_fg_colour'], data['txt_fg_alpha']
local movex = txt_radius * math.cos(angle_to_position(graph_start_angle, angle))
local movey = txt_radius * math.sin(angle_to_position(graph_start_angle, angle))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, txt_weight)
cairo_set_font_size (display, txt_size)
cairo_set_source_rgba (display, rgb_to_r_g_b(txt_fg_colour, txt_fg_alpha))
cairo_move_to (display, x + movex - (txt_size / 2), y + movey + 3)
cairo_show_text (display, value)
cairo_stroke (display)
-- caption
local caption = data['caption']
local caption_weight, caption_size = data['caption_weight'], data['caption_size']
local caption_fg_colour, caption_fg_alpha = data['caption_fg_colour'], data['caption_fg_alpha']
local tox = graph_radius * (math.cos((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
local toy = graph_radius * (math.sin((graph_start_angle * 2 * math.pi / 360)-(math.pi/2)))
cairo_select_font_face (display, "ubuntu", CAIRO_FONT_SLANT_NORMAL, caption_weight);
cairo_set_font_size (display, caption_size)
cairo_set_source_rgba (display, rgb_to_r_g_b(caption_fg_colour, caption_fg_alpha))
cairo_move_to (display, x + tox + 5, y + toy + 1)
-- bad hack but not enough time !
if graph_start_angle < 105 then
cairo_move_to (display, x + tox - 30, y + toy + 1)
end
cairo_show_text (display, caption)
cairo_stroke (display)
end
-------------------------------------------------------------------------------
-- go_gauge_rings
-- loads data and displays gauges
--
function go_gauge_rings(display)
local function load_gauge_rings(display, data)
local str, value = '', 0
str = string.format('${%s %s}',data['name'], data['arg'])
str = conky_parse(str)
if data['name'] == "hddtemp" then
if str=="N/A" then
str=lasthddtemp
else
lasthddtemp=str
end
end
value = tonumber(str)
if value == nil then value = 0 end
draw_gauge_ring(display, data, value)
end
for i in pairs(gauge) do
load_gauge_rings(display, gauge[i])
end
end
-------------------------------------------------------------------------------
-- MAIN
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)
local display = cairo_create(cs)
go_gauge_rings(display)
end
-------------------------------------------------------------------------------
-- resolve_hddtemp
-- displays old hddtemp value when new value is N/A
--
function conky_resolve_hddtemp(device)
local str, value = '', 0
str = string.format('${%s %s}', 'hddtemp', device)
str = conky_parse(str)
if str == "N/A" then
str = lasthddtemp
else
lasthddtemp = str
end
value = tonumber(str)
if value == nil then value = 0 end
return value
end
conkyrc_weather (set up for weather folder under .conky)
Code:
#==============================================================================
# conkyrc_weather
#
# by mjjohanson based on work by TeoBigusGeekus
#
#==============================================================================
background yes
update_interval 2000
double_buffer yes
no_buffers yes
text_buffer_size 2048
gap_x 44
gap_y 720
minimum_size 170 480
maximum_width 170
own_window yes
own_window_type override
own_window_transparent yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
border_inner_margin 1
border_outer_margin 1
alignment tr
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
override_utf8_locale yes
use_xft yes
xftfont ubuntu:size=7
xftalpha 0.5
uppercase 20
default_color cccccc #text
color1 999999 #lines
color2 aaaaaa #icons
color3 888888
color4 666666
color5 444444
lua_load ~/.conky/weather/set_icon.lua
TEXT
${exec sh ~/.conky/weather/conky_weather.sh}
${color1}${hr 1}${color2}
${font conkyweather:size=32}${lua_parse conky_set_icon 3}${color}${font}${voffset -30}${goto 52}${exec sed -n '3p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '4p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '5p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2} ${exec sed -n '7p' ~/.conky/weather/descriptions}
${color1}${hr 1}${color2}
${font conkyweather:size=32}${lua_parse conky_set_icon 9}${color}${font}${voffset -30}${goto 52}${exec sed -n '9p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '10p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '11p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2} ${exec sed -n '13p' ~/.conky/weather/descriptions}
${color1}${hr 1}${color2}
${font conkyweather:size=32}${lua_parse conky_set_icon 15}${color}${font}${voffset -30}${goto 52}${exec sed -n '15p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '16p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '17p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2} ${exec sed -n '19p' ~/.conky/weather/descriptions}
${color1}${hr 1}${color2}
${font conkyweather:size=32}${lua_parse conky_set_icon 21}${color}${font}${voffset -30}${goto 52}${exec sed -n '21p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '22p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '23p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2} ${exec sed -n '25p' ~/.conky/weather/descriptions}
${color1}${hr 1}${color2}
${font conkyweather:size=32}${lua_parse conky_set_icon 27}${color}${font}${voffset -30}${goto 52}${exec sed -n '27p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '28p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2}${goto 52}${exec sed -n '29p' ~/.conky/weather/descriptions | fold -s -w 28}
${voffset 2} ${exec sed -n '31p' ~/.conky/weather/descriptions}
${color1}${hr 1}${color3}
${font ubuntu:size=6}last update ${time %e %B %Y %H:%M}
conky_weather.sh (set up for weather folder under .conky)
Code:
#!/bin/bash
# by mjjohanson based on work by TeoBigusGeekus
wget -O ~/.conky/weather/weather_data http://ical.wunderground.com/auto/ical/MN/Minneapolis.ics?units=english
grep -E "DESCRIPTION|SUMMARY" <~/.conky/weather/weather_data >~/.conky/weather/descriptions #put description and summary lines in new file
sed -i 's/.$//' ~/.conky/weather/descriptions #remove line feed from lines
sed -i 's/^DESCRIPTION://' ~/.conky/weather/descriptions #remove 'description:'
sed -i 's/^SUMMARY:[[:alpha:] ]*//' ~/.conky/weather/descriptions #remove 'summary:' and up to temp
sed -i 's/\.\.\./ /' ~/.conky/weather/descriptions #change ellipsis to space
sed -i 's/ \\n//' ~/.conky/weather/descriptions #remove ' \n'
sed -i 's/\.//3' ~/.conky/weather/descriptions #remove the third dot at eol or middle if > 3 dots
sed -i 's/$/\./' ~/.conky/weather/descriptions #add a dot to end of lines if 2 or 3 existing
sed -i 's/\.//4' ~/.conky/weather/descriptions #remove the fourth dot to set up for next step
sed -i 's/\./\n/g' ~/.conky/weather/descriptions #change dots to new lines, three lines per day
sed -i 's/^[ \t]//' ~/.conky/weather/descriptions #remove leading white space
#sed -i 's/\([0-9]\) mph/\1mph/g' ~/.conky/weather/descriptions #move mph
sed -i 's/\([0-9]\) percent/\1%/g' ~/.conky/weather/descriptions #change percent
sed -i 's/\([0-9]\)F/\1\u00b0/g' ~/.conky/weather/descriptions #change F to degree symbol
sed -i '/mph/!s/\([0-9]\) /\1\u00b0 /g' ~/.conky/weather/descriptions #add degree symbol after temp in lines
sed -i 's/\([0-9]\)$/\1\u00b0/g' ~/.conky/weather/descriptions #add degree symbol after temp at end of lines
#sed -i 's/\([0-9]\)mph/\1 mph/g' ~/.conky/weather/descriptions #move mph back
set_icon.lua (set up for weather folder under .conky)
Code:
-------------------------------------------------------------------------------
-- set_icon
-- parses weather line and returns letter of weather icon
--
function conky_set_icon(line)
local str = "${exec sed -n \'" .. line .. "\p' ~/.conky/weather/descriptions}"
local text = string.lower(conky_parse(str))
if string.find(text, "tonight") then
if string.find(text, "clear") then return("A")
elseif string.find(text, "scattered clouds") then return("B")
elseif string.find(text, "partly cloudy") then return("C")
elseif string.find(text, "cloudy") then return("D")
elseif string.find(text, "overcast") then return("D")
elseif string.find(text, "freezing") then return("O")
elseif string.find(text, "sleet") then return("O")
elseif string.find(text, "flurries") then return("O")
elseif string.find(text, "snow") then return("O")
elseif string.find(text, "thunderstorms") then return("K")
elseif string.find(text, "fog") then return("0")
elseif string.find(text, "haze") then return("0")
elseif string.find(text, "rain") then return("G")
elseif string.find(text, "snow") then return("O")
else
return("-")
end
else
if string.find(text, "clear") then return("a")
elseif string.find(text, "sunny") then return("b")
elseif string.find(text, "scattered clouds") then return("b")
elseif string.find(text, "partly cloudy") then return("c")
elseif string.find(text, "mostly cloudy") then return("d")
elseif string.find(text, "cloudy") then return("e")
elseif string.find(text, "overcast") then return("f")
elseif string.find(text, "chance of rain") then return("g")
elseif string.find(text, "light rain") then return("g")
elseif string.find(text, "freezing rain") then return("v")
elseif string.find(text, "sleet") then return("w")
elseif string.find(text, "chance of flurries") then return("o")
elseif string.find(text, "chance of snow") then return("q")
elseif string.find(text, "chance of thunderstorms") then return("m")
elseif string.find(text, "thunderstorms") then return("n")
elseif string.find(text, "fog") then return("0")
elseif string.find(text, "haze") then return("7")
elseif string.find(text, "rain") then return("i")
elseif string.find(text, "snow") then return("r")
else
return("-")
end
end
end
Bookmarks