diff options
Diffstat (limited to 'dotfiles/.local/bin/screensht')
| -rwxr-xr-x | dotfiles/.local/bin/screensht | 51 | 
1 files changed, 51 insertions, 0 deletions
| diff --git a/dotfiles/.local/bin/screensht b/dotfiles/.local/bin/screensht new file mode 100755 index 0000000..f170d38 --- /dev/null +++ b/dotfiles/.local/bin/screensht @@ -0,0 +1,51 @@ +#!/bin/sh + +notify_saved() { +    notify-send -i "$1" "🖼 Screenshot" "Screenshot has been saved in $1" ; +} + +notify_copied() { +    notify-send "🖼 Screenshot" "Screenshot has been copied to clipboard" ; +} + +if [ "$2" = "copy" ]; then +	case "$1" in +		"select area") +			grim -g "$(slurp)" - | wl-copy +			notify_copied +			;; +		"current window") +			grim -g "$(swaygetcurrentwindow)" - | wl-copy +			notify_copied +			;; +		"full screen") +    		grim - | wl-copy +    		notify_copied +    		;; +    	*) exit 0;; +	esac +	exit 0 +else +	if ! [ -d $SCROT_DIR ]; then +		mkdir -p $SCROT_DIR +	fi +	case "$1" in +		"select area") +			scrpath="$SCROT_DIR/selected-$(date '+%y%m%d-%H%M-%S').png" +			grim -g "$(slurp)" "$scrpath" +			notify_saved "$scrpath" +			;; +		"current window") +			scrpath="$SCROT_DIR/window-$(date '+%y%m%d-%H%M-%S').png" +			grim -g "$(swaygetcurrentwindow)" "$scrpath" +			notify_saved "$scrpath" +			;; +		"full screen") +			scrpath="$SCROT_DIR/fullscreen-$(date '+%y%m%d-%H%M-%S').png" +    		grim "$scrpath" +    		notify_saved "$scrpath" +    		;; +    	*) exit 0;; +	esac +	exit 0 +fi | 
