• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    Ruby
  • License
    MIT License
  • Created 10 months ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An X11 window manager in pure Ruby

A Ruby X11 Window Manager

WARNING:

This is experimental. It will eat your cat and burn down your house, format your hard drive and post all your secrets to Facebook.

Also it will likely crash on you.

If you're not comfortable figuring out how to recover from an X session where your window manager is gone and lots of your windows appears to have disappeared ... somewhere, and you might not be able to get focus to a terminal window without switching to the text console, this is not yet for you.

So why should I run this?

You almost certainly shouldn't.

But what is it then, at least?

It's a minimalist (currently <1K lines) pure Ruby (including the X11 driver) X11 window manager. It is focused on tiling, but allows you to choose to assign a tiling layout to specific desktops or leave them floating. Currently whether or not you use tiling or floating layout there is no window decoration and windows are not draggable or resizable by pulling on borders (but you can do that with Windows key + left/right mouse button)

Like bspwm, which was an inspiration, the wm supports no keyboard handling - all keyboard handling is deferred to separate tools like sxhkd. Unlike bspwm this WM has no dedicated IPC mechanism. Instead, so far, all communication happens via X11 ClientMessage events, which means any tool, like xdotool etc. that can produce those events can control the WM.

It currently does not do anything to facilitate working on multiple monitors, as in my current setup I'm only using a single monitor for my Linux machine.

Screenshots

Note that most of what you see here is not the wm. The wm decoration is minimalist: a 1 pixel rectangular frame. Nothing else. But people want to see screenshots anyway, so here:

Why did you write this?

It started with mild frustration that bspwm handled my desire for one of my virtual desktops to have floating windows by default poorly. It's possible, but didn't work great for me. It also frustrated me that my file manager was visible on all the virtual desktops instead of just the floating one. I also happened to know an X11 WM can be really minimal to start off with.

So I ditched bspwm, and translated TinyWM - a really minimal C wm - to Ruby, made that my main wm, and gradually started adding the features I needed, drawing a lot of inspiration from the code of KatriaWM to figure out how to make my experience gradually less painful.

This has been my only WM since that day, and I now feel that I have rough parity in term of the features I use with bspwm. That does not mean it will have parity for you - it lacks lots of things. It also does not mean there aren't plenty of bugs, because there are.

Will you add...?

Maybe. As long as it can either 1) be done with little code, and/or 2) be done by you, and/or 3) it can easily be kept as a separate gem.

Talk to me. But please respect I'm primarily releasing this "as is", and I'm not committing to supporting this - I do not care if you decide it doesn't work for you and is horrible. I'll think it's great if you get some utility out of this code, though. But my goal is not a big user base. Or a user base.

My goal is a functional, minimalist WM that works for me. And so, I'll help if it's not compromising my own goal. To the extent our goals are not compatible, I'm happy to e.g. split out generic/reusable functionality so people can fork this and we can still benefit from sharing the bits where we do agree how things should be.

Pre-requisites:

  • sxhkd or similar is needed to handle input, as this WM does not listen to keybindings other than grabbing windows+ left/right mouse button for move and resize.

  • A recent version of Ruby. I currently use 3.2.2

How to run

This is a subset of my .xinitrc.

WARNING: You probably want to try this in a vm or something first and see if it works for you:

  (sxhkd 2>&1 | logger -t sxhkd) &
  (cd ~/Desktop/Projects/wm ; ruby rubywm.rb 2>&1 | logger -t rubywm) &
  
  while true do
    wait
    sleep 5
  done

For most "normal" window managers, people tend to start the window manager last and let it end the X session when it quits, but since this is in development, I'm not going to do that because most stuff on my desktop can survive my WM crashing and being restarted just fine, as it should be, but will obviously get killed if the X session dies.

Using with sxhkd

This is my related integration with sxhkd from my sxhkd config, but any app that supports sending XClientMessage events can work:

    # Full screen
    super + f
    	/home/vidarh/bin/xclimsg -mpw focused _NET_WM_STATE 2 _NET_WM_STATE_FULLSCREEN 0 2
    
    # Shift Focus
    super + {Left,Down,Up,Right}
    	/home/vidarh/bin/xclimsg -mpw focused _RWM_FOCUS {Left,Down,Up,Right}
    
    # Shift direction
    super + shift + d
    	/home/vidarh/bin/xclimsg -mpw focused _RWM_SHIFT_DIRECTION 0
    
    # Swap node layout
    super + shift + l
    	/home/vidarh/bin/xclimsg -mpw focused _RWM_SWAP_NODES 0
    
    # Move
    super + shift + {Left,Down,Up,Right}
    	/home/vidarh/bin/xclimsg -mpw focused _RWM_MOVE {Left,Down,Up,Right}
    
    super + F1
    	/home/vidarh/bin/xclimsg -mpw focused _NET_RESTACK_WINDOW 2 0 0
    
    super + F2
    	/home/vidarh/bin/xclimsg -mpw focused _NET_RESTACK_WINDOW 2 0 1
    
    # Focus desktop
    super + {1-9,0}
    	/home/vidarh/bin/xclimsg -mp _NET_CURRENT_DESKTOP {0-8,9}
    
    # Move to desktop
    super + shift + {1-9,0}
    	/home/vidarh/bin/xclimsg -mpw focused _NET_WM_DESKTOP {0-8,9}

The _RWM events are custom for this WM. The others works on other EWMH compatible wms.

xclimsg is from https://github.com/phillbush/xclimsg I intend to "build in" the same client code in rubywm to avoid that external dependency. Alternatively you can e.g. use xdotool or similar

More Repositories

1

writing-a-compiler-in-ruby

Code from my series on writing a Ruby compiler in Ruby
Ruby
273
star
2

diagram-tools

A number of small tools for generating and manipulating diagrams, mostly based around Graphviz
XSLT
110
star
3

sliding-stats

Sliding stats is Rack Middleware that presents a "sliding window" over a web apps last N requests (where N is a reasonably low value, as it's all kept in memory). This is currently a "work in progress" - don't deploy this anywhere without testing it first; It is likely to have nasty bugs.
Ruby
36
star
4

re

A very simple, very much in progress text editor written in Ruby.
Ruby
19
star
5

wave-gadget-emulator

Small emulation layer for the Google Wave gadget API to run a gadget side by side in two iframes
JavaScript
17
star
6

FrexxEd

FrexxEd is a flexible Amiga text editor with scripting support, ARexx, multiple views, built in filesystem handler for open buffers and more
C
17
star
7

Git

AmigaOS/AROS/MorphOS port of Git
C
9
star
8

ACE

Compiler for a large subset of Amiga BASIC + extensions
C
9
star
9

skrift

A pure Ruby conversion (*not* wrapper) of the libschrift TrueType font renderer
Ruby
9
star
10

wave-gadget-svg-editor

SVG editor as a Google Wave gadget
6
star
11

packrat

Package manager for AmigaOS and Amiga-like OS's (AROS etc.)
C
5
star
12

FPL

Frexx Programming Language - a portable scripting language originating on the Amiga
C
5
star
13

amiga-restoration

Project to "restore" classic Amiga freeware so that it will build and run on AROS and AmigaOS 3.5+
C
3
star
14

html2builder

Take HTML in, and spit Markaby / Nokogiri style Builder code out
Ruby
3
star
15

rouge-gtk_theme_loader

Load GtkSourceView themes into Rouge (Ruby syntax highlighter)
Ruby
3
star
16

sdlvnc

Shell
2
star
17

svg_graph

SVG graph generation in Ruby
Ruby
2
star
18

amiga-spec

Test suite for AmigaOS compatible OS's
C
2
star
19

rubyterm

Tiny ruby terminal for X11
Makefile
2
star
20

p9fs-ruby

A very early/incomplete/experimental/broken start of a Plan 9 filesystem implementation in Ruby
Ruby
1
star
21

make-rules

A small collection of somewhat reusable Makefile rules I include in projects
Makefile
1
star
22

filters

Experimental set of line oriented text filters
Ruby
1
star
23

sequel-track-changes

Small Sequel plugin to track changes to tables manipulated via Sequel models.
Ruby
1
star
24

aros-vm

Scripts to build a Linux OpenVz container suitable for AROS development
Shell
1
star
25

file_writer

Ruby gem to overwrite files safely and efficiently and make backup copy.
Ruby
1
star
26

m68k-amiga-crosstools

Makefile to generate Debian package of gcc, binutils etc. to compile M68k Amiga code on x86 Linux
1
star
27

collectionadapters

Adapters for Ruby collections classes
Ruby
1
star