A Wayland native snapshot editing tool, inspired by Snappy on macOS
Go to file
2021-02-15 21:39:45 -05:00
.github/workflows refactor(ci): rename main into build 2020-06-23 23:11:17 -04:00
.vscode chore(vscode): use clang 11 path 2021-02-13 19:32:22 -05:00
docs/images docs(screenshot): update screenshot with 1.0.0 release 2020-06-20 22:44:09 -04:00
example feat(config): have overridable defaults 2020-01-12 22:00:41 -05:00
include refactor(swappy): rename surface variables for clarity 2021-02-15 20:44:01 -05:00
res chore(git): format with new lines at eof 2021-02-15 14:01:43 -05:00
script chore(release): add bump meson script (#39) 2020-06-22 23:03:37 -04:00
src fix(ui): commit state before copying or saving 2021-02-15 21:39:45 -05:00
test/images fix(blur): use rendered surface after commit 2020-06-13 14:42:50 -04:00
.clang-format chore(git): format with new lines at eof 2021-02-15 14:01:43 -05:00
.clang-tidy chore(clang): add more linting tasks 2020-06-13 19:45:57 -04:00
.commitlintrc.yml chore(ci): add commitlint for pull_requests 2020-06-23 23:11:17 -04:00
.gitignore git: ignore glade backup file 2019-12-17 22:26:35 -05:00
.versionrc chore(release): add bump meson script (#39) 2020-06-22 23:03:37 -04:00
CHANGELOG.md chore(release): 1.2.1 2020-07-11 12:17:09 -04:00
LICENSE chore(license): happy new year 2020-07-10 23:19:47 -04:00
meson_options.txt chore(build): allow downstream force enable/disable libnotify 2020-06-26 08:45:44 -04:00
meson.build fix(ui): compute window sizes and buffers properly 2021-02-15 13:53:33 -05:00
README.md docs(readme): add support for Void Linux 2021-01-08 16:14:39 -05:00
swappy.1.scd feat(cli): add configure options for filename save 2020-12-12 13:03:38 -05:00

swappy

A Wayland native snapshot and editor tool, inspired by Snappy on macOS. Works great with grim, slurp and sway. But can easily work with other screen copy tools that can output a final PNG image to stdout. See below.

Screenshot

Swappy Screenshot

Example usage

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

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

Swappshot a PNG file:

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

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
save_filename_format=swappy-%Y%m%d-%H%M%S.png
show_panel=false
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
  • save_filename_format: is the filename template, if it contains a date format, this will be parsed into a timestamp. Format is detailed in strftime(3). If this date format is missing, filename will have no timestamp
  • show_panel is used to toggle the paint panel on or off upon startup
  • 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
  • d: Switch to Blur (d stands for droplet)

  • 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

  • Copy: If you don't have wl-clipboard installed, copy to clipboard won't work if you close swappy (the content of the clipboard is lost). This because GTK 3.24 has not implemented persistent storage on wayland backend yet. We need to do it on the Wayland level, or wait for GTK 4. For now, we use wl-copy if installed and revert to gtk clipboard if not found.
  • Fonts: Swappy relies on Font Awesome 5 being present to properly render the icons. On Arch you can simply install those with: sudo pacman -S otf-font-awesome

Installation

Building from source

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

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

Optional dependencies:

  • wl-clipboard (to make sure the copy is saved if you close swappy)
  • libnotify (not get notified when swappshot is copied or saved)
  • otf-font-awesome (to draw the paint icons properly)

Then run:

meson build
ninja -C build

Contributing

Pull requests are welcome. This project uses conventional commits to automate changelog generation.

Generating a new release

This is only for maintainers, to create a new release. We rely on standard-version which is part of the JavaScript ecosystem but works well with any project.

npx standard-version --sign
git push --follow-tags

License

MIT