about summary refs log tree commit diff
path: root/scripts/screenshot
blob: 97ea82e4b35f1d375cc839c8fbae1576af211cf8 (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
#!/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, 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
#v1.0
#revamped by baitinq. Eliminated most of the depends, made it simpler to use.


############### Configuration options ##############################

IMG_PATH=$HOME/Images
FILEMASK=%Y-%m-%d-@%H-%M-%S-screenshot.png
RES=1920x1080   #set your screen resolution
TIME=3000       #How long will notifications be visible (ms)?
COUNTER=3000    #Ms to count for delay

################## Configuration End ##############################

prog="
---Local screenshots (saved at IMG_PATH)---
1.Normal_fullscreen
2.Delayed_fullscreen
3.Section
---Recordings
4.Cast
5.Stop_cast
"


cmd=$(dmenu -l 10 -p 'Choose Screenshot Type' <<< "$prog")

(( rounded_num= ($COUNTER + (2 - 1) / 2))) #round the number

cd $IMG_PATH
case ${cmd%% *} in

    #for local screenshots
    1.Normal_fullscreen)            scrot -d 1 "$FILEMASK" && notify-send -u low -t ${TIME} "Screenshot saved"  ;;
    2.Delayed_fullscreen)           notify-send -u low -t $rounded_num "Screenshot in $COUNTER seconds" && sleep $COUNTER && scrot -d 1 "$FILEMASK" && notify-send -u low -t ${TIME} "Screenshot saved"  ;;
    3.Section)                      scrot -s "$FILEMASK" && notify-send -u low -t ${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 -t ${TIME} "Screencast started"  ;;
    5.Stop_cast)                    kill $(pgrep -f x11grab) && sleep 3 && notify-send -u low -t ${TIME} "Screencast stopped"  ;;
	  *)		exec "'${cmd}'"  ;;
esac