55 lines
1.5 KiB
Bash
Executable file
55 lines
1.5 KiB
Bash
Executable file
#! /usr/bin/sh
|
|
|
|
listopts() {
|
|
echo "Focused monitor"
|
|
echo "Focused monitor → 📋"
|
|
echo "Select region"
|
|
echo "Select region → 📋"
|
|
echo "Focused window"
|
|
echo "Focused window → 📋"
|
|
echo "Select window"
|
|
echo "Select window → 📋"
|
|
}
|
|
|
|
gen_filename() {
|
|
echo ~/Photos/screenshots/$(date +'screenshot-%Y%m%dT%H%M%S.png')
|
|
}
|
|
|
|
if [ -z "$1" ]; then
|
|
option=$(listopts | fuzzel --dmenu)
|
|
else
|
|
option="$1"
|
|
fi
|
|
|
|
get_focused_monitor() {
|
|
swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name'
|
|
}
|
|
|
|
get_focused_window() {
|
|
swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"'
|
|
}
|
|
|
|
select_window() {
|
|
swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x),\(.y) \(.width)x\(.height)"' | slurp
|
|
}
|
|
|
|
case "${option}" in
|
|
"everything")
|
|
grim "$(gen_filename)";;
|
|
"Focused monitor")
|
|
grim -o "$(get_focused_monitor)" "$(gen_filename)";;
|
|
"Focused monitor → 📋")
|
|
grim -o "$(get_focused_monitor)" - | wl-copy;;
|
|
"Select region")
|
|
grim -g "$(slurp)" "$(gen_filename)";;
|
|
"Select region → 📋")
|
|
grim -g "$(slurp)" - | wl-copy;;
|
|
"Focused window")
|
|
grim -g "$(get_focused_window)" "$(gen_filename)";;
|
|
"Focused window → 📋")
|
|
grim -g "$(get_focused_window)" - | wl-copy;;
|
|
"Select window")
|
|
grim -g "$(select_window)" "$(gen_filename)";;
|
|
"Select window → 📋")
|
|
grim -g "$(select_window)" - | wl-copy;;
|
|
esac
|