GithubHelp home page GithubHelp logo

jtheoof / swappy Goto Github PK

View Code? Open in Web Editor NEW
959.0 9.0 39.0 981 KB

A Wayland native snapshot editing tool, inspired by Snappy on macOS

License: MIT License

C 92.49% Meson 3.40% CSS 0.53% JavaScript 0.41% Shell 3.17%
wayland snapshot snappy sway screenshot annotation-tool

swappy's Introduction

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 image to stdout. See below.

Screenshot

Swappy Screenshot

Example usage

Output of grim (or any tool outputting an image 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
paint_mode=brush
early_exit=false
fill_shape=false
  • save_dir is where swappshots will be saved, can contain env variables, when it does not exist, swappy attempts to create it first, but does not abort if directory creation fails
  • 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
  • paint_mode is the mode activated at application start (must be one of: brush|text|rectangle|ellipse|arrow|blur, matching is case-insensitive)
  • early_exit is used to make the application exit after saving the picture or copying it to the clipboard
  • fill_shape is used to toggle shape filling (for the rectangle and ellipsis tools) on or off upon startup

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
  • f: Toggle Shape Filling
  • k: Clear Paints (cannot be undone)

  • Ctrl: Center Shape (Rectangle & Ellipse) based on draw start

  • 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)
  • otf-font-awesome (to draw the paint icons properly)

Then run:

meson setup build
ninja -C build

i18n

This section is for developers, maintainers and translators.

To add support to a new locale or when translations are updated:

  1. Update src/po/LINGUAS (when new locales are added)
  2. Generate a new po file (ignore and do not commit potential noise in other files):
ninja -C build swappy-update-po

To rebuild the base template (should happen less often):

ninja -C build swappy-pot

See the meson documentation for details.

Contributing

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

Release

We rely on standard-version which is part of the JavaScript ecosystem but works well with any project.

./script/github-release

Make sure everything is valid in the Draft release, then publish the draft.

Release tarballs are signed with this PGP key: F44D05A50F6C9EB5C81BCF966A6B35DBE9442683

License

MIT

swappy's People

Contributors

ammgws avatar apiraino avatar bhepple avatar blurgyy avatar brodi1 avatar city-busz avatar emlove avatar flowln avatar jbeich avatar jmcelroy01 avatar jtheoof avatar jubalh avatar kianmeng avatar maxverevkin avatar moetayuko avatar nickhastings avatar oersen avatar seppesoete avatar snakedye avatar xfgusta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swappy's Issues

[new feature] button to open sidepanel

Hi,
It would be cool if there was a button to open the side panel so that I don't have to open yet another key shortcut.

as on the top of the following image:
Swappshot Thu Jun  4 17:40:31 2020

Close button

Would is be possible to add a close button?

As with many sway installs, a title bar is mostly non-existent. I think a close button would be beneficial.

Fails to build

Hi,

I get

The Meson build system
Version: 0.52.1
Source dir: /tmp/nix-build-swappy-2020-02-26.drv-0/source
Build dir: /tmp/nix-build-swappy-2020-02-26.drv-0/source/build
Build type: native build
Project name: swappy
Project version: 1.0.0
C compiler for the host machine: /nix/store/1kn7fi3hhi33jms3113riyzwyn2yqpqd-gcc-wrapper-9.2.0/bin/cc (gcc 9.2.0 "gcc (GCC) 9.2.0")
C linker for the host machine: GNU ld.bfd 2.31.1
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /nix/store/w6pfcj87889hgz0f77blq59z85mdrsh8-pkg-config-0.29.2/bin/pkg-config (0.29.2)
Run-time dependency cairo found: YES 1.16.0
Run-time dependency pango found: YES 1.44.7
Library m found: YES
Library rt found: YES
Run-time dependency gtk+-3.0 found: YES 3.24.13
Run-time dependency wayland-client found: YES 1.18.0
Run-time dependency wayland-cursor found: YES 1.18.0
Run-time dependency wayland-protocols found: YES 1.18
Run-time dependency libnotify found: YES 0.7.8
Found pkg-config: /nix/store/w6pfcj87889hgz0f77blq59z85mdrsh8-pkg-config-0.29.2/bin/pkg-config (0.29.2)
Program wayland-scanner found: YES (/nix/store/iy3kwxmv486mjm9qd9mszrh7by92bjch-wayland-1.18.0/bin/wayland-scanner)
Program scdoc found: YES (/nix/store/6fl4pl3l742in7pzndxw2syg1hrzykhf-scdoc-1.10.1/bin/scdoc)
Program sh found: YES (/nix/store/1iaxkm0941nj1m4m5g4fxgg4cq5jckf0-bash-4.4-p23/bin/sh)
Build targets in project: 5
Found ninja-1.10.0 at /nix/store/5x6l9s9idzf44np1wz1kv8pyq246q98h-ninja-1.10.0/bin/ninja
meson: enabled parallel building
building
build flags: -j4 -l4
[17/31] Compiling C object 'swappy@exe/src_buffer.c.o'.res_swappy.c.o'.ed_wlr-screencopy-unstable-v1-protocol.c.o'.
FAILED: swappy@exe/src_buffer.c.o 
/nix/store/1kn7fi3hhi33jms3113riyzwyn2yqpqd-gcc-wrapper-9.2.0/bin/cc -Iswappy@exe -I. -I.. -I../include -Ires -I/nix/store/a92yhf0icjl9lh553s4qjchdsm8lyzsy-cairo-1.16.0-dev/include/cairo -I/nix/store/1zlkr4x0bvxw3mn65chw9v3b48n8jh52-freetype-2.10.1-dev/include/freetype2 -I/nix/store/1zlkr4x0bvxw3mn65chw9v3b48n8jh52-freetype-2.10.1-dev/include -I/nix/store/5ad0cyv6lxpkk2m1prcrasdp2pysz73q-glib-2.62.4-dev/include -I/nix/store/5ad0cyv6lxpkk2m1prcrasdp2pysz73q-glib-2.62.4-dev/include/glib-2.0 -I/nix/store/vwvjrh97byihk40gwl26f0lnb3w405cv-glib-2.62.4/lib/glib-2.0/include -I/nix/store/sm843466f7cvhf1b804jjlay1nv7fyq0-pango-1.44.7-dev/include/pango-1.0 -I/nix/store/70yjv9sr9mhf75bliwmmxgyr37mx9lac-harfbuzz-2.6.4-dev/include/harfbuzz -I/nix/store/i5yw4gdhknqahzhkaqjfbgc9ydb2885w-gtk+3-3.24.13-dev/include/gtk-3.0 -I/nix/store/vmm5hrcbqrb7b605dnir17qbiz85x17n-atk-2.34.1-dev/include/atk-1.0 -I/nix/store/4w16ai3cx8sp7av9kc432w34r4fpdmfp-gdk-pixbuf-2.40.0-dev/include/gdk-pixbuf-2.0 -I/nix/store/i1mssjnbih9czf12fcda1883pvkirgss-libnotify-0.7.8-dev/include -I/nix/store/iy3kwxmv486mjm9qd9mszrh7by92bjch-wayland-1.18.0/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Werror -std=c11 -Wno-unused-parameter -DHAVE_LIBNOTIFY -DHAVE_WAYLAND_PROTOCOLS -MD -MQ 'swappy@exe/src_buffer.c.o' -MF 'swappy@exe/src_buffer.c.o.d' -o 'swappy@exe/src_buffer.c.o' -c ../src/buffer.c
../src/buffer.c: In function 'randname':
../src/buffer.c:12:3: error: implicit declaration of function 'clock_gettime' [-Werror=implicit-function-declaration]
   12 |   clock_gettime(CLOCK_REALTIME, &ts);
      |   ^~~~~~~~~~~~~
../src/buffer.c:12:17: error: 'CLOCK_REALTIME' undeclared (first use in this function)
   12 |   clock_gettime(CLOCK_REALTIME, &ts);
      |                 ^~~~~~~~~~~~~~
../src/buffer.c:12:17: note: each undeclared identifier is reported only once for each function it appears in
../src/buffer.c: In function 'create_shm_file':
../src/buffer.c:45:7: error: implicit declaration of function 'ftruncate'; did you mean 'strncat'? [-Werror=implicit-function-declaration]
   45 |   if (ftruncate(fd, size) < 0) {
      |       ^~~~~~~~~
      |       strncat
cc1: all warnings being treated as errors
[20/31] Compiling C object 'swappy@exe/src_render.c.o'.'.
ninja: build stopped: subcommand failed.

Bad visuals when on dark-mode system

I've just downloaded it on Arch Linux with Sway to test it out, but after I took the screenshot, the icons are white on white background.

Is there a way to set the dark theme for the background?

P.s: The problem is probably because I also use Dolphin in the dark mode, so the GTK icons must be white, but other parts of UI aren't.

This is what it looks like for me.
image

[Request] Option to set default state of paint panel & tool

Hello again!

This tool keeps putting a smile on my face every workday and I would like to thank you again for creating it.

My main use case is highlighting specific parts of a screenshot - because I'd use grim/slurp directly if it wasn't. Therefore, I almost always need to bring up the paint panel (then select rectangle/arrow because I don't want to annoy people with shitty mouse drawings). It would be pretty cool if I could force-enable the paint panel in the config file - and probably even the default tool selection.

What do you think about adding such a feature?

Image is wrongly copied into clipboard as text

When I use the "copy to clipboard" function, the PNG contents are copied to the clipboard, but wl-clipboard assumes the data is text:

wl-paste -l
text/plain
text/plain;charset=utf-8
TEXT
STRING
UTF8_STRING

as a result the content cannot be pasted anywhere usefully. specifiying -t image/png to wl-copy on the command line should solve this issue.

Show info about selected tool in top bar

Swappy should show info about selected tool in the top bar, when the toolbar is closed:

  • name of tool
  • line width/text size (depends on selected tool)
  • current color

Unable to create manpage for 1.2.0

With scdoc 1.11.0 I get:

[    4s] ninja: Entering directory `build'                                                                                                                    
[    4s] [1/19] glib-compile-resources ../res/swappy.gresource.xml --sourcedir ../res --internal --generate --target res/swappy.h                             
[    4s] [2/19] /usr/bin/sh -c '/usr/bin/scdoc < ../swappy.1.scd > swappy.1'                                                                                  
[    4s] FAILED: swappy.1                                                                                                                                     
[    4s] /usr/bin/sh -c '/usr/bin/scdoc < ../swappy.1.scd > swappy.1'                                                                                         
[    4s] Error at 17:58: Cannot nest inline formatting (began with * at 17:53)                                                                                
[    4s] [3/19] glib-compile-resources ../res/swappy.gresource.xml --sourcedir ../res --internal --generate --target res/swappy.c --dependency-file res/swappy
.c.d                                                                                                                                                          
[    4s] [4/19] cc -Iswappy@exe -I. -I.. -I../include -Ires -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1
 -I/usr/include/freetype2 -I/usr/include/uuid -I/usr/include/libpng16 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/fribidi -I/usr/include/l
ibmount -I/usr/include/blkid -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/wayland -I/usr/include/libxkbcomm
on -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -fdiagnostics-color=a
lways -pipe -D_FILE_OFFSET_BITS=64 -Werror -std=c11 '-DSWAPPY_VERSION="1.2.0"' -Wno-unused-parameter -DHAVE_LIBNOTIFY '-DGETTEXT_PACKAGE="intltest"' -O2 -Wall
 -D_FORTIFY_SOURCE=2 -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -pthread
 -MD -MQ 'swappy@exe/src_algebra.c.o' -MF 'swappy@exe/src_algebra.c.o.d' -o 'swappy@exe/src_algebra.c.o' -c ../src/algebra.c                                  
[    4s] [5/19] /usr/bin/meson --internal msgfmthelper ../src/po/swappy.desktop.in src/po/swappy.desktop desktop /home/abuild/rpmbuild/BUILD/swappy-1.2.0/src/
po

So:

[    4s] /usr/bin/sh -c '/usr/bin/scdoc < ../swappy.1.scd > swappy.1'                                                                                         
[    4s] Error at 17:58: Cannot nest inline formatting (began with * at 17:53) 

Can't verify tarball

Hi Jeremy,

Your friendly local Fedora packager here.

I'm having problems with verifying the 1.3.0 tarball:

$ gpg2 --keyring=$PWD/6A6B35DBE9442683.gpg --verify swappy-1.3.0.tar.gz.sig swappy-1.3.0.tar.gz
gpg: Signature made Thu 18 Feb 2021 11:57:39 AEST
gpg: using RSA key F44D05A50F6C9EB5C81BCF966A6B35DBE9442683
gpg: BAD signature from "Jeremy Attali [email protected]" [unknown]

I notice that the 1.3.0 release does not have a 'Verified' button next to it (1.2.0 does have that button and it points to public key 6A6B35DBE9442683

Am I using the right public key?

Thanks

Compile fails on armv7 and i686

This is on fedora:

gcc -Iswappy@exe -I. -I.. -I../include -Ires -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libxml2 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/gtk-3.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/at-spi-2.0 -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Werror -std=c11 '-DSWAPPY_VERSION="1.1.0"' -Wno-unused-parameter -DHAVE_LIBNOTIFY -O2 -fexceptions -g -grecord-gcc-switches -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -march=armv7-a -mfpu=vfpv3-d16 -mtune=generic-armv7-a -mabi=aapcs-linux -mfloat-abi=hard -pthread -MD -MQ 'swappy@exe/src_config.c.o' -MF 'swappy@exe/src_config.c.o.d' -o 'swappy@exe/src_config.c.o' -c ../src/config.c
In file included from /usr/include/glib-2.0/glib.h:62,
                 from ../include/swappy.h:3,
                 from ../include/config.h:1,
                 from ../src/config.c:1:
../src/config.c: In function ‘load_config_from_file’:
../src/config.c:118:11: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘guint64’ {aka ‘long long unsigned int’} [-Werror=format=]
  118 |           "line_size is not a valid value: %ld - see man page for details",
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  119 |           line_size);
      |           ~~~~~~~~~
      |           |
      |           guint64 {aka long long unsigned int}
../src/config.c:118:46: note: format string is defined here
  118 |           "line_size is not a valid value: %ld - see man page for details",
      |                                            ~~^
      |                                              |
      |                                              long int
      |                                            %lld
In file included from /usr/include/glib-2.0/glib.h:62,
                 from ../include/swappy.h:3,
                 from ../include/config.h:1,
                 from ../src/config.c:1:
../src/config.c:135:11: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘guint64’ {aka ‘long long unsigned int’} [-Werror=format=]
  135 |           "text_size is not a valid value: %ld - see man page for details",
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  136 |           text_size);
      |           ~~~~~~~~~
      |           |
      |           guint64 {aka long long unsigned int}
../src/config.c:135:46: note: format string is defined here
  135 |           "text_size is not a valid value: %ld - see man page for details",
      |                                            ~~^
      |                                              |
      |                                              long int
      |                                            %lld
cc1: all warnings being treated as errors

This patch fixes it (but is obviously not 'smooth'):

diff -Nur swappy-1.1.0-orig/src/config.c swappy-1.1.0/src/config.c
--- swappy-1.1.0-orig/src/config.c	2020-06-23 13:05:18.000000000 +1000
+++ swappy-1.1.0/src/config.c	2020-06-30 15:36:59.110245105 +1000
@@ -115,7 +115,11 @@
       config->line_size = line_size;
     } else {
       g_warning(
+#if defined(__arm__) || defined(__i686__)
+          "line_size is not a valid value: %lld - see man page for details",
+#else
           "line_size is not a valid value: %ld - see man page for details",
+#endif
           line_size);
     }
   } else {
@@ -132,7 +136,11 @@
       config->text_size = text_size;
     } else {
       g_warning(
+#if defined(__arm__) || defined(__i686__)
+          "text_size is not a valid value: %lld - see man page for details",
+#else
           "text_size is not a valid value: %ld - see man page for details",
+#endif
           text_size);
     }
   } else {

Drawing Tools only creating Points, not Lines/Shapes

I've recently moved from Gnome to Sway, so I don't have other systems/accounts to test on just yet.

I used Flameshot on X11 and was very excited to find this sceenshot tool for use with Sway...

The swappy build went find with no errors, but when I try to draw I can only get a point, not a line...

Not sure if it's something caused by my Dygma keyboard? Hasn't been an issue with any other app though...

I tried both my Elecom Huge tackball and a regular mouse, but had the same issue on each. I took a short screen capture. You can't see when the button is pressed, but I'm attempting to draw any shape, but the most I can get is a point.

recording.mp4

Note, I tried on the latest swappy release, v1.3.1 and using a copy of the latest git code.
swappy v1.5.1
wlroots v0.12.0
Ubuntu 21.04

swaymsg -t get_inputs
[
  {
    "identifier": "1133:16419:Logitech_Wireless_Keyboard_PID:4023",
    "name": "Logitech Wireless Keyboard PID:4023",
    "vendor": 1133,
    "product": 16419,
    "type": "pointer",
    "libinput": {
      "send_events": "enabled",
      "natural_scroll": "disabled"
    }
  },
  {
    "identifier": "1133:16419:Logitech_Wireless_Keyboard_PID:4023",
    "name": "Logitech Wireless Keyboard PID:4023",
    "vendor": 1133,
    "product": 16419,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled",
      "natural_scroll": "disabled"
    }
  },
  {
    "identifier": "1133:16418:Logitech_Wireless_Mouse_PID:4022",
    "name": "Logitech Wireless Mouse PID:4022",
    "vendor": 1133,
    "product": 16418,
    "type": "pointer",
    "libinput": {
      "send_events": "enabled",
      "accel_speed": 0.0,
      "accel_profile": "adaptive",
      "natural_scroll": "disabled",
      "left_handed": "disabled",
      "middle_emulation": "disabled",
      "scroll_method": "none",
      "scroll_button": 274
    }
  },
  {
    "identifier": "1133:2142:Logitech_BRIO_Consumer_Control",
    "name": "Logitech BRIO Consumer Control",
    "vendor": 1133,
    "product": 2142,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled"
    }
  },
  {
    "identifier": "1133:2142:Logitech_BRIO",
    "name": "Logitech BRIO",
    "vendor": 1133,
    "product": 2142,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled"
    }
  },
  {
    "identifier": "4617:8705:Dygma_Raise",
    "name": "Dygma Raise",
    "vendor": 4617,
    "product": 8705,
    "type": "pointer",
    "libinput": {
      "send_events": "enabled",
      "natural_scroll": "disabled",
      "left_handed": "disabled",
      "middle_emulation": "disabled",
      "calibration_matrix": [
        1.0,
        0.0,
        0.0,
        0.0,
        1.0,
        0.0
      ]
    }
  },
  {
    "identifier": "4617:8705:Dygma_Raise_Mouse",
    "name": "Dygma Raise Mouse",
    "vendor": 4617,
    "product": 8705,
    "type": "pointer",
    "libinput": {
      "send_events": "enabled",
      "accel_speed": 0.0,
      "accel_profile": "adaptive",
      "natural_scroll": "disabled",
      "left_handed": "disabled",
      "middle_emulation": "disabled",
      "scroll_method": "none",
      "scroll_button": 274
    }
  },
  {
    "identifier": "4617:8705:Dygma_Raise_System_Control",
    "name": "Dygma Raise System Control",
    "vendor": 4617,
    "product": 8705,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled"
    }
  },
  {
    "identifier": "4617:8705:Dygma_Raise_Keyboard",
    "name": "Dygma Raise Keyboard",
    "vendor": 4617,
    "product": 8705,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled"
    }
  },
  {
    "identifier": "4617:8705:Dygma_Raise_Consumer_Control",
    "name": "Dygma Raise Consumer Control",
    "vendor": 4617,
    "product": 8705,
    "type": "pointer",
    "libinput": {
      "send_events": "enabled",
      "natural_scroll": "disabled"
    }
  },
  {
    "identifier": "4617:8705:Dygma_Raise_Consumer_Control",
    "name": "Dygma Raise Consumer Control",
    "vendor": 4617,
    "product": 8705,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled",
      "natural_scroll": "disabled"
    }
  },
  {
    "identifier": "1390:269:ELECOM_TrackBall_Mouse_HUGE_TrackBall",
    "name": "ELECOM TrackBall Mouse HUGE TrackBall",
    "vendor": 1390,
    "product": 269,
    "type": "pointer",
    "libinput": {
      "send_events": "enabled",
      "accel_speed": 0.0,
      "accel_profile": "adaptive",
      "natural_scroll": "disabled",
      "left_handed": "disabled",
      "middle_emulation": "disabled",
      "scroll_method": "none",
      "scroll_button": 274
    }
  },
  {
    "identifier": "1390:269:ELECOM_TrackBall_Mouse_HUGE_TrackBall",
    "name": "ELECOM TrackBall Mouse HUGE TrackBall",
    "vendor": 1390,
    "product": 269,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled",
      "accel_speed": 0.0,
      "accel_profile": "adaptive",
      "natural_scroll": "disabled",
      "left_handed": "disabled",
      "middle_emulation": "disabled",
      "scroll_method": "none",
      "scroll_button": 274
    }
  },
  {
    "identifier": "1452:4362:Apple,_Inc._USB-C_to_3.5mm_Headphone_Jack_Adapter",
    "name": "Apple, Inc. USB-C to 3.5mm Headphone Jack Adapter",
    "vendor": 1452,
    "product": 4362,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled"
    }
  },
  {
    "identifier": "0:3:Sleep_Button",
    "name": "Sleep Button",
    "vendor": 0,
    "product": 3,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled"
    }
  },
  {
    "identifier": "0:1:Power_Button",
    "name": "Power Button",
    "vendor": 0,
    "product": 1,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled"
    }
  },
  {
    "identifier": "0:1:Power_Button",
    "name": "Power Button",
    "vendor": 0,
    "product": 1,
    "type": "keyboard",
    "xkb_layout_names": [
      "English (US)"
    ],
    "xkb_active_layout_index": 0,
    "xkb_active_layout_name": "English (US)",
    "libinput": {
      "send_events": "enabled"
    }
  }
]

Core dump on empty input

Getting a core dump when feeding swappy with a empty input like so: swappy -f - -o -, this also happens when using it with grim but pressing escape before selecting area

#0  0x00007ffff7cf5ba8 in g_log_structured_array () at /usr/lib/libglib-2.0.so.0
#1  0x00007ffff7cf5e76 in g_log_default_handler () at /usr/lib/libglib-2.0.so.0
#2  0x00007ffff7cf72b9 in g_logv () at /usr/lib/libglib-2.0.so.0
#3  0x00007ffff7cf7560 in g_log () at /usr/lib/libglib-2.0.so.0
#4  0x000055555555cf7d in pixbuf_init_from_file ()
#5  0x000055555555d5d5 in  ()
#6  0x00007ffff7b4b658 in  () at /usr/lib/libgio-2.0.so.0
#7  0x00007ffff7de2ddf in g_closure_invoke () at /usr/lib/libgobject-2.0.so.0
#8  0x00007ffff7e0bfbd in  () at /usr/lib/libgobject-2.0.so.0
#9  0x00007ffff7dff2db in g_signal_emit_valist () at /usr/lib/libgobject-2.0.so.0
#10 0x00007ffff7e00210 in g_signal_emit () at /usr/lib/libgobject-2.0.so.0
#11 0x00007ffff7ba9d27 in  () at /usr/lib/libgio-2.0.so.0
#12 0x00007ffff7bab00a in  () at /usr/lib/libgio-2.0.so.0
#13 0x00007ffff7bab19a in g_application_run () at /usr/lib/libgio-2.0.so.0
#14 0x0000555555559092 in main ()

Straight line [Proposal]

Hi! Thank you for great tool!
Would be great if there would be possibility to draw only straight lines, eg shift + Brush draws only horizontal or vertical line as you move the pointer.

Feature request: Delete button

I often want to take a screenshot, copy it in somewhere then immediately delete it from disk to keep things tidy. When using Swappy as my "screenshot GUI", my usual workflow currently looks like this:

  1. Press screenshot key on the keyboard, which launches grim and opens the resulting file in Swappy
  2. Draw some arrows, blur some sensitive information
  3. Press ctrl+c
  4. Paste image into chat or email
  5. Go back to Swappy and close it
  6. Open file manager
  7. Browse to screenshot directory
  8. Delete screenshot

I think it would be nice to add a "Delete" button when Swappy is launched with the -f argument pointing to a file. The button could have a trash can icon and be placed to the left of the copy button. When pressed, Swappy would exit, delete the file and display a notification saying "Screenshot deleted".

As an extra convenience, it could have a keyboard shortcut bound to the delete key by default.

When the image is passed via STDIN, the button would be hidden or greyed out.

This would simplify the previous workflow a lot:

  1. Press screenshot key on keyboard, which launches grim and opens the resulting file in Swappy
  2. Draw some arrows, blur some sensitive information
  3. Press ctrl+c
  4. Paste image into chat or email
  5. Go back to Swappy and press the delete key

Lowered image quality

Is there a way to adjust the quality of the final image? Swappy seems to always lower it, regardless of any edits I make.

  • swappy (810x649)
    grim_swappy

  • original (1270x1019)
    grim

CTRL+q to close or option to remap

Hello,

first thing first, thank you so much for this amazing app, I use it daily and it's a time saver!

If I can suggest a very small addition would be allowing to close the app using CTRL+q or an option to remap the keys in the config.

I use sway and CTRL+q is the keybind that closes app almost everywhere so I keep hitting it in swappy but nothing happens, then I remember it's CTRL+w.

A very minor annoyance for an amazing app, thanks again and keep up the great work!

cairo status: out of memory

I'm getting the following error when trying to use swappy.

** (swappy:103534): WARNING **: 13:22:12.535: error while loading png file: /data/downloads/avatar.jpg - cairo status: out of memory

I used the following commands

$ swappy -f /data/downloads/avatar.jpg
$ grimshot | swappy -f -

Both of them produce the same error message.

Some information which might be helpful.

OS - Arch Linux 5.10.13
Swappy Version - 1.2.1
Terminal - Kitty, QTerminal
Shells - Bash, Fish
Display Server - Wayland
Window Manager - sway version 1.5.1

[Feature request] echo output file path on stdout

I used to

grimshot save area /home/user/img/grimshots/$(zenity --entry --text "Set filename:" --entry-text ".png") | wl-copy -p

and want to replace by

grimshot save area - | swappy -f -

My first problem is #61 (comment)
Second is that swappy doesn't echo the output filename to let me autocopy this with | wl-copy -p

Then a question : why swappy doesn't exit when saving the file ?
I would, when finish editing and set filename in editor panel, save to "exit swappy and print file path on stdout"

No longer prints to stdout

The command chain grim -g "$(slurp)" - | swappy -f - -o - no longer produces any output for me.
I believe this started today, so maybe something in 320dae0 broke it?

Saving pictures regularly seems to be unaffected

swappy startup takes 20s

Hi.

I just did fresh swappy install and it takes incredibly long to start each time (cca 20s).
Either I do something like:
grim -g "$(slurp)" - | swappy -f - or swappy -f name_of_image.png in the terminal the wait is the same.

Once it starts it functions OK, saves, clipboard work, drawing works etc.

PC is not topping out with resources and while waiting on swappy, I can open terminals, browsers and other applications instantly.

Operating System: Arch Linux (using sway)
Kernel: Linux 5.13.8-arch1-1
Architecture: x86-64

Image is cutoff / cropped

I've recently discovered this tool and implemented it into my daily workflow. However for some reason the images when copied to clipboard or saved are cut off or zoomed in. Here is an example

This picture is a screen shot straight from grim into wl-copy
image

This is the "same" screen shot which goes into swappy then into my clipboard:
image

I'm running sway 1.0 with wlroots 0.10.0 (latest on arch)

Let me know if there is anything else that you may need to debug!

[Performance] Swappy becomes laggy the more paints are made

The way the render works is to re-render all the paints every time. This makes the tool become more and more laggy as more things are being drawn. Some paints are heavier than others, for example, the new blur tool is quite intensive. Once a blur has been rendered, no need to re-render it every time, only for some undo/redo, or clear.

Need to find a better to not re-render every time. For example use the last drawn cairo surface as base for new paints and flag the rendered paints.

[feature-request] crop support

While you can preselect with slurp, there are situations where more refinement is useful. A cropping tool would be most handy.

[request] Blur tool

Hi,

First thanks for this cool project !

Cool you please add the basic blur tool in swappy?

Best regards

[feature request]: Register mime types to open images with swappy

In addition to opening a file with swappy -f "~/Desktop/my-gnome-saved-file.png", which is great, you could also create a /usr/share/applications/swappy.desktop entry, and register opening png / jpg files, e.g. like this:

MimeType=image/jpeg;image/jpg;image/png;

Copying to clipboard crashes wayland session

It's a pity, but it does.

I have installed swappy from your Fedora repo.

And I use this command to achieve such effect:

export NOW=$(date '+%s'); gnome-screenshot -a -f /tmp/$NOW.png; swappy -f /tmp/$NOW.png -o -

When I click a button 'copy to clipboard' my wayland session crashes to login.

Missing dependencies in REAMDE

Hi!

It seems that the following dependencies are not listed in the README:

  • ninja
  • pkgconfig
  • cmake
  • scdoc
  • gio-sharp
  • libnotify

Maybe you wanna update that file.

(Context: I'm packaging this for nixos).

Add support for defining file output

I prefer to store screenshots in a specific directory that isn't $XDG_CONFIG_HOME/Desktop. Can you add support for specifying an output dir and filename on save?

Related, can the output be sent back to stdout so I can send it to something like pngquant? My current workflow involves sending from grim to pngquant, and I'd like to insert swappy in between so I can annotate the screenshots before sending them back to stdout.

Save error when using the same strftime variable twice

I was experimenting with the save_file_fmt config and it appears re-using the same placeholder twice makes the save fail.

config parameter:
save_filename_format=%Y-%m-swappy-%Y%m%d-%H%M%S.png

Result:
** (swappy:1600448): CRITICAL **: 04:36:19.122: unable to save drawing area to pixbuf: Failed to open “/home/jinks/Pictures/Screenshots/2021-01-swappy-20210120-043619.p��e �\u007f” for writing: Invalid or incomplete multibyte or wide character

Question about i18n

Hey, just a quick question, I saw your commit 57c707a describing how to build i18n, and I want to make sure I'm doing everything correctly for your package once I moved it to Arch [community], but I never worked with i18n before - what is supposed to happen if I change ninja -C build to ninja -C build swappy-pot? Or in other words, how can I test that everything is good? I don't see any changes to the package, that's why I'm a bit confused 🤔

PKGBUILD is pretty much how you made it for AUR: https://github.com/archlinux/svntogit-community/blob/dbc2f1633d5abf5c112f17f03e12c1ec335259f4/trunk/PKGBUILD#L22-L23

[Blur] Make blur more effective on scaled display

Following #17, the blur is not effective enough on scaled displays. Even smashing all the way to 500, the user has to do many passes to effectively blur sensitive texts on terminal or code editor.

Example trying to blur the following text on black background will lead to:

blur times (level 500) | secret password
----------------------------------------
0                      | passzero
1                      | passone
2                      | passtwo
5                      | passfive
10                     | passten

image

Ideas:

  1. Transform the blur level into an input, where users can go crazy
  2. Make it Low Medium High setting
  3. Give it an insane value not configurable (if it's only used for sensitive data, which it probably is)

Wrong units comparison when deciding on initial window size

Hi again 🙂

I'm on HiDPI screen (scaling factor 2.5), and I noticed that sometimes the window size is completely off, like the height of swappy window would be two times bigger than the height of my screen.

Turns out this is caused by comparing different units when deciding on window size.

swappy/src/application.c

Lines 555 to 569 in f3a4ae9

double threshold = 0.75;
double scaling = 1.0;
if (state->geometry->width > workarea.width * threshold) {
scaling = workarea.width * threshold / state->geometry->width;
} else if (state->geometry->height > workarea.height * threshold) {
scaling = workarea.height * threshold / state->geometry->height;
}
state->window->width = state->geometry->width * scaling;
state->window->height = state->geometry->height * scaling;
g_info("size of monitor at window: %ux%u", workarea.width, workarea.height);
g_info("size of window to render: %ux%u", state->window->width,
state->window->height);

My screen is 3840x2400px. I'm opening a 1237x2397px image with swappy -f image.png and here's what is logged:

** INFO: 23:26:13.993: size of image: 1237x2397
** INFO: 23:26:14.024: size of monitor at window: 1536x960
** INFO: 23:26:14.024: size of window to render: 1152x2232

Size of image is used as-is, while size of monitor is divided by scale value of 2.5, so comparing those values is wrong.

As you can imagine, swappy window is now 2232*2.5=5580px in height!

I wasn't sure which way is proper to fix the issue, but I hope this gives you enough information to come up with a quick patch.

Thanks!

P.S. Have I already mentioned how awesome your tool is? It is! 😄
P.P.S. Excited about your rust refactoring branch 😉

GDK/Cairo failures when taking a screenshot

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

Produces the following output when I try to save the file:

(swappy:3089974): Gdk-CRITICAL **: 18:42:54.734: gdk_pixbuf_get_from_surface: assertion 'width > 0 && height > 0' failed

(swappy:3089974): GdkPixbuf-CRITICAL **: 18:42:54.734: gdk_pixbuf_savev: assertion 'GDK_IS_PIXBUF (pixbuf)' failed

(swappy:3089974): GLib-GObject-CRITICAL **: 18:42:54.736: g_object_unref: assertion 'G_IS_OBJECT (object)' failed

I get a notification that the file has been saved, but it doesn't exit on the disk.

And swappy -f hello.png fails with:

** (swappy:3077837): WARNING **: 18:38:36.490: error while loading png file: hello.png - cairo status: file not found

swappy --version -> swappy version 1.2.1-8e5b959 (Aug 3 2020, branch 'master')

I run Arch Linux and I have gtk3, glib2 and glibc installed.

Allow resizing window and making it non-floating

Right now it's impossible to resize the window, to make it fullscreen or non-floating (if you do, you can't draw inside, for example).

When resizing a window, the image inside should be scaled appropriately.

This would have been a workaround for #56, but I'm also thinking that sometimes it could be convenient to just open swappy window in full screen for comfortable editing.

swappy desktop file is useless

See: https://bugzilla.redhat.com/show_bug.cgi?id=1941697 which I copy here for convenience.

Description of problem:

the swappy desktopfile is useless:

TryExec=swappy
Exec=swappy -f %F
Terminal=false
Type=Application

If the app is started with this desktopfile, it starts this way:

"swappy -f "

which results in:

Mär 22 15:47:46 fedorapine sm.puri.Phosh.desktop[68835]: Für -f wird ein Argument benötigt

German for "you need an argument for -f option" .

Swappy is meant to be started after an image is taken i.e. by grim and then given to swappy as argument.

Solution:

Add a dependency for "grim" and "slurp", so those get installed along side swappy.

Change the "Exec=" to "Exec=swappy-wrap" and create: /usr/local/sbin/snappy-wrap
like this:

# cat /usr/local/sbin/swappy-wrap 
#!/bin/bash

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

Now Snappy works as indented, which is also flawed, but thats a different story / bugreport.

Version-Release number of selected component (if applicable):

Name : swappy
Version : 1.3.1
Release : 1.fc35
Architecture: aarch64

Can this be used to redact data?

When saving & generating the new image, are painted over areas completely lost? I don't plan on using this for work or anything with a lot at stake. But if I wanted to maintain some anonymity when sharing things like screenshots, could the original portions of the image that were painted over be recovered? Thanks.

Icons are not taken from font-awesome

Hi there,

on my nixos system with sway, I do get ugly fall back icons when using swappy:
image

font-awesome is installed though.

Sidenote: Why do you even rely on fontawesome? I don't know exactly how e.g. nautilus does not, but they also can provide good looking icons without fontawesome.

Thanks!

"Cairo status: out of memory" error when reading from stdin under PowerShell Core

When I try to use swappy with input through stdin (e.g. the output of grim or simply just cat-ing a png file) under PowerShell Core (my default shell), I get the following error:

** (swappy:9317): WARNING **: 12:59:14.433: error while loading png file: /tmp/swappy-stdin-O1S1N0.png - cairo status: out of memory

The same works perfectly with bash. Does anyone have any idea as to what could be causing this issue, or how it could be fixed? My only faint guess is that it might have to do with the fact, that pwsh does not have the < operator for file to stdin redirection, but piping usually works just the same.

(In the meantime as a workaround I can set up my hotkeys to run through bash, but ideally this extra step shouldn't be needed.)

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.