Score:0

Mirroring the currently focussed window

gq flag

Every now and then, while presenting using a projector, I have the displays set up as extended and have a window on the projector screen for the audience to watch while having my notes, etc. on the laptop screen. Since I'm not facing the projector, it becomes difficult to interact with the windows showing on the projector. Having a copy of the window I wish to project on the projector permits me to interact with the original window, while the audience can see the content of that window only. For this reason, I need to create a copy of a window by using the following commands:

wmctrl -l 

Followed by:

gst-launch-1.0 ximagesrc xid=0x04000007 ! videoconvert ! autovideosink

Changing the xid number with the one for the desired window.

It would be convenient to be able have a keyboard shortcut to mirror the currently active window. Is it possible to create a script or something to:

  1. Get the xid of the focused window.
  2. Create mirror window
  3. (optionally) Place the copy on the external monitor.
Score:0
gq flag

I found a solution myself to this issue using xdotool

I wrote this small script:

#!/usr/bin/env bash

xdotool getwindowfocus | xargs -I% gst-launch-1.0 ximagesrc xid=% ! videoconvert ! autovideosink

I saved it in one folder that is in the %PATH% and made it executable. When I want to mirror a window, I give it focus, then ALT + F2 and run the script. A copy of the window is created that can then manually be put on the external monitor.

gq flag
This works only on XOrg sessions. Would love to have a solution for Wayland sessions.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.