1# `wl-mirror` - a simple Wayland output mirror client 2 3`wl-mirror` attempts to provide a solution to sway's lack of output mirroring 4by mirroring an output onto a client surface. 5 6## Features 7 8- Mirror an output onto a resizable window 9- Mirror an output onto another output by fullscreening the window 10- Reacts to changes in output scale 11- Preserves aspect ratio 12- Corrects for flipped or rotated outputs 13- Supports custom flips or rotations 14- Supports mirroring custom regions of outputs 15- Supports receiving additional options on stdin for changing the mirrored 16 screen or region on the fly (works best when used with [pipectl](https://github.com/Ferdi265/pipectl)) 17 18![demo screenshot](https://user-images.githubusercontent.com/4077106/141605347-37ba690c-f885-422a-93a6-81d5a48bee13.png) 19 20## Usage 21 22``` 23usage: wl-mirror [options] <output> 24 25options: 26 -h, --help show this help 27 -v, --verbose enable debug logging 28 --no-verbose disable debug logging (default) 29 -c, --show-cursor show the cursor on the mirrored screen (default) 30 --no-show-cursor don't show the cursor on the mirrored screen 31 -i, --invert-colors invert colors in the mirrored screen 32 --no-invert-colors don't invert colors in the mirrored screen (default) 33 -s l, --scaling linear use linear scaling (default) 34 -s n, --scaling nearest use nearest neighbor scaling 35 -s e, --scaling exact only scale to exact multiples of the output size 36 -t T, --transform T apply custom transform T 37 -r R, --region R capture custom region R 38 --no-region capture the entire output (default) 39 -S, --stream accept a stream of additional options on stdin 40 41transforms: 42 transforms are specified as a dash-separated list of flips followed by a rotation 43 flips are applied before rotations 44 - normal no transformation 45 - flipX, flipY flip the X or Y coordinate 46 - 0cw, 90cw, 180cw, 270cw apply a clockwise rotation 47 - 0ccw, 90ccw, 180ccw, 270ccw apply a counter-clockwise rotation 48 the following transformation options are provided for compatibility with sway output transforms 49 - flipped flip the X coordinate 50 - 0, 90, 180, 270 apply a clockwise rotation 51 52regions: 53 regions are specified in the format used by the slurp utility 54 - '<x>,<y> <width>x<height> [output]' 55 on start, the region is translated into output coordinates 56 when the output moves, the captured region moves with it 57 when a region is specified, the <output> argument is optional 58``` 59 60The [`scripts/`](scripts/) folder contains examples on how `wl-mirror` can be used. 61 62- [`wl-present`](scripts/wl-present) is a small script to demonstrate the use 63 of the `-S` option to interactively present on Sway. 64 This script is especially useful when binding the `wl-present` subcommands to 65 keyboard shortcuts. 66 67## Dependencies 68 69- `CMake` 70- `libwayland-client` 71- `libwayland-egl` 72- `libEGL` 73- `libGLESv2` 74- `wayland-scanner` 75 76## Script Dependencies 77 78- `pipectl` (`scripts/wl-present`) 79- `slurp` (`scripts/wl-present`) 80- `rofi` or `dmenu` (`scripts/wl-present`) 81 82## Building 83 84- Install Dependencies 85- Clone Submodules 86- Run `cmake -B build` 87- Run `make -C build` 88 89## CMake Options 90 91- `INSTALL_EXAMPLE_SCRIPTS`: also install example scripts (default `OFF`) 92- `FORCE_SYSTEM_WL_PROTOCOLS`: always use system-installed wayland-protocols, do not use submodules (default `OFF`) 93- `FORCE_SYSTEM_WLR_PROTOCOLS`: always use system-installed wlr-protocols, do not use submodules (default `OFF`) 94- `WL_PROTOCOL_DIR`: directory where system-installed wayland-protocols are located (default `/usr/share/wayland-protocols`) 95- `WLR_PROTOCOL_DIR`: directory where system-installed wlr-protocols are located (default `/usr/share/wlr-protocols`) 96 97## Files 98 99- `src/main.c`: main entrypoint 100- `src/options.c`: CLI and stream option parsing 101- `src/wayland.c`: Wayland and `xdg_surface` boilerplate 102- `src/egl.c`: EGL boilerplate 103- `src/mirror.c`: output mirroring code 104- `src/transform.c`: matrix transformation code 105- `src/event.c`: event loop and asynchronous option stream input 106