REF get root dir from conky.conf

This commit is contained in:
Nathan Dwarshuis 2022-07-19 18:11:46 -04:00
parent bdca0c6511
commit c9918ba358
2 changed files with 40 additions and 35 deletions

View File

@ -1,5 +1,7 @@
local update_interval = 1 -- in seconds local update_interval = 1 -- in seconds
local conky_dir = debug.getinfo(1).source:match("@?(.*/)")
conky.config = { conky.config = {
background = false, background = false,
@ -30,9 +32,9 @@ conky.config = {
no_buffers = true, no_buffers = true,
-- Lua Load -- Lua Load
lua_load = '~/.config/conky/main.lua', lua_load = conky_dir..'main.lua',
lua_draw_hook_post = 'main', lua_draw_hook_post = 'main',
lua_startup_hook = string.format('start %f', update_interval) lua_startup_hook = string.format('start %f %s', update_interval, conky_dir)
} }
--control updates entirely in lua --control updates entirely in lua

View File

@ -1,4 +1,14 @@
local conky_dir = debug.getinfo(1).source:match("@?(.*/)") --------------------------------------------------------------------------------
-- startup - this is where the modules are compiled and arranged
local draw_dynamic
local __cairo_xlib_surface_create
local __cairo_create
local __cairo_surface_destroy
local __cairo_destroy
function conky_start(update_interval, conky_dir)
local subdirs = { local subdirs = {
'?.lua', '?.lua',
'drawing/?.lua', 'drawing/?.lua',
@ -20,16 +30,15 @@ end
package.cpath = package.cpath..';'..conky_dir..'lib/lib/lua/5.4/?.so;' package.cpath = package.cpath..';'..conky_dir..'lib/lib/lua/5.4/?.so;'
--------------------------------------------------------------------------------
-- startup - this is where the modules are compiled and arranged
require 'cairo' require 'cairo'
__cairo_xlib_surface_create = cairo_xlib_surface_create
__cairo_create = cairo_create
__cairo_surface_destroy = cairo_surface_destroy
__cairo_destroy = cairo_destroy
local compile = require 'compile' local compile = require 'compile'
local draw_dynamic
function conky_start(update_interval)
conky_set_update_interval(update_interval) conky_set_update_interval(update_interval)
draw_dynamic = compile(update_interval, conky_dir..'config.yml') draw_dynamic = compile(update_interval, conky_dir..'config.yml')
@ -38,12 +47,6 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- main loop - where all the drawing/updating happens -- main loop - where all the drawing/updating happens
local __cairo_xlib_surface_create = cairo_xlib_surface_create
local __cairo_create = cairo_create
local __cairo_surface_destroy = cairo_surface_destroy
local __cairo_destroy = cairo_destroy
local updates = -2 -- this accounts for the first few spazzy iterations local updates = -2 -- this accounts for the first few spazzy iterations
function conky_main() function conky_main()