diff --git a/i3/config b/i3/config index 8726c29..415db7f 100644 --- a/i3/config +++ b/i3/config @@ -145,7 +145,9 @@ bindsym $mod+Shift+p exec rofi-pass --root $(grep path ~/.config/gopa bindsym $mod+Shift+e exec "pkill rofi; rofi -show emoji -modi emoji -normal-window" bindsym $mod+Shift+i exec rofi-fontawesome bindsym --release Print exec screenshot -bindsym --release $mod+Print exec imgur-screenshot +bindsym --release $mod+Print exec screenshot --clip +bindsym --release Shift+Print exec screenshot --active +bindsym --release $mod+Shift+Print exec screenshot --active --clip bindsym $mod+Shift+x exec systemd-run-i3 -n i3-sensible-terminal --class floating-term --hold -e /bin/echo "$(xprop -id $(xdotool getactivewindow))" bindsym $mod+$alt+space exec systemd-run-i3 -n ~/.config/i3/cycleaudio.py && pkill -RTMIN+10 i3blocks bindsym $mod+numbersign exec systemd-run-i3 -n i3-sensible-terminal --hold -e sh -c 'xclip -o | gpg --decrypt 2>&1' diff --git a/scripts/screenshot b/scripts/screenshot index a2416e7..b9f88f3 100755 --- a/scripts/screenshot +++ b/scripts/screenshot @@ -13,6 +13,29 @@ URL_PATH=https://frebib.net/s # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +params=$(getopt -o ac -l active,clip -n screenshot -- "$@") +eval set -- "$params" +unset params + +while true; do + case "$1" in + '-a'|'--active') + active=1 + shift + continue;; + '-c'|'--clip') + clip=1 + shift + continue;; + '--') + shift + break;; + *) + echo 'getopt error' >&2 + exit 1;; + esac +done + send_notification() { title="$1" body="$2" @@ -28,24 +51,24 @@ send_notification() { # Make the screenshot directory mkdir -p "$DIRECTORY" - -# Take screenshot geometry -read -r winid geom < <(slop -f "%i %g") || : -if [ -z "$geom" -o -z "$winid" ]; then - send_notification "Screenshot error" "Failed to capture screenshot area" > /dev/null - exit 1 -fi - out_path="$DIRECTORY/$FILENAME" -args=(-g "$geom") -# If selection is the root window -if xwininfo -id "$winid" | grep -qw root; then - isroot=1 - args+=(-i "$winid") -elif [ "$1" == "--active" -o "$1" == "-a" ]; then +if [ "$active" = '1' ]; then args+=(-i "$(xdotool getactivewindow)") - shift +else + # Take screenshot geometry + read -r winid geom < <(slop -f "%i %g") || : + if [ -z "$geom" -o -z "$winid" ]; then + send_notification "Screenshot error" "Failed to capture screenshot area" > /dev/null + exit 1 + fi + args=(-g "$geom") + + # If selection is the root window + if xwininfo -id "$winid" | grep -qw root; then + isroot=1 + args+=(-i "$winid") + fi fi # Take the screenshot and save it @@ -60,10 +83,10 @@ if [ "$isroot" != "1" ]; then convert "$out_path" \( +clone -background black -alpha set -channel Alpha -evaluate set 60% -shadow 100x16+0+0 \) +swap -background none -layers merge +repage "$out_path" || : fi -if [ "$1" == "--clip" -o "$1" == "-c" ]; then +if [ "$clip" = '1' ]; then # Add image to clipboard xclip -i "$out_path" -selection clipboard -t image/png - send_notification "Screenshot captured" "$FILENAME

The image is available in the clipboard" + send_notification "Screenshot captured" "$FILENAME

The image is available in the clipboard" >/dev/null exit 0 fi