naelstrof b8acd68dc2 Merge branch 'master' of github.com:naelstrof/slop | 7 years ago | |
---|---|---|
modules | 7 years ago | |
shaderexamples | 7 years ago | |
src | 7 years ago | |
.gitignore | 7 years ago | |
CMakeLists.txt | 7 years ago | |
COPYING | 10 years ago | |
README.md | 7 years ago | |
license.txt | 10 years ago | |
slop.1 | 7 years ago | |
slop.1.gz | 7 years ago |
slop (Select Operation) is an application that queries for a selection from the user and prints the region to stdout.
slop can be used to create a video recording script in only two lines of code.
#!/bin/bash
read -r X Y W H G ID < <(slop -f "%x %y %w %h %g %i")
ffmpeg -f x11grab -s "$W"x"$H" -i :0.0+$X,$Y -f alsa -i pulse ~/myfile.webm
You can also take images using imagemagick like so:
#!/bin/bash
read -r G < <(slop -f "%g")
import -window root -crop $G ~/myimage.png
If you don't like ImageMagick's import: Check out maim for a better screenshot utility.
Ok. Here's a comparison between 'scrot -s's selection and slop's:
You can see scrot leaves garbage lines over the things you're trying to screenshot! While slop not only looks nicer, it's impossible for it to end up in screenshots or recordings because it waits for DestroyNotify events before completely shutting down. Only after the window is completely destroyed can anything take a screenshot.
Note: Dependencies should be installed first: libxext, OpenGL, and glm.
git clone https://github.com/naelstrof/slop.git
cd slop
cmake -DCMAKE_INSTALL_PREFIX="/usr" ./
make && sudo make install
Slop allows for chained post-processing shaders. Shaders are written in a language called GLSL, and have access to the following data from slop: | GLSL Name | Data Type | Bound to | |------------|----------------|-------------------------------------------------------------------------------------------------| | mouse | vec2 | The mouse position on the screen. | | desktop | sampler2D | An upside-down snapshot of the desktop, this doesn't update as the screen changes. | | texture | sampler2D | The current pixel values of slop's frame buffer. Usually just contains the selection rectangle. | | screenSize | vec2 | The dimensions of the screen, where the x value is the width. | | position | vec2 attribute | This contains the vertex data for the rectangle. Only contains (0,0), (1,0), (1,1), and (0,1). | | uv | vec2 attribute | Same as the position, this contians the UV information of each vertext. | The desktop texture is upside-down because flipping it would cost valuable time.
Shaders must be placed in your ${XDG_CONFIG_HOME}/slop
directory, where XDG_CONFIG_HOME is typically ~/.config/
. This folder won't exist unless you make it yourself.
Shaders are loaded from the --shader
flag in slop. They are delimited by commas, and rendered in order from left to right. This way you can combine multiple shaders for interesting effects! For example, slop -rblur1,wiggle
would load ~/.config/slop/blur1{.frag,.vert}
and ~/.config/slop/wiggle{.frag,.vert}
. Then render the selection rectangle twice, each time accumulating the changes from the different shaders.
Enough chatting about it though, here's some example shaders you can copy to ~/.config/slop
to try out!
And all together now...
Finally here's an example of a magnifying glass.
It's fairly easy to adjust how the shaders work by editing them with your favourite text editor. Or even make your own!