• Stars
    star
    845
  • Rank 53,657 (Top 2 %)
  • Language
    C++
  • License
    Other
  • Created about 11 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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 <<< $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 <<< $slop
import -window root -crop $G ~/myimage.png

Furthermore, if you are adventurous, you can create a simple script to copy things from an image itself, unselectable pdf, or just VERY quick rectangular selection or for places where there is no columnar selection (very useful for dataoperators)

You need to have tesseract with support for the specific language, xclip and others are nice if you just want them in clipboard.

#!/bin/env bash

imagefile="/tmp/sloppy.$RANDOM.png"
text="/tmp/translation"
echo "$imagefile"
slop=$(slop -f "%g") || exit 1
read -r G <<< $slop
import -window root -crop $G $imagefile
tesseract $imagefile $text 2>/dev/null 
cat $text".txt" | xclip -selection c

GIF Example of tesseract

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!

More Repositories

1

maim

maim (make image) takes screenshots of your desktop. It has options to take only a region, and relies on slop to query for regions. maim is supposed to be an improved scrot.
C++
2,135
star
2

UnityJigglePhysics

A unity addon for adding stretchy bouncy physics to bones and meshes.
ShaderLab
257
star
3

VRPlayspaceMover

A little app that lets you adjust your play-space by gripping the universe!
C++
157
star
4

SkinnedMeshDecals

An example of rendering decals on SkinnedMesh Renderers in Unity.
ShaderLab
152
star
5

UnityPenetrationTech

A gpu-based deformation system for mapping penetrators along orifice paths.
ShaderLab
103
star
6

KoboldKare

A public repo for the game KoboldKare
C#
87
star
7

UnitySourceTools

Some tools that I use to port source maps to Unity.
C#
31
star
8

ShapedAudioReverbZones

A Unity implementation for arbitrarily shaped Reverb Zones.
C#
23
star
9

URPUnityTerrainTools

Some brush-based tools for creating terrains in Unity. WIP
ShaderLab
11
star
10

ChurnVectorSDK

Tools to develop characters and maps for Churn Vector.
GLSL
9
star
11

astrostructlove

A SS13 clone designed on the Love2D framework with proper networking.
Lua
7
star
12

UnityBehaviorTreeImplementation

An example of how to implement behavior trees within Unity.
C#
7
star
13

slop-python

Slop bindings for python3. Requires slop: https://github.com/naelstrof/slop
C
5
star
14

invictus

Hobby engine built using SFML.
C++
5
star
15

UnityMozzarellaTech

Some gpu related experiments involving mozzarella somewhat.
ShaderLab
4
star
16

auto-usb-arch-scripts

Mainly for personal use, I take no responsibility!
Shell
4
star
17

astrostructlove2

Another prototype for my game engine.
Lua
3
star
18

VRCLipSyncOSC

A lightweight C++ implementation of VRChat lip sync. Uses lua to configure.
C++
3
star
19

PugBot-Discord-Django

UT4Pugs.us pugbot
JavaScript
3
star
20

liveamp

Flashes your desktop wallpaper to music currently playing!
C++
3
star
21

wallpaper-post-processor

scans a directory for images to collage into appropriately sized desktop wallpapers. Uses OpenCV AI to upscale and match resolutions between photos.
Rust
3
star
22

com.naelstrof.inflatable

A limited tween solution for making body parts go boowomp in my games. For personal use.
C#
3
star
23

com.naelstrof.splines

Crude tools to do math on splines.
C#
2
star
24

UnityScriptableSettings

A tool to help with creating, localizing, and subscribing to serializable user preferences.
ShaderLab
2
star
25

2420-C-Sharp-Sorts-and-Data-Structures

Homework Assignments
C#
2
star
26

Pong

For my buddy max <3
C++
2
star
27

GodotJigglePhysics

Messing around porting jiggle physics from unity to godot.
C#
2
star
28

quadtrees

C++
2
star
29

SpaceJanitor

A machinima production for EAE 3660-02.
2
star
30

omnichem

Chemistry buddy for goonchem :honk:
JavaScript
2
star
31

Syme

Another iteration of the many game engines I'm working on. This one in particular has a 2D focus and relies on SFML for pretty much everything.
C++
2
star
32

DynamicPenetrationForGames

Tools that assist with penetration in the Unity Engine.
ShaderLab
2
star
33

com.naelstrof.easing

A library of MIT easing function implementations for Unity.
C#
2
star
34

com.naelstrof.orbitcam

A data-driven programmable camera solution for Unity. Just for personal use.
C#
1
star
35

com.naelstrof.extensions

A collection of extension methods that I use in my games.
C#
1
star
36

UnityFlocking

A tool designed to help you add foliage to scenes.
GLSL
1
star
37

com.naelstrof.projectiles

A tool that will help shoot a projectile on an intersection course.
C#
1
star
38

2420-DingoDanger

Another homework assignment, this time a GAME!
C#
1
star
39

BodegaBash

Game WIP
Mathematica
1
star
40

laser_pointer

Lets you point at people's screen remotely.
Rust
1
star