diff options
| author | Akshay Nair <phenax5@gmail.com> | 2022-03-09 12:18:55 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2022-03-09 12:18:55 +0530 |
| commit | db36ce12e4b4bfa7f5f34f835d58493429254521 (patch) | |
| tree | 901f1f78db70ce5d99650650156f217acc49c3b9 /scripts | |
| parent | 8fb6246ffca8b5376c6f47f54f3f28fed29e1520 (diff) | |
| download | nixos-config-db36ce12e4b4bfa7f5f34f835d58493429254521.tar.gz nixos-config-db36ce12e4b4bfa7f5f34f835d58493429254521.zip | |
fixes screenshot script
Diffstat (limited to '')
| -rwxr-xr-x | scripts/screenshot.sh | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/scripts/screenshot.sh b/scripts/screenshot.sh index 4ae4e4f..9fc6d8f 100755 --- a/scripts/screenshot.sh +++ b/scripts/screenshot.sh @@ -2,23 +2,33 @@ SCREENSHOTS=$HOME/Pictures/screenshots; -notify() { notify-send "$@"; } +notify() { notify-send "Screenshot captured. $@"; } -scrsht() { - local type=$1; - local window=$([ -z "$2" ] && echo "" || echo $([[ "$2" == root ]] && "-screen" || "-window $2")); - import $window "$SCREENSHOTS/$type-$(date '+%Y_%m_%d_%H_%M_%S').jpg"; - notify "Screenshot ($type) captured"; +file_name() { + echo "$SCREENSHOTS/$1-$(date '+%Y_%m_%d_%H_%M_%S').jpg" } -full_screenshot() { scrsht full root; } -part_screenshot() { sleep 0.2; scrsht part & disown; } -window_screenshot() { scrsht window "${1:-"$(xdo id)"}"; } +full_screenshot() { + import -window root "$(file_name full)" + notify "(full)" +} +part_screenshot() { + sleep 0.2; + import "$(file_name part)" + notify "(selection)" +} +window_screenshot() { + local wid="${1:-"$(xdotool getwindowfocus)"}" + echo "WID: $wid" + import -window "$wid" "$(file_name window)" + notify "(window)" +} case $1 in full) full_screenshot ;; part) part_screenshot ;; window) window_screenshot "$2" ;; + monitor) full_screenshot -display "$1" ;; *) echo "no"; exit 1 ;; esac |
