A Wayland native snapshot editing tool, inspired by Snappy on macOS
Go to file
2020-05-31 23:25:37 -04:00
.github/workflows chore(ci): apt-get update before script 2020-01-19 23:48:55 -05:00
.vscode chore(vscode): add large file test 2020-05-31 23:25:37 -04:00
docs/images docs(readme): update documentation 2019-12-28 19:50:47 -05:00
example feat(config): have overridable defaults 2020-01-12 22:00:41 -05:00
include fix(ui/render): adjust rendering based on window size 2020-05-18 00:18:03 -04:00
protocol revert:"wip(copy): handle data control protocol" 2020-01-05 16:30:37 -05:00
res feat(text): add controls in toggle panel 2020-01-05 16:17:19 -05:00
src fix(render): fix arrow glitch with 0 ftx 2020-05-24 16:14:38 -04:00
test/images chore(vscode): add large file test 2020-05-31 23:25:37 -04:00
.clang-format works, next is screencopy 2019-11-24 23:07:44 -05:00
.gitignore git: ignore glade backup file 2019-12-17 22:26:35 -05:00
LICENSE Initial commit 2019-11-19 00:21:06 -05:00
meson_options.txt feat: init project 2019-11-19 00:23:34 -05:00
meson.build fix(dependencies): include glib2 2020-05-17 12:58:43 -04:00
README.md fix(dependencies): include glib2 2020-05-17 12:58:43 -04:00
swappy.1.scd feat(application): print final surface to file or stdout 2020-01-19 23:48:55 -05:00

swappy

A Wayland native snapshot and editor tool, inspired by Snappy on macOS. Works great with grim, slurp and sway. Also works with other screenshot tools if you use the -f option. See below.

Wayland code was largely taken from grim and requires a compositor that implements the wlr-screencopy-unstable-v1 protocol.

You can use this tool in two ways, either use it as the output of grim (recommended) or grab the geometry yourself (wayland code is still WIP).

Screenshot

Swappy Screenshot

Example usage

Output of grim (or any tool outputing a PNG file):

grim -g "$(slurp)" - | swappy -f -

Swappshot a PNG file (good for compositors not supporting screencopy protocol):

swappy -f "~/Desktop/my-gnome-saved-file.png"

Swappshot a region:

swappy -g "100,100 200x200"

Select a region and swappshot it:

swappy -g "$(slurp)"

Print final surface to stdout (useful to pipe with other tools):

grim -g "$(slurp)" - | swappy -f - -o - | pngquant -

Grab a swappshot from a specific window under Sway, using swaymsg and jq:

grim -g "$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)" - | swappy -f -

Config

The config file is located at $XDG_CONFIG_HOME/swappy/config or at $HOME/.config/swappy/config.

The file follows the GLib conf format. See the man page for details. There is example config file here.

The following lines can be used as swappy's default:

	[Default]
	save_dir=$HOME/Desktop
	line_size=5
	text_size=20
	text_font=sans-serif
  • save_dir is where swappshots will be saved, can contain env variables and must exist in your filesystem
  • line_size is the default line size (must be between 1 and 50)
  • text_size is the default text size (must be between 10 and 50)
  • text_font is the font used to render text, its format is pango friendly

Keyboard Shortcuts

  • Ctrl+b: Toggle Paint Panel

  • b: Switch to Brush
  • t: Switch to Text
  • r: Switch to Rectangle
  • o: Switch to Ellipse
  • a: Switch to Arrow

  • R: Use Red Color
  • G: Use Green Color
  • B: Use Blue Color
  • C: Use Custom Color
  • Minus: Reduce Stroke Size
  • Plus: Increase Stroke Size
  • Equal: Reset Stroke Size
  • k: Clear Paints (cannot be undone)

  • Ctrl+z: Undo
  • Ctrl+Shift+z or Ctrl+y: Redo
  • Ctrl+s: Save to file (see man page)
  • Ctrl+c: Copy to clipboard
  • Escape or q or Ctrl+w: Quit swappy

Limitations

Installation

Building from source

Install dependencies (on Arch, name can vary for other distros):

  • meson
  • ninja
  • wayland
  • cairo
  • pango
  • gtk
  • glib2
  • scdoc

Optional dependencies:

  • wayland-protocols (for the -g option to work with wlr-screencopy-unstable-v1 protocol)
  • wl-clipboard (to make sure the copy is saved if you close swappy)
  • libnotify (not get notified when swappshot is copied or saved)

Then run:

meson build
ninja -C build

Contributing

Pull requests are welcome.

License

MIT