-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
e-z.gg.sh
executable file
·254 lines (224 loc) · 13.6 KB
/
e-z.gg.sh
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#!/bin/bash -e
# ░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░░▒▓████████▓▒░▒▓███████▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ ░▒▓██████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓███████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓██████▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓██████▓▒░░▒▓████████▓▒░▒▓█▓▒░ ░▒▓██████▓▒░ ░▒▓█▓▒▒▓█▓▒░░▒▓██████▓▒░ ░▒▓██████▓▒░
# ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░░▒▓████████▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░░▒▓████████▓▒░ ░▒▓██▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓█▓▒░ ░▒▓███████▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓████████▓▒░░▒▓██████▓▒░░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░
# ░▒▓█▓▒░░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓████████▓▒░▒▓███████▓▒░
# Script by PhoenixAceVFX
# Licensed under GPL-2.0
# Main script variables
url="https://api.e-z.host/files"
temp_file="/tmp/screenshot.png"
response_file="/tmp/upload.json"
settings_file="$HOME/.config/e-z.gg/settings.json"
pckmgrs_file="$HOME/.config/hyprupld/pckmgrs.json"
# Helper functions
get_saved_value() {
[[ -f "$settings_file" ]] && jq -r ".$1" "$settings_file" || echo ""
}
save_value() {
mkdir -p "$(dirname "$settings_file")"
[[ -f "$settings_file" ]] && jq ".$1=\"$2\"" "$settings_file" > "$settings_file.tmp" && mv "$settings_file.tmp" "$settings_file" || echo "{\"$1\": \"$2\"}" > "$settings_file"
}
detect_package_managers() {
declare -a managers=("pacman" "apt-get" "dnf" "nix-env" "emerge" "zypper" "xbps-install" "yay" "paru")
declare -A manager_names=(
["pacman"]="arch"
["apt-get"]="debian"
["dnf"]="fedora"
["nix-env"]="nixos"
["emerge"]="gentoo"
["zypper"]="opensuse"
["xbps-install"]="void"
["yay"]="arch_community"
["paru"]="arch_community"
)
detected_managers=()
for manager in "${managers[@]}"; do
if command -v "$manager" &>/dev/null; then
detected_managers+=("${manager_names[$manager]}")
fi
done
# Save detected managers to JSON
printf '%s\n' "${detected_managers[@]}" | jq -R . | jq -s . > "$pckmgrs_file"
echo "${detected_managers[@]}"
}
get_package_managers() {
if [[ -f "$pckmgrs_file" ]]; then
jq -r '.[]' "$pckmgrs_file"
else
detect_package_managers
fi
}
install_dependencies() {
required_packages=("$@")
package_managers=($(get_package_managers))
missing_packages=()
# Check for missing dependencies
for package in "${required_packages[@]}"; do
if ! command -v "$package" &>/dev/null; then
missing_packages+=("$package")
fi
done
if [[ ${#missing_packages[@]} -eq 0 ]]; then
return
fi
echo "The following packages are missing: ${missing_packages[*]}"
for manager in "${package_managers[@]}"; do
case "$manager" in
"arch") sudo pacman -S --noconfirm "${missing_packages[@]}" && return ;;
"debian") sudo apt-get install -y "${missing_packages[@]}" && return ;;
"fedora") sudo dnf install -y "${missing_packages[@]}" && return ;;
"nixos") sudo nix-env -iA nixpkgs."${missing_packages[@]}" && return ;;
"gentoo") sudo emerge --ask "${missing_packages[@]}" && return ;;
"opensuse") sudo zypper install -y "${missing_packages[@]}" && return ;;
"void") sudo xbps-install -y "${missing_packages[@]}" && return ;;
"arch_community")
if command -v yay &>/dev/null; then
yay -S --noconfirm "${missing_packages[@]}" && return
elif command -v paru &>/dev/null; then
paru -S --noconfirm "${missing_packages[@]}" && return
fi
;;
esac
done
echo "Could not install dependencies. Install the following manually: ${missing_packages[*]}"
exit 1
}
# Ensure Zenity, jq, and xclip are installed
install_dependencies "zenity" "jq" "xclip"
# Detect distro and desktop environment
distro=$(awk -F= '/^NAME/{print $2}' /etc/os-release | tr -d '"')
desktop_env=$(echo "$XDG_CURRENT_DESKTOP" | tr '[:upper:]' '[:lower:]')
# Get auth key
auth=$(get_saved_value "auth")
if [[ -z "$auth" ]]; then
auth=$(zenity --entry --title="Authentication Key" --text="Enter your auth key:" --width=500) || exit 1
save_value "auth" "$auth"
fi
# Handle screenshots based on the desktop environment
case "$desktop_env" in
*"sway"*|*"hyprland"*|*"i3"*)
install_dependencies "grimblast"
grimblast save area "$temp_file"
;;
*"kde"*)
install_dependencies "flameshot" "spectacle"
tool=$(get_saved_value "kde_tool")
if [[ -z "$tool" ]]; then
tool=$(zenity --list --radiolist --title="KDE Screenshot Tool" --text="Choose your preferred screenshot tool:" --column="" --column="Tool" TRUE Flameshot FALSE Spectacle --width=500 --height=316) || exit 1
save_value "kde_tool" "$tool"
fi
if [[ "$tool" == "Flameshot" ]]; then
flameshot gui -p "$temp_file"
else
spectacle --region --background --nonotify --output "$temp_file"
fi
;;
*"xfce"*)
install_dependencies "xfce4-screenshooter" "flameshot"
tool=$(get_saved_value "xfce_tool")
if [[ -z "$tool" ]]; then
tool=$(zenity --list --radiolist --title="XFCE Screenshot Tool" --text="Choose your preferred screenshot tool:" --column="" --column="Tool" TRUE XFCE4-Screenshooter FALSE Flameshot --width=500 --height=316) || exit 1
save_value "xfce_tool" "$tool"
fi
if [[ "$tool" == "XFCE4-Screenshooter" ]]; then
xfce4-screenshooter -r -s "$temp_file"
else
flameshot gui -p "$temp_file"
fi
;;
*"gnome"*)
install_dependencies "gnome-screenshot" "flameshot"
tool=$(get_saved_value "gnome_tool")
if [[ -z "$tool" ]]; then
tool=$(zenity --list --radiolist --title="GNOME Screenshot Tool" --text="Choose your preferred screenshot tool:" --column="" --column="Tool" TRUE GNOME-Screenshot FALSE Flameshot --width=500 --height=316) || exit 1
save_value "gnome_tool" "$tool"
fi
if [[ "$tool" == "GNOME-Screenshot" ]]; then
gnome-screenshot -a -f "$temp_file"
else
flameshot gui -p "$temp_file"
fi
;;
*"cinnamon"*)
install_dependencies "gnome-screenshot" "flameshot"
tool=$(get_saved_value "cinnamon_tool")
if [[ -z "$tool" ]]; then
tool=$(zenity --list --radiolist --title="Cinnamon Screenshot Tool" --text="Choose your preferred screenshot tool:" --column="" --column="Tool" TRUE GNOME-Screenshot FALSE Flameshot --width=500 --height=316) || exit 1
save_value "cinnamon_tool" "$tool"
fi
if [[ "$tool" == "GNOME-Screenshot" ]]; then
gnome-screenshot -a -f "$temp_file"
else
flameshot gui -p "$temp_file"
fi
;;
*"deepin"*)
install_dependencies "deepin-screenshot"
deepin-screenshot -s "$temp_file"
;;
*"mate"*)
install_dependencies "mate-screenshot" "flameshot"
tool=$(get_saved_value "mate_tool")
if [[ -z "$tool" ]]; then
tool=$(zenity --list --radiolist --title="MATE Screenshot Tool" --text="Choose your preferred screenshot tool:" --column="" --column="Tool" TRUE MATE-Screenshot FALSE Flameshot --width=500 --height=316) || exit 1
save_value "mate_tool" "$tool"
fi
if [[ "$tool" == "MATE-Screenshot" ]]; then
mate-screenshot -a -f "$temp_file"
else
flameshot gui -p "$temp_file"
fi
;;
*)
notify-send "Error" "Unsupported desktop environment: $desktop_env" -a "Screenshot Script"
exit 1
;;
esac
# Verify screenshot
if [[ ! -f "$temp_file" ]]; then
notify-send "Error" "Failed to take screenshot." -a "Screenshot Script"
exit 1
fi
# Upload screenshot
image_url=$(curl -X POST -F "file=@"$temp_file -H "key: "$auth -v "$url" 2>/dev/null)
echo $image_url > /tmp/upload.json
response_file="/tmp/upload.json"
if [[ -z "$image_url" || "$image_url" == "null" ]]; then
notify-send "Error" "Failed to upload screenshot." -a "Screenshot Script"
rm -f "$temp_file"
exit 1
fi
# List of URLs to choose from
# This is if you want to use multiple domains
# List of URLs to choose from
# This is if you want to use multiple domains
# url_list=(
# "guns.website.com"
# "guns.website2.com"
# )
# Copy URL to clipboard
cat /tmp/upload.json | jq -r ".imageUrl" | xclip -sel c
# Get the clipboard contents
# clipboard_content=$(xclip -selection clipboard -o)
# Pick a random URL from the list
# random_url=${url_list[RANDOM % ${#url_list[@]}]}
# Replace "xvids.lol" with the randomly chosen URL
#modified_content=$(echo "$clipboard_content" | sed "s/xvids.lol/$random_url/g")
# Set the modified content back to the clipboard
# echo -n "$modified_content" | xclip -selection clipboard
# Final alert, swap these IF you are using a custom url
# notify-send "Image URL copied to clipboard" "$modified_content" -a "Screenshot Script" -i "$temp_file"
notify-send "Image URL copied to clipboard" "$image_url" -a "Screenshot Script" -i "$temp_file"
# Clean up temporary files
rm -f "$temp_file" "$response_file"