Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pad percentage outputs #8

Open
sdfg2 opened this issue Sep 7, 2018 · 5 comments · May be fixed by #17
Open

Pad percentage outputs #8

sdfg2 opened this issue Sep 7, 2018 · 5 comments · May be fixed by #17

Comments

@sdfg2
Copy link

sdfg2 commented Sep 7, 2018

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
Copy link

+1 that would be nice. Any updates?

yutkat added a commit to yutkat/tmux-plugin-sysstat that referenced this issue Feb 27, 2020
…at_mem_pused_format" and "@sysstat_mem_pfree_format"
@LFd3v
Copy link

LFd3v commented Oct 28, 2023

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_SCRIPTS_DIR 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
Copy link

tuv7041 commented Oct 29, 2023

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
Copy link

LFd3v commented Oct 29, 2023

@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
Copy link

tuv7041 commented Oct 29, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants