#selection #x11 #screenshot #nexromancers

app hacksaw

Lightweight selection tool for usage in screenshot scripts etc

5 stable releases

1.0.4 Apr 1, 2020
1.0.3 Mar 29, 2020
1.0.1 Mar 28, 2020

#556 in Unix APIs

Download history 41/week @ 2024-07-22 22/week @ 2024-07-29 18/week @ 2024-08-05 13/week @ 2024-08-12 16/week @ 2024-08-19 14/week @ 2024-08-26 13/week @ 2024-09-02 20/week @ 2024-09-09 14/week @ 2024-09-16 34/week @ 2024-09-23 22/week @ 2024-09-30 24/week @ 2024-10-07 26/week @ 2024-10-14 15/week @ 2024-10-21 15/week @ 2024-10-28 20/week @ 2024-11-04

78 downloads per month

Custom license

27KB
584 lines

hacksaw lets you select areas of your screen

(on x11)

screencast

Installation

Dependencies

Before installing, make sure you have the following libraries installed (this list is non-exhaustive):

  • xcb-shape
  • xcb-xkb

On systems with apt, you should be able to run:

apt install libxcb-shape0-dev libxcb-xkb-dev

Once you have the dependencies

Simply run cargo install hacksaw to install from crates.io.

Manual installation alternative

Clone this repo, cd into it, and run cargo install --path .

Examples

Take a screenshot (with shotgun) of a selection/window and copy to clipboard

selection=$(hacksaw)  # add hacksaw arguments inside as you wish
shotgun -g "$selection" - | xclip -t 'image/png' -selection clipboard

Take a screenshot of a selection/window and save to a file

selection=$(hacksaw)  # add hacksaw arguments inside as you wish
shotgun -g "$selection" screenshot.png

Record an area of the screen with ffmpeg

#!/bin/sh
#
# record - record an area of the screen

dir=~/medias/videos/records
current=$(date +%F_%H-%M-%S)

mkdir -p "$dir"

hacksaw -n | {
    IFS=+x read -r w h x y

    w=$((w + w % 2))
    h=$((h + h % 2))

    ffmpeg               \
        -v 16            \
        -r 30            \
        -f x11grab       \
        -s "${w}x${h}"   \
        -i ":0.0+$x,$y"  \
        -preset slow     \
        -c:v h264        \
        -pix_fmt yuv420p \
        -crf 20          \
        "$dir/$current.mp4"
}

Also: open a terminal with the selected size and shape (on bspwm)

Features

  • Guide Lines to check precise positions and line up before you start a selection
    • just like the popular Guides shader for slop
  • doesn't instantly quit on first keypress
    • keep typing like a pro while you screenshot your memes
    • (tiling wm exclusive) you can still navigate windows while in hacksaw
  • select with any mouse button, not just left click!
    • except right click, that's cancel
    • restart selection by scrolling scrollwheel
  • you can customise the colour and width of the lines
    • and you can customise the width of selection and guide lines separately!
  • did i mention it's written in RUST
  • lightweight and fast
    • not that i've actually run any performance comparisons to slop
  • one of Thor's favorites
  • built for the most advanced and cutting edge platform of today, X11

Stability

  • Main functionality is all there and pretty solid
  • You may experience bugs when invoking hacksaw while a popup is open

Usage

USAGE:
    hacksaw [FLAGS] [OPTIONS]

FLAGS:
    -h, --help         Prints help information
    -n, --no-guides    Disable fighter pilot guide lines
    -V, --version      Prints version information

OPTIONS:
    -f, --format <format>
            Output format. You can use:
                  %x for x-coordinate,
                  %y for y-coordinate,
                  %w for width,
                  %h for height,
                  %i for selected window id,
                  %g as a shorthand for %wx%h+%x+%y (X geometry),
                  %% for a literal '%'.
            Other %-codes will cause an error. [default: %g]
    -g, --guide-thickness <guide-thickness>          Thickness of fighter pilot guide lines [default: 1]
    -c, --colour <line-colour>
            Hex colour of the lines (RGB or RGBA), '#' optional [default: #7f7f7f]

    -r, --remove-decorations <remove-decorations>
            Number of (nested) window manager frames to try and remove [default: 0]

    -s, --select-thickness <select-thickness>        Thickness of selection box lines [default: 1]

Dependencies

~4.5MB
~83K SLoC