diff options
author | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-06-13 00:02:21 +0200 |
---|---|---|
committer | Manuel Palenzuela <manuelpalenzuelamerino@gmail.com> | 2019-06-13 00:02:21 +0200 |
commit | 55f434bbc7d1f44d68406e47ffc151e9d647d7e7 (patch) | |
tree | 6e0861d2f3ecc6a237abbf3d41a097dded40a085 | |
parent | Added exit script (diff) | |
download | dmenu-55f434bbc7d1f44d68406e47ffc151e9d647d7e7.tar.gz dmenu-55f434bbc7d1f44d68406e47ffc151e9d647d7e7.tar.bz2 dmenu-55f434bbc7d1f44d68406e47ffc151e9d647d7e7.zip |
Added screenshot script
-rwxr-xr-x | scripts/screenshot | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/scripts/screenshot b/scripts/screenshot new file mode 100755 index 0000000..2248177 --- /dev/null +++ b/scripts/screenshot @@ -0,0 +1,89 @@ +#!/bin/bash +# teiler - A script to share (german word: teilen) screenshots/casts for tiling WMs - Pun intended +# (c) Rasmus Steinke <rasi at xssn dot at> +# Additional Ideas, testing and some code by Zeltak <zeltak at gmail dot com> +# +# Requirements: +# dmenu, xclip, scrot, bc, some notification daemon + + +#changelog +#v0.8 +#Put notify-send into its own function, Made delay being calculated from counter value. +#v0.7 +#Massive Code Cleanup +#v0.6 +#Countdown script stolen from Google and integrated. +#v0.5 +#added clip uploading +#v0.4 +#added screencast function +#v0.3 +#added 1.notifications 2.unique names for each type (for quick launch) 3.better photo editor (pinta) 4.dmenu title + + +############### Configuration options ############################## + +IMG_PATH=$HOME/Images +FILEMASK=%Y-%m-%d-@%H-%M-%S-screenshot.png +RES=1920x1080 #set your screen resolution +TIME=3 #How long will notifications be visible? +COUNTER1=3 #Seconds to count for delay (Use $COUNTD variable) +COUNTER2=6 #Seconds to count for delay (Use $COUNTD2 variable) + + +#DMENU/DZEN2 CONFIGURATION +FONT="Envy Code R-9" +NF="#7c7c72" +NB="#1a1a1a" +SF="#FFFFFF" +SB="#33B5E5" +DZEN2_W=100 #Width of dzen2 +DZEN2_X=850 #X Padding + +################## Configuration End ############################## + + +# Needed for the countdown +# Based on some script by Marco Fontani - MFONTANI at cpan dot org +set -bm +COLOR='#7c7c72' +function countdown () { + seq 1 ${1:-10} | tac | \ + perl -ne'BEGIN{$|++;$msg=shift}$m=int($_/60);$s=int($_-$m*60);printf("$m:%02d -- $msg\n",$s);sleep 1;' \ + "${2:-ready...}" +} + +####Some Variables to clean up the code a bit +COUNTD="countdown $COUNTER1 GO | dzen2 -fn \"$FONT\" -fg \"$NF\" -ta c -w \"$DZEN2_W\" -bg \"$NB\" -x \"$DZEN2_X\"" +COUNTD2="countdown $COUNTER2 GO | dzen2 -fn \"$FONT\" -fg \"$NF\" -ta c -w \"$DZEN2_W\" -bg \"$NB\" -x \"$DZEN2_X\"" +XCLIP="(xclip -o;echo) | xclip -selection clipboard" + + + +prog=" +---Local screenshots (saved at IMG_PATH)--- +1.quick_fullscreen +2.delayed_fullscreen +3.section +---Screencasts +c.cast +k.kill_cast +" + + +cmd=$(dmenu -l 10 -p 'Choose Screenshot Type' <<< "$prog") + +cd $IMG_PATH +case ${cmd%% *} in + + #for local screenshots + 1.quick_fullscreen) scrot -d 1 "$FILEMASK" && notify-send -u low ${TIME} "Screenshot saved" ;; + 2.delayed_fullscreen) eval $COUNTD & scrot -d $(echo $COUNTER1+1 | bc) "$FILEMASK" && notify-send -u low ${TIME} "Screenshot saved" ;; + 3.section) scrot -s "$FILEMASK" && notify-send -u low ${TIME} "Screenshot saved" ;; + + #for screencasts + 4.cast) ffmpeg -r 25 -f x11grab -s $RES -i :0.0+0,0 -vcodec libx264 temp_cast.mkv && notify-send -u low ${TIME} "Screencast started" ;; + 5.kill_cast) kill $(pgrep -f x11grab) && sleep 3 && $UL temp_cast.mkv && rm -f temp_cast.mkv && eval $XCLIP && notify-send -u low ${TIME} "Screencast uploaded" ;; + *) exec "'${cmd}'" ;; +esac |