wl-mirror - a simple Wayland output mirror client

Overview

wl-mirror - a simple Wayland output mirror client

wl-mirror attempts to provide a solution to sway's lack of output mirroring by mirroring an output onto a client surface.

This project is currently a working prototype, but work is still ongoing.

Features

  • Mirror an output onto a resizable window
  • Mirror an output onto another output by fullscreening the window
  • Reacts to changes in output scale
  • Preserves aspect ratio

demo screenshot

Usage

usage: wl-mirror [options] 

options:
  -h,   --help             show this help
  -v,   --verbose          enable debug logging
  -c,   --show-cursor      show the cursor on the mirrored screen (default)
  -n,   --no-show-cursor   don't show the cursor on the mirrored screen
  -s l, --scaling linear   use linear scaling (default)
  -s n, --scaling nearest  use nearest neighbor scaling
  -s e, --scaling exact    only scale to exact multiples of the output size

Dependencies

  • CMake
  • libwayland-client
  • libwayland-egl
  • libEGL
  • libGLESv2
  • wayland-scanner

Building

  • Install Dependencies
  • Clone Submodules
  • Run cmake -B build
  • Run make -C build

Files

  • src/main.c: main entrypoint
  • src/wayland.c: Wayland and xdg_surface boilerplate
  • src/egl.c: EGL boilerplate
  • src/mirror.c: output mirroring code
Comments
  • Black output when mirroring monitor connected to secondary (nouveau) GPU

    Black output when mirroring monitor connected to secondary (nouveau) GPU

    I have 2 GPUS, each has one monitor connected. I can easily mirror the monitor connected to my intel (main) GPU, but trying to mirror monitor connected to secondary GPU (nouveau) only results in black "screen".

    OBS/pipewire has no problem sharing the secondary screen so I assume it's possible at least in some way. I can provide more detailed info if needed.

    I also personally don't need this to work (since I'd use this on a laptop with just one GPU) but I thought I'd still file this in case you'd want to investigate/fix

    bug 
    opened by sochotnicky 11
  • v0.9.0 fails to build on non-Linux

    v0.9.0 fails to build on non-Linux

    Regressed by 7a78782f311d. Affects FreeBSD package.

    src/mirror-screencopy.c:165:27: warning: implicit declaration of function 'mremap' is invalid in C99 [-Wimplicit-function-declaration]
            void * new_addr = mremap(backend->shm_addr, backend->shm_size, new_size, MREMAP_MAYMOVE);
                              ^
    src/mirror-screencopy.c:165:82: error: use of undeclared identifier 'MREMAP_MAYMOVE'
            void * new_addr = mremap(backend->shm_addr, backend->shm_size, new_size, MREMAP_MAYMOVE);
                                                                                     ^
    

    Note, all other wlr-screencopy-unstable-v1 clients (e.g., grim, wayvnc, waypipe, wf-recorder, xdg-desktop-portal-wlr) work fine on FreeBSD (and DragonFly).

    bug 
    opened by jbeich 4
  • Wrong region displayed when using `-r` and dmabuf backend on screen with display scaling 2

    Wrong region displayed when using `-r` and dmabuf backend on screen with display scaling 2

    Hi, thank you for the great utility.

    I noticed an issue where the wrong region is mirrored when passing in region coordinates with -r on the dmabuf backend on my 3000x2000 laptop screen with display scaling 2. It seems that the region I specify (in the scaled coordinate space of size 1500x1000) is wrongly interpreted in the unscaled coordinate system (with size 3000x2000).

    With -b screencopy it displays correctly, and changing the display scaling to 1 also fixes the problem.

    Version info:

    wl-mirror v0.12.1
    sway version 1.7
    

    I've been using this command to select regions with slurp:

    swaymsg -t get_tree | \
        jq -r  '.. | (.nodes? // empty)[] | select(.pid and .visible) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | \
        slurp -r -o | \
        xargs -d "\n" wl-mirror -b dmabuf -r
    
    bug 
    opened by akselaase 3
  • Screencopy Backend does not work on latest Sway (1.8-dev-956b689d)

    Screencopy Backend does not work on latest Sway (1.8-dev-956b689d)

    For some reason the screencopy backend has stopped working on the latest release of sway. The reason for this is still unknown, investigation ongoing.

    bug upstream-bug 
    opened by Ferdi265 3
  • Include protocols in release tarballs

    Include protocols in release tarballs

    wlr-protocols are generally not packaged in distributions (there's not even a release, even wlroots itself copies what it needs (see https://gitlab.freedesktop.org/wlroots/wlroots/-/tree/master/protocol).

    IMO It would be better if you included the protocols you need - at least in the release tarballs. Though you might want to consider making a copy of needed protocols just like wlroots itself does even in the git repo. After all - it's not very likely to change all that much.

    enhancement 
    opened by sochotnicky 3
  • Mirror a region of the screen

    Mirror a region of the screen

    It would be nice to pass some coordinates to wl-mirror that defines a rectangle to mirror. (see slurp command). A lot of interesting workflows could arise combining it with swaywm virtual outputs

    (reference) https://www.reddit.com/r/swaywm/comments/k1zl41/thank_you_devs_free_ipad_repurposed_as_a_second/

    enhancement 
    opened by victordiaz 3
  • Read Stream of Regions from Stdin or Unix Socket

    Read Stream of Regions from Stdin or Unix Socket

    As an extension to #2 (Mirror a region of the screen), wl-mirror could support a mode where it reads a stream of regions from Stdin or a Unix domain socket, to be able to update the selected region while the program is running.

    One use case for this could be a presentation setup where the presenter could zoom into an area of the screen to highlight some detail and afterwards zoom back out.

    Pros and Cons of input sources

    • Stdin: simple and easy, but more of a hassle to set up if you want to combine it with keyboard shortcuts to change region
    • Unix Socket: a bit more complicated to set up, but something like wl-mirror-ctl set-region $REGION could be easily done from anywhere
    enhancement 
    opened by Ferdi265 2
  • Colour inverting mirrored surface

    Colour inverting mirrored surface

    When consuming media or watching screen casts, I often have to stare at black text on white background, which is rather painful during these dark winter days.

    I'd like to use wl-mirror to mirror the original window but inverting colours -- in this case, so that I get white text on black background.

    Can this maybe be implemented as a transform?

    enhancement 
    opened by WhyNotHugo 1
  • Support output transforms

    Support output transforms

    Sway supports setting output transforms such as "rotate 90 degrees" or "flip horizontally". Currently, wl-mirror doesn't handle these, even though they are sent with the wl_output.geometry event.

    Support Roadmap:

    • [x] save wl_output transform in output_event_geometry()
    • [x] calculate texture coordinate transform
    • [x] set viewport to transformed output
    • [x] apply texture coordinate transform

    This is very similar to #2 "Mirror a region of the screen" and should probably be implemented alongside it.

    enhancement 
    opened by Ferdi265 1
  • Sending --invert-colors via --stream does not update the shader uniforms

    Sending --invert-colors via --stream does not update the shader uniforms

    When sending --invert-colors as input via --stream, the shader uniforms are not immediately updated, resulting in the inverted colors only being visible after the next option that does update the shader uniforms (such as region change).

    bug 
    opened by Ferdi265 0
  • Support opening an xwayland shell

    Support opening an xwayland shell

    Okay, forgive me for the cursed suggestion.

    Until recently I've been using a gnome casting test script to be able to share my screen in X11-only applications, such as (non-ozone) Chrome and Discord. The test script would spawn an X11 window with a capture of my screen on it, which Discord is then able to screenshare.

    Unfortunately, the script has stopped working. Instead of trying to fix it, a better performing (and non-green?) solution such as wl-mirror would be preferable - if it was able to show X11 windows.

    enhancement 
    opened by zeroeightysix 1
  • Support more scaling filters such as Bicubic or Lanczos

    Support more scaling filters such as Bicubic or Lanczos

    I just thought it would be cool to have a few more scaling filters available, like bicubic and lanczos. Bicubic has looked a bit nicer for downscaling in my experience!

    enhancement 
    opened by Sukid 1
Releases(v0.12.2)
  • v0.12.2(Oct 6, 2022)

    This bugfix release fixes an issue with regions on scaled outputs, updates the wlr-protocols submodule to latest master, and updates the wayland-protocols submodule to 1.26.

    Bugfixes

    • Fixed an issue where coordinates of regions on scaled outputs where not scaled to the actual output texture size when using the dmabuf backend, leading to an incorrect region being displayed.
    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.12.2.tar.gz(178.13 KB)
    wl-mirror_0.12.2-1_amd64_debian-bookworm.deb(25.51 KB)
    wl-mirror_0.12.2-1_amd64_debian-bullseye.deb(25.32 KB)
    wl-mirror_0.12.2-1_amd64_ubuntu-jammy.deb(27.11 KB)
  • v0.12.1(Jul 20, 2022)

    This bugfix release fixes a missing CMake include in 0.12.0 causing man pages to be installed in the wrong location.

    Bugfixes

    • fixed CMAKE_INSTALL_MANDIR not being set by including GNUInstallDirs
    • fixed hardcoded CMAKE_INSTALL_PREFIX/bin path by switching to CMAKE_INSTALL_BINDIR
    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.12.1.tar.gz(176.27 KB)
  • v0.12.0(Jul 19, 2022)

    This documentation release adds manual pages for wl-mirror and wl-present. This release increments a minor version number despite no actual features being added because an optional dependency was added.

    New Features

    • wl-mirror and wl-present now have manual pages that are built using scdoc if available.

    Upgrading

    This release adds a CMake option, INSTALL_DOCUMENTATION that is OFF by default. Users that wish to install the manual pages should compile with -DINSTALL_DOCUMENTATION=ON. Note that turning this option on makes scdoc a required dependency.

    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.12.0.tar.gz(176.26 KB)
  • v0.11.2(Apr 16, 2022)

  • v0.11.1(Apr 11, 2022)

  • v0.11.0(Apr 11, 2022)

  • v0.10.0(Apr 10, 2022)

    This release contains some minor project structure changes and a performance tweak for the screencopy backend. This release also adds the script used to generate the release tar balls to the repo.

    New Scripts

    • release.sh: Generates a release tar ball for the currently checked out commit if there's a release tag on it

    Other Changes

    • The GLSL shaders used by wl-mirror are no longer hardcoded string literals in egl.c and are now files in glsl/ that are embedded into the program at build time.
    • The screencopy backend is now region-aware and uses capture_output_region instead of needlessly capturing the whole output. This should give a slight performance improvement on larger screen resolutions when only mirroring a small region.
    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.10.0.tar.gz(173.31 KB)
  • v0.9.2(Mar 27, 2022)

  • v0.9.1(Mar 27, 2022)

  • v0.9.0(Mar 27, 2022)

    This release contains a major new feature: multiple screen capture backends!

    This will finally (hopefully, I haven't been able to test it completely yet), make wl-mirror work on more exotic GPU setups such as multi-GPU (see #5), since wlr-dmabuf-export does not work there under some conditions.

    This release also contains changes to the --verbose program output. It now includes less needless prints that don't contain information to reduce log spam.

    New Features

    • The --backend or -b option allows selecting between the auto, dmabuf, and screencopy backends.
    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.9.0.tar.gz(171.53 KB)
  • v0.8.2(Mar 11, 2022)

  • v0.8.1(Jan 1, 2022)

    This bugfix release changes the default for installing the new example scripts to OFF.

    Bugfixes

    • Fixed users installing an updated version of wl-mirror receiving an unexpected wl-present program that doesn't work without installing new dependencies. Users wanting the scripts now have to explicitly opt in to install the scripts using -DINSTALL_EXAMPLE_SCRIPTS=ON.
    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.8.1.tar.gz(162.39 KB)
  • v0.8.0(Dec 31, 2021)

    This release adds an example script, wl-present, that demonstrates the use of the -S or --stream option, and adds more information to the README.

    New Scripts

    • wl-present: an example script that demonstrates the use of the -S or --stream option, and allows interactive control of the output or region that is mirrored.
      wl-present depends on pipectl, slurp, and rofi or dmenu

    Upgrading

    This release adds a new CMake option, INSTALL_EXAMPLE_SCRIPTS that is ON by default. Users not wishing to install wl-present into the bin directory should compile with -DINSTALL_EXAMPLE_SCRIPTS=OFF.

    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.8.0.tar.gz(163.27 KB)
  • v0.7.0(Dec 30, 2021)

    This release adds "streaming mode", where wl-mirror will read in additional options from stdin asynchronously, allowing the user to change the mirrored screen, region, or transform settings without restarting wl-mirror. This release also contains a few bug fixes.

    New Features

    • Support receiving additional options on stdin for changing the mirrored screen or region on the fly using the --stream or -S option

    Bugfixes

    • Fix y coordinates of regions being offset slightly due to an incorrect texture transform matrix
    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.7.0.tar.gz(162.11 KB)
  • v0.6.0(Dec 26, 2021)

  • v0.5.0(Nov 18, 2021)

    This release adds the ability to record partial regions of an output and removes some redundancy in the way the OpenGL draw calls are done.

    New Features

    • Support for mirroring custom regions of outputs with the --region or -r option, described using the region syntax of slurp
    Source code(tar.gz)
    Source code(zip)
    wl-mirror-0.5.0.tar.gz(153.27 KB)
  • v0.4.0(Nov 17, 2021)

  • v0.3.1(Nov 13, 2021)

Owner
Ferdinand Bachmann
Computer Science Bachelor Student at TU Graz and member of the CTF Team @LosFuzzys
Ferdinand Bachmann
Triton Python and C++ client libraries and example, and client examples for go, java and scala.

Triton Client Libraries and Examples To simplify communication with Triton, the Triton project provides several client libraries and examples of how t

Triton Inference Server 228 Jan 5, 2023
VEngine-Client - vEngine: Official Client Module

━ S Y N O P S I S ━ Maintainer(s): Aviril, Tron vEngine is Next-Gen Sandbox-Engine being crafted in C++. In contrast to UE/Unity/ReverseEngineered-Mod

ᴠ : ꜱᴛᴜᴅɪᴏ 15 Sep 7, 2022
Pyth-client - client API for on-chain pyth programs

pyth-client client API for on-chain pyth programs Build Instructions # depends on openssl apt install libssl-dev # depends on libz apt install zlib1g

Pyth Network 115 Dec 16, 2022
Webdav-client-cpp - C++ WebDAV Client provides easy and convenient to work with WebDAV-servers.

WebDAV Client Package WebDAV Client provides easy and convenient to work with WebDAV-servers: Yandex.Disk Dropbox Google Drive Box 4shared ownCloud ..

Cloud Polis 103 Jan 1, 2023
This repository provides a C++ client SDK for Unleash that meets the Unleash Client Specifications.

Unleash Client SDK for C++ This repository provides a C++ client SDK for Unleash that meets the Unleash Client Specifications. Features The below tabl

Antonio Ruiz 4 Jan 30, 2022
Mirror of Apache C++ Standard Library

$Id$ Apache C++ Standard Library (STDCXX) 5.0.0 ------------------------------------------ 0 Index -------- Inde

The Apache Software Foundation 56 Oct 6, 2022
Automated upstream mirror for bpftool stand-alone build.

bpftool This is a mirror of bpf-next Linux source tree's tools/bpf/bpftool directory, plus its few dependencies from under kernel/bpf/, and its suppor

null 91 Dec 23, 2022
Simple server and client using python socket and declarative programming

Socket-programming Simple server and client using python socket and declarative programming How to use? open cmd and navigate to the location of the s

MAINAK CHAUDHURI 24 Dec 17, 2022
Simple WHIP Client (based on GStreamer's webrtcbin)

Simple WHIP Client This is an attempt to create a simple prototype of a WHIP client, to be used mostly for testing with my Simple WHIP Server (based o

Lorenzo Miniero 34 Nov 18, 2022
Ole Christian Eidheim 741 Dec 27, 2022
Simple Tcp Chat Client / Server written in C++

What this TcpXat TcpXat Is A Simple Tcp Chat Setup TcpXat sudo apt install make;make client;make serv;echo "done by FuryM3m0ry"; How To Run TcpXat Ter

sami 1 Dec 28, 2021
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio.

A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.

Ole Christian Eidheim 2.4k Dec 23, 2022
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.

Welcome! The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design

Microsoft 7.2k Dec 30, 2022
A C++ header-only HTTP/HTTPS server and client library

cpp-httplib A C++11 single-file header-only cross platform HTTP/HTTPS library. It's extremely easy to setup. Just include the httplib.h file in your c

null 8.3k Dec 31, 2022
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution

CppServer Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and

Ivan Shynkarenka 958 Jan 3, 2023
A portable MQTT C client for embedded systems and PCs alike.

MQTT-C is an MQTT v3.1.1 client written in C. MQTT is a lightweight publisher-subscriber-based messaging protocol that is commonly used in IoT and net

Liam Bindle 570 Dec 29, 2022
C++ client for making HTTP/REST requests

REST client for C++ About This is a simple REST client for C++. It wraps libcurl for HTTP requests. Usage restclient-cpp provides two ways of interact

Daniel Schauenberg 1.4k Dec 30, 2022
Wangle is a framework providing a set of common client/server abstractions for building services in a consistent, modular, and composable way.

Wangle C++ networking library Wangle is a library that makes it easy to build protocols, application clients, and application servers. It's like Netty

Facebook 2.9k Jan 8, 2023
C++ websocket client/server library

WebSocket++ (0.8.2) WebSocket++ is a header only C++ library that implements RFC6455 The WebSocket Protocol. It allows integrating WebSocket client an

Peter Thorson 6k Jan 8, 2023