Wprintidle: Print Idle Time in Wayland

Greetings! I thought I’d drop by and share a little project I’ve been working on to obtain the users idle time for Wayland environments, wprintidle.

Essentially, it is an xprintidle replacement for Wayland compositors that implement the ext-idle-notify protocol. That is, any compositor compatible with swayidle will work with wprintidle.

While I doubt such a utility will be of great use for Wayland, this was my first time mixing Zig with their protocols so I chose something on the simpler end. I had considered doing a re-write of swayidle outright, but again I wasn’t not convinced the effort was either wanted or necessary.

Feel free to provide criticism, undying praise, shouting, and/or insults :upside_down_face: Well, except for the over-engineered doc comments, I obviously had too much fun exploring autodoc.

6 Likes

I for one find it very interesting, I was considering dipping my toes into some Wayland and Zig development, but am rather inexperienced with the former, so the detailed comments and documentation is very much appreciated. This seems like a great project to use as a guide for the basics and a “real-world” example that isn’t too complicated with Wayland concepts that are over my head.

Thanks for sharing. :+1:

4 Likes

No problem, thanks for your feedback!

I think that’s a great point too. One of the struggles I had early on with this project was how few (maintained) examples there are.

To be fair, it’s not like there’s zero information - yet I felt like I spent way to much time in the weeds with basic memory problems in the case of grabbing the seat name from the compositor. The solution turned out to be pretty simple in the end, but not intuitive for me. Even if all I accomplished was saving someone else a lot of head-scratching I’m OK with that.

Thought I’d drop an FYI that there’s a new release for Zig 0.15.x.

I still have to assume no one actually uses this in the wild, but it was fun to read the release notes from this summer and push a few updates. I also might get back into writing more code soon (after getting a little burnt out looking for work this spring). Checking around the interwebs I clearly have far to few opinions on the new IO stuff too.

(queue the fishing for ideas…)

My creativity is also at an all time low, and I’ve just been playing around with rewriting other peoples software in Zig. A Zig zzz? Sure why not :joy: I realize you’re all very capable and so on but if anyone were to claim they have a use for something Zig + Wayland I might just blindly write it. Who knows, could be fun!

How about screensavers for Wayland? You could go the distance and create a framework where people can drop their own code (in Lua?) and write their own screensavers.

Another idea is doing the Omarchy-style, low-res, terminal graphics screensavers.

Just an idea. Cheers.

1 Like

Hey thanks, I’ve been using waylock for the longest time so it could be interesting to take a zig screensaver a little farther.

Terminal graphics are always fun but I’m curious how you envision the drop-in “write your own” option working? I’m struggling to think of something similar. I definitely like the sound of it, somehow reminiscent of the old Winamp visualizations.

I guess what I had in mind is to create (in Zig) a bit of an abstraction for “writing / animating crap on the screen (graphical or terminal)” and exposing a reasonable API for this abstraction, something that you could call from a dynamic language such as Lua. Then, your Lua screensaver would be something like “initialize the abstraction; generate a maze; draw the maze; animate the search for the maze’s solution; rinse and repeat;”.

This is all very handwavy, but I think it would be nice to have something like it for playing around with screensaver ideas.

1 Like

Hey sorry for the delay, thanks for explaining!

Handwavy is ok haha, lets the imagination have some fun with it. It’s been a few years since I played with anything graphical in big way so that sounds pretty cool. My Lua sucks but I could probably bake in a few classics like the “game of life” too.

1 Like

What does it mean to be idle? Is it like not using keyboard or mouse for a period of time?

Yep that’s correct, I’m using the same Wayland protocol as swayidle

1 Like