This repository was archived by the owner on Jan 29, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathscreenshot.sh
More file actions
executable file
·105 lines (92 loc) · 3.3 KB
/
screenshot.sh
File metadata and controls
executable file
·105 lines (92 loc) · 3.3 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env sh
sleep 0.25
if [ -z "$XDG_PICTURES_DIR" ]; then
XDG_PICTURES_DIR="$HOME/Pictures"
fi
save_dir="${3:-$XDG_PICTURES_DIR/Screenshots}"
save_file=$(date +'%y%m%d_%Hh%Mm%Ss_screenshot.png')
full_path="$save_dir/$save_file"
mkdir -p "$save_dir"
mockup_mode="$2"
print_error() {
cat <<EOF
./screenshot.sh <action> [mockup]
...valid actions are...
p : print selected screen
s : snip selected region
w : snip focused window
EOF
}
case $1 in
p)
hyprshot -z -s -m output -o "$save_dir" -f "$save_file"
;;
s)
hyprshot -z -s -m region -o "$save_dir" -f "$save_file"
;;
w)
hyprshot -s -m window -o "$save_dir" -f "$save_file"
;;
*)
print_error
exit 1
;;
esac
if [ -f "$full_path" ]; then
# Copiar al portapapeles si no es mockup
if [ "$mockup_mode" != "mockup" ]; then
if command -v wl-copy >/dev/null 2>&1; then
wl-copy < "$full_path"
elif command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard -t image/png < "$full_path"
fi
fi
# Procesar mockup
if [ "$mockup_mode" = "mockup" ]; then
temp_file="${full_path%.png}_temp.png"
mockup_file="${full_path%.png}_mockup.png"
mockup_success=true
# Redondear esquinas y transparencia
if [ "$mockup_success" = true ]; then
magick "$full_path" \
\( +clone -alpha extract -draw 'fill black polygon 0,0 0,20 20,0 fill white circle 20,20 20,0' \
\( +clone -flip \) -compose Multiply -composite \
\( +clone -flop \) -compose Multiply -composite \
\) -alpha off -compose CopyOpacity -composite "$temp_file" || mockup_success=false
fi
# Añadir sombra
if [ "$mockup_success" = true ]; then
magick "$temp_file" \
\( +clone -background black -shadow 60x20+0+10 -alpha set -channel A -evaluate multiply 1 +channel \) \
+swap -background none -layers merge +repage "$mockup_file" || mockup_success=false
fi
if [ "$mockup_success" = true ] && [ -f "$mockup_file" ]; then
rm "$temp_file"
mv "$mockup_file" "$full_path"
if command -v wl-copy >/dev/null 2>&1; then
wl-copy < "$full_path"
elif command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard -t image/png < "$full_path"
fi
else
echo "Warning: Mockup processing failed, manteniendo original." >&2
rm -f "$temp_file" "$mockup_file"
if [ "$mockup_mode" = "mockup" ]; then
if command -v wl-copy >/dev/null 2>&1; then
wl-copy < "$full_path"
elif command -v xclip >/dev/null 2>&1; then
xclip -selection clipboard -t image/png < "$full_path"
fi
fi
fi
fi
ACTION=$(notify-send -a "Ax-Shell" -i "$full_path" "Screenshot saved" "in $full_path" \
-A "view=View" -A "edit=Edit" -A "open=Open Folder")
case "$ACTION" in
view) xdg-open "$full_path" ;;
edit) swappy -f "$full_path" ;;
open) xdg-open "$save_dir" ;;
esac
else
notify-send -a "Ax-Shell" "Screenshot Aborted"
fi