From b70f19b8ad0f3a5dd722470696d7747177327310 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Sun, 8 Aug 2021 19:51:45 -0400 Subject: [PATCH] ENH call systemd from within conky --- conky.conf | 3 ++- main.lua | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/conky.conf b/conky.conf index a89a8f5..d473b44 100644 --- a/conky.conf +++ b/conky.conf @@ -31,7 +31,8 @@ conky.config = { --Lua Load lua_load = '~/.config/conky/main.lua', lua_draw_hook_post = 'main', - lua_startup_hook = string.format('start %f', update_interval) + lua_startup_hook = string.format('start %f', update_interval), + lua_shutdown_hook = 'stop' } --control updates entirely in lua diff --git a/main.lua b/main.lua index 60ccfea..ac67171 100644 --- a/main.lua +++ b/main.lua @@ -38,6 +38,10 @@ function conky_start(update_interval) local devices = {'sda', 'nvme0n1'} local battery = 'BAT0' local fs_paths = {'/', '/boot', '/home', '/mnt/data', '/mnt/dcache', "/tmp"} + local STATS_FILE = '/tmp/.conky_pacman' + + -- TODO so far this seems like the best way to 'fork' a process from conky + i_o.execute_cmd('systemctl --user start conky_pacman.timer') local mem = memory(update_freq) local rw = readwrite(update_freq, devices) @@ -57,7 +61,6 @@ function conky_start(update_interval) {pcm.static, fs.static, pwr.static, mem.static} ) - local STATS_FILE = '/tmp/.conky_pacman' draw_dynamic = function(cr, _updates) -- draw static components @@ -91,6 +94,10 @@ function conky_start(update_interval) end end +function conky_stop() + i_o.execute_cmd('systemctl --user stop conky_pacman.timer') +end + local updates = -2 -- this accounts for the first few spazzy iterations function conky_main()