I can't figure this out, so i hope you guys can give me a hand here. So, i was trying to figure a way to show the TLP status on my conky. In the terminal you would type: tlp-stat -s

However....that's too much info, i just want the current status part. The way i tried to do it in conky, is like this:

${exec tlp-stat -s |grep 'battery\|AC'}

now, this works perfectly, when i plug/unplugg the charger, it changes accordingly, but.. the lines are not properly aligned!

conky screenshot

See? How is it possible to align this to match the rest of my theme? thanks in advance here's the config:

conky.config = {

--Various settings

background = true, -- forked to background cpu_avg_samples = 2, -- The number of samples to average for CPU monitoring. diskio_avg_samples = 10, -- The number of samples to average for disk I/O monitoring. double_buffer = true, -- Use the Xdbe extension? (eliminates flicker) if_up_strictness = 'address', -- how strict if testing interface is up - up, link or address net_avg_samples = 2, -- The number of samples to average for net data no_buffers = true, -- Subtract (file system) buffers from used memory? temperature_unit = 'celsius', -- fahrenheit or celsius text_buffer_size = 2048, -- size of buffer for display of content of large variables - default 256 update_interval = 1, -- update interval imlib_cache_size = 0, -- disable image cache to get a new spotify cover per song


alignment = 'top_right', -- top_left,top_middle,top_right,bottom_left,bottom_middle,bottom_right, -- middle_left,middle_middle,middle_right,none --Arch Duoscreen --gap_x = -1910, gap_x = 15, -- pixels between right or left border gap_y = 15, -- pixels between bottom or left border minimum_height = 600, -- minimum height of window minimum_width = 300, -- minimum height of window maximum_width = 300, -- maximum height of window


border_inner_margin = 10, -- margin between border and text border_outer_margin = 5, -- margin between border and edge of window border_width = 0, -- border width in pixels default_bar_width = 80, -- default is 0 - full width default_bar_height = 10, -- default is 6 default_gauge_height = 25, -- default is 25 default_gauge_width =40, -- default is 40 default_graph_height = 40, -- default is 25 default_graph_width = 0, -- default is 0 - full width default_shade_color = '#000000', -- default shading colour default_outline_color = '#000000', -- default outline colour draw_borders = false, -- draw borders around text draw_graph_borders = true, -- draw borders around graphs draw_shades = false, -- draw shades draw_outline = false, -- draw outline stippled_borders = 0, -- dashing the border


extra_newline = false, -- extra newline at the end - for asesome's wiboxes format_human_readable = true, -- KiB, MiB rather then number of bytes font = 'Roboto Mono:size=10', -- font for complete conky unless in code defined max_text_width = 0, -- 0 will make sure line does not get broken if width too smal max_user_text = 16384, -- max text in conky default 16384 override_utf8_locale = true, -- force UTF8 requires xft short_units = true, -- shorten units from KiB to k top_name_width = 21, -- width for $top name value default 15 top_name_verbose = false, -- If true, top name shows the full command line of each process - Default value is false. uppercase = false, -- uppercase or not use_spacer = 'none', -- adds spaces around certain objects to align - default none use_xft = true, -- xft font - anti-aliased font xftalpha = 1, -- alpha of the xft font - between 0-1


own_window = true, -- create your own window to draw own_window_argb_value = 0, -- real transparency - composite manager required 0-255 own_window_argb_visual = true, -- use ARGB - composite manager required own_window_colour = '#000000', -- set colour if own_window_transparent no own_window_hints = 'undecorated,below,sticky,skip_taskbar,skip_pager', -- if own_window true - just hints - own_window_type sets it own_window_transparent = false, -- if own_window_argb_visual is true sets background opacity 0% own_window_title = 'system_conky', -- set the name manually - default conky "hostname" own_window_type = 'desktop', -- if own_window true options are: normal/override/dock/desktop/panel


default_color = '#CB9D7A', -- default color and border color color1 = '#FF0000', color2 = '#C17D12', color3 = '#cccccc', color4 = '#D9BC83', color5 = '#BF4E0C', color6 = '#FFFFFF',

--Signal Colours color7 = '#1F7411', --green color8 = '#FFA726', --orange color9 = '#F1544B', --firebrick



conky.text = [[

${color5}${font Roboto:size=10}${voffset 10}S Y S T E M ${hr 2}${font}${color} ${color2}${voffset 8}Hostname:${color} ${alignr}${nodename} ${color2}Distro:${color}${alignr}${alignr}${execi 999999 lsb_release -ds} ${color2}Kernel:${color}${alignr}${exec uname} ${exec uname -r} ${color2}Nvidia Driver: ${color}${alignr}${execi 60000 nvidia-smi | grep "Driver Version"| awk {'print $3'}} ${color2}Uptime:${color} ${alignr}${uptime}

${color5}${font Roboto:size=10}T E M P E R A T U R E S ${hr 2}${font}${color} ${color2}CPU Temp:${color} $alignr${execi 10 sensors | grep 'Core 0' | awk {'print $3'}} ${color2}GPU Temp ${color} ${alignr}${execi 60 nvidia-smi --query-gpu=temperature.gpu --format=csv,noheader} °C

${color5}${font Roboto:size=10}P R O C E S S O R S ${hr 2}${font}${color} ${color2}CPU Freq:${color} $alignr${freq}MHz

${color2}${offset 20}CPU Core 1:${color} ${alignr}${offset -10}${cpu cpu1}%${alignr}${cpubar cpu1} ${color2}${offset 20}CPU Core 2:${color} ${alignr}${offset -10}${cpu cpu2}%${alignr}${cpubar cpu2} ${color2}${offset 20}CPU Core 3:${color} ${alignr}${offset -10}${cpu cpu3}%${alignr}${cpubar cpu3} ${color2}${offset 20}CPU Core 4:${color} ${alignr}${offset -10}${cpu cpu4}%${alignr}${cpubar cpu4} ${color2}${offset 20}CPU Core 5:${color} ${alignr}${offset -10}${cpu cpu5}%${alignr}${cpubar cpu5} ${color2}${offset 20}CPU Core 6:${color} ${alignr}${offset -10}${cpu cpu6}%${alignr}${cpubar cpu6} ${color2}${offset 20}CPU Core 7:${color} ${alignr}${offset -10}${cpu cpu7}%${alignr}${cpubar cpu7} ${color2}${offset 20}CPU Core 8:${color} ${alignr}${offset -10}${cpu cpu8}%${alignr}${cpubar cpu8} ${color2}${offset 20}CPU Core 9:${color} ${alignr}${offset -10}${cpu cpu9}%${alignr}${cpubar cpu9} ${color2}${offset 20}CPU Core 10:${color} ${alignr}${offset -10}${cpu cpu10}%${alignr}${cpubar cpu10} ${color2}${offset 20}CPU Core 11:${color} ${alignr}${offset -10}${cpu cpu11}%${alignr}${cpubar cpu11} ${color2}${offset 20}CPU Core 12:${color} ${alignr}${offset -10}${cpu cpu12}%${alignr}${cpubar cpu12}

${color2}${offset 20}CPU Total:${color} ${alignr}${offset -10}${cpu cpu0}%${alignr}${cpubar cpu0}

${color5}${offset 20}Governor:${color} ${alignr}${offset -10}${execi 5 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor}

${color2}Top Processes${goto 222}CPU%${goto 274} ${voffset 4}
${color2} 1 - ${top name 1}${alignr}${goto 170} ${goto 222}${color}${top cpu 1} ${color2} 2 - ${top name 2}${alignr} ${goto 222}${color}${top cpu 2} ${goto 274} ${color2} 3 - ${top name 3}${alignr} ${goto 222}${color}${top cpu 3} ${goto 274}
${color2} 4 - ${top name 4}${alignr} ${goto 222}${color}${top cpu 4} ${goto 274} ${color2} 5 - ${top name 5}${alignr} ${goto 222}${color}${top cpu 5} ${goto 274}

${color5}${font Roboto:size=10}D R I V E S ${hr 2}${font}${color} ${offset 30}${color2}SSD:${color} ${alignr}${offset -10}${fs_used /} / ${fs_size /}${alignr}${fs_used_perc /} % ${offset 30}${color2}HDD:${color} ${alignr}${offset -10}${fs_used /home} / ${fs_size /home}${alignr}${fs_used_perc /home} %

${color5}${color5}${font Roboto:size=10}N E T W O R K ${hr 2}${font}${color} ${color2}${offset 30}IP Address: ${color} ${alignr}${offset -10$}${addrs wlo1}

${color5}${color5}${font Roboto:size=10}B A T T E R Y ${hr 2}${font}${color} ${color2}${offset 30}Time Left: ${color} ${alignr}${offset -10$}${battery_time BAT0} ${color2}${offset 30}State: ${color} ${alignr}${offset -10$}$Battery

${color5}${color5}${font Roboto:size=10}T L P ${hr 2}${font}${color} ${color2}${offset 30}Status:${color} ${alignr}${offset -10}${exec tlp-stat -s |grep 'battery\|AC'}


2 Answers 2


There are probably numerous ways to achieve what you want but personally I use sed and awk for this sort of string manipulation. (These are not conky tools).

So say the output you expect is Power source = AC then the actual item you are interested in is the fourth value (space separated values) so an awk command to return only the fourth value would be:

tlp-stat -s |grep 'battery\|AC' |awk '{print $4}'

So you can use that form to output what you need along with conky alignment commands such as {alignr 80} or whatever you need to align text/values etc.

sed and awk are powerful string scanning/manipulation tools - have a look at the man pages and do online searches for what's possible.


Thanks a lot! Solved like this:

${color2}Mode:${color} ${exec tlp-stat -s |grep 'Mode' |awk '{print $3}' } ${color2}Power Source:${color} ${exec tlp-stat -s |grep 'source' |awk '{print $4}' }

Here is the final result!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .