Just curious to know if I were to write up my own taskbar (something similar to polybar) in Rust, how difficult would it be?
It looks like 99% of the problem is in interaction with the OS, so in Rust it's probably as difficult as in any other language.
Oh ok so then how difficult would it be though if I were to write my own taskbar?
I wrote a taskbar for Sway window manager to learn rust: GitHub - zthompson47/barnine: A swaybar implementation using swaybar-protocol.. It was easy to get started because
cargo new generates most of the program. The protocol is just "print text to stdout in a loop".
Interesting, did you find it personally difficult to design the taskbar using Rust?
I'm coming from (most recently) a python background, so the hardest thing was getting used to the type system and borrow checker in rust. Once I got comfortable, rust language features made the process easy and joyful. At first, I would encounter frustration that rust "doesn't let me" do something, only to find out later that I was nudged into a better design.
As for the taskbar itself, the ecosystem provides plenty of crates to handle OS specific stuff. Just like in python, someone's already written most of what you need. For example, although I wrote my own code to read the battery level, I could have used the battery crate.
Also, if you like async, tokio has been a pleasure to work with. You might need some concurrent code to run event listener tasks and whatnot.
Very interesting mate
I see mate, did you write most of the stuff for your taskbar yourself or did you use a lot of pre-existing crates?
In regards to your taskbar, is it like DWM where all the configuration is done through the code?
I think it was a mix of using crates for low-level stuff and wrapping that with my own code. Part of the goal was learning, so I was leaning towards my own implementations.
I went with a hot-reloadable config file using the notify crate. Recompiling and relaunching to see every small tweak to the config was tedious.
Does it still let you script it in a similar manner as DWM and Xmonad?
There's the swayipc-async crate to interact with Sway window manager. It looks fully scriptable from rust code. I use it to get the window title of the currently focused window, and to dim the screen when I'm in a workspace with Firefox.
The Sway window manager is for wayland, isn't it?
Thanks for showing me your taskbar, but I think I am going to create my own taskbar, not because I hate your project but because I want to learn Rust by doing things myself, so therefore I am also going to avoid using most of the crates as well so I really get a feel as to how to use Rust
Yes, sway is for wayland. Have fun on your Rust endeavors!
Thanks mate, by the way, where can I learn all this stuff in regards to low level programming, like how did you learn all this stuff mate?
Another question, is there a Rust version for sway?
Just lots of tinkering, really. Years of Linux sysadmin and whatnot. With Rust in particular, I recommend using an IDE that shows errors as you type, and write a bunch of small programs to test each new feature as you learn. Become friends with the compiler because it will teach you a lot.
As for Rust window managers, there are a few projects that you can find by searching, but I don't know much about them.