8 ms·
Show HN: X11 tool to share a screen area in any video meeting
- splitbrain 2y agoI have a big 49" wide screen monitor and sharing my screen in Google Meet was cumbersome because you can only share a window or the whole screen, but not a screen region. So I wrote a small tool that uses the xrandr extension to mirror an area to a virtual monitor which then can be shared. See my blog post for some more details: https://www.splitbrain.org/blog/2024-10/11-introducing_clipscreen https://www.splitbrain.org/blog/2024-10/11-introducing_clips...
- prima-facie 2y agoThis is very cool and definitely useful when you have a large screen at your disposal. I have a 27" screen which doesn't give you as much screen real-estate as yours. So what I'm using is a script which spawns a separate Xephyr window as DISPLAY 9, and puts a bunch of windows on that screen. https://gist.github.com/radupotop/d77a47767e2e65a7e7d40d1ea83102a1 https://gist.github.com/radupotop/d77a47767e2e65a7e7d40d1ea8... I use this as my demo environment.
- kees99 2y agoNeat trick. Another, similar one, is possible with "xrandr --setmonitor". That doesn't require starting a separate X server & WM instance: https://askubuntu.com/q/150066#998435 https://askubuntu.com/q/150066#998435 However, both Xephyr/Xnest and "xrandr --setmonitor" create separate non-overlapping screen(s), which means sharing part of a window (say, browser sans chrome [1]) can't be done here, but is possible with OP's tool. [1] EDIT: "chrome", as in - parts of browser's window other than webpage itself: tabs, URL bar, bookmarks, etc...
- TZubiri 2y ago[flagged]
- ceooflinux 2y ago[flagged]
- splitbrain 2y agoI'm not sure what you are referring to. What's the proprietary solution you're suggesting here?
- squilliam 2y agoOBS has had the ability to do this for quite some time
- ragebol 2y agoAs per the blog post, only Zoom allows to stream a selected area of the screen. What other proprietary SW can do this? With this tool, they should all be able to
- z991 2y agoWow, this is fantastic! This exact use case, on Linux, is why our company selected Zoom instead of Meet. Awesome!
- z991 2y agoBuilt it and took a fullscreen screenshot with GIMP to figure out the width/height/x/y coordinates I wanted and tested with Google Meet. Working perfectly!
- machinestops 2y agohttps://github.com/naelstrof/slop https://github.com/naelstrof/slop Can also use a utility like this one, which lets you select an area of the screen and output it in a specified format.
- z991 2y agoWow that is also very cool. For those wondering, this is what it looks like: $ sudo apt install slop $ slop <selects an area on screen> 1719x1403+1080+277
- machinestops 2y agoPutting the two together is easy too: $ clipscreen $(slop -F "%x %y %w %h") NB. The lack of quotes around $() enables wordsplitting to occur.
- samwhiteUK 2y agoOr $ clipscreen $(slop | tr -s "+x" " ")
- Narishma 2y agoI think you got the size and position switched.
- 2y ago
- amelius 2y agoNice. This is the first time I read about creating a virtual monitor in X.
- OsrsNeedsf2P 2y agoI love how simple this is- Barely 100 lines or C++ (ignoring comments). That's one thing that makes me prefer X11 over Wayland.
- asveikau 2y agoThe code is a little weird. There is no XLib event loop. It calls sleep(100) in a loop until it hits SIGINT. That will have high cpu usage for no reason.
- splitbrain 2y agoFYI the code has been updated to use sigwait instead.
- diath 2y agoIt will not, even adding just a 1ms sleep in a loop will drop CPU usage to barely noticeable levels, 10 wakes a second is barely anything for any CPU from the past 3 decades.
- asveikau 2y agoNot my experience at all. Granted I haven't tried writing a loop like this in 20ish years, because once you spot that mistake you don't tend to make it again, and CPUs are better now. Another thing to note is when you call sleep with a low value it may decide not to sleep at all, so this loop just might be constantly doing syscalls in a tight loop.
- diath 2y ago> Not my experience at all. Granted I haven't tried writing a loop like this in 20ish years, because once you spot that mistake you don't tend to make it again, and CPUs are better now. You can trivially verify it by running the following, I have personally been using "sleep for 1ms in a loop to prevent CPU burn" for years and never noticed it having any impact, it's not until I go into microseconds when I can start noticing my CPU doing more busy work. // g++ -std=c++20 -osleep sleep.cpp #include <thread> #include <chrono> int main(int, char **) { while (true) { std::this_thread::sleep_for(std::chrono::milliseconds {1}); } return 0; } > Another thing to note is when you call sleep with a low value it may decide not to sleep at all, so this loop just might be constantly doing syscalls in a tight loop. On what system? AFAIK, if your sleep time is low enough, it will round up to whatever is the OS clock resolution multiple, not skip the sleep call completely. On Linux, it will use nanosleep(2) and I cannot see any mention of the sleep not suspending the thread at all with low values.
- Brajeshwar 2y agoAlso, I remember a friend showing me in Zoom that you can share not just one but multiple screens/windows—press the SHFT key while clicking the windows you want to share.
- HPsquared 2y agoHow do people discover these things?
- Brajeshwar 2y agoThe same question I asked (that was me after using Zoom for 3+ years).
- jdbdndj 2y agoIsn't that the same of how you select multiple files in most file managers? Shift+Click: select from currently selected item to clicked item Ctrl+Click: add/remove clicked item to set of selected items
- hackernewds 2y agoSure, but the idea you can share multiple windows this way. Can Google Meet (or hangout or w/e they call it now adays) do some of this?
- starkparker 2y agoReading documentation, usually: Sharing your desktop, screen, or content in https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0060596#collapseMacPC https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_arti... More useful shortcuts in https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_article=KB0067050 https://support.zoom.com/hc/en/article?id=zm_kb&sysparm_arti...
- TacticalCoder 2y agoThat s very cool... Speaking of which: any easy way to allow two people, both on X, to both share and interact (keyboard and mouse) with a common X window? The app that we d like to share and both control is a browser (running on a machine on our LAN) so a browser extension would work too I guess.
- patrakov 2y agoMy preferred solution for that would be a VNC server (so that it shares the whole screen) installed in a VM.
- bee_rider 2y agoI think there was some way to do that with existing tools. I forget the details because I only threw it together as a bit of fun novelty. I think the terms to google are x2x and multiseat though, at least to start your search…
- benjiweber 2y agoThis is brilliant. I've wanted this so many times and had to awkwardly switch between window being shared instead.
- fweimer 2y agoI wouldn't mind switching between windows if I could use the GNOME Activities overview for that. But maybe that is not possible because there is no way to communicate the change in stream size if the windows have different sizes?
- snowe2010 2y agoDang. I need this for Mac. I’ve been wishing I had exactly this for years.
- thefreeman 2y agoI use "Advanced Screen Share" for this purpose. it has a one time purchase if you want to remove a small overlay but it gets the job done and is installable through the app store.
- _joel 2y agoWasn't the same thing posted for MacOS a few days back, can't recall the name? Looking at the time on the repo makes me think the author pushed after seeing people requesting something similar for Linux. edit: Here you go https://github.com/Stengo/DeskPad https://github.com/Stengo/DeskPad
- joombaga 2y agoThat's not quite the same. With DeskPad you have to move the window to the virtual monitor. clipscreen allows you to select a portion of your screen without moving any windows.
- zczc 2y agoDeskPad was discussed there: https://news.ycombinator.com/item?id=41800602 https://news.ycombinator.com/item?id=41800602 And for Windows there is RegionToShare https://github.com/tom-englert/RegionToShare https://github.com/tom-englert/RegionToShare
- iknowstuff 2y agoyou can just share multiple windows on the newest macOS and they will ne nicely arranged for viewers. You can even add the presenter thing to show your face next to them.
- ho_schi 2y agoNeat. Now I want for Wayland. Don’t use X11 for some years.
- singpolyma3 2y agoNever to late to upgrade to X11 :)
- udev4096 2y agoThis is only helpful if you are using a desktop environment. What about window managers like i3?
- hamdouni 2y agoI'm not sure about i3 but you can have floating windows in DWM and move them to the targeted area with the mouse
- salviati 2y agoDo I understand correctly that you could to this with OBS on any platform, including Wayland? I'm reading many comments that make me think either many people don't know about OBS, or I'm overestimating it's abilities.
- splitbrain 2y agoYou probably can. I never used OBS, but it's probably a bit more than a 20kb binary though ;-)
- lopkeny12ko 2y agoI don't understand, what is the significance of a 20kb binary? The only person using this would be someone who takes Zoom meetings on a company-issued computer and I can't imagine such machines are disk space-constrained.
- phkahler 2y agoOBS lets you share a window or just the client area of an app.
- movedx 2y agoWith OBS, you can add an entire screen to your canvas and then add a filter to crop it down to a particular part of that screen. This nets you the same results as the small C++ tool being proposed here. A lot more work involved, though.
- procparam 2y agoI've always wanted something like this, but for i3 workspaces. Something like "share workspace 2." Anyone know how to accomplish this?
- tincholio 2y agoThat only works if the workspace is on an actual screen, because it's otherwise not rendered. Maybe the virtual monitor solution via xrandr would work for that, but I haven't yet tried that.
- alanjames00 2y agoI've looking for something like this for quite sometime. It's simple, clean and elegant.
- tcsenpai 2y agoThis is surely useful right now. I wonder what will happens to all the nice X11 tools once Wayland (hopefully soon) will be the golden standard. There are options to enable X11 behaviors in Wayland but I guess that is just a fallback to the insecure implementation.
- attah_ 2y agoI was just about to go looking for something like this! I'll look so pro on the meeting tomorrow :)
- yazzku 2y agoCan you not use std::condition_variable to avoid the active waiting of the signal?
- IceDane 2y agoYou can literally do this with just xrandr. xrandr --setmonitor screenshare 2560/1x1440/1+0+0 none
- attah_ 2y agoIn fairness; that and the overlay is what is happening, just from C++. Props for nice oneliner none the less. :)
- deleted 2y ago[deleted]
- Liskni_si 2y agoTo make the selection interactive, the command becomes: geo=$(slop -f '%w/1x%h/1+%x+%y') && xrandr --setmonitor screenshare "$geo" none
- Liskni_si 2y agoAlso looks like one can just do xrandr --delmonitor screenshare before this to seamlessly update the shared region — Chrome will immediately pick up the change and continue sharing the updated virtual monitor.
- 0cf8612b2e1e 2y agoCan someone explain why this is still an unmet need within the current video conference platforms? Giant monitors have become increasingly common-especially for the developers who might be working on these tools.
- simonmysun 2y agoMaybe because a workaround with OBS isn't that difficult?
- movedx 2y agoYou might have missed the point being made here. We, as engineers, can't expect everyone to know what OBS is, download it, learn in, and use it every day to enable their ability to share a sub-section of their monitor (regardless of its size.) We, as engineers, _are_ expected to make our software easier to use and feature rich. Adding this capability into Zoom or Meet, etc. is a reasonable thing to expect from a software company of note. And people _do_ know what Zoom and Meet are, download them, learn them, and use them every day. Why not implement the feature directly into the software they're already using?
- wink 2y agoAlso which percentage of people taking part in meetings with screen sharing are even allowed to "just install" OBS? More for developers, much less for other office workers.
- simonmysun 2y agoI mean a possible alternative can be a huge resistance. Users knowing this should be feasible probably know OBS, and other users may never thought of this possibility. I can't deny the effort the author here have done. It is very useful and convenient. I just gave an explanation of why this comes so late.
- shmerl 2y agoI'm waiting for ffmpeg to implement pipewire screen grab so it could work on Wayland.
- yanchep 2y agoWhen I click share in Jitsi (or whatever) on KDE 6.1 w/ Wayland in Chromium, I get offered to share the 'Entire Screen". After that dialog another one pops up with the options 'Full Workspace', 'New Virtual Output', 'Rectangular Region' and a list of my displays. 'Rectangular Region' allows to share a selected part of the screen, 'New Virtual Output' instantly creates a virtual screen, visible in KDE 'Display Configuration' that may or may not be positioned on top of pre-existing physical displays.
- zh3 2y agoYou can do this with xzoom, which also allows magnification from x1 upwards - is there an advantage I'm missing here?
- alexcroox 2y agoWith my 49" I use OBS + Mouse follow script + OBS preview window on laptop screen and share my entire laptop screen. That way I know the window size is suitable for others viewing from their laptops and the preview follows my mouse and you can tweak zoom levels and mouse boundaries on the fly. Also the OBS preview window opens on launch, without opening the main OBS window. So you never have to see/interact with the main OBS window/application again so it really feels standalone which is great. https://github.com/BlankSourceCode/obs-zoom-to-mouse https://github.com/BlankSourceCode/obs-zoom-to-mouse
- brazzledazzle 2y agoThis is so cool. Seeing the word splitbrain definitely gave me a moment of dreaded recollection though, not gonna lie. Not a fun place to be when you're dealing with databases and clusters.