Write a script for selecting screenshot modes
This commit is contained in:
parent
3d946665f1
commit
3d97448fee
2 changed files with 57 additions and 2 deletions
|
|
@ -243,8 +243,8 @@ bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
|
|||
# Screenshots
|
||||
#
|
||||
|
||||
bindsym Print exec grim ~/Photos/screenshots/$(date +'fullscreen-%Y%m%dT%H%M%S.png')
|
||||
bindsym Shift+Print exec grim -g "$(slurp)" ~/Photos/screenshots/$(date +'selection-%Y%m%dT%H%M%S.png')
|
||||
bindsym Print exec take-screenshot everything
|
||||
bindsym Shift+Print exec take-screenshot
|
||||
|
||||
#
|
||||
# Start a password manager in the scratchpad
|
||||
|
|
|
|||
55
.local/bin/take-screenshot
Executable file
55
.local/bin/take-screenshot
Executable file
|
|
@ -0,0 +1,55 @@
|
|||
#! /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
|
||||
Loading…
Add table
Add a link
Reference in a new issue