summaryrefslogtreecommitdiff
path: root/home/wayland/pkgs/wayland-scripts/src/bin/freezshot
blob: 754064a04e75a036abe4d42d334896c1f6c02b15 (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
#!/usr/bin/env bash

out_dir="${GRIM_DEFAULT_DIR:-${XDG_PICTURES_DIR:-.}}"

info() {
	notify-send "   freezhot" "$1"
	printf "\033[32;1merr: %b\032[0m\n" "$1"
}

focused_clinet_name() {
	name="$(swaymsg -t get_tree | jq -r '.. | select(.focused? == true) | .name')"
	if [ -z "$name" ]; then
		echo "screenshot"
	else
		echo "$name"
	fi
}

########
# MAIN #
########

if [ ! -d "$out_dir" ]; then
	mkdir -p "$out_dir"
fi
out="$out_dir/$(date +'%Y%m%d-%Hh%Mm%Ss')-$(focused_clinet_name).png"

grim "$out" && info "Screenshot saved to $out"