blob: 2248177f9d5dd740d91ca382c8a3557c123323b0 (
plain) (
blame)
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
|
#!/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
|