├── .gitmodules ├── README.md ├── conky.conf ├── conky.desktop ├── demo.gif ├── install ├── launchConky.sh ├── onResolutionChange.sh ├── remove ├── screenshot_full.jpg └── userFunc.lua /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "xeventbind"] 2 | path = xeventbind 3 | url = https://github.com/ajitjadhav28/xeventbind 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # conky-config 2 | Conky configurations for laptop with following features: 3 | - Conky is displayed always on primary monitor (using resolution change events) 4 | - with installation of config and fonts (installation tested on ubuntu 18.04) 5 | - Laptop-Desktop Mode Indicator 6 | - battery indicator with capacity 7 | - CPU, RAM, HDD, Network info 8 | - top 5 cpu hungry processes 9 | - all drives mounted in /media/$user/* are shown (default max 6) 10 | 11 | This is fork of [andrea-rosa/conky-config](https://github.com/andrea-rosa/conky-config) repository. 12 | It is modified according to my needs for Dell Inspiron 5520 laptop. 13 | Thanks to [andrea-rosa](https://github.com/andrea-rosa) for this beautiful configuration and [ritave](https://github.com/ritave/xeventbind) for xeventbind. 14 | 15 | # Install 16 | Make script executable 17 | `sudo chmod +x install` 18 | then install 19 | `./install` 20 | If asked password enter it. It is required to create autostart entry. 21 | #### This script installs conky on ubuntu if not installed. On distroes other than debian-based, conky-all should be installed first. 22 | 23 | #### For Lenovo Legion 15ARH05 (Ryzen 5 + NVIDIA GPU) check branch [lenovo_legion_15ARH05](https://github.com/ajitjadhav28/conky-config/tree/lenovo_legion_15ARH05), tested on Kubuntu 20.04 24 | 25 | # Demo 26 | ![gif](https://github.com/ajitjadhav28/conky-config/blob/master/demo.gif) 27 | ![Screenshot](https://github.com/ajitjadhav28/conky-config/blob/master/screenshot_full.jpg) 28 | 29 | #### **Notes**: 30 | You need to install following fonts 31 | 1. [Font Awesome](https://github.com/FortAwesome/Font-Awesome) 32 | -------------------------------------------------------------------------------- /conky.conf: -------------------------------------------------------------------------------- 1 | conky.config = { 2 | background = true, 3 | lua_load = '~/.config/conky/userFunc.lua', 4 | lua_draw_hook_pre = 'main', 5 | update_interval = 2, 6 | update_interval_on_battery = 5, 7 | cpu_avg_samples = 2, 8 | net_avg_samples = 2, 9 | out_to_console = false, 10 | override_utf8_locale = true, 11 | double_buffer = true, 12 | no_buffers = true, 13 | text_buffer_size = 32768, 14 | imlib_cache_size = 0, 15 | own_window = true, 16 | own_window_type = 'desktop', 17 | own_window_argb_visual = true, 18 | own_window_argb_value = 200, 19 | own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager', 20 | border_inner_margin = 5, 21 | border_outer_margin = 5, 22 | xinerama_head = 2, 23 | alignment = 'top_right', 24 | gap_x = 0, 25 | gap_y = 40, 26 | draw_shades = false, 27 | draw_outline = false, 28 | draw_borders = false, 29 | draw_graph_borders = false, 30 | use_xft = true, 31 | font = 'Ubuntu Mono:size=11', 32 | xftalpha = 0.1, 33 | uppercase = false, 34 | default_color = '#FFFFFF', 35 | own_window_colour = '#000000', 36 | minimum_width = 0, minimum_height = 0, 37 | }; 38 | conky.text = [[ 39 | ${if_match ${laptop_mode} != 0}\ 40 | ${goto 10}${color #AAFF00}${font FontAwesome:size=14}\ 41 | $else\ 42 | ${goto 10}${color #20FF00}${font FontAwesome:size=14}\ 43 | $endif\ 44 | ${font Ubuntu Mono:size=12}${nodename} $machine ${color}${goto 220}${font FontAwesome}${font}${voffset -2} ${time %d/%m/%y} ${font FontAwesome}${font}${voffset -2} ${time %H:%M} 45 | ${goto 10}${voffset 3}${color #FF1A21}Uptime:${goto 100}${color}${uptime}\ 46 | ${goto 220}${color #FF1A21}Thr/Proc: $color$threads/$processes${voffset 0} 47 | ${if_match ${battery_percent BAT1} <= 10}\ 48 | ${goto 10}${color #FF1A21}${blink Battery:} \ 49 | $else \ 50 | ${goto 10}${color #FF1A21}Battery: \ 51 | $endif\ 52 | ${goto 102}${color}${voffset 2}${battery_bar 7,70 BAT1} ${voffset -1}${goto 180}${battery BAT1}${alignr}${battery_time BAT1} 53 | ${goto 10}${color #FF1A21}${lua distribution}${font}${alignr}${color}${kernel} 54 | ${goto 10}${hr} 55 | ${lua_parse drawnetworks 2}\ 56 | ${goto 10}${hr} 57 | ${goto 10}${font FontAwesome}${font} ${color #00FF00}Storage Drives${color} 58 | ${lua_parse mountmedia 6}\ 59 | ${goto 10}${diskiograph_read 20,178 06E9F8 2104FA}${goto 202}${diskiograph_write 20,175 FFFF00 DD3A21} 60 | ${font FontAwesome}${goto 10}${font} ${diskio_read}${font FontAwesome}${goto 202}${font} ${diskio_write} 61 | ${goto 10}${hr} 62 | ${goto 10}${font FontAwesome}${font}${voffset -2}${color #00FF00} ${mem}/${memmax} (${memperc}%) | Swap: ${swapperc}%$color 63 | ${goto 10}${memgraph 30,355 5014e8 ff00ff -t } 64 | ${goto 10}${hr} 65 | ${goto 10}${font FontAwesome} ${font}${color #00FF00}${lua processor}$color 66 | ${lua_parse drawcpus} \ 67 | ${goto 10}${hr} 68 | ${goto 10}${color #FFFF00}CPU ${color}${lua_parse cputemp}°C \ 69 | ${goto 150}${color #FFFF00}FAN ${font FontAwesome}${font} ${color}${lua_parse fanrpm 1} RPM\ 70 | ${goto 300}${color #FFFF00}ACPI ${font FontAwesome} ${font}${color}${acpitemp}°C 71 | ${goto 10}${hr} 72 | ${lua_parse topprocess 5} 73 | ]]; 74 | -------------------------------------------------------------------------------- /conky.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Conky 3 | GenericName=Startup execution of conky 4 | Comment=Run launch script for conky 5 | Exec=~/.config/conky/launchConky.sh 6 | Terminal=false 7 | Type=Application 8 | X-GNOME-Autostart-enabled=true -------------------------------------------------------------------------------- /demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajitjadhav28/conky-config/4b414f81a7ede9f781e954a4e6fdcbc4334de4eb/demo.gif -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # install conky on debian based os with requirements 4 | sudo apt install conky-all git fonts-font-awesome grep libx11-dev gawk lm-sensors smartmontools -y 5 | 6 | CONKY_PATH=~/.config/conky 7 | AUTOSTART="/etc/xdg/autostart" 8 | 9 | # make config folder for user 10 | mkdir -p $CONKY_PATH 11 | 12 | # move necessary files 13 | cp conky.conf $CONKY_PATH 14 | cp launchConky.sh $CONKY_PATH 15 | cp onResolutionChange.sh $CONKY_PATH 16 | cp *.lua $CONKY_PATH 17 | echo "Configurations moved to $CONKY_PATH" 18 | 19 | awk -v home="$HOME" '{ if ($0 ~ /Exec=.*/) {printf("Exec=%s/.config/conky/launchConky.sh\n", home)} else { print $0}}' conky.desktop >> conkyMod.desktop 20 | sudo cp conkyMod.desktop "$AUTOSTART/conky.desktop" 21 | rm conkyMod.desktop 22 | echo "Added autostart entry at $AUTOSTART" 23 | 24 | # make executable 25 | sudo chmod +x "$CONKY_PATH/*.sh" 26 | 27 | # git update submodules 28 | git submodule update --init --recursive 29 | 30 | # compile xeventbind and move to coky 31 | cd xeventbind 32 | make && cp xeventbind $CONKY_PATH 33 | make clean 34 | 35 | # start conky 36 | bash ~/.config/conky/launchConky.sh 37 | echo "Installation complete." 38 | 39 | exit 40 | -------------------------------------------------------------------------------- /launchConky.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Current resolution 4 | CURRENT_WIDTH=$( xrandr | grep -o 'current [0-9]* x [0-9]*'| grep -o '[0-9]*' | head -n1 ) 5 | CURRENT_HEIGHT=$( xrandr | grep -o 'current [0-9]* x [0-9]*'| grep -o '[0-9]*' | head -n2 | tail -n1 ) 6 | 7 | # Get Primary monitor resolution 8 | PRIMARY=$( xrandr | grep -o ' connected primary [0-9]*x[0-9]*+[0-9]*+[0-9]*' | grep -o -P --regexp='(?! connected primary [0-9]*x[0-9]*+)([0-9]*+[0-9]*)' ) 9 | 10 | if [ -n $PRIMARY ]; then 11 | PRIMARY=$( xrandr | grep -o ' connected [0-9]*x[0-9]*+[0-9]*+[0-9]*' | grep -o -P --regexp='(?! connected [0-9]*x[0-9]*+)([0-9]*+[0-9]*)' ) 12 | fi 13 | 14 | PRIMARY_WIDTH=$( echo $PRIMARY | sed --expression="s/ /\n/g" | head -n1 ) 15 | PRIMARY_HEIGHT=$( echo $PRIMARY | sed --expression="s/ /\n/g" | head -n2 | tail -n1 ) 16 | PRIMARY_START_X=$( echo $PRIMARY | sed --expression="s/ /\n/g" | head -n3 | tail -n1 ) 17 | PRIMARY_START_Y=$( echo $PRIMARY | sed --expression="s/ /\n/g" | tail -n1 ) 18 | PRIMARY_END_X=$(( $PRIMARY_START_X+$PRIMARY_WIDTH )) 19 | 20 | #Conky Position on primary monitor 10px plus for inner padding and 40px for ubuntu top bar 21 | CONKY_X=$(( $CURRENT_WIDTH-$PRIMARY_END_X+10 )) 22 | CONKY_Y=$(( $PRIMARY_START_Y+40 )) 23 | 24 | # Get secondary monitor resolution 25 | # SECONDARY_WIDTH=$( xrandr | grep -o ' connected [0-9]*x[0-9]*'| grep -o '[0-9]*x[0-9]*' | grep -o '^[0-9]*' ) 26 | # SECONDARY_HEIGHT=$( xrandr | grep -o ' connected [0-9]*x[0-9]*'| grep -o '[0-9]*x[0-9]*' | grep -o '[0-9]*$' ) 27 | 28 | if [[ $PRIMARY_HEIGHT == $CURRENT_HEIGHT ]]; then 29 | conky -x $CONKY_X -y 0 -a 'middle_right' 30 | else 31 | conky -x $CONKY_X -y $CONKY_Y 32 | fi 33 | 34 | # Start xeventbind and run onResolutionChange.sh on resolution change event 35 | $HOME/.config/conky/xeventbind resolution "$HOME/.config/conky/onResolutionChange.sh" 36 | -------------------------------------------------------------------------------- /onResolutionChange.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | kill $( top -bn1 | grep "conky$" | awk '{print $1}' ) 4 | kill $( top -bn1 | grep "xeventbind$" | awk '{print $1}' ) 5 | 6 | bash ~/.config/conky/launchConky.sh -------------------------------------------------------------------------------- /remove: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Kill processes 4 | kill $( top -bn1 | grep "conky$" | awk '{print $1}' ) 5 | kill $( top -bn1 | grep "xeventbind$" | awk '{print $1}' ) 6 | echo "Killed conky processes." 7 | # remove conky on debian based os 8 | sudo apt remove conky conky-all -y 9 | 10 | CONKY_PATH=~/.config/conky 11 | AUTOSTART="/etc/xdg/autostart" 12 | 13 | # remove conf files 14 | rm "$CONKY_PATH/conky.conf" 15 | rm "$CONKY_PATH/launchConky.sh" 16 | rm "$CONKY_PATH/onResolutionChange.sh" 17 | echo "Configurations removed" 18 | 19 | sudo rm "$AUTOSTART/conky.desktop" 20 | echo "removed autostart entry from $AUTOSTART" 21 | 22 | rm "$CONKY_PATH/xeventbind" 23 | 24 | echo "Uninstallation complete." 25 | 26 | exit 27 | -------------------------------------------------------------------------------- /screenshot_full.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ajitjadhav28/conky-config/4b414f81a7ede9f781e954a4e6fdcbc4334de4eb/screenshot_full.jpg -------------------------------------------------------------------------------- /userFunc.lua: -------------------------------------------------------------------------------- 1 | require 'cairo' 2 | 3 | conky_start = 1 4 | processor = '' 5 | distribution = '' 6 | mounted_media = '' 7 | topprocesses = '' 8 | cpus = -1 9 | ncpu = 0 10 | cpu_temp_file = '' 11 | active_network_interface = false 12 | fan = -1 13 | fan_files = {} 14 | fan_rpms = {} 15 | ctemp = 0 16 | start_flag = 1 17 | cpu_min_freq = {} 18 | cpu_max_freq = {} 19 | 20 | cpu_temp_update_freq = 4 21 | 22 | -- Configs 23 | ENABLE_COLORS = true 24 | COLOR_SHUFFLE = 1 25 | 26 | _COLORS = {"#f1c40f", "#884ea0", "#3498db", "#2ecc71", "#ec7063", "#82e0aa", "#C41CB8", "#EDEA29"} 27 | COLORS = {"#ffffff"} 28 | 29 | _TOP_COLORS = {"#f3d346","#f4bb2f","#f3a422","#f18f1a","#f1721a","#f1441a"} 30 | _TOP_COLORS_SIZE = 6 31 | 32 | RED_START = 0x44 33 | RED_END = 0xff 34 | GREEN_START = 0xFF 35 | GREEN_END = 0x00 36 | 37 | -- Conky main function 38 | function conky_main() 39 | if conky_window == nil then 40 | return 41 | end 42 | local cs = cairo_xlib_surface_create(conky_window.display, 43 | conky_window.drawable, 44 | conky_window.visual, 45 | conky_window.width, 46 | conky_window.height) 47 | cr = cairo_create(cs) 48 | 49 | cairo_destroy(cr) 50 | cairo_surface_destroy(cs) 51 | cr=nil 52 | if start_flag == 1 then 53 | local file = io.popen("lscpu -a -p='cpu' | tail -n 1") 54 | ncpu = trim(file:read("*a")) 55 | file:close() 56 | if COLOR_SHUFFLE and ENABLE_COLORS then 57 | COLORS = shuffle(_COLORS) 58 | end 59 | start_flag = 0 60 | end 61 | end 62 | 63 | -- Returns processor name 64 | function conky_processor() 65 | if processor == '' then 66 | local file = io.popen("lscpu | grep -Po '(?<=Model name:)(.*)'") 67 | processor = trim(file:read("*a")) 68 | file:close() 69 | end 70 | 71 | return processor 72 | end 73 | 74 | -- Returns distribution name 75 | function conky_distribution() 76 | if distribution == '' then 77 | local file = io.popen('cat /etc/lsb-release | grep -Po --regexp "(?<=DISTRIB_ID=).*$"') 78 | distribution = trim(file:read("*a")) 79 | file = io.popen('cat /etc/lsb-release | grep -Po --regexp "(?<=DISTRIB_RELEASE=).*$"') 80 | distribution = distribution .. " " .. trim(file:read("*a")) 81 | file:close() 82 | end 83 | 84 | return distribution 85 | end 86 | 87 | -- Draws max n mounted partitions and its stats 88 | function conky_mountmedia(n) 89 | if tonumber(conky_parse("$updates")) % 4 == 0 then 90 | local file = io.popen('lsblk | grep -oE ".*sd.* part /.*" | grep -oE "(/.*)"') 91 | local count = 1 92 | local media = '' 93 | for line in file:lines() do 94 | local short_name = string.sub(string.sub(trim(line), string.find(trim(line), '/[^/]*$')), 1) 95 | if count <= tonumber(n) then 96 | media = media 97 | .. "${goto 10}" .. "${color ".. COLORS[(count % table.getn(COLORS))+1] .."}" .. short_name .. "${goto 150}${fs_bar 7,70 " .. trim(line) 98 | .. "}${goto 255}${fs_used " .. trim(line) .. "}/${fs_size " .. trim(line) .. "}" .. "$color" 99 | .. "\n" 100 | else 101 | break 102 | end 103 | count = count + 1 104 | end 105 | file:close() 106 | mounted_media = media 107 | return media 108 | end 109 | return mounted_media 110 | end 111 | 112 | -- Draws all cpu cores stats 113 | function conky_drawcpus() 114 | if cpus == -1 or tonumber(conky_parse("$updates")) % 2 == 0 then 115 | -- local file = io.popen("lscpu -a -p='cpu' | tail -n 1") 116 | -- local ncpu = trim(file:read("*a")) 117 | -- file:close() 118 | local conky_cpus = '' 119 | for c = 1, tonumber(ncpu) do 120 | if c % 2 ~= 0 then 121 | conky_cpus = conky_cpus 122 | .. "${goto 20}${color ".. (ENABLE_COLORS and get_color_freq_cpu(c-1) or "#FFFFFF").."}" .. c ..": ${goto 42}${cpu cpu".. c 123 | .."}%${goto 90}${cpubar 7,30 cpu".. c 124 | .."}${goto 130}${freq_g ".. c 125 | .."}GHz${goto 200}${color ".. (ENABLE_COLORS and get_color_freq_cpu(c) or "#FFFFFF") .."}| ".. c+1 126 | ..":${goto 240}${cpu cpu".. c+1 127 | .."}%${goto 285}${cpubar 7,30 cpu".. c+1 .."}${goto 325}${freq_g ".. c+1 .."}GHz" 128 | .. "${color}\n" 129 | end 130 | end 131 | cpus = conky_cpus 132 | return conky_cpus 133 | end 134 | return cpus 135 | end 136 | 137 | -- Draws max n network interfaces 138 | function conky_drawnetworks(n) 139 | local active_ifaces = {} 140 | if active_network_interface == false or tonumber(conky_parse("$updates")) % 2 == 0 then 141 | local ifaces = io.popen('ip link | grep -Po --regexp "(?<=[0-9]: ).*"') 142 | for line in ifaces:lines() do 143 | if string.find(line, "= 1 then 150 | local draw_other_ifaces = '${goto 10}${font FontAwesome}${font} ${color #00FF00}Network Interfaces $color \n' 151 | for i, iface in pairs(active_ifaces) do 152 | if i <= tonumber(n) then 153 | draw_other_ifaces = draw_other_ifaces 154 | .. "${goto 20}".. "${color ".. COLORS[(i % table.getn(COLORS)) + 1] .."}" .. i ..". " 155 | .. iface .." ".. "${font FontAwesome} ${font}${voffset 0} ${addrs " .. iface .. "}${color}" .. "\n" 156 | .. "${goto 20}${upspeedgraph " .. iface .. " 20,175 00ffff 00ff00}${goto 202}${downspeedgraph " 157 | .. iface .. " 20,175 FFFF00 DD3A21}" .. "\n" 158 | .. "${font FontAwesome}${goto 50}${font} ${upspeed " 159 | .. iface .. "}${font FontAwesome}${goto 250}${font} ${downspeed " .. iface .. "}" .. "\n" 160 | if i < table.maxn( active_ifaces ) and i ~= tonumber(n) then 161 | draw_other_ifaces = draw_other_ifaces .. "${goto 20}${stippled_hr 1}\n" 162 | end 163 | end 164 | end 165 | active_network_interface = draw_other_ifaces 166 | return active_network_interface 167 | else 168 | active_network_interface = '${goto 10}${font FontAwesome}${font} ${color #00FF00}Network Interfaces $color \n${goto 50} Device not connected.\n' 169 | end 170 | end 171 | return active_network_interface 172 | end 173 | 174 | -- Returns CPU temperature in Celsius 175 | function conky_cputemp() 176 | if tonumber(conky_parse("$updates")) % cpu_temp_update_freq == 0 or ctemp == 0 then 177 | -- Get find cpu temp file on first call 178 | if ctemp == 0 then 179 | local all_hwmon_temp_names = io.popen('ls /sys/class/hwmon/*/temp* | grep -Po --regexp ".*(label)$"') 180 | for l in all_hwmon_temp_names:lines() do 181 | local name = io.popen('cat ' .. l):read("*a") 182 | if name:match("^Package*") then 183 | cpu_temp_file = l:gsub("label", "input") 184 | break 185 | end 186 | end 187 | all_hwmon_temp_names:close() 188 | end 189 | cpu_temp_file_handle = io.open(cpu_temp_file, "r") 190 | ctemp = tonumber(cpu_temp_file_handle:read("*a")) / 1000 191 | cpu_temp_file_handle:close() 192 | end 193 | if ctemp > 75 then 194 | cpu_temp_update_freq = 2 195 | return "${color #ff0000}${font FontAwesome} ${font}${blink " .. ctemp .. "}${color}" 196 | elseif ctemp > 50 then 197 | cpu_temp_update_freq = 4 198 | else 199 | cpu_temp_update_freq = 6 200 | end 201 | return "${font FontAwesome} ${font}" .. ctemp 202 | end 203 | 204 | -- Returns Nth fan's speed in RPM 205 | function conky_fanrpm(n) 206 | if tonumber(conky_parse("$updates")) % 4 == 0 or fan == -1 then 207 | if fan == -1 or fan_files[n] == nil then 208 | local all_hwmon_fans = io.popen('ls /sys/class/hwmon/*/fan?_input') 209 | for l in all_hwmon_fans:lines() do 210 | if l:match('fan' .. n .. '_input') then 211 | fan_files[n] = l 212 | end 213 | end 214 | all_hwmon_fans:close() 215 | end 216 | local fan_file = io.open(fan_files[n], 'r') 217 | fan_rpms[n] = tonumber(fan_file:read('*a')) 218 | fan = 1 219 | fan_file:close() 220 | return fan_rpms[n] 221 | end 222 | return fan_rpms[n] 223 | end 224 | 225 | function get_color_freq_cpu(n) 226 | local min, max, cur, mid, mapped_color 227 | if cpu_min_freq[n+1] == nil then 228 | min = get_cpu_min_freq(n) 229 | if min == nil then 230 | min = 1200000 231 | end 232 | cpu_min_freq[n+1] = min 233 | else 234 | min = cpu_min_freq[n+1] 235 | end 236 | 237 | if cpu_max_freq[n+1] == nil then 238 | max = get_cpu_max_freq(n) 239 | if max == nil then 240 | max = 3000000 241 | end 242 | cpu_max_freq[n+1] = max 243 | else 244 | max = cpu_max_freq[n+1] 245 | end 246 | mid = math.floor(min+max/2) 247 | cur = get_cpu_freq(n) 248 | if cur == nil then 249 | cur = 2000000 250 | end 251 | if cur <= mid then 252 | red = map(cur, min, mid, RED_START, RED_END) 253 | mapped_color = string.format( "#%02xff00", red) 254 | else 255 | green = map(cur, mid, max, GREEN_START, GREEN_END) 256 | mapped_color = string.format( "#ff%02x00", green) 257 | end 258 | 259 | return mapped_color 260 | end 261 | 262 | function get_cpu_freq(cpu) 263 | local path = '/sys/devices/system/cpu/cpu' .. cpu .. '/cpufreq/scaling_cur_freq' 264 | local cpu_freq = io.open( path, 'r' ) 265 | local freq = tonumber(cpu_freq:read('*a')) 266 | return freq 267 | end 268 | 269 | function get_cpu_max_freq(cpu) 270 | local path = '/sys/devices/system/cpu/cpu' .. cpu .. '/cpufreq/cpuinfo_max_freq' 271 | local cpu_freq = io.open( path, 'r' ) 272 | local freq = tonumber(cpu_freq:read('*a')) 273 | return freq 274 | end 275 | 276 | function get_cpu_min_freq(cpu) 277 | local path = "/sys/devices/system/cpu/cpu" .. cpu .. "/cpufreq/cpuinfo_min_freq" 278 | local cpu_freq = io.open( path, 'r' ) 279 | local freq = tonumber(cpu_freq:read('*a')) 280 | return freq 281 | end 282 | 283 | function conky_topprocess(n) 284 | local p 285 | col = "${color #ffffff}" 286 | if topprocesses == '' then 287 | topprocesses = topprocesses .. "${color #00FF00}${goto 10}Name ${goto 190}Pid${goto 255}Cpu%${goto 310}Mem%${color}\n" 288 | for p = 1, tonumber(n) do 289 | if ENABLE_COLORS then 290 | col = "${color " .. _TOP_COLORS[(_TOP_COLORS_SIZE + 1) - p] .. "}" 291 | end 292 | topprocesses = topprocesses 293 | .. col .. "${goto 10}${top name ".. p .. "} ${goto 180}${top pid ".. p .. "}${goto 235}${top cpu ".. p 294 | .. "}${goto 290}${top mem ".. p .. "}${color}\n" 295 | end 296 | end 297 | return topprocesses 298 | end 299 | 300 | 301 | function map(x, in_min, in_max, out_min, out_max) 302 | return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min 303 | end 304 | 305 | -- Trims given string and returns 306 | function trim(s) 307 | return s:gsub("^%s+", ""):gsub("%s+$", "") 308 | end 309 | 310 | -- shuffle function 311 | function shuffle(tbl) 312 | for i = #tbl, 2, -1 do 313 | local j = math.random(i) 314 | tbl[i], tbl[j] = tbl[j], tbl[i] 315 | end 316 | return tbl 317 | end 318 | --------------------------------------------------------------------------------