librem5-goodies/screenshot

29 lines
975 B
Bash
Executable File

#!/bin/bash
# This screenshot program was based on an initial command-line only version
# by the purismforum user in community/librem-5
#
# I've since expanded it to use libnotify and provide a GUI
# It requires the grim, libnotify-bin and yad packages:
# sudo apt install grim yad libnotify-bin
#Variable
SCREENSHOT="/home/$USER/Pictures/$(date +%Y-%m-%d-%H%M%S).png"
if [ -e /usr/bin/yad ]; then
INPUT=`yad --title Screenshot --text="Take screenshot after X seconds" --form --field=filename:SFL --field=seconds:NUM "$SCREENSHOT" "5" --focus-field=2`
echo $INPUT
SCREENSHOT=`echo $INPUT | cut -d '|' -f1`
SECONDS=`echo $INPUT | cut -d '|' -f2`
else
SECONDS=`zenity --title Screenshot --text="Take screenshot after X seconds" --entry-text=5 --entry`
fi
if [ "$SECONDS" -eq 0 ]; then
exit
fi
notify-send -t 1000 screenshot "Taking a screenshot in $SECONDS seconds"
sleep $SECONDS;
grim "$SCREENSHOT"
notify-send screenshot "Screenshot stored at ${SCREENSHOT}"