From 84ad436aeb4a0f54a5e820e138fe500ffa8ba88e Mon Sep 17 00:00:00 2001 From: juan Date: Fri, 22 Apr 2022 00:13:06 +0800 Subject: [PATCH] Update screenshot utilitys' code. boxshadow.sh: Add a tips for what this script does. grimshot-ui.sh: Move the box shadow editing part to this script. grimshot.sh: Same as above, to make the grimshot-ui a pure wrapper to this and grim, making the codebase cleaner. --- .config/sway/scripts/boxshadow.sh | 4 +++- .config/sway/scripts/grimshot-ui.sh | 11 ++++++++++- .config/sway/scripts/grimshot.sh | 5 +---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.config/sway/scripts/boxshadow.sh b/.config/sway/scripts/boxshadow.sh index d5ba794..719548e 100755 --- a/.config/sway/scripts/boxshadow.sh +++ b/.config/sway/scripts/boxshadow.sh @@ -1,6 +1,8 @@ #!/bin/sh +# Take $1 as input, add a box shadow, output to $2 -background_color=#2a2f33 +# you can change background color here +background_color=none convert $1 \ \( -clone 0 -background black -shadow 40x5+12+16 \) \ diff --git a/.config/sway/scripts/grimshot-ui.sh b/.config/sway/scripts/grimshot-ui.sh index 20cae2d..7160d0e 100755 --- a/.config/sway/scripts/grimshot-ui.sh +++ b/.config/sway/scripts/grimshot-ui.sh @@ -1,5 +1,8 @@ #!/bin/sh +SCRIPT_LOC=~/.config/sway/scripts/ +FILE="/tmp/share/screenshots/`date +'%y%m%d%H%M.png'`" + action=`echo "copy\nsave" | wofi -d -Oalphabetical --prompt="Select your action"` target=`echo "active\nscreen\noutput\narea\nwindow" | wofi -d -Oalphabetical --prompt="Select the target"` @@ -10,4 +13,10 @@ test -d /tmp/share/screenshot || mkdir -p /tmp/share/screenshots # TODO, add box shadows -XDG_SCREENSHOTS_DIR=/tmp/share/screenshots ~/.config/sway/scripts/grimshot.sh --notify $action $target +XDG_SCREENSHOTS_DIR=/tmp/share/screenshots ~/.config/sway/scripts/grimshot.sh --notify $action $target $FILE + +if [ $target = "active" ] || [ $target = "window" ] || [ $target = "area" ] +then + $SCRIPT_LOC/boxshadow.sh "$FILE" "$FILE" || die "Unable to save screenshot" + echo "saved file" +fi diff --git a/.config/sway/scripts/grimshot.sh b/.config/sway/scripts/grimshot.sh index 140e54f..7b65c9c 100755 --- a/.config/sway/scripts/grimshot.sh +++ b/.config/sway/scripts/grimshot.sh @@ -1,7 +1,6 @@ #!/bin/sh ## TAKEN FROM https://github.com/swaywm/sway/blob/master/contrib/grimshot -## With some modifications ## ## Grimshot: a helper for screenshots within sway ## Requirements: @@ -32,7 +31,6 @@ fi ACTION=${1:-usage} SUBJECT=${2:-screen} FILE=${3:-$(getTargetDirectory)/$(date +'%y%m%d%H%M.png')} -SCRIPT_LOC=~/.config/sway/scripts/ if [ "$ACTION" != "save" ] && [ "$ACTION" != "copy" ] && [ "$ACTION" != "check" ]; then echo "Usage:" @@ -100,8 +98,7 @@ takeScreenshot() { elif [ -z "$GEOM" ]; then grim "$FILE" || die "Unable to invoke grim" else - grim -g "$GEOM" "$FILE" || die "Unable to invoke grim" && \ - $SCRIPT_LOC/boxshadow.sh "$FILE" "$FILE" || die "Unable to save screenshot" + grim -g "$GEOM" "$FILE" || die "Unable to invoke grim" fi }