aboutsummaryrefslogtreecommitdiff
path: root/scripts/screenshot.sh
blob: 59770dd8e299024b6aec3e5d589f97f9e080e083 (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
#!/usr/bin/env bash

SCREENSHOTS=$HOME/Pictures/screenshots;

notify() { notify-send "$@"; }

scrsht() {
  local type=$1;
  local window=$([ -z "$2" ] && echo "" || echo "-window $2");
  magick import $window "$SCREENSHOTS/$type-$(date '+%Y_%m_%d_%H_%M_%S').jpg";
  notify "Screenshot ($type) captured";
}

full_screenshot() { scrsht full root; }
part_screenshot() { sleep 0.2; scrsht part & disown; }
window_screenshot() { scrsht window "${1:-"$(xdo id)"}"; }

case $1 in
  full) full_screenshot ;;
  part) part_screenshot ;;
  window) window_screenshot "$2" ;;
  *) echo "no"; exit 1 ;;
esac