From 678c3a1fcbfccdbdaf383650ae2478b6933f3826 Mon Sep 17 00:00:00 2001 From: BluishHumility Date: Mon, 29 Jul 2024 22:00:22 -0400 Subject: [PATCH] feat(screenshots): add swappy, add screenshot scripts and keybindings * Add [swappy](https://github.com/jtheoof/swappy) for handling screenshots. It's a nice Flameshot-like tool that allows adding simple annotations (drawing circles, arrows, text, etc) to screenshots and can save to file or pass to the clipboard. * Add keybindings for "snip", screenshot window, and screenshot current display. * Add scripts for the screenshot window and screenshot current display functions. * `packages-repository.txt` has also been alphabetically sorted to make it easier to work with. --- .config/sway/config.d/default | 8 ++++++-- .config/sway/scripts/screenshot.sh | 18 ------------------ .config/sway/scripts/screenshot_display.sh | 4 ++++ .config/sway/scripts/screenshot_window.sh | 3 +++ packages-repository.txt | 1 + 5 files changed, 14 insertions(+), 20 deletions(-) delete mode 100644 .config/sway/scripts/screenshot.sh create mode 100755 .config/sway/scripts/screenshot_display.sh create mode 100755 .config/sway/scripts/screenshot_window.sh diff --git a/.config/sway/config.d/default b/.config/sway/config.d/default index 4cf2cb6..75ef7d2 100644 --- a/.config/sway/config.d/default +++ b/.config/sway/config.d/default @@ -219,8 +219,12 @@ bindsym $mod+r mode "resize" # # Screenshots # - bindsym print exec /usr/share/sway-contrib/grimshot --notify save output - bindsym Shift+print exec ~/.config/sway/scripts/screenshot.sh + # Snip a selection and pipe to swappy + bindsym print exec grim -g "$(slurp)" - | swappy -f - + # Screenshot a window and pipe to swappy + bindsym Ctrl+Print exec ~/.config/sway/scripts/screenshot_window.sh + # Screenshot the current display and pipe to swappy + bindsym Shift+Print exec ~/.config/sway/scripts/screenshot_display.sh # # Keybindings List # diff --git a/.config/sway/scripts/screenshot.sh b/.config/sway/scripts/screenshot.sh deleted file mode 100644 index 75b836d..0000000 --- a/.config/sway/scripts/screenshot.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -entries="Active Screen Output Area Window" - -selected=$(printf '%s\n' $entries | wofi --style=$HOME/.config/wofi/style.widgets.css --conf=$HOME/.config/wofi/config.screenshot | awk '{print tolower($1)}') - -case $selected in - active) - /usr/share/sway-contrib/grimshot --notify save active;; - screen) - /usr/share/sway-contrib/grimshot --notify save screen;; - output) - /usr/share/sway-contrib/grimshot --notify save output;; - area) - /usr/share/sway-contrib/grimshot --notify save area;; - window) - /usr/share/sway-contrib/grimshot --notify save window;; -esac diff --git a/.config/sway/scripts/screenshot_display.sh b/.config/sway/scripts/screenshot_display.sh new file mode 100755 index 0000000..5b50f5e --- /dev/null +++ b/.config/sway/scripts/screenshot_display.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +output_id=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused).name') +grim -o $output_id - | swappy -f - diff --git a/.config/sway/scripts/screenshot_window.sh b/.config/sway/scripts/screenshot_window.sh new file mode 100755 index 0000000..9b58a1c --- /dev/null +++ b/.config/sway/scripts/screenshot_window.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +grim -g "$(swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp)" - | swappy -f - diff --git a/packages-repository.txt b/packages-repository.txt index c0f5ae5..880cb0e 100644 --- a/packages-repository.txt +++ b/packages-repository.txt @@ -38,3 +38,4 @@ xed ttf-jetbrains-mono ttf-ubuntu-font-family xfce4-terminal +swappy