diff --git a/bin/screenshot.sh b/bin/screenshot.sh new file mode 100755 index 0000000..b580cb7 --- /dev/null +++ b/bin/screenshot.sh @@ -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 diff --git a/dotfiles/config/i3/config b/dotfiles/config/i3/config index d1c53bc..bb2b595 100644 --- a/dotfiles/config/i3/config +++ b/dotfiles/config/i3/config @@ -158,20 +158,15 @@ bindsym XF86MonBrightnessUp exec --no-startup-id xbacklight -inc 10 bindsym XF86MonBrightnessDown exec --no-startup-id xbacklight -dec 10 # screenshots -set $scrotformat %F-%T.png -set $screendir ~/Pictures/Screenshots -# whole screen +# region/selection bindsym --release Print exec --no-startup-id \ - mkdir -p $screendir && \ - /usr/bin/scrot $screendir/$scrotformat -# current window + ~/bin/screenshot.sh region +# full screen bindsym --release Shift+Print exec --no-startup-id \ - mkdir -p $screendir && \ - /usr/bin/scrot -u $screendir/$scrotformat -# selection + ~/bin/screenshot.sh full +# single window bindsym --release $alt+Sys_Req exec --no-startup-id \ - mkdir -p $screendir && \ - /usr/bin/scrot -s $screendir/$scrotformat + ~/bin/screenshot.sh window # useful utilities exec --no-startup-id gnome-keyring-daemon --start --components=pkcs11,secrets