bin/scripts/i3scripts/i3-scrot (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
#!/bin/sh # /usr/bin/i3-scrot # # simple screenshot-script using scrot for manjaro-i3 by oberon@manjaro.org # added some options to copy and upload the screenshot to a host using # my uploader `xup` _conf=$HOME/.config/i3-scrot.conf if ! [ -f $_conf ]; then echo "scrot_dir=$(xdg-user-dir PICTURES)" > $_conf fi source $_conf if ! [ -d $scrot_dir ]; then mkdir -p $scrot_dir fi give_options () { set -o pipefail scrot_dir="$HOME/pictures/screenshots" latest_screen=$(ls -tc $scrot_dir | head -1) path="$(echo $scrot_dir/$latest_screen)" echo $path choice=$(echo -ne "copy\nupload" | dmenu $DMENU_ARGS) case "$choice" in upload) xup "$path" | xsel -ib && notify-send "URL Copied"; ;; copy) xclip -selection clipboard -t image/png -i "$path"\ && notify-send "Copied" ;; esac } if ! [[ -z "$2" ]]; then cmd="scrot -d $2" else cmd='scrot' fi case "$1" in --desk|-d|$NULL) cd $scrot_dir $cmd && notify-send "Screenshot saved" ;; --window|-w) cd $scrot_dir $cmd -u && notify-send "Screenshot saved" give_options ;; --select|-s) cd $scrot_dir notify-send 'Select an area for the screenshot' & scrot -s && notify-send "Screenshot saved" give_options ;; --help|-h) echo " available options: -d | --desk full screen -w | --window active window -s | --select selection -h | --help display this information The -d or -w options can be used with a delay by adding the number of seconds, like for example: 'i3-scrot -w 5' Default option is 'full screen'. The file destination can be set in ${_conf}. Default is $scrot_dir " ;; *) echo " == ! i3-scrot: missing or wrong argument ! == available options: -d | --desk full screen -w | --window active window -s | --select selection -h | --help display this information Default option is 'full screen'. The file destination can be set in ${_conf}. Default is $scrot_dir " exit 2 esac exit 0 |