You are not logged in.
So, I have some ring graphs for a bunch of things, they are all semi-transparent and they look pretty darn good, but the text I use is unreadable because of my background having multiple colors.
Well, after reading the conky config settings page I decided that
draw_outline yesis what I'm looking for, however this has the drawback of making my ring graphs look really bad, they lose all their transparency and they get really aliased, any idea how I would get the outlines without losing the transparency on my rings?
.conkyrc (truncated to remove all the text, you only need to see two of the text entries)
update_interval 1
total_run_times 0
double_buffer yes
use_xft yes
xftfont SourceCodePro:size=12
xftalpha 0.75
uppercase yes
own_window yes
own_window_type normal
own_window_transparent yes
own_window_argb_visual yes
own_window_hints undecorate,sticky,skip_taskbar,skip_pager,below
alignment top_left #top_right #bottom_left #bottom_right
default_color FFFFFF
default_shade_color 000000
default_outline_color 000000
draw_shades no
draw_outline yes
draw_borders no
stippled_borders 0
border_width 0
border_inner_margin 0
border_outer_margin 0
minimum_size 1366 768
maximum_width 1366
gap_x 0
gap_y 0
use_spacer none
cpu_avg_samples 2
no_buffers yes
net_avg_samples 2
override_utf8_locale no
#out_to_console no
#mail_spool $MAIL
lua_load ~/.conky/scripts/rings.lua
lua_draw_hook_pre clock_rings
TEXT
${offset 00210}${voffset 00090}${color ffffff}${font SourceCodePro:size=16:style=Bold}Cube_
${offset 00210}${voffset 00000}${color ffffff}${font SourceCodePro:size=16}Arch Linux amd64
#Truncated, including all the text is hardly necessary
${image ~/.conky/overlay.png}and the rings.lua file (also truncated to remove unnecessary entries)
--[[
Rings.lua v1.6 (2014/04/02)
This is a script that generates rings for various things such as CPU and memory usage, current time and a bunch of other things
the reason I wrote it was because another, rather similar script, called haunted.lua was way too messy for easy editing.
Thus this script was born, the goal of this script is to keep it minimal and free from clutter.
The haunted.lua was written by Harshit, who in turn edited lua.lua originally written by londonali1010
The former of which had no license and the latter of which is under CC-BY-NC-SAv3.0
I will release this script (written from scratch, using a structure eerily similar to lua.lua) under the GPLv3
Written by Andreas "Cube_" Björkman.
If you aren't interested in the settings but rather want to see the code then jump to "--Main script logic"
--]]
defaultXLoc = 1230
defaultYLoc = 160
settings =
{
--Time ring settings
{
name = 'time',
arg = '%I.%M',
maxRange = 11,
bgcolor = 0xffffff,
bgAlpha = 0.4,
fgcolor = 0x992424,
fgAlpha = 0.8,
xLoc = defaultXLoc,
yLoc = defaultYLoc,
radius = 35,
thickness = 8,
angleStart = 0,
angleEnd = 360
},
}
clockRadius = 130
clockXLoc = defaultXLoc
clockYLoc = defaultYLoc
clockColor = 0xffffff
clockAlpha = 0.8
showSeconds = true
--Main script logic
require 'cairo'
--The five original functions are already optimized, I just rewrote them for readability.
--This function converts hex color values to more conventional RGB values, mind you this code is essentially identical to haunted.lua/lua.lua (not much improvement needed
function rgbToRGB(color,alpha)
return ((color / 0x10000) % 0x100) /255., ((color / 0x100) % 0x100) /255., (color % 0x100) /255., alpha
end
--This function, as the title might hint, draws the rings. Again, this one is rather optimized already and thus is very similar to haunted.lua/lua.lua
function ringDrawing(cr, t, pt)
local w,h=conky_window.width,conky_window.height
local xc,yc,ring_r,ring_w,sa,ea=pt['xLoc'],pt['yLoc'],pt['radius'],pt['thickness'],pt['angleStart'],pt['angleEnd']
local bgc, bga, fgc, fga=pt['bgcolor'], pt['bgAlpha'], pt['fgcolor'], pt['fgAlpha']
local angle_0=sa*(2*math.pi/360)-math.pi/2
local angle_f=ea*(2*math.pi/360)-math.pi/2
local t_arc=t*(angle_f-angle_0)
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_f)
cairo_set_source_rgba(cr,rgbToRGB(bgc,bga))
cairo_set_line_width(cr,ring_w)
cairo_stroke(cr)
cairo_arc(cr,xc,yc,ring_r,angle_0,angle_0+t_arc)
cairo_set_source_rgba(cr,rgbToRGB(fgc,fga))
cairo_stroke(cr)
end
--Yet another feature that is very similar to the original, this one draws the clock hands.
function clockHandDrawing(cr,xc,yc)
local secs,mins,hours,secs_arc,mins_arc,hours_arc
local xh,yh,xm,ym,xs,ys
secs=os.date("%S")
mins=os.date("%M")
hours=os.date("%I")
secs_arc=(2*math.pi/60)*secs
mins_arc=(2*math.pi/60)*mins+secs_arc/60
hours_arc=(2*math.pi/12)*hours+mins_arc/12
xh=xc+0.7*clockRadius*math.sin(hours_arc)
yh=yc-0.7*clockRadius*math.cos(hours_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xh,yh)
cairo_set_line_cap(cr,CAIRO_LINE_CAP_ROUND)
cairo_set_line_width(cr,5)
cairo_set_source_rgba(cr,rgbToRGB(clockColor,clockAlpha))
cairo_stroke(cr)
xm=xc+clockRadius*math.sin(mins_arc)
ym=yc-clockRadius*math.cos(mins_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xm,ym)
cairo_set_line_width(cr,3)
cairo_stroke(cr)
if showSeconds then
xs=xc+clockRadius*math.sin(secs_arc)
ys=yc-clockRadius*math.cos(secs_arc)
cairo_move_to(cr,xc,yc)
cairo_line_to(cr,xs,ys)
cairo_set_line_width(cr,1)
cairo_stroke(cr)
end
end
--This function, as the title suggests, draws the rings related to time.
function conky_clock_rings()
local function setup_rings(cr,pt)
local str=''
local value=0
str=string.format('${%s %s}',pt['name'],pt['arg'])
str=conky_parse(str)
value=tonumber(str)
if value == nil then value = 0 end
pct=value/pt['maxRange']
ringDrawing(cr,pct,pt)
end
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 cr=cairo_create(cs)
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num>5 then
for i in pairs(settings) do
setup_rings(cr,settings[i])
end
end
clockHandDrawing(cr,clockXLoc,clockYLoc)
end
--now this one is rather esoterically named, I couldn't think of a better name (and thus kept the original naming)
function ring(cr, name, arg, maxRange, bgc, bga, fgc, fga, xc, yc, r, t, sa, ea)
local function rgbToRGB(color,alpha)
return ((color / 0x10000) % 0x100) / 255., ((color / 0x100) % 0x100) / 255., (color % 0x100) / 255., alpha
end
local function draw_ring(pct)
local angle_0=sa*(2*math.pi/360)-math.pi/2
local angle_f=ea*(2*math.pi/360)-math.pi/2
local pct_arc=pct*(angle_f-angle_0)
-- Draw background ring
cairo_arc(cr,xc,yc,r,angle_0,angle_f)
cairo_set_source_rgba(cr,rgbToRGB(bgc,bga))
cairo_set_line_width(cr,t)
cairo_stroke(cr)
-- Draw indicator ring
cairo_arc(cr,xc,yc,r,angle_0,angle_0+pct_arc)
cairo_set_source_rgba(cr,rgbToRGB(fgc,fga))
cairo_stroke(cr)
end
local function ringSetup()
local str = ''
local value = 0
str = string.format('${%s %s}', name, arg)
str = conky_parse(str)
value = tonumber(str)
if value == nil then value = 0 end
pct = value/maxRange
ringDrawing(pct)
end
local updates=conky_parse('${updates}')
update_num=tonumber(updates)
if update_num>5 then ringSetup() end
end
--I'll add more functions here some day, but for now the cleaning up of the original code and prepping it to fit my coding style is enoughSo... does anyone have any suggestions for how to keep the transparency of the rings while also having the text outlined?
Oh and if anyone can find why the terminal spews
Conky: unknown variable at me that would be most appreciated, I can't find the cause for this myself.
And yes, this is my own config that is somewhat derived from an existing conky config (once I get this to play nice it'll have more unique entries, until then I'll just keep to what I already have in there)
I do apologize for the messy looking lua script, it's still wip
Offline
I usually get what I want by playing with the own_window parameters. I have no exact idea what they do, but the rule is that once I switch wm they have to change as well.
fs/super.c : "Self-destruct in 5 seconds. Have a nice day...\n",
Offline
I usually get what I want by playing with the own_window parameters. I have no exact idea what they do, but the rule is that once I switch wm they have to change as well.
Sorry, no-can-do. I've tried every last window type, results:
normal - works as expected (obviously aside from aforementioned issues)
desktop - log indicates that it's drawing to root window¹, nothing shows up on desktop.
override - log indicates that it's drawing to root window¹, nothing shows up on desktop
dock - works as expected (obviously aside from aforementioned issues)
panel - works as expected (obviously aside from aforementioned issues)
Setting 'own_window' to 'no' and commenting out all the settings related to 'own_window' causes conky to run fine, aside from not rendering anything at all².
¹Conky: desktop window (7e) is root window
Conky: window type - desktop/override
Conky: drawing to created window (0x3e00002)
Conky: drawing to double buffer
Conky: unknown variable
...
²Conky: desktop window (7e) is root window
Conky: drawing to desktop window
Conky: drawing to double buffer
Conky: unknown variable
...
So yeah, I've experimented with this for a week now and I still can't find the solution >.>;
Offline
Hi CG,
I think with conky own_window_type set to override or desktop, the lua defaultXLoc and defaultYLoc settings are relative to conky rather than the whole desktop. Try setting the values relative to the conky top left corner.
It may not solve your overall problem, but it may explain why nothing shows up on the desktop.
Offline
mm, I've played with those already, as far as I can tell the alignment option is set to top left and all coordinates are already adjusted according to top left, I'll experiment a bit with that and see if I can get it working (but window type panel works fine, aside from the transparency issue with text outlines)
If I can't figure out how to keep transparency for the rings and have text outlines I'll just have two conky instances running
Offline