btop icon indicating copy to clipboard operation
btop copied to clipboard

[REQUEST] Bring btop to windows? (Yes. In development)

Open m1karii opened this issue 2 years ago • 9 comments

TL;DR btop has nice UI and there isnt really any CLI resource monitor for windows

m1karii avatar Mar 16 '22 19:03 m1karii

@m1karii While I wouldn't mind having btop on Windows since I have the misfortune of managing multiple Windows servers in my work, ~it's unlikely to happen soon if ever~.

Porting btop to a non POSIX operating system would require rewriting a lot of things from scratch, not only the system info collection code but things like threading, input and output.

If I at some point got a week free and are bored, I might give it a go ;) But if it ever happens it would likely be it's own project aimed only at Windows with a suitable silly name like bTop4Win++ or something...

aristocratos avatar Mar 24 '22 19:03 aristocratos

@aristocratos you might be able to use b*top on WSL, that would eliminate the requirement of complete rewrite.

zampierilucas avatar Mar 31 '22 14:03 zampierilucas

@zampierilucas @m1karii Turns out input, output and threading was the easy part. The tricky part is navigating all the different windows functions and API's for collecting system information, there seem to be at least 3 functions for everything that does almost all you want it to do, but you're forced to mix them all to get the desired information...

But I've got it running :) Key/mouse input, output/drawing and threading all working great. Cpu and memory stats are done, but a lot of stuff to do/fix/cleanup still...

image

aristocratos avatar Mar 31 '22 16:03 aristocratos

So it's coming along...

All collection is done + a separate view for Windows services and GPU stats for nvidia cards :) Need to fix killing programs and stopping/starting services, temperature sensors and some small stuff and it should be done, but currently in the middle of a move while also dealing with a death in my family so will be a little while before I have time to finish it up.

image

aristocratos avatar Apr 22 '22 21:04 aristocratos

@aristocratos Well damn, that looks really good. I tried it in WSL yesterday, but wouldn't give me a lot of useful details.

Do you have a working prototype we can try? What you posted in that screenshot looks really, really good.

mortenmoulder avatar Jun 02 '22 08:06 mortenmoulder

it would likely be it's own project aimed only at Windows

You do realize I brought this up before due to C++ being a platform agnostic language. Why should you need a separate project? Better coding practice would be to make the project portable for even Windows. There are plenty of projects that offer support for all major platforms. Take the terminal Contour for example, it's able to build and run on all 3 major OS and as a terminal utility, this project should be able to support terminals like Contour without need for a separate project. It's understandable if you're not familiar enough with C++ to write it in a portable way that even Windows can use and use IF statements for Windows specific API calls, you surely are doing something similar for Mac. I certainly don't have such familiarity but knowing it has been done and is pretty common should provide the motivation. It would of been easier if you had done this from the start but you will just need to do some refactoring so that you aren't relying as much on OS specific functionalities, which is always sub-optimal.

WSLUser avatar Jun 17 '22 16:06 WSLUser

@WSLUser You are making a lot of statements with what seems to be a very uninformed understanding of what this project is, the codebase, C++ and frankly what's happening in this thread.

You do realize I brought this up before due to C++ being a platform agnostic language. Why should you need a separate project? Better coding practice would be to make the project portable for even Windows.

Btop++ was written with the aim of supporting linux, macos and freebsd, all posix compatible operating systems. Windows is not a posix compatible operating system which means alot of code needed to be changed.

I do question your judgement as arbiter of "Better coding practice", since you don't seem to have a that much C++ experience or understanding of the btop++ code.

There are plenty of projects that offer support for all major platforms. Take the terminal Contour for example, it's able to build and run on all 3 major OS and as a terminal utility, this project should be able to support terminals like Contour without need for a separate project.

Because plenty of projects support "all major platforms", every other project should too? I'm really confused by your mental leaps:

  1. Contour runs on multiple platforms
  2. Contour is a terminal emulator
  3. Btop++ runs in a terminal
  4. Therefore btop++ should run on all platforms Contour does?

I question the sanity of this logic.

It's understandable if you're not familiar enough with C++ to write it in a portable way that even Windows can use and use IF statements for Windows specific API calls, you surely are doing something similar for Mac. I certainly don't have such familiarity but knowing it has been done and is pretty common should provide the motivation.

There are some subtle clues in this thread, like my post above that proclaims that btop4win is almost done + the screenshots, that should in fact make it clear that btop4win (that would be the btop++ version for Windows) is almost done...

It would of been easier if you had done this from the start [...]

Writing alternate windows code for all posix centered code at the start would have been the same amount of work as doing it now, but instead of bloating the codebase with windows stuff, I'm writing it in it's own project to make it possible to just open the solution in Visual Studio and easily have all Windows dependencies available and directly compile it with msvc.

[...] but you will just need to do some refactoring so that you aren't relying as much on OS specific functionalities, which is always sub-optimal.

Sir, this is a system monitoring program. It should not be a shock that there is no generic functions for getting cpu percentages, disk usage, memory usage, temperatures, etc... And because Windows isn't posix compatible, the posix functions for terminal i/o (and others) that works on linux, macos and freebsd don't work on Windows.

Honestly, I'm not quite sure what the aim with your post is?

Regardless, btop4win will be released when I've got time and energy to pick it up again, probably within a month or so.

aristocratos avatar Jun 17 '22 19:06 aristocratos

The absolute entitlement of the poster above. It gets better each sentence 😄 my favorite part is

you will just need to do some refactoring so that

I am sure if @aristocratos ever feels unmotivated to work on btop in his free time for others to use for free knowing

it has been done and is pretty common should provide the motivation

will provide enough motivation to carry on doing so.

btw @aristocratos its easier to remember the dumb comments rather than positive/constructive ones personally I installed btop along with buch of other cli tools to try not thinking much of it and it was one of the few that I haven't uninstalled shortly after and its usually one of the first things I install on new systems its fantastic, little things like vim navigation support and so on 🙏

kolpav avatar Jun 21 '22 11:06 kolpav

I second @kolpav - btop is an awesome tool @aristocratos, clearly made with love and attention to detail! A grateful user of both bpytop and btop on WSL and Mac here 😀

andrey-zotov avatar Jun 21 '22 11:06 andrey-zotov

@m1karii @andrey-zotov @kolpav @mortenmoulder First release of btop4win available at https://github.com/aristocratos/btop4win :)

aristocratos avatar Aug 28 '22 18:08 aristocratos

Oh nice, you're the man @aristocratos ! BTW OpenHardwareMonitor hasn't been maintaned recently, LibreHardwareMonitor is the maintained fork.

andrey-zotov avatar Aug 28 '22 21:08 andrey-zotov

@andrey-zotov

BTW OpenHardwareMonitor hasn't been maintaned recently, LibreHardwareMonitor is the maintained fork.

Oh, good to know. Will likely rewrite based on LibreHardwareMonitor and try to add an intermediary dll that btop4win can directly import from, to get away from how I currently have implemented it.

aristocratos avatar Aug 28 '22 21:08 aristocratos

@andrey-zotov

BTW OpenHardwareMonitor hasn't been maintaned recently, LibreHardwareMonitor is the maintained fork.

Oh, good to know. Will likely rewrite based on LibreHardwareMonitor and try to add an intermediary dll that btop4win can directly import from, to get away from how I currently have implemented it.

LHM has a built-in webserver which serves JSON with sensors data - it might be easier to pull values from it rather than integrating via dll (which I think not just a user mode dll, it injects a kernel driver to read sensors - that's why it needs elevation). btop could probe it on start on the default port (http://127.0.0.1:8085/data.json) and accept command-line options. I can try to push a PR for this.

andrey-zotov avatar Aug 29 '22 09:08 andrey-zotov

@andrey-zotov Already got a working DLL exporting from C# to managed C++ to the unmanaged C++ of btop4win :)

Reading from the webserver would mean the need for adding netcode and json parsing, which i suspect would use a lot of cpu cycles. But if you would like to work on it as an alternative to the DLL import without the need for admin rights, feel free to create a branch. And if works out we can add it as a third alternative in the releases.

But running btop4win elevated would be the recommendation regardless, otherwise a lot of information for processes not owned by the user will be missing.

aristocratos avatar Aug 29 '22 09:08 aristocratos

Took you long enough @aristocratos. I assume you finally got motivated, picked up some good coding practices, read about if statements and got yourself familiar with C++. Hope you now realize it has already been done before, reflect on your past mistakes otherwise we will not let it slide so easily next time.

Jokes aside, cg on bringing btop to even more users 🎉

kolpav avatar Aug 30 '22 12:08 kolpav

Closing this since it's completed. Further ideas or discussions regarding btop4win should be redirected to https://github.com/aristocratos/btop4win

Thanks everyone for the support ❤️

aristocratos avatar Sep 08 '22 17:09 aristocratos

I know you closed this, but dude this is awesome work! Sometimes that just needs to be said.

shayneoneill avatar Nov 25 '22 03:11 shayneoneill