samoshkin / tmux-plugin-sysstat

Prints CPU usage, memory & swap, load average, net I/O metrics in Tmux status bar
MIT License
158 stars 48 forks source link

Pad percentage outputs #8

Open sdfg2 opened 6 years ago

sdfg2 commented 6 years ago

This is just a quick one - I love this wee plugin!

How would I go about padding the CPU and MEM % outputs? I'd like them to always take up the same amount of space.

madnight commented 5 years ago

+1 that would be nice. Any updates?

LFd3v commented 1 year ago

This should fix the problem (more or less like #17, but applied manually after the installation):

SYSSTAT_SCRIPTS_DIR="$HOME"/.tmux/plugins/tmux-plugin-sysstat/scripts
cd "$SYSSTAT_SCRIPTS_DIR"
sed -i 's/%.[01]f%%/%2.0f%%/g' {cpu,mem,swap}.sh

_SYSSTAT_SCRIPTSDIR is where the files cpu.sh, mem.sh and swap.sh are located, it is usually:

~/.tmux/plugins/tmux-plugin-sysstat/scripts

or

~/.config/tmux/plugins/tmux-plugin-sysstat/scripts

Cheers

tuv7041 commented 1 year ago

Thanks for taking a look. I tried it out and it works. The only downside that I see for this fix is that if CPU usage is low (less than 10%) the script is still reserving a 2 character space even if you remove the floating point, so you end up with Original: "CPU: 5.5%" Modified: "CPU: 5%" (Ideally I think it should be "CPU: 5%", without the extra space) But it's a really particular use case.

LFd3v commented 1 year ago

@tuv7041 Actually the padding is intentional (as requested in this issue): the CPU usage percentage value varies from X to XX, it causes the status widget to change the width a lot ("CPU" moves its position in the status bar from time to time when this happens), what I think is very distracting. The padding avoids this.

Cheers

tuv7041 commented 1 year ago

oh, sorry, my bad. I commented here a long time ago and forgot about the context (I was more focused on the decimal than the padding). Thanks again for fixing it.