Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Bonk, a command-line tool for X11 window management (github.com/fascinatedbox)
72 points by FascinatedBox 8 months ago | hide | past | favorite | 67 comments



Good, but wmctrl and xdotool do exactly that with far more features.


This does not appear to do anything that xdotool doesn't already do.


This solves a few issues in xdotool for me:

Window selection allows for multiple criteria at once, and I can also reject windows.

I'm also able to use the window manager's client list as a source, which makes getting toplevel windows much easier.

Window movement is done using static gravity, fixing an issue where windows were moving differently if they were a terminal window versus non-terminal window.

Bonk can delete properties. I sometimes delete WM_NORMAL_HINTS if a window has size hints set where I can't resize it the way I want.

xdotool can raise windows but can't lower them (bonk can do both).


> I sometimes delete WM_NORMAL_HINTS if a window has size hints set where I can't resize it the way I want.

With kwin it's easy to manually override an application/window to ignore geometry constraints or whatever. I do this for xterm to avoid having a few pixels of background showing at the edge when maximized.

I also used to do this a lot to get the much-nicer "soft fullscreen" in SDL1 applications.


Can it send whatever signal it is that WMs do when a window is fullscreened, or block the signal sent when it's unfullscreened? If so, I'm 100% sold.


Yes, through the state option (xdotool calls it windowstate). I was confused when implementing it, because there appear to be three different fields: maximized_horz, maximized_vert, and fullscreen. If you want total fullscreen (covers taskbar and other stuff), use the last one. If you want the window maximized, use both of the maximized ones.

Come to think of it, I should put in better documentation for the state option, as well as a general maximize alias.


GP's question seems like it might be a common question. Would it make sense to add this to the readme?


Good point. I'll make a note to add some documentation to that effect. I didn't think of it originally because I didn't expect this much interest in my project.


Good problem to have!


Nice to see an alternative, there is some old issues with xdotool or wmctrl and after some tests I will probably replace them completely with bonk.

I updated my script for i3wm to toggle windows between scratchpad/active/start/stop:

https://gist.github.com/tkapias/0443d4930c1d7b520f4496e1ff39...


"bonk - Box's windOw maNager toolKit."

Obviously.


fascinatedbox, bonk. this person has great names. I hope they can offer their version of a renaming of MacOS releases to avoid the blandish (tho triumphal and majestic, to be sure) Californiaisms. For instance what would this person call MacOS 12, 13, 14?


The name confuses me profoundly.


Yeah, I also kept thinking of the 1988 debut studio album by Big Pig and the urban dictionary usage of the word upon which the album was named.


FYI bonk.io has been around for almost a decade.


Kind of obsolete in the age of Wayland.


Wayland is still buggier than a swamp. At this point they're no longer showstopping bugs, but if you don't want to be constantly annoyed by little things not working, X11 is still the way to go.


It depends a lot on your desktop enviornment/window manager, distro, hardware, etc. I personally find Wayland works perfectly out of the box whereas X11 still to this day has issues with basic stuff like screen tearing that needs me to add a line to my xorg config file to enable the driver feature that stops screen tearing. (Note that every other display server has zero issues -- MacOS, Windows, Wayland, etc so the fact X11 still suffers from this in 2024 is a strong indicator of its suitability for everyday use). For me the GNOME/Debian/Wayland on Intel GPU has worked flawlessly since Debian switched the default to Wayland a few years ago. The same combo has been problematic for X11 for years until Debian switched over to Wayland and it has been great ever since. Firefox has supported GPU/Video acceleration in Wayland for several years as well which has solved that particular bugbear. I understand though that other combos (particually the less-used DE/WMs and/or closed-source GPU drivers etc) are better for X11 for legacy reasons however I suspect with time these issue will be resolved.


What are you running when you experience screen tearing? I've literally never once encountered it in over 20 years of using X.


Maybe you are not sensitive to it. Some people dont percieve tearing as much as others. I run base PopOS (ubintu derivative with gnome) and i get tearing in x. I don’t know much about linux jist that when i login i can choose x/wayland and wayland seems to be a lot better at everything (fractional scaling also works).


I can consistently trigger it playing a video in any player under X11 e.g. videos in Firefox or in a standalone player like mpv/VLC etc. It's pretty damn obvious in certain types of videos e.g. action movies. But always on Intel GPU so it's possible it's not so noticeable with other GPU due to hardware or driver software differences. The Intel driver for xorg has a configuration flag that stops screen tearing.


IIRC I get it in Firefox occasionally. I vaguely suspect some combination of smooth scrolling, video, and a portrait mode screen but it isn’t annoying enough to investigate


mpv running an anime for example, where the scene pans to the left or right

Sometimes adding a compositor like Compton helps, but you still see it


Buggier or not - it's too late to think X11 is the alternative. It's not. Wayland is going to get better for whatever is needed.

X11 is absolutely not the way to go.


The question is "when?". Wayland is 15 years old, it already had a lot of time to "get better". So today, in most cases, I'd say X11 is still the way to go, it just works better.

When Wayland will get better and apps start supporting Wayland more than they support X11, it will be the time to switch, but at the glacial pace Wayland advances, chances are that your current system will be obsolete when it will happen.

It is still a good idea to consider Wayland support for your own apps and have at least a test machine running it, but doesn't mean writing apps designed to work with X11 like this one is a wasted effort. X11 is here to stay, for a while at least.


Further, it's not even clear that this kind of program is practically possible on Wayland. At best, that's yet another new protocol someone would need to invent that only some compositors would implement.


This was the question I came to ask. I've been a Wayland avoider because for me there was nothing "broken" to be fixed.

Occasionally, I've enjoying playing around with window management and hacking with WMs, using stuff like this and/or xdotool and wmctrl.

I was curious as to what this might be like in Wayland-land? Do tools like this even exist?


My understanding is that "window managing" tools like this are not possible due to how wayland handles information. Pro: More secure than x11, Con: I can't use wayland. Aside from investing a lot of time learning how to use a tiling wm I dont see how I'm going to get over my addiction to minimizing only the active window. ( xdotool windowminimize $(xdotool getactivewindow) )


For improved security with X11, try firejail+Xpra, or Qubes OS. They will not just help in the graphical front, but also others like processes and storage isolation.


Workarounds for the inherently broken security model of X11.

Gee, if only there were a modern display server protocol with a fixed security model!


All models are wrong, some are useful?

Theoretically, X11 is dangerous. But what isn't?



Besides the limitations others have mentioned users should be aware that since ydotool works by writing events directly into /dev/uinput the input will go to whatever happens to be focused at the moment. It will happily type your secrets into a chat window if you move the mouse at the wrong time.

There is no way to do the equivalent of xdotool type --window 0x600005 "my important input"


It's not like xdotool is so secure in the first place. X11 is one huge hole from that perspective. Anything can read anything and all your important input can be read by some other window anyway.


This is a totally different issue; Wayland gives up the ability to provide user-aid that prevents an obvious human error. This is not really a security issue, it is a usability issue that can just happen to allow a user to make a security slip-up.

In exchange, Wayland gains… well, nothing really, the idea is that it’ll protect users from malicious programs peeking at other windows on their computer. But in that case situation is already FUBAR, there’s no way to protect a computer that is already running attacks locally on itself.


The idea is that to worry about security in something broken by design is a folly.


Right, the idea of running hostile programs on your system is broken by design, Wayland is engaging in folly by trying to protect against it. X11 gives up that pointless quest and, by doing so, at least it can provide some extra user-assistance features (including ones that can help mitigate security related user errors).


Are you posting from seL4, OpenBSD, or Genode?


>> Occasionally, I've enjoying playing around with window management and hacking with WMs, using stuff like this and/or xdotool and wmctrl.

Ydotool readme:

> Currently implemented command(s):

> type - Type a string

> key - Press keys

> mousemove - Move mouse pointer to absolute position

> click - Click on mouse buttons

So... No.


For what xdotool does - pretty much a substitute. For anything else you need a compositor specific tool.

KWin scripts or something might work for KDE: https://develop.kde.org/docs/plasma/kwin/


> For what xdotool does - pretty much a substitute.

No; for just the input functions, and that only if you're not using `--window`, it's a substitute. But xdotool is a lot more than that.

> For anything else you need a compositor specific tool.

Yes, exactly. For the things that were asked for, your best hope is do see if your particular compositor deigned to provide the API surface, and then if it did, write something that uses those non-portable APIs to do what you want.


Makes perfect sense for it to be something that interacts with the compositor. So KWin does expose such API. But that's not part of Wayland itself or its protocols.

Want to make it easy? Use KDE which cares about flexibility and write scripts for it. Otherwise - probably tough luck, not sure how much other compositors even care about such things.


Or I could just use X11, where this is a solved problem using a single API that works on arbitrary window managers / desktop environments. The only problem is people keep showing up to tell me that I need to stop using it and use their feature-poor alternative.


You couldn't really since it's DOA. Otherwise you'd be stuck with unsupported path.


> Further, it's not even clear that this kind of program is practically possible on Wayland.

It's pretty clear. But some are too stuck up to even research it or be part of shaping it. Which is common among legacy vendors who very rarely even care to communicate with Wayland developers about their needs.

Those who aren't stuck up deal with it just fine (OBS Studio for example).


Lol - it's "stuck up" to prefer software that works? If you want people to switch, it'd help to actually cover their use cases. Showing up to proclaim software "obsolete" when the supposed replacement literally doesn't support the features in use, then... what, claiming we're bad people for not contributing to Wayland? is the cultural part of why people don't like Wayland. (In a distant second place behind the technical reasons people don't like it, which boils down to missing features and present bugs.)


Stuck up means they don't care to collaborate. If they don't, how would anyone know about their specific needs? Those who don't have this dinosaur mentality do work with Wayland developers and their needs are addressed faster. Others learn the hard way but also usually like to complain that "things don't work".


Maybe people don‘t because they see, for example, Valve (a billion dollar company) struggling to get GNOME to implement drm-leasing for VR headsets. IIRC they‘ve been at it for multiple years, too.

Or maybe it‘s because the compositor developers are not exactly concerned about ease of development. To quote a GNOME dev[0] about support for the aforementioned drm-leasing protocol:

> I honestly don't have a problem with forcing clients to implement the portal if they want to work on mutter.

I wouldn‘t blame the people who choose to simply not engage with that process, especially those who work on these things in their free time.

[0]: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2759


> The question is "when?". Wayland is 15 years old, it already had a lot of time to "get better". So today, in most cases, I'd say X11 is still the way to go, it just works better.

If you run more than one monitor with different DPI, Wayland is the only choice. If you want to do HDR, Wayland will be the only choice.

> When Wayland will get better and apps start supporting Wayland more than they support X11, it will be the time to switch, but at the glacial pace Wayland advances, chances are that your current system will be obsolete when it will happen.

Toolkit developers are already considering removing their X11 code paths. All of the effort is going into Wayland. The best time to switch was a few years ago. The second best time to switch is now.


I tried Wayland (Fedora 39) on two screens and the experience was so terrible and full of bugs I gave up after less than a day. New windows open at random locations and screens no matter what's focused, UI scaling of a window is sometimes wrong for its screen, at least once an hour the screens just go blank for a couple seconds etc.

For me it's definitely not usable yet, let alone the "only choice"

> All of the effort is going into Wayland

Yes, because it's still work in progress. And at some point in the future that effort will have paid off, but that's not now and definitely not a few years ago.


> Yes, because it's still work in progress.

And because the X11 maintainers decided that Wayland is the way forward and X11 will simply not get new display features like HDR.


What I care about are the existing features. Bugs don't look any better in HDR. I'm sure it'll all be fixed sooner or later but until then it's a downgrade for me, and I just don't get this "best time to switch" sentiment about an unfinished component that a user shouldn't even need to know about.


> And because the X11 maintainers decided that Wayland is the way forward and X11 will simply not get new display features like HDR.

Is Wayland a racket? Barely maintain the previous code instead of making clear that others should take it over because you are insterested in something else, then force everyone into your new incomplete code base, and probably bill for the reimplementation of basic capabilities, piece by piece.

OTOH, not everyone involved with X11 thinks it has no future. Keith Packard posted ideas [0] about how to improve it further.

[0] https://keithp.com/x-ideas/


What? It's been known that the X maintainers had moved on to devote almost all their efforts to Wayland for years now. And yes, part of the Wayland strategy has been -- much like with systemd -- to drag the community, kicking and screaming if need be, into modernity.

Anybody who wants to maintain Xorg is free to step up.

Nobody has really stepped up.


X11 has supported mixed dpi from nearly the very beginning.

http://wok.oblomov.eu/tecnologia/mixed-dpi-x11/


Is that article correct, that mixed DPI on Wayland works by just rendering everything to a virtual screen whose resolution corresponds to the maximum DPI of any physical screen, and then downscaling all the other screens?


Yet it doesnt seems to work (from nearly the very begining).


> If you run more than one monitor with different DPI, Wayland is the only choice.

I run multiple monitors with differing physical DPIs on X11. Yeah, that means they have differing resolutions. It doesn’t bother me, and I can do all the things that I want, unlike if I were using Wayland.

Maybe someday Wayland will be a replacement for X11, but that day is not today.


> The question is "when?

I'd say within this year already. Some major parts like explicit sync are being merged already. And all future work (like HDR) will only go to Wayland. Not to X11.

So this claim that X11 is a viable option is a fallacy.


It works. Therefore, it's viable.

It's my computer. I decide what's "the way to go" or "viable" there. None of your business. No one is forcing you or anyone to use it.

This is clearly a "I wrote it because it's useful for me, I put it online for whom it may concern"-type of project. You need to calm your tits and stop shitting all over people's hobby projects.


You can decide whatever you want. Being stuck with unsupported case (X11) you support yourself is "viable" as long as support yourself is something you can do.


It's not "unsupported". That's just not true.


X11 was absolutely not the way to go since the day it was released on 15 September 1987, but that never stopped it.


The difference is that back then there were people actually developing it, the Wayland core team is basically the developers left in the GNU/Linux ecosystem that still care about GUIs, most of them former X contributors.

There isn't anyone left standing to care for X11 development, only vocal users.


Have you ever tried running it with a non-Nvidia GPU?


I've only once ever used an NVidia card long ago, and learned enough to never try that again.

I'm not talking about low-level system/graphics bugs, but standard shell/toolkit/application bugs. Things like "alt-letter does not select the correct menu" and "switching between English/Greek keyboard layouts sometimes gets stuck".


Probably will be, whenever that occurs.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: