ubuntuusers.de

lxde-openbox-screenshot

Datum:
6. Dezember 2014 18:51
Code:
 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
cat ~/bin/my_screenshot.sh
#!/bin/bash
# after some tests - the lxdefault did not work, had
# to change the keybind-calls in .config/openbox/lubuntu-rc.xml directly
#
# xwd always ask (mousecurser changes) which window to capture in alt+print
# while scrot hat option -u to capture the focused window
#
notifysend="zenity --info --text"  
FOLDER="$HOME/screenshots/"
  
if [ ! -d "${FOLDER}" ]; then
  mkdir ${FOLDER}
fi
  
DATE=$(date +%Y-%m-%d-%H%M%S)
FNAME="${FOLDER}screenshot-${DATE}.png"
C=0
while [ -f "${FNAME}" ] ; do
    FNAME="${FOLDER}screenshot-${DATE}.${C}.png"
    let C++
done

CAPTUREROOT="xwd -root | convert - ${FNAME}"
CAPTUREWINDOW="xwd | convert - ${FNAME}"
CAPTUREROOT="scrot ${FNAME}"
CAPTUREWINDOW="scrot -u ${FNAME}"
  
touch ${FNAME}
#$notifysend "$0 $1"  
if [ "$1" != "window" ]; then
  if $CAPTUREROOT; then
    $notifysend "Desktop screenshot saved!\nDesktop screenshot was saved as:\n ${FNAME}"
  else
    $notifysend "Desktop screenshot could not be saved!\nThere was an error."
  fi
else
  if $CAPTUREWINDOW; then
    $notifysend "Window screenshot saved!\nWindow screenshot was saved as:\n ${FNAME}"
  else
    $notifysend "Window screenshot could not be saved!\nThere was an error."
  fi
fi