configs/desktop/scripts/print-window.sh

22 lines
875 B
Bash
Raw Normal View History

2023-10-09 17:55:47 -03:00
#!/bin/bash
if [[ $XDG_SESSION_TYPE == "x11" ]]; then
maim -i $(xdotool getactivewindow) | xclip -sel clip -t image/png
fi
if [[ $XDG_SESSION_TYPE == "wayland" ]]; then
2023-11-18 05:25:05 -03:00
if [[ $XDG_CURRENT_DESKTOP == "Hyprland" ]]; then
window_info=$(hyprctl activewindow)
coordinates=$(echo "$window_info" | grep -oP 'at: \K([0-9]+,[0-9]+)')
size=$(echo "$window_info" | grep -oP 'size: \K([0-9]+,[0-9]+)')
IFS=',' read -r x y <<< "$coordinates"
IFS=',' read -r width height <<< "$size"
grim -g "${x},${y} ${width}x${height}" ~/tmp/jabuxas.png
wl-copy < ~/tmp/jabuxas.png
fi
if [[ $XDG_CURRENT_DESKTOP == "sway" ]]; then
2023-10-09 17:55:47 -03:00
grim -g "$(swaymsg -t get_tree | jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"')" ~/tmp/jabuxas.png
xclip -sel clip ~/tmp/jabuxas.png
wl-copy < ~/tmp/jabuxas.png
2023-11-18 05:25:05 -03:00
fi
2023-10-09 17:55:47 -03:00
fi