-- vim: ts=4 sw=4 noet ai cindent syntax=lua
-- Based on https://github.com/lutzseverino/conky-setup
--[[
Conky, a system monitor, based on torsmo

Any original torsmo code is licensed under the BSD license

All code written since the fork of torsmo is licensed under the GPL

Please see COPYING for details

Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
All rights reserved.

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
]]

conky.config = {

    --Various settings

        background = true,
        cpu_avg_samples = 2,
        diskio_avg_samples = 10,
        double_buffer = true,
        if_up_strictness = 'address',
        net_avg_samples = 2,
        no_buffers = true,
        temperature_unit = 'celsius',
        update_interval = 1,
        imlib_cache_size = 0,
        out_to_console = false,
        out_to_stderr = false,
        extra_newline = false,
        stippled_borders = 0,
        uppercase = false,
        use_spacer = 'none',
		top_name_verbose = false,
		top_name_width = 10,
    
    -- Placement

        xinerama_head = 0, -- This changes the monitor (0 for primary, then check experimentally)
        alignment = 'top_right',
        gap_x = 10,
        gap_y = 45,
        minimum_width = 280,
        maximum_width = 280,
        
    -- Graphical

        border_inner_margin = 10,
        border_outer_margin = 10,
        draw_borders = false,
        draw_graph_borders = false,
        draw_shades = false,
        draw_outline = false,
        show_graph_scale = false,
        show_graph_range = false,
        
    -- Window specifications

        own_window = true,
        own_window_argb_visual = true,
        own_window_transparent = true,
        --own_window_argb_value = 145,
        own_window_type = 'desktop', -- options are: normal/override/dock/desktop/panel
    
    -- Text settings

        font  = 'JetBrains Mono:size=10',   -- the default font used
        font2 = 'Krona One:size=36',        -- font for the time
        font3 = 'ConkySymbols:size=12',     -- font for the symbols
        font4 = 'Barlow:bold:size=12',      -- font for the headings
        format_human_readable = true,
        use_xft = true,
        max_text_width = 0,
        short_units = true,
        xftalpha = 1,
    
    -- Colors
        
        default_color = 'white',
        default_outline_color = 'white',
        default_shade_color = 'white',

        -- Catppuccin Mocha palette    
        -- Sky
        --color1 = '#89DCEB',            -- title color
        -- Lavender
        --color2 = '#B4BEFE',            -- subtitle color
        -- Blue
        --color3 = '#89B4FA',            -- text color
        -- Peach
        --color4 = '#FAB387'             -- accent color
        
        -- Mauve
        color1 = '#CBA6F7',          -- title color
        -- Lavender
        color2 = '#B4BEFE',          -- subtitle color
        -- Blue
        color3 = '#89B4FA',          -- text color
        -- Peach
        color4 = '#FAB387'           -- accent color
        
}

conky.text = [[
${font2}${color1}${alignc}${time %H:%M}${voffset -30}
${color1}${font3}A${font4} SYSTEM ${hr 2}${font}${voffset 5}
${font}${color3}Date: ${alignr}${color}${time %A, %d %B %Y}
${color3}Kernel: ${alignr}${color}${kernel}
${color3}Distro: ${alignr}${color}${execi 36000 lsb_release -d | grep 'Descr'|awk {'print $2 " " $3" " $4"" $5'}}
${color3}Uptime: ${alignr}${color}${uptime}
# Update with your location
#${color3}Weather: ${alignr}${font JetBrains Mono:size=9}${color}${execi 1200 curl wttr.in/Madrid?format=1}${font}
#
#------------+
# TEMPS
#------------+
# uncomment according to gpu/ssd
#${color1}${font3}h${font4} TEMPS ${hr 2}${font}${voffset 5}
#${color}${color3}CPU: $color${execi 5 sensors | grep "temp1" | cut -c 16-19}°C
#${color}${font}${color3}CPU: $color${execi 5 sensors | grep "temp1" | cut -c 16-19}°C${color3}${alignr}GPU: $color${nvidia temp}°C
#${color}${color3}SSD:${color}${execi 5 hddtemp /dev/sda | cut -d ":" -f 3}

#------------+
# CPU
#------------+
${color1}${font3}f${font4} PROCESSOR ${hr 2}${font}${voffset 5}
# Adjust this according to your cpu
${color3}Name: $color$alignr${execi 36000 cat /proc/cpuinfo | grep 'model name' | sed -e 's/model name.*: //'| uniq | cut -c 1-20}
${color3}Freq: $color${freq_g} GHz$alignr${color3}Usage: $color${cpu}%
# ${color4}${cpugraph 25}
#------------+
# CPU CORES
#------------+
# uncomment according to number of cores
${voffset 5}${color3} 1${goto 45}$color${cpu cpu1}%${goto 85}${color4}${cpubar cpu1 13, 60}${goto 170}${color3} 2${goto 195}$color${cpu cpu2}%${goto 235}${color4}${cpubar cpu2 13, 60}
${voffset 2}${color3} 3${goto 45}$color${cpu cpu3}%${goto 85}${color4}${cpubar cpu3 13, 60}${goto 170}${color3} 4${goto 195}$color${cpu cpu4}%${goto 235}${color4}${cpubar cpu4 13, 60}
#${voffset 2}${color3} 5${goto 45}$color${cpu cpu5}%${goto 85}${color4}${cpubar cpu5 13, 60}${goto 170}${color3} 6${goto 195}$color${cpu cpu6}%${goto 235}${color4}${cpubar cpu6 13, 60}
#${voffset 2}${color3} 7${goto 45}$color${cpu cpu7}%${goto 85}${color4}${cpubar cpu7 13, 60}${goto 170}${color3} 8${goto 195}$color${cpu cpu8}%${goto 235}${color4}${cpubar cpu8 13, 60}
#${voffset 2}${color3} 9${goto 45}$color${cpu cpu9}%${goto 85}${color4}${cpubar cpu9 13, 60}${goto 170}${color3}10${goto 195}$color${cpu cpu10}%${goto 235}${color4}${cpubar cpu10 13, 60}
#${voffset 2}${color3}11${goto 45}$color${cpu cpu11}%${goto 85}${color4}${cpubar cpu11 13, 60}${goto 170}${color3}12${goto 195}$color${cpu cpu12}%${goto 235}${color4}${cpubar cpu12 13, 60}
#${voffset 2}${color3}13${goto 45}$color${cpu cpu13}%${goto 85}${color4}${cpubar cpu13 13, 60}${goto 170}${color3}14${goto 195}$color${cpu cpu14}%${goto 235}${color4}${cpubar cpu14 13, 60}
#${voffset 2}${color3}15${goto 45}$color${cpu cpu15}%${goto 85}${color4}${cpubar cpu15 13, 60}${goto 170}${color3}16${goto 195}$color${cpu cpu16}%${goto 235}${color4}${cpubar cpu16 13, 60}
#
#------------+
# GPU
#------------+
# uncomment if have a dedicated GPU - need to modify for AMD
# ${color1}${font3}f${font4} GPU ${hr 2}${font}${voffset 5}
# ${color3}Name: ${color}$alignr${execi 36000 nvidia-smi --query-gpu=gpu_name --format=csv,noheader,nounits}
# ${color3}Driver: ${color}${execi 36000 nvidia-smi --query-gpu=driver_version --format=csv,noheader,nounits}
# ${color3}Freq: ${color}${nvidia gpufreq} GHz$alignr${color3}Usage: $color${exec nvidia-smi -i 0 | grep % | cut -c 71-73}%

#------------+
# MEMORY
#------------+
${color1}${font3}J${font4} MEMORY ${hr 2}${font}${voffset 5}
${color3}Mem used: ${color}${mem} ($memperc%)${color3}${alignr}Free: ${color}${memeasyfree}
${color4}${membar}
${font}${color3}SWAP used: ${color}${swap} ($swapperc%)${color3}${alignr}Free: ${color}${swapfree}
${color4}${swapbar}

#------------+
# PROCESSES
#------------+
${color1}${font3}n${font4} PROCESSES ${hr 2}${font}${voffset 5}
${color3}NAME${goto 145}PID${goto 205}CPU%${goto 260}MEM${color}${font}
${color4}${stippled_hr}${color}
${color3}${top name 1}${color}${font}${goto 125}${top pid 1}${goto 190}${top cpu 1}${goto 255}${top mem_res 1}
${color3}${top name 2}${color}${font}${goto 125}${top pid 2}${goto 190}${top cpu 2}${goto 255}${top mem_res 2}
${color3}${top name 3}${color}${font}${goto 125}${top pid 3}${goto 190}${top cpu 3}${goto 255}${top mem_res 3}
${color3}${top name 4}${color}${font}${goto 125}${top pid 4}${goto 190}${top cpu 4}${goto 255}${top mem_res 4}
${color3}${top name 5}${color}${font}${goto 125}${top pid 5}${goto 190}${top cpu 5}${goto 255}${top mem_res 5}
${voffset 5}${color3}Processes: ${color}${processes}${alignr}${color3}Running:$color ${running_processes}
# ${color3}Threads: ${color}${threads}${alignr}${color3}Running: ${color}${running_threads}

#------------+
# NETWORK
#------------+
# Adjust this according to your network interface
${color1}${font3}b${font4} NETWORK ${hr 2}${font}${voffset 5}
${color3}${addr wlo1}${alignr}${font}${color}${if_existing /sys/class/net/wlo1/operstate up}ONLINE${else}OFFLINE${endif}
${font}${color3}${execi 36000 curl ipinfo.io/ip}${alignr}${font}${color}${if_existing /sys/class/net/wlo1/operstate up}ONLINE${else}OFFLINE${endif}
${font}${color}
${color3}Down: ${color}${downspeed wlo1}/s  ${color3}${alignr} Total: ${color}${totaldown wlo1}
${color4}${downspeedgraph wlo1 20}${color}
${color3}Up: ${color}${upspeed wlo1}/s      ${color3}${alignr} Total: ${color}${totalup wlo1}
${color4}${upspeedgraph wlo1 20}${color}
]]