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

feat: add option to show disk usage of multiple disks #329

Merged
merged 6 commits into from
Oct 4, 2024

Conversation

Rolv-Apneseth
Copy link
Contributor

In relation to #286

After rebasing the 8.0.0 branch over on libmacchina (see Macchina-CLI/libmacchina#179), and cherry-picking an old commit I had where I achieved the disks functionality, it all seems to still work. Let me know what you think.

Note that the Cargo.toml and Cargo.lock changes aren't included since 8.0.0 isn't live, and I just pointed libmacchina to a local path for development.

@Rolv-Apneseth
Copy link
Contributor Author

Just when you get the chance to update libmacchina and review this, would you also be interested in some other stuff I worked on in my own fork, such as options for shorter CPU and GPU names? @grtcdr

@grtcdr
Copy link
Member

grtcdr commented Sep 28, 2024

Thanks for working on this, Rolv.

I merged the 8.0.0 rebase branch over in libmacchina.

Note that the Cargo.toml and Cargo.lock changes aren't included since 8.0.0 isn't live, and I just pointed libmacchina to a local path for development.

master branch is a moving target so feel free to change the two files.

@grtcdr
Copy link
Member

grtcdr commented Sep 28, 2024

Just when you get the chance to update libmacchina and review this, would you also be interested in some other stuff I worked on in my own fork, such as options for shorter CPU and GPU names? @grtcdr

Sure, I'd love to take a look :)

@Rolv-Apneseth
Copy link
Contributor Author

master branch is a moving target so feel free to change the two files.

Alright I have updated the files - though until libmacchna v8 is released the tests won't pass. Would you like me to bump the version of macchina itself? Also maybe a changelog entry, or do you prefer to do those yourself?

Sure, I'd love to take a look :)

Great, I'll have a look at making some PRs after this one is finished then

@grtcdr
Copy link
Member

grtcdr commented Sep 29, 2024

Would you like me to bump the version of macchina itself? Also maybe a changelog entry, or do you prefer to do those yourself?

All that would be great.

Thanks for all the help :)

@Rolv-Apneseth
Copy link
Contributor Author

Made some minor changes there but how do you run scdoc again? I did scdoc < macchina.1.scd > macchina.1 and it made a lot more changes than I intended.

@grtcdr
Copy link
Member

grtcdr commented Sep 29, 2024

That's alright. I ran the same command on my machine and it generated identical changes, for example: .P -> .PP. scdoc must have changed its output in recent versions.

@Rolv-Apneseth
Copy link
Contributor Author

Alright cool

Cargo.toml Outdated Show resolved Hide resolved
@grtcdr
Copy link
Member

grtcdr commented Oct 4, 2024

The readout's accuracy has definitely improved but there is still a discrepancy between the results of macchina, df and those of lsblk, here's an example:

~/projects/macchina $ grep disk ~/.config/macchina/macchina.toml
disks=["/"]

~/projects/macchina $ cargo run
                                 
  Disk Space   96.4 GB / 337.1 GB       

~/projects/macchina $ lsblk         
NAME          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
nvme0n1       259:0    0 953.9G  0 disk  
├─nvme0n1p1   259:1    0   512M  0 part  /boot
└─nvme0n1p2   259:2    0 953.4G  0 part  
  ├─lvm-root  254:0    0   320G  0 lvm   /gnu/store
  │                                      /
  ├─lvm-swap  254:1    0     8G  0 lvm   [SWAP]
  ├─lvm-state 254:2    0    12G  0 lvm   [SWAP]
  └─lvm-home  254:3    0   480G  0 lvm   
    └─home    254:4    0   480G  0 crypt /home

~/projects/macchina $ df / -h                             
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/lvm-root  314G   75G  225G  26% /

df returns the filesystem size as 314G, lsblk is listing the logical volume's size as 320G and macchina is the outlier in that it returns 337.1G.

@Rolv-Apneseth
Copy link
Contributor Author

I didn't touch how the disk space readout is calculated on this one - but did you use df -H? It's pretty spot on for me

@grtcdr
Copy link
Member

grtcdr commented Oct 4, 2024

Totally forgot we were doing powers of 1000!

Yeah, the results are accurate now :)

We should mention in the man page this gotcha/detail to avoid any confusion as to the nature of the result.

@Rolv-Apneseth
Copy link
Contributor Author

All good. Powers of 10 are the standard as far as I know, just some old stuff still uses power of 2 when the units for power of 2 should be KiB, MiB etc.

@grtcdr
Copy link
Member

grtcdr commented Oct 4, 2024

Alright, well this looks good to me :)

Thanks a lot for the terrific work!

@grtcdr grtcdr merged commit 7372f7f into Macchina-CLI:main Oct 4, 2024
13 checks passed
@Rolv-Apneseth Rolv-Apneseth deleted the multiple-disks branch October 4, 2024 12:10
@Rolv-Apneseth
Copy link
Contributor Author

No problem!

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

Successfully merging this pull request may close these issues.

2 participants