Code Monkey home page Code Monkey logo

slop's Introduction

slop

slop (Select Operation) is an application that queries for a selection from the user and prints the region to stdout.

Features

  • Hovering over a window will cause a selection rectangle to appear over it.
  • Clicking on a window makes slop return the dimensions of the window, and it's ID.
  • OpenGL accelerated graphics where possible.
  • Supports simple arguments:
    • Change selection rectangle border size.
    • Select X display.
    • Set padding size.
    • Force window, or pixel selections with the tolerance flag.
    • Set the color of the selection rectangles to match your theme! (Even supports transparency!)
    • Remove window decorations from selections.
  • Supports custom programmable shaders.
  • Move started selection by holding down the space bar.

Practical Applications

slop can be used to create a video recording script in only three lines of code.

#!/bin/bash
slop=$(slop -f "%x %y %w %h %g %i") || exit 1
read -r X Y W H G ID < <(echo $slop)
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
slop=$(slop -f "%g") || exit 1
read -r G < <(echo $slop)
import -window root -crop $G ~/myimage.png

If you don't like ImageMagick's import: Check out maim for a better screenshot utility.

Lets see some action

Ok. Here's a comparison between 'scrot -s's selection and slop's:

scrotbad slopgood

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.

how to install

Install using your Package Manager (Preferred)

Install using CMake (Requires CMake)

Note: Dependencies should be installed first: libxext, glew, and glm.

git clone https://github.com/naelstrof/slop.git
cd slop
cmake -DCMAKE_INSTALL_PREFIX="/usr" ./
make && sudo make install

Shaders

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 vertex.

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 from shaderexamples to ~/.config/slop to try out!

The files listed to the right of the | are the required files for the command to the left to work correctly.

  • slop -r blur1,blur2 -b 100 | ~/.config/slop/{blur1,blur2}{.frag,.vert}

slop blur

  • slop -r wiggle -b 10 | ~/.config/slop/wiggle{.frag,.vert}

slop animation

And all together now...

  • slop -r blur1,blur2,wiggle -b 50 -c 1,1,1 | ~/.config/slop/{blur1,blur2,wiggle}{.frag,.vert}

slop animation

Finally here's an example of a magnifying glass.

  • slop -r crosshair | ~/.config/slop/crosshair{.frag,.vert}

slop animation

It's fairly easy to adjust how the shaders work by editing them with your favourite text editor. Or even make your own!

slop's People

Contributors

naelstrof avatar soapgentoo avatar lilyinstarlight avatar stevenhoneyman avatar winny- avatar nylen avatar jfly avatar goberghen avatar leo60228 avatar alezost avatar pitasi avatar cicku avatar conradludgate avatar 9ary avatar nicop06 avatar rafi avatar riri avatar darkwater avatar samuel-hunter avatar shadowkyogre avatar stuartlangridge avatar vaygr avatar koalaman avatar njhanley avatar unek avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.