-- This is an update of the legacy conkyrc syntax to the new Conky Lua syntax.
-- Configs are saved in `conky.config`; the text to be displayed is stored in `conky.text`

-- Lua uses `--` to preface comments. Comment out any line to disable that config.
-- Inside `conky.text`, the comments are disabled with `#`.

-- Conky documentation can be found here:
--    Variables (in text) = https://conky.cc/variables
--    Config Settings     = https://conky.cc/config_settings
--    Lua API             = https://conky.cc/lua

CONKYRC_EXTRA_LUA_FILES_LOCATION = "/root/.config/conky-gtk/"

conky.config = {
    use_xft = true, -- use xft?
    font = 'DejaVuSans:size=9:weight=bold', -- [font name]:size=[font size]:weight=[font weight]
    xftalpha = 1,
    uppercase = false, -- all text in uppercase?
    pad_percents = 0,
    text_buffer_size = 2048,
    override_utf8_locale = true, -- Force UTF8? note that UTF8 support required XFT
    use_spacer = 'none', -- Add spaces to keep things from moving about?  This only affects certain objects.

    update_interval = 2, -- Update interval in seconds
    double_buffer = true, -- Use double buffering (reduces flicker, may not work for everyone)
    total_run_times = 0, -- This is the number of times Conky will update before quitting. Set to zero to run forever.

    -- background = true, -- Run in background (same as running conky &)

    -- Create own window instead of using desktop (required in nautilus)
    own_window = true,
    own_window_class = 'Conky',
    own_window_transparent = true,
    own_window_argb_visual = false,
    own_window_argb_value = 255,
    own_window_type = 'override',
    own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',

    -- Minimum size of text area
    minimum_height = 50,
    minimum_width = 300,

    draw_shades = false, -- draw shades?
    draw_outline = false, -- draw outlines?
    draw_borders = false, -- draw borders around text?
    draw_graph_borders = yes, -- draw borders around graphs
    stippled_borders = 0, -- stripled borders?

    imlib_cache_size = 0, -- Imlib2 image cache size, in bytes. Defaults to 4MiB. Increase this value if you use $image lots. Set to 0 to disable the image cache.

    -- Gap between borders of screen and text. Same thing as passing -x at command line
    gap_x = 64,
    gap_y = 5,

    alignment = 'middle_right', -- alignment on {y_axis}_{x_axis}

    cpu_avg_samples = 2, -- number of cpu samples to average. set to 1 to disable averaging
    net_avg_samples = 2, -- number of net samples to average. set to 1 to disable averaging

    no_buffers = true, -- Subtract file system buffers from used memory?

    default_color = 'e0e0e0',
    default_shade_color = '000000',
    default_outline_color = '000000',

    temperature_unit = 'celsius', -- Parameters are either "fahrenheit" or "celsius". The default unit is degree Celsius.

    color1 = 'CECECE', -- heading color
    color2 = 'CECECE', -- normal text color

    -- Shorten units to a single character (kiB->k, GiB->G, etc.). Default is false (off)
    short_units = true,

    -- Test network interface status: 'up' (interface up), 'link' (interface up with link) or 'address' (interface up with link and assigned IP address)
    if_up_strictness = 'link',

    lua_load = CONKYRC_EXTRA_LUA_FILES_LOCATION .. '/show_mounts.lua',
};

conky.config.maximum_width = conky.config.minimum_width -- so that the width as a whole can be changed by only changing minimum_width

conky.text = [[
${color1}SYSTEM ${hr 2}
${color2}${nodename}
#${color}${pre_exec cat /etc/DISTRO_SPECS | grep DISTRO_NAME | cut -d '"' -f2} # ${pre_exec} is deprecated in newer conky, use `execi [SOME BIG VALUE]` instead
${color2}${texeci 36000 cat /etc/DISTRO_SPECS | grep DISTRO_NAME | cut -d '"' -f2 | cut -d "'" -f2}
${color2}${sysname} ${kernel}
${color2}Uptime ${uptime}

${color1}PROCESSES ${hr 2}
${color1}${alignr}CPU% used
${color2}${top name 1}${alignr}${top cpu 1} %
${color2}${top name 2}${alignr}${top cpu 2} %
${color2}${top name 3}${alignr}${top cpu 3} %
${color2}${top name 4}${alignr}${top cpu 4} %
#${color2}${top name 5}${alignr}${top cpu 5} %
#${color2}${top name 6}${alignr}${top cpu 6} %
#${color2}${top name 7}${alignr}${top cpu 7} %
${color1}${alignr}MEM  used
${color2}${top_mem name 1}${alignr}${top_mem mem_res 1}
${color2}${top_mem name 2}${alignr}${top_mem mem_res 2}
${color2}${top_mem name 3}${alignr}${top_mem mem_res 3}
${color2}${top_mem name 4}${alignr}${top_mem mem_res 4}
#${color2}${top_mem name 5}${alignr}${top_mem mem_res 5}
#${color2}${top_mem name 6}${alignr}${top_mem mem_res 6}
#${color2}${top_mem name 7}${alignr}${top_mem mem_res 7}

${color1}RESOURCES ${hr 2}
#${color2}Temp: ${hwmon 3 temp 1}°C
${color2}CPU0: ${cpu cpu0}%${alignr}${color1}${cpubar cpu0 10,120}
#${color2}CPU1: ${cpu cpu1}%${alignr}${color1}${cpubar cpu1 10,120}
#${color2}CPU2: ${cpu cpu2}%${alignr}${color1}${cpubar cpu2 10,120}
#${color2}CPU3: ${cpu cpu3}%${alignr}${color1}${cpubar cpu3 10,120}
#${color2}CPU4: ${cpu cpu4}%${alignr}${color1}${cpubar cpu4 10,120}
#${color2}CPU5: ${cpu cpu5}%${alignr}${color1}${cpubar cpu5 10,120}
#${color2}CPU6: ${cpu cpu6}%${alignr}${color1}${cpubar cpu6 10,120}
#${color2}CPU7: ${cpu cpu7}%${alignr}${color1}${cpubar cpu5 10,120}
#${color2}CPU8: ${cpu cpu8}%${alignr}${color1}${cpubar cpu6 10,120}

${color2}Mem: ${memperc}% ${alignr}${color1}${membar 10,120}
${alignr}${mem} / ${memmax}
${color2}Swap: ${swapperc}% ${alignr}${color1}${alignr}${swapbar 10,120}
${alignr}${swap} / ${swapmax}
#${color2}Bat: ${battery} ${alignr}${color1}${battery_bar 10,120}
${color1}FILE SYSTEMS ${hr 2}${lua conky_show_mounts}

${color1}NETWORK ${hr 2}${color2}]]

package.path = package.path .. ";" .. CONKYRC_EXTRA_LUA_FILES_LOCATION .. "/show_netdevs.lua"
require 'show_netdevs'
conky.text = conky.text .. conky_show_netdevs() -- thanks to https://unix.stackexchange.com/a/768938/540879!

conky.text = conky.text .. [[

EXT: ${alignr}  ${texeci 3600 wget -O - -q icanhazip.com}
${color1}${voffset 2}${hr 2}
####don't write below this line as used for conky gui weather
#
#
#
]]
