Skip to content

Instantly share code, notes, and snippets.

@ChatchaiJ
Created July 19, 2017 10:08
Show Gist options
  • Save ChatchaiJ/12985f511223ddc489c03cf6c7ec5729 to your computer and use it in GitHub Desktop.
Save ChatchaiJ/12985f511223ddc489c03cf6c7ec5729 to your computer and use it in GitHub Desktop.
Using scrot to capture screen and send that screen capture image by Telegram bot
#!/bin/sh
BINDIR="${HOME}/bin"
WORKDIR="/tmp/capture"
SENDPHOTO="$BINDIR/botSendPhoto" # see botSendPhoto.sh script
## mode 777 is needed since we capture screen as 'pi' user
[ ! -d $WORKDIR ] && mkdir -m 0777 -p $WORKDIR
cd $WORKDIR || exit
CAPTION="`hostname` screen capture `date +%Y%m%d_%H%M%S`"
## This is run as 'pi' user on raspberry pi raspbian ##
DISPLAY=:0.0 sudo -u pi scrot -z -d 5 -q 25 capture.png
# Caption ImageFile To
$SENDPHOTO "$CAPTION" capture.png $USER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment