Update screenprint2.sh
This commit is contained in:
+88
-20
@@ -12,15 +12,25 @@ notify_ok() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
print_usage() {
|
||||||
|
echo "Usage:"
|
||||||
|
echo " $0 -> Take screenshot for all screens in one save"
|
||||||
|
echo " $0 only-one -> Click = selected screen, drag = selected area"
|
||||||
|
}
|
||||||
|
|
||||||
|
is_wayland() {
|
||||||
|
[ "${XDG_SESSION_TYPE:-}" = "wayland" ]
|
||||||
|
}
|
||||||
|
|
||||||
take_fullscreen() {
|
take_fullscreen() {
|
||||||
local file="$DIR/tam-ekran-$(date +%Y%m%d-%H%M%S).png"
|
local file="$DIR/tam-ekran-$(date +%Y%m%d-%H%M%S).png"
|
||||||
|
|
||||||
if [ "${XDG_SESSION_TYPE:-}" = "wayland" ] && command -v grim >/dev/null 2>&1; then
|
if is_wayland && command -v grim >/dev/null 2>&1; then
|
||||||
grim "$file"
|
grim "$file"
|
||||||
elif command -v scrot >/dev/null 2>&1; then
|
elif command -v scrot >/dev/null 2>&1; then
|
||||||
scrot "$file"
|
scrot "$file"
|
||||||
else
|
else
|
||||||
echo "No working screenshot tool found" >&2
|
echo "No working screenshot tool found (need grim or scrot)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -28,25 +38,86 @@ take_fullscreen() {
|
|||||||
printf '%s\n' "$file"
|
printf '%s\n' "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
take_selection() {
|
take_wayland_selected_or_monitor() {
|
||||||
local file="$DIR/secili-alan-$(date +%Y%m%d-%H%M%S).png"
|
local geom
|
||||||
|
geom="$(slurp 2>/dev/null || true)"
|
||||||
|
[ -z "$geom" ] && exit 0
|
||||||
|
|
||||||
if [ "${XDG_SESSION_TYPE:-}" = "wayland" ] && command -v grim >/dev/null 2>&1 && command -v slurp >/dev/null 2>&1; then
|
local pos_part size_part x y w h
|
||||||
local geom
|
pos_part="${geom%% *}"
|
||||||
geom="$(slurp 2>/dev/null || true)"
|
size_part="${geom#* }"
|
||||||
[ -z "$geom" ] && exit 0
|
|
||||||
grim -g "$geom" "$file"
|
x="${pos_part%,*}"
|
||||||
elif command -v scrot >/dev/null 2>&1; then
|
y="${pos_part#*,}"
|
||||||
scrot -s "$file"
|
w="${size_part%x*}"
|
||||||
else
|
h="${size_part#*x}"
|
||||||
echo "No working area screenshot tool found" >&2
|
|
||||||
exit 1
|
case "$x" in ''|*[!0-9]*) exit 0 ;; esac
|
||||||
|
case "$y" in ''|*[!0-9]*) exit 0 ;; esac
|
||||||
|
case "$w" in ''|*[!0-9]*) exit 0 ;; esac
|
||||||
|
case "$h" in ''|*[!0-9]*) exit 0 ;; esac
|
||||||
|
|
||||||
|
# Tek tık gibi küçük seçimse, Hyprland varsa seçilen monitörün tamamını çek
|
||||||
|
if [ "$w" -le 5 ] || [ "$h" -le 5 ]; then
|
||||||
|
if command -v hyprctl >/dev/null 2>&1; then
|
||||||
|
local output_name
|
||||||
|
output_name="$(
|
||||||
|
hyprctl monitors -j 2>/dev/null | python3 -c '
|
||||||
|
import sys, json
|
||||||
|
|
||||||
|
x = int(sys.argv[1])
|
||||||
|
y = int(sys.argv[2])
|
||||||
|
|
||||||
|
try:
|
||||||
|
mons = json.load(sys.stdin)
|
||||||
|
except Exception:
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
for m in mons:
|
||||||
|
mx = int(m.get("x", 0))
|
||||||
|
my = int(m.get("y", 0))
|
||||||
|
mw = int(m.get("width", 0))
|
||||||
|
mh = int(m.get("height", 0))
|
||||||
|
|
||||||
|
if mx <= x < mx + mw and my <= y < my + mh:
|
||||||
|
print(m.get("name", ""))
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
sys.exit(1)
|
||||||
|
' "$x" "$y"
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [ -n "${output_name:-}" ]; then
|
||||||
|
local file="$DIR/tam-ekran-$(date +%Y%m%d-%H%M%S).png"
|
||||||
|
grim -o "$output_name" "$file"
|
||||||
|
notify_ok "Selected Screen"
|
||||||
|
printf '%s\n' "$file"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Normal alan seçimi
|
||||||
|
local file="$DIR/secili-alan-$(date +%Y%m%d-%H%M%S).png"
|
||||||
|
grim -g "$geom" "$file"
|
||||||
notify_ok "Selected Area"
|
notify_ok "Selected Area"
|
||||||
printf '%s\n' "$file"
|
printf '%s\n' "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
take_selection() {
|
||||||
|
if is_wayland && command -v grim >/dev/null 2>&1 && command -v slurp >/dev/null 2>&1; then
|
||||||
|
take_wayland_selected_or_monitor
|
||||||
|
elif command -v scrot >/dev/null 2>&1; then
|
||||||
|
local file="$DIR/secili-alan-$(date +%Y%m%d-%H%M%S).png"
|
||||||
|
scrot -s "$file"
|
||||||
|
notify_ok "Selected Area"
|
||||||
|
printf '%s\n' "$file"
|
||||||
|
else
|
||||||
|
echo "No working area screenshot tool found (need grim+slurp or scrot)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
case "$ARG" in
|
case "$ARG" in
|
||||||
"")
|
"")
|
||||||
take_fullscreen
|
take_fullscreen
|
||||||
@@ -55,14 +126,11 @@ case "$ARG" in
|
|||||||
take_selection
|
take_selection
|
||||||
;;
|
;;
|
||||||
-h|--help|help|-help)
|
-h|--help|help|-help)
|
||||||
echo "Usage:"
|
print_usage
|
||||||
echo " $0 -> Take fullscreen screenshot"
|
exit 0
|
||||||
echo " $0 only-one -> Select area screenshot"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage:"
|
print_usage
|
||||||
echo " $0 -> Take fullscreen screenshot"
|
|
||||||
echo " $0 only-one -> Select area screenshot"
|
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
Reference in New Issue
Block a user