--Modulus Battery Conky by AVLinux
--Utilizes the following font: Red Hat Text

conky.config = {
	background = true,
	cpu_avg_samples = 2,
	default_color = '#ffffff', --predominant color (white)
	color2 = '#FF0000', -- red
 	color3 = '#787878', -- hdd color (bar)
        color4 = '#3E4446', -- dark grey
 	double_buffer = true,
	font = 'Red Hat Text:Bold:size=8',
	draw_shades = false,
        gap_x =-400,
	gap_y =80,
        border_inner_margin = 0,
        border_width = 0,
	no_buffers = true,
        own_window = true,
        own_window_type = 'normal',
        own_window_hints  = 'sticky,undecorated,below,skip_taskbar,skip_pager',
        own_window_argb_visual = true,
        own_window_argb_value = 35, -- This controls opacity (Range 0-255)
        own_window_title = 'SysStatsBattConky',
	update_interval = 1.0,
	use_xft = true,
        if_up_strictness = 'address',
	maximum_width = 80,
	minimum_width = 80, 
        --minimum_height = 80,
	alignment = 'top_middle',

template1 = 'BAT0',
	--template1 = 'BAT1',
	--template1 = 'BAT-1',

--### warning re battery depletion percentage level ###
template2 = '20',

lua_load = './LUA/draw_bg.lua',
lua_draw_hook_pre = 'draw_bg',

        };

-- fluxbox adjustment
-- requires fluxbox to be running, increase sleep time in conky-startup.sh if necessary
if os.execute('pidof -q fluxbox') and not os.execute('pidof -q picom') then
   conky.config.own_window_argb_visual = false
   conky.config.own_window_transparent = true
end

conky.text = [[
#BACKGROUND IMAGE (Comment out if you just want the text w/o BG)
${voffset 0}${image ./conky_battery.png -p 0,0 -s 80x80}
#BATTERY_STATS
${if_existing /sys/class/power_supply/BAT0}${voffset 22}${if_match ${battery_percent $template1}<=$template2}${alignc}${color2}${blink ${battery_percent $template1}%}${else}${color4}${if_match ${battery_percent $template1}>$template2}${alignc}${battery_percent $template1}%${endif}${endif}${else}${voffset 22}${endif}
${if_existing /sys/class/power_supply/BAT0}${voffset 28}${alignc}${color3}${battery_bar 8,46 $template1}${endif} 
${voffset -12}
]];
	
