Open giezu opened 4 years ago
ugh.. I didn't thought on that! it's a really good question.
I will look around. if you found a good solution that works for multiple and single monitors set up don't doubt on making a PR. Will be very appreciated.
I'm thinking to make the script that runs the glslViewer a bit more complex and probably using a better scripting language than bash... probably python. The motivation for that is also to support shaders that use geometries and vertex shaders and multiple images.... In that case I think the challenge would be how to excecute multiple instances of glslViewer one for each monitors. Do you have a clear idea how to execute glfw3 apps in different screens ?
Sure thing, I will try to do it later on Gnome3 and i3wm :)
thanks! I'm excited to collaborate on it!
I wrote script that may work, but there are some problems. First I get list of resolution and position of connected displays with xrandr and some filtering with awk/cut. Next I make screenshot of each display and filter offsets of displays (x and y, needed for xdotool later). Now time for glslViewer instance with given screenshot (/tmp/glslScreensaver$i.png) running in background. When I run second instance, I think first one is killed ? I'm not sure, but looks like it stops immediately. Also there is problem with synchronization, when I want to move windows with xdotool sometimes they're not created yet so I can't get window id. Sleep is just a hack that sometimes works sometimes not.
run.sh: `#!/bin/sh
screenshotPath='/tmp/glslScreensaver' extension='.png' displays=$(xrandr | grep connected | awk '{gsub("primary ", "");print}' | cut -d" " -f3 | awk '{gsub(" ", "\n");print}') i=1 echo "$displays" | while IFS= read -r display_pos; do screenshot=${screenshotPath}${i}${extension} import -window root -crop $display_pos $screenshot glslViewer /home/$USER/.glslScreensaver/shader.frag -e cursor,off -ss $screenshot > /dev/null & i=$((i+1)) done
sleep 5 #wait for glslViewer start?
i=1 echo "$displays" | while IFS= read -r display_pos; do xoffset=$(echo $display_pos | cut -d"+" -f2) yoffset=$(echo $display_pos | cut -d"+" -f3) winID=$(xdotool search --name glslViewer | sed "${i}q;d") echo $winID echo $xoffset $yoffset xdotool windowmove $winID $xoffset $yoffset i=$((i+1)) done`
@giezu ! I was just looking into this.
~
folder as ~/.glslScreenSaver.yaml
. Take a look to it... the idea is that will give more flexibility on what kind of shaders we can loadHope this changes gives you more high level tools to work in this
That python script with YAML configuration file looks like a good way. I was thinking about other way, creating multiple OpenGL windows with multiple contexts and passing list of screenshots created for each window to each shader instance but looks like you found easier way :)
I think you will be able to push your approach better in that Python script. I'm failing to lunch glslViewer in a particular screen with DISPLAY=:0.0 glslViewer ...
I just look to your script and seams you lunch it and then move it with xdotool
. Never use it? how it works?
Well, I'm trying to move it with xdotool
but I need window ID to do that. Sometimes I can get id of just one window, because first is killed already, sometimes I don't get any id because I run xdotool
to early. It's tool for moving windows geometry, setting fullscreen/windowed mode etc.
DISPLAY=:0.0
approach may not work because in my case two displays are treated as one bigger screen, one of resolution 1920x1080 with offset 0+0, second one 1440x900 with offset 1920+0 (to the right of primary display).
Hi! It works really well, but I had issue with multi monitor setup on nvidia optimus laptop. gnome-screenshot took screenshot of both monitors, since nvidia drivers treats it as one bigger display. I changed your scrips a bit, so they are using ImageMagick now:
import -window root -crop 1920x1080+0+0 /tmp/glslScreensaver.png
That way I can crop left monitor if I want to run screensaver on left display.So question is: how to run it on several displays? Maybe some tricks using xrandr and grep, to get every display dimensions?