elenapan/bin/screenshot.sh
elena 199af78429 dotfile overhaul, reorganized directories, updated almost everything, and only kept the most essential
Former-commit-id: 4295c806ec
Former-commit-id: c87f8e56cd2677dbb5a2a15e90f879a9fa1a1a6b
Former-commit-id: 1ad787023efcecb57853b9a5103dff461192e56d
Former-commit-id: 595bf6d1621414a7b6e7d8e9acb374ce52687596
2018-09-28 02:54:28 +03:00

44 lines
1.7 KiB
Bash
Executable file

#!/bin/bash
# Screenshot wrapper
# Uses maim (which uses slop)
# "Friendship ended with scrot. Now maim is my best friend."
SCREENSHOTS_DIR=~/pix/Screenshots
TIMESTAMP="$(date +%Y.%m.%d-%H.%M.%S)"
#TIMESTAMP="$(date +%Y.%m.%d--%s)"
FILENAME=$SCREENSHOTS_DIR/$TIMESTAMP.screenshot.png
PHOTO_ICON_PATH=~/.icons/oomox-only_icons/categories/scalable/applications-photography.svg
# -u option hides cursor
# -m option changes the compression level
# -m 3 takes the shot faster but the file size is slightly bigger
if [[ "$1" = "-s" ]]; then
# Area/window selection.
notify-send 'Select area to capture.' --urgency low -i $PHOTO_ICON_PATH
maim -u -m 3 -s $FILENAME
if [[ "$?" = "0" ]]; then
notify-send "Screenshot taken." --urgency low -i $PHOTO_ICON_PATH
fi
elif [[ "$1" = "-c" ]]; then
notify-send 'Select area to copy to clipboard.' --urgency low -i $PHOTO_ICON_PATH
# Copy selection to clipboard
#maim -u -m 3 -s | xclip -selection clipboard -t image/png
maim -u -m 3 -s /tmp/maim_clipboard
if [[ "$?" = "0" ]]; then
xclip -selection clipboard -t image/png /tmp/maim_clipboard
notify-send "Copied selection to clipboard." --urgency low -i $PHOTO_ICON_PATH
rm /tmp/maim_clipboard
fi
elif [[ "$1" = "-b" ]]; then
# Browse with feh
cd $SCREENSHOTS_DIR ; feh $(ls -t) &
elif [[ "$1" = "-e" ]]; then
# Edit last screenshot with GIMP
cd $SCREENSHOTS_DIR ; gimp $(ls -t | head -n1) & notify-send 'Opening last screenshot with GIMP' --urgency low -i ~/.icons/oomox-only_icons/categories/scalable/applications-painting.svg
else
# Full screenshot
maim -u -m 3 $FILENAME
notify-send "Screenshot taken." --urgency low -i $PHOTO_ICON_PATH
fi