Add multiple tool screenshotting capabilities.

This commit is contained in:
David Tomaschik
2020-10-19 17:59:46 -07:00
parent 2a71557663
commit 3c83cb1761
2 changed files with 68 additions and 11 deletions

62
bin/screenshot.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
# Screenshot tool to try a few different tools
set -ue
TOOLS="flameshot scrot"
SCREENDIR=${SCREENDIR:-${HOME}/Pictures/Screenshots}
SCROT_FORMAT="%F-%T.png"
function default_screenshot_command {
for tool in ${TOOLS} ; do
if which "${tool}" >/dev/null 2>&1 ; then
echo "${tool}"
return 0
fi
done
exit 1
}
TOOL=${SHOT:-$(default_screenshot_command)}
CMD=${1:-region}
function flameshot_gui_capture {
flameshot gui -p "${SCREENDIR}"
}
function flameshot_region_capture {
flameshot_gui_capture
}
function flameshot_window_capture {
flameshot_gui_capture
}
function flameshot_full_capture {
flameshot full -p "${SCREENDIR}"
}
function scrot_region_capture {
scrot -s "${SCREENDIR}/${SCROT_FORMAT}"
}
function scrot_window_capture {
scrot -u "${SCREENDIR}/${SCROT_FORMAT}"
}
function scrot_full_capture {
scrot "${SCREENDIR}/${SCROT_FORMAT}"
}
case "${CMD}" in
region|window|full)
mkdir -p "${SCREENDIR}"
${TOOL}_${CMD}_capture
exit $?
;;
*)
echo "Usage: $0 [region|window|full]" >/dev/stderr
exit 1
;;
esac

View File

@@ -158,20 +158,15 @@ bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 10
bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 10 bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 10
# screenshots # screenshots
set $scrotformat %F-%T.png # region/selection
set $screendir ~/Pictures/Screenshots
# whole screen
bindsym --release Print exec --no-startup-id \ bindsym --release Print exec --no-startup-id \
mkdir -p $screendir && \ ~/bin/screenshot.sh region
/usr/bin/scrot $screendir/$scrotformat # full screen
# current window
bindsym --release Shift+Print exec --no-startup-id \ bindsym --release Shift+Print exec --no-startup-id \
mkdir -p $screendir && \ ~/bin/screenshot.sh full
/usr/bin/scrot -u $screendir/$scrotformat # single window
# selection
bindsym --release $alt+Sys_Req exec --no-startup-id \ bindsym --release $alt+Sys_Req exec --no-startup-id \
mkdir -p $screendir && \ ~/bin/screenshot.sh window
/usr/bin/scrot -s $screendir/$scrotformat
# useful utilities # useful utilities
exec --no-startup-id gnome-keyring-daemon --start --components=pkcs11,secrets exec --no-startup-id gnome-keyring-daemon --start --components=pkcs11,secrets