You are not logged in.

#1 2015-06-26 23:25:19

ralph_13
Member
Registered: 2015-02-06
Posts: 73

Moonphases lua script for conky stopped working

I've used a script for moonphases on my wip conky for a while, and after I added the line for mpd on my .conkyrc, the moon no longer appeared on the conky window. The conky log doesn't show any error messages. Here's my .conkyrc (The mail: 0 part is just a placeholder):

alignment bl

cpu_avg_samples 1
net_avg_samples 1
update_interval 1

default_color white
default_outline_color white
default_shade_color white
color2 gray50
 
draw_borders no
draw_shades no
draw_graph_borders no
draw_outline no

border_width 0

gap_x 0
gap_y 6


use_xft yes
xftfont Kingthings Trypewriter 2-11
xftalpha 0.8

own_window yes
own_window_class Conky
own_window_type normal
own_window_transparent yes
own_window_hints undecorated,normal,sticky,skip_taskbar,skip_pager
own_window_argb_visual yes


use_spacer left
double_buffer yes
no_buffers no

total_run_times 0
background no

lua_load /home/ralph/.config/conkyscripts/moonphases.lua
lua_draw_hook_post main

TEXT 


${color2} Mail: ${color}0 ${if_mpd_playing} ${color2} Now $mpd_status: ${color}$mpd_artist - ${mpd_title 300} - $mpd_elapsed/$mpd_length $endif 

And here's the moonphases script:

 require 'weatherlib'
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}'))
        -- creating an array with all the letter
	a = {"a","b","c","d","e","f","g","h","i","h","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
	today = os.time();
	-- loading the variable (taken from mrpeachy)
	font="Moon Phases"
	font_size=26
	xpos,ypos=1340,60
	red,green,blue,alpha=255,255,255,255
	font_slant=CAIRO_FONT_SLANT_NORMAL
	font_face=CAIRO_FONT_WEIGHT_NORMAL
	
	moonphase = weatherlib.calc_moon(today)
	_, _, num = string.find(moonphase, "(%d+)")  -- parsing the data that comes out
	moon = (a[math.floor(num/360*26)])

	cairo_select_font_face (cr, font, font_slant, font_face);
	cairo_set_font_size (cr, font_size)
	cairo_set_source_rgba (cr,red,green,blue,alpha)
	cairo_move_to (cr,xpos,ypos)
	cairo_show_text (cr,moon)
	cairo_stroke (cr)

	cairo_destroy(cr)
	cairo_surface_destroy(cs)
	cr=nil
end 

I'm pretty sure the script is being loaded, since when I make any changes to the script the conky log says "Conky: Lua script '/home/ralph/.config/conkyscripts/moonphases.lua' reloaded"

I've tried changing the position and font size for the moon to make sure it's not just offscreen.

Offline

Board footer

Powered by FluxBB