I am trying to use conky to display a random image and play a corresponding .mp3 file with mpg123.
I have a directory with .png files numbered 1-51.png and a directory of .mp3 files named 1-51.mp3
Here is the conf:
Code: Select all
--[[
Bleys 2024
]]
conky.config = {
-- — Conky settings
background = false,
total_run_times = 0,
no_buffers = true,
-- — Window specifications with Background
own_window = true,
own_window_type = dock,
own_window_hints = 'skip_taskbar,skip_pager,undecorated,above',
own_window_transparent = false,
own_window_argb_visual = true,
own_window_argb_value = 0,
own_window_colour = '000000',
double_buffer = true,
minimum_width = 324, minimum_height = 214,
alignment = 'middle_middle',
gap_x = 20,
gap_y = 20,
update_interval = 3600,
-- Lua Load
lua_load = '/home/logansfury/.conky/Biohazzard/test.lua',
lua_draw_hook_post = 'main',
};
conky.text = [[
]];
Code: Select all
require 'cairo'
require "imlib2"
home_path = os.getenv ('HOME')
function fDrawImage(cr,path,xx,yy,ww,hh,arc)
cairo_save (cr)
local img = cairo_image_surface_create_from_png(path)
local w_img, h_img = cairo_image_surface_get_width(img), cairo_image_surface_get_height(img)
cairo_translate (cr, xx, yy)
if arc then
cairo_rotate (cr, arc)
end
cairo_scale (cr, ww/w_img, hh/h_img)
cairo_set_source_surface (cr, img, -w_img/2, -h_img/2)
cairo_paint (cr)
cairo_surface_destroy (img)
collectgarbage ()
cairo_restore (cr)
end
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)
local cr = cairo_create(cs)
math.randomseed(os.time())
local random_number = math.random(1, 51)
fDrawImage(cr, '/home/logansfury/Pictures/microsoft_jokes/' .. tostring(random_number) .. '.png', 162, 107, 324, 214)
--end
cairo_surface_destroy(cs)
cairo_destroy(cr)
end
Now I need an edit for mpg123 to navigate to /home/logansfury/Music/eyegor/ and play the $random_number .mp3
Can anyone provide code to help?
Thanks for reading,
Logan