├── kiosk-wm-run.sh ├── README.md ├── LICENSE └── kiosk-wm.c /kiosk-wm-run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Full path to this executable 4 | SELF="$(readlink -f "$0")" 5 | 6 | # If we're not in an X session, start one. 7 | if [ "$DISPLAY" == "" ]; then 8 | exec startx $SELF $@ 9 | exit 10 | fi 11 | 12 | # Start kiosk-wm and store its PID 13 | $(dirname "$SELF")/kiosk-wm & 14 | WM_PID=@! 15 | 16 | # Execute the argument 17 | $@ 18 | 19 | # When it's terminated, kill kiosk-wm 20 | kill $WM_PID 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kiosk-wm 2 | A super simple X11 window manager that centres and full-screens all windows. That's it! No 3 | keybindings, no dragging windows. 4 | 5 | ## kiosk-wm-run.sh 6 | A simple utility script to start kiosk-wm and run a command. 7 | 8 | ### Usage 9 | ``` 10 | kiosk-wm-run.sh command 11 | ``` 12 | 13 | Start kiosk-wm (or exec `startx $0 $@` if `"$DISPLAY" == ""`) and execute `command`. 14 | 15 | When `command` terminates, kiosk-wm will also be terminated. 16 | 17 | 18 | ## Building 19 | ``` 20 | gcc -lX11 -o kiosk-wm kiosk-wm.c 21 | ``` 22 | 23 | ## Other Resources 24 | ### TinyWM 25 | If you'd like a slightly more sophisticated, but still incredibly simple, window manager to start 26 | hacking on, I'd recommend [tinywm](https://github.com/mackstann/tinywm) - that's where I started! 27 | ### libX11 Reference 28 | [www.x.org/releases/current/doc/libX11/libX11/libX11.html](https://www.x.org/releases/current/doc/libX11/libX11/libX11.html) 29 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Jacob O'Toole 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /kiosk-wm.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | Display *display = XOpenDisplay(0x0); 5 | if (!display) return 1; 6 | 7 | Window root = DefaultRootWindow(display); 8 | 9 | // This allows us to receive CreateNotify and ConfigureNotify events. 10 | XSelectInput(display, root, SubstructureNotifyMask); 11 | 12 | for(;;) { 13 | XEvent ev; 14 | XNextEvent(display, &ev); 15 | 16 | if (ev.type == CreateNotify) { 17 | // MoveResize all created windows. 18 | XMoveResizeWindow(display, ev.xcreatewindow.window, 0, 0, 1920, 1080); 19 | } else if (ev.type == ConfigureNotify) { 20 | // We may also need to catch windows that move or resize themselves. 21 | // A lot of applications resize their windows immediately after creating them. 22 | XConfigureEvent ce = ev.xconfigure; 23 | // Only MoveResize if it's not correct already. 24 | if ( 25 | ce.x != 0 26 | || ce.y != 0 27 | || ce.width != 1920 28 | || ce.height != 1080 29 | ) { 30 | XMoveResizeWindow(display, ce.window, 0, 0, 1920, 1080); 31 | } 32 | } 33 | } 34 | 35 | return 0; 36 | } 37 | --------------------------------------------------------------------------------