Unbloat screenshot script
Shorten the code and fix bugs.
This commit is contained in:
parent
8d0d4e2f5a
commit
243b5fb2ed
@ -1,32 +1,22 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
# rofi prompts
|
m() { rofi -dmenu -i -l "$@"; }
|
||||||
TYPE="$(printf "Screen\nArea\n" | rofi -dmenu -l 2 -i -p 'What do you want to screenshot?')"
|
|
||||||
if [ -z "$TYPE" ]; then exit; fi
|
|
||||||
SAVE="$(printf "No\nYes" | rofi -dmenu -l 2 -i -p 'Do you want to copy to clipboard?')"
|
|
||||||
if [ -z "$SAVE" ]; then exit; fi
|
|
||||||
TIME="$(printf "0.7\n5\n10\n15" | rofi -dmenu -l 3 -i -p 'How many seconds you want to wait?')"
|
|
||||||
if [ -z "$TIME" ]; then exit; fi
|
|
||||||
|
|
||||||
# Set flag if selected "Area"
|
TYPE="$(printf "Screen\nArea\n" | m 2 -p 'What do you want to screenshot?')"
|
||||||
case "$TYPE" in
|
[ ! "$TYPE" ] && exit
|
||||||
Area) TYPE="-s -u";;
|
SAVE="$(printf "No\nYes" | m 2 -p 'Do you want to copy to clipboard?')"
|
||||||
*) TYPE=""
|
[ ! "$SAVE" ] && exit
|
||||||
esac
|
TIME="$(printf "0.7\n5\n10\n15" | m 3 -p 'How many seconds you want to wait?')"
|
||||||
|
[ ! "$TIME" ] && exit
|
||||||
|
|
||||||
# Prepere for screenshot
|
[ "$TYPE" = "Area" ] && TYPE="-s -u" || TYPE=""
|
||||||
mkdir ~/Pictures/Screenshots
|
|
||||||
|
mkdir -p ~/Pictures/Screenshots
|
||||||
sleep "$TIME"
|
sleep "$TIME"
|
||||||
SCREEN_PATH=~/Pictures/Screenshots/$(date +%G-%m-%d_%s).png
|
SCREEN_PATH=~/Pictures/Screenshots/$(date +%G-%m-%d_%s).png
|
||||||
|
|
||||||
# Copy to clipboard (and save) or only save to file
|
maim $TYPE "$SCREEN_PATH" &&
|
||||||
case "$SAVE" in
|
notify-send -u low -t 1400 -i "$SCREEN_PATH" "Screenshot created!"
|
||||||
Yes)
|
|
||||||
maim $TYPE $SCREEN_PATH
|
|
||||||
xclip -selection clipboard -t image/png $SCREEN_PATH;;
|
|
||||||
*)
|
|
||||||
maim $TYPE $SCREEN_PATH;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Send notify
|
[ "$SAVE" = "Yes" ] &&
|
||||||
notify-send -u low -t 1400 -i $SCREEN_PATH "Screenshot created!"
|
xclip -selection clipboard -t image/png "$SCREEN_PATH" || exit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user