Berry is a healthy, byte-sized window manager written in C for Unix systems
berrywm.org
berrywm.org
If you work with multiple monitors, give it a try (today is sunday)! It uses the monitor swapping feature from xmonad but comes with simplicity of editing the config (one doesn't need to learn new programming language to edit config). It's a pretty cool window manager.
(I'm exaggerating; of course I know why people still write things in C, but I would have a hard time justifying starting a new project in C these days.)
Portability might be the most reasonable argument, which is understandable when you're writing things like build systems, e.g.:
https://git.sr.ht/~lattis/muon
Then there are small tools when using anything else just doesn't buy you much, and if you're familiar with C, why bother? e.g.
https://git.sr.ht/~kennylevinsen/wlsunset
And situations like this one where you need both C API (for maximum compatibility), and manual memory management is a much for various reasons (read the blog post)
What's the objection there? I want the state to be freed when the object's lifetime ends. For something only needed during a function, a local value variable makes sense. For something that needs to last longer, either give it a move operator, or put it on the heap and use unique_ptr.
If your point is that people sometimes use unique_ptr<std::string> instead of std::string or std::optional<std::string>, then yeah I agree, that's generally not good.
In my C firmware projects I do not allocate memory at all. Everything is predetermined.
Having said that, "delete" hardly showed up at all.
How does it continue? Assembly=walking, fixie=C, regular bike=fortran, electrically assisted bike=C++, electric wheelchair=python, ...
:_D You made my day! I'd continue like this: barely moving eye-popping-graffiti-painted squeaky wheelchair with no bearings mounted with duck tape inside a rusty sea container, that is chained to a heavy truck with broken exhaust and flat tires = (you guessed it! :) )
If you add a solid rocket booster to this contraption (so that it actually moves) that would be exactly javascript.
It is alot easier to reason about performance. The code does somewhat translate to the machine instructions you anticipate.
But the greatest advantage is all the fancy pants idioms you don't feel compelled to use.
Life is too short to waste time tracking down double frees, out-of-bounds writes, memory leaks, and weird concurrency issues.
However this is hardly going to change outside the domains where corporations push for blessed languages on their platform SDKs, people keep being educated that C maps 1:1 to Assembly language and thus the myth continues.
Even Microsoft with all their security talk only allows on Azure Sphere OS and Azure RTOS, the reasoning being their target market doesn't wan't anything else.
On desktops / servers I prefer other languages and would not want to mess with C, at least for the types of products I do.
Window managers don't do all that much most of the time; I bet you could even write one in Python and not see performance issues. Hell, Go would be more than performant enough.
And energy efficiency?
And then... rofi. Which I tried with fvmw3. I love you, whomever did this.
I am not sure how to work with berry but I am going to give it a serious try. Two pieces of configuration information I will have to ferret out are:
Can I have overlapping windows with automatic mouse focus and elevation, with configurable delays? How do I choose among the virtual desktops? rofi doesn't do these, it seems.
berry appears to be for X11.
if the term compositor wins out, then fine, but i feel that that won't happen.
Calling WL compositors "window managers" is somewhat like asking where's the horse in that car.
FWIW, it’s 34KB and while it’s only the source, that seems pretty small. I haven’t gone through the build process to figure out the executable though.
I wonder, what do the previous 5-10 skill-building coding projects look like as one ramps up to writing a window manager?
I wrote this as a sophomore in college after finishing the intro computer science sequence (which goes into basic data structures/algs topics like binary trees, recursion, etc). This was my first real project outside of school, and to be honest didn't require a ton of pre-requisite knowledge. Mainly it just required a familiarity with event-based architecture and linked lists (all the window stacking is represented as linked lists). The difficult part with writing a window manager, imo, is getting familiar with the necessary specs and APIs. This is built using XLib, which relies on the X11 protocol. I also had to learn about ICCCM and EWMH, since many program rely on them as well. It was good practice learning and implementing specs.
I also added features throughout college as I took more classes. The smart window placement feature, for example, is implemented using a dynamic programming algorithm I thought up after taking a formal algorithms class. You can read about it on my blog if you're curious: https://www.josherv.in/2019/06/27/dp/.
1. Learn C.
2. Read the source code to evilwm.
Without workspaces this means re-arranging even more windows yet to accomplish this task switching.
In well designed WMs like i3 each desktop is typically bound to a key for instant switching, unlike the full screen atrocity of macOS where there is an unremovable delay when switching.
Full screen applications, adjacent workspaces, and a simple left or right swipe to switch workspace allows me to find relevant apps using our fast spatial reasoning wetware and avoids the problem of having to context switch into a hunt for the right window mode.
If I was 22 years old and had a large wraparound gaming monitor, then a tiling approach would probably work well. Truly, that approach did work for me when I was in my 20s. I'm still pretty interested in the VR office idea, but haven't bit bullet on it yet.
now you want to look at a different context with the same windowing complexity. You just switch to a different workspace and it's all laid out for you. Then you can go back.
How would you accomplish that without workspaces?
I have 1 workspace dedicated to programming. It has all the terminals, the code editor, and everything else.
The 2nd workspace is for browsing. Incidentally this also includes web app preview (if I am working on a web app).
I have mapped the Ctrl + ` for easy switching between the 2. So I make a change in the editor, press a key and see the preview. Nice and easy. My code editor is never minimized or in the background so all good.
I have to do all this when I am working on a small laptop screen where switching between windows is too annoying. I am aware that there are other ways to accomplish somewhat the same functionality but workspaces work for me.
In my window manager I took virtual desktops a step further and added contexts, each of which has its own set of virtual desktops. Windows, virtual desktops, and contexts all get kept in most-recently used (MRU) order.
So when I'm working within a virtual desktop, usually it's kept to a very localized specific topic involving multiple windows, Mod+Tab switches through those windows with the hot ones always staying at the top of the MRU-ordered list. Sometimes I end up with a slightly tangential set of windows so I spin up a virtual desktop within that context and keep those windows there, and the virtual desktop switching within the context can be achieved with Mod+Space, also in MRU-order.
But I also usually have multiple contexts active, each with one or more virtual desktops. Those contexts are for entirely disparate topics. Usually one context is communications, I'll have email, IRC, browser, etc. in one or more virtual desktops within that context. Another context will be one development project, with one or more virtual desktops full of terminals, kcachegrind, testing, etc. Usually I have two or three active development contexts repeating that mess. I can switch between the contexts using Mod+Grave, also in MRU-order.
The major value this all brings to me is it organizes my virtual spaces in the same way I organize my thinking and logically switch contexts. Due to everything always being kept in MRU-order, and having explicit keyboard controls for switching to the next recently used {window,virtual-desktop,context}, whenever I switch between these things, what's put immediately in front of me is the last item I was focused on within that context/virtual-desktop. And when I'm cycling through just windows or virtual-desktops, I don't get distracted by ever seeing the stuff put elsewhere.
But I do somewhat agree in the sense that many window managers offering virtual desktops utterly fail to deliver the obvious potential workflow advantages. It's totally ubiquitous for Mod+Tab to cycle window focus in MRU-order, but for some unclear reason nobody seems to do the same for virtual desktops, and I've never seen any before that grouped virtual desktops into another MRU-ordered and iterable/focusable thing which I've termed contexts.
Something I've come to really appreciate with how my window manager works is I'll sometimes spend over a month just living within the three MRU contexts getting shit done. Then I'll finally come up for air and hit Mod-Grave that fourth time without releasing Mod and rediscover that project I was working on last month still sitting there waiting for me to resume working on it, with the last focused window still sitting on top and focused ready to go. The entire month I spent in the top three MRU contexts I didn't have that backburner context's windows/virtual-desktops entering my cognition one iota, despite it being there all running and waiting happily.
If you're using a standard overlapping window system, virtual desktops are more of an optional workflow preference than an absolute necessity.
When you take a break from, e.g. gaming, you would probably want all the related windows to be out of sight. Rather than close all of them and open a new batch for work then later close all the windows and reopen all of the gaming ones, you can simply switch between workspaces.
Berry seems to be a stacking WM, but there doesn't seem to be any way to minimize or otherwise access opened windows from a centralized "task bar" either, so similar workflows apply.
Long before I used a tiling window manager I tried workspaces, too. But it just made the general chaos worse, not able to quickly find what I wanted. It's "too easy" to open a new window in the wrong workspace. Maybe just a psychological difference, with tiling I have learned not to create a mess.
Short of that, I really want virtual desktops.
- Leisure (browsing Hacker News, reading the news, listening to music, chatting with friends, etc.)
- Play (usually an idle game I enjoy)
- Software development (code editor, terminal, browsing code documentation, debugging tools)
- Virtual office work (writing documents, checking email, managing my calendar, managing projects)
- Learning (these days that means formal schoolwork as I've gone back to school to chase a graduate degree)
Then the other three workspaces (I just have four arranged in a 2x2 grid) are for a particular topic or project. One of them is devoted to some ESP32 rust hacking I've been playing with. Another has a window open for a consulting gig I was working on recently (though that project has concluded, so I can probably clean that one up). And the fourth one is for a different coding project I'm working on.
I find this much easier organizationally than having them all in the same workspace, and having to dig through the various windows to get things where I want it when I switch context.
Perhaps I'm a little odd, though: this is a laptop with a 13" screen, and I do all my work and play on it, without an external monitor. So keeping unrelated things separate is useful for me to keep clutter down.
Never needed to wear glasses, though I was borderline when I did my last check for my drivers license. Maybe eye surgery is something to consider!
With the complexity of keeping track of which together rising with the number of windows.
If S1 consists of a single window maximized and S2 a different window maximized the cost of switching workspaces is just as high as clicking on say a taskbar or hitting alt tab.
Let us consider a very simple stacking window manager with 2 workspaces and a task bar.
Let us first disregard the second workspace.
Suppose one has taken the trouble to size 7 windows to fit on 3 monitors. First you drag one window to the left-hand side of the leftmost monitor. Then we drag one side then the other. Repeat 7 times over for each window to be placed on each monitor.
Now suppose we only have 3 applications we ought to be able to see together separate from the other 7. This is easier as they can be dragged to a display and maximized.
Now consider the hassle to recreate the state repeatedly. You don't need to resize it but you have to manually select first 7 then 3 then 7 then 3 applications to bring them to the forefront.
Now what if you want to show 3 windows from the rightmost monitor then put them back. Now we are stuck resizing each in turn.
Now let us fully utilize the workspaces and separate the states on different desktops. Suddenly the switch between S1 and S2 is a click. The operation of moving the applications displayed on one end of S1 and showing them on the other end of S2 is of course just as much of a hassle as it ever was because workspaces encompass all monitors at once.
Now let us lastly switch to using per monitor workspaces. Now the last operation is as trivial as the first at the expense of making the process of changing all 3 at once more expensive. To decide which makes sense we would consider how frequently we want to do each operation.
If we find that we frequently need to switch multiple monitors at once we can trivially add that back but not the reverse.
I've not bothered with that setup in many years. I have enough pixels that it is no longer necessary or even helpful.
How are you navigating to another workspace, that it could possibly be slower than finding the right window if they're all piled one on top of another?
Since forever (early 90s), I've use 9 workspaces in a 3x3 grid. Because that conveniently maps to the numeric keypad on the keyboard (which I've never used for number entry). So it's one keystroke to jump to any of the nine workspaces, nothing could be faster.
Each workspace is dedicated to a specific project or workflow, so when I switch working from something to something else it's just one keystroke away to have all those windows in their correct locations ready to go.
Edit: Benefit of the doubt, it's a command line json processor written in 2013 mostly in C.
https://web.archive.org/web/20030228034147/http://www.crockf...
Edit: i misread and thought you asked what people used it for