You are not logged in.

#1 2010-04-12 17:49:39

Henry Flower
Member
Registered: 2010-04-12
Posts: 63

[SOLVED] Conky lua problem (transparency)

Hi,
I'm trying to transfer my conky from Ubuntu to Arch: below is a screenshot of the Ubuntu version (what it should look like).  On Arch I have a solid black background.   If it's relevant, I'm running Archbang rather than pure Arch, so with Openbox.

My main issue at the moment is the semi-transparency (and I'd like to have the rounded corners too).   I understand that conky 1.8.0 can do transparency, but only with a compositor, and I'd rather keep my system as light as possible.  So I've replaced my conky with 1.7.2 conky-lua from AUR and (don't know if this was necessary) installed cairo and lua from the repos.   Unfortunately the lua script I used on Ubuntu isn't working; when I run conky in the terminal I get the message ".conkyrc: 121: config file error".  At lines 120 and 121 I have my

lua_load ~/scripts/draw_bg.lua
        lua_draw_hook_pre

My .conkyrc and lua script are below.  Thanks for looking!

261btjm.jpg

# conky configuration
# edited by Mark Buck (Kaivalagi) <m_buck@hotmail.com>

# set to yes if you want Conky to be forked in the background
background no

# X font when Xft is disabled, you can pick one with program xfontsel
#font 5x7
#font 6x10
#font 7x13
#font 8x13
#font 9x15
#font *mintsmild.se*
#font -*-*-*-*-*-*-34-*-*-*-*-*-*-*

# Use Xft?
use_xft yes

# Xft font when Xft is enabled
xftfont Bitstream Vera Sans Mono:size=9

# Text alpha when using Xft
xftalpha 0.8

# Update interval in seconds
update_interval 1.0

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 200 700
maximum_width 200

# Draw shades?
draw_shades yes

# Draw outlines?
draw_outline no

# Draw borders around text
draw_borders no
draw_graph_borders yes

# Stippled borders?
stippled_borders 8

# border margins
border_inner_margin 2
border_outer_margin 2

# border width
border_width 1

# Default colors and also border colors
default_color white
default_shade_color black
default_outline_color white

# own window options
own_window        yes
own_window_type desktop
#own_window_hints undecorated,skip_taskbar

# Text alignment, other possible values are commented
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 5
gap_y 35

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average
# set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about?  This only affects certain objects.
use_spacer right

# colours
color1 white
# light blue
color2 6892C6

color3 6892C6
# green
color4 78BF39
# red
color5 CC0000
color6 88ff88

text_buffer_size 2048

# variable is given either in format $variable or in ${variable}. Latter
# allows characters right after the variable and must be used in network
# stuff because of an argument

# stuff after 'TEXT' will be formatted on screen

lua_load ~/scripts/draw_bg.lua 
        lua_draw_hook_pre
TEXT
${offset -5}${font StyleBats:style=CleanCut:size=12}q ${voffset -2}${font Bitstream Vera Sans Mono:style=Bold:size=11}Weather${font}  ${hr}${color1}

${execpi 1800 conkyForecast --location=MZXX0003 --template=/home/mark/conky/conkyForecast.template}
${goto 25}${color1}${font Bitstream Vera Sans Mono:size=14}${execi 1800 conkyForecast --location=MZXX0003 --datatype=CT}${font}
${goto 20}${font ConkyWeather:style=Bold:size=30}${execi 1800 conkyForecast --location=MZXX0003 --datatype=WF}   ${goto 120}${font ConkyWindNESW:size=30}${execi 1800 conkyForecast --location=MZXX0003 --datatype=BS}${font}
${goto 10}${execi 1800 conkyForecast --location=MZXX0003 --datatype=HT --centeredwidth=4}/${execi 1800 conkyForecast --location=MZXX0003 --datatype=LT --centeredwidth=4}  ${goto 100}${execi 1800 conkyForecast --location=MZXX0003 --datatype=WS --imperial} - ${execi 1800 conkyForecast --location=MZXX0003 --datatype=WD}

$if_mpd_playing${offset -5}${font StyleBats:style=CleanCut:size=12}q ${voffset -2}${font Bitstream Vera Sans Mono:style=Bold:size=11}Music${font}  ${hr}${color1}

${font Bitstream Vera Sans:size=9}${color2}MPD:${color6} $mpd_status
${color}${texeci 10 /home/mark/conky/composer.sh}
${font Bitstream Vera Sans:size=9}$color$mpd_artist
${font Bitstream Vera Sans:size=9}$mpd_album 
${font Bitstream Vera Sans:size=9}$mpd_title  
${color #ccddff} ${mpd_bar 5, 100}
$endif

${offset -5}${font StyleBats:style=CleanCut:size=12}q ${voffset -2}${font Bitstream Vera Sans Mono:style=Bold:size=11}${color1}System${font}  ${hr}${color1}

${color2}CPU Temp: ${color}${acpitemp}${color}°${font Bitstream Vera Sans Mono:size=9}
$color2}CPU1: $color${cpu cpu1}% ${cpubar cpu1 4,65}${font Bitstream Vera Sans Mono:size=9}
$color2}CPU2: $color${cpu cpu2}% ${cpubar cpu2 4,65}${font Bitstream Vera Sans Mono:size=9}
${color2}RAM:$color $mem/$memmax
${color2}Root: $color${fs_used /}/${fs_size /}${font Bitstream Vera Sans Mono:size=9}
${color2}Home: $color${fs_used /home/}/${fs_size /home/}${font Bitstream Vera Sans Mono:size=9}    

${color2}Today:${color6}${execi 10 vnstat -i eth0 | grep "today" | awk '{print $5 $6}'}${goto 120}${color1}${execi 10 vnstat -i eth0 | grep "today" | awk '{print $8 $9}'}
${color2}Week: ${color6}${execi 10 vnstat -i eth0 -w | grep "current week" | awk '{print $6 $7}'}${goto 120}${color1}${execi 10 vnstat -i eth0 -w | grep "current week" | awk '{print $9 $10}'}
${color2}Month: ${color6}${execi 10 vnstat -i eth0 -m | grep "`date +"%b '%y"`" | awk '{print $6 $7}'}${goto 120}${color1}${execi 10 vnstat -i eth0 -m | grep "`date +"%b '%y"`" | awk '{print $9 $10}'}${font}
${color2}Battery:$color ${color red}${battery_bar 4,50 BAT0}
--[[
Background by londonali1010 (2009)
 
This script draws a background to the Conky window. It covers the whole of the Conky window, but you can specify rounded corners, if you wish.
 
To call this script in Conky, use (assuming you have saved this script to ~/scripts/):
    lua_load ~/scripts/draw_bg.lua
    lua_draw_hook_pre
 
Changelog:
+ v1.0 -- Original release (07.10.2009)
]]
 
-- Change these settings to affect your background.
-- "corner_r" is the radius, in pixels, of the rounded corners. If you don't want rounded corners, use 0.
 
corner_r=15
 
-- Set the colour and transparency (alpha) of your background.
 
bg_colour=0x000000
bg_alpha=0.4
 
require 'cairo'
function rgb_to_r_g_b(colour,alpha)
    return ((colour / 0x10000) % 0x100) / 255., ((colour / 0x100) % 0x100) / 255., (colour % 0x100) / 255., alpha
end
 
function conky_draw_bg()
    if conky_window==nil then return end
    local w=conky_window.width
    local h=conky_window.height
    local cs=cairo_xlib_surface_create(conky_window.display, conky_window.drawable, conky_window.visual, w, h)
    cr=cairo_create(cs)
 
    cairo_move_to(cr,corner_r,0)
    cairo_line_to(cr,w-corner_r,0)
    cairo_curve_to(cr,w,0,w,0,w,corner_r)
    cairo_line_to(cr,w,h-corner_r)
    cairo_curve_to(cr,w,h,w,h,w-corner_r,h)
    cairo_line_to(cr,corner_r,h)
    cairo_curve_to(cr,0,h,0,h,0,h-corner_r)
    cairo_line_to(cr,0,corner_r)
    cairo_curve_to(cr,0,0,0,0,corner_r,0)
    cairo_close_path(cr)
 
    cairo_set_source_rgba(cr,rgb_to_r_g_b(bg_colour,bg_alpha))
    cairo_fill(cr)
end

Last edited by Henry Flower (2010-04-13 04:54:08)

Offline

#2 2010-04-12 20:42:19

renato_garcia
Member
From: Brazil
Registered: 2009-08-14
Posts: 24

Re: [SOLVED] Conky lua problem (transparency)

The error in line 121 is because of lua_draw_hook_pre command must have a function name. In your file, it would be:

lua_draw_hook_pre draw_bg

To get the transparency put the command:

own_window_transparent yes

I have tried this in an AwesomeWM, with conky 1.8.0 compiled with lua support, and without compositing.

Offline

#3 2010-04-13 04:52:37

Henry Flower
Member
Registered: 2010-04-12
Posts: 63

Re: [SOLVED] Conky lua problem (transparency)

Thanks, that did it.   smile

Offline

Board footer

Powered by FluxBB