Skip to content

Commit 3301543

Browse files
authored
Merge branch 'dev' into patch-1
2 parents 6f64d0e + c9ebeae commit 3301543

File tree

25 files changed

+1716
-1342
lines changed

25 files changed

+1716
-1342
lines changed

CHANGELOG.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@ All notable changes to `HyDE` will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to _Modified_ [CalVer](https://calver.org/). See [Versioning](https://github.com/HyDE-Project/HyDE/blob/master/RELEASE_POLICY.md#versioning-yymq) For more info
66

7+
## v25.9.3 (Unreleased)
8+
9+
### Changed
10+
11+
- OCR: `imagemagick` screenshot preprocessing tuned for better recognition results
12+
13+
### Added
14+
15+
- Turkish documentation.
16+
- No changes have been made to other codes.
17+
- OCR: `tesseract` now supports explicit language settings via `hyde/config.toml`:
18+
```toml
19+
[screenshot.ocr]
20+
tesseract_languages = ["eng"]
21+
```
22+
To use text recognition bind `hyde-shell screenshot sc` to any hotkey.
23+
- Hyprlock: Added hyprlock preview
24+
25+
### Fixed
26+
27+
- Hyprlock: fix hyprlock crashing by handling it as a systemd scope unit
28+
729
## v25.9.1
830

931
This release delivers a new gesture syntax for hyprland v0.51.0. This is a breaking change for users of the previous gesture syntax. Please update HyDE before opening an issue.
@@ -24,7 +46,6 @@ gesture = 3, vertical, workspace
2446
- Gestures: Chase hyprland v0.51.0 gesture syntax
2547
2648
### Added
27-
2849
- pinch gesture to toggle tile and floating
2950
3051
## v25.8.3

CONTRIBUTORS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ _These contributors help with quality assurance and testing._
2828
- [@Prof-Shiba](https://github.com/Prof-Shiba)
2929
- [@UnaTried](https://github.com/UnaTried)
3030

31+
- [@Vu4ll](https://github.com/Vu4ll)
32+
3133
---
3234

3335
## How to add yourself to this list

Configs/.config/hypr/windowrules.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ windowrule = float, title:^(Library)(.*)$
116116
windowrule = float,class:^(.*dialog.*)$
117117
windowrule = float,title:^(.*dialog.*)$
118118

119+
# workaround for jetbrains IDEs dropdowns/popups cause flickering
120+
windowrule = noinitialfocus,class:^(.*jetbrains.*)$,title:^(win[0-9]+)$
121+
119122
# █░░ ▄▀█ █▄█ █▀▀ █▀█   █▀█ █░█ █░░ █▀▀ █▀
120123
# █▄▄ █▀█ ░█░ ██▄ █▀▄   █▀▄ █▄█ █▄▄ ██▄ ▄█
121124

Configs/.config/zsh/plugin.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Use your plugin system here
22

3-
return 1 # <--- Comment this line to disable HyDE's plugin loader // same as HYDE_ZSH_NO_PLUGINS
3+
return 1 # <--- Comment this line to disable HyDE's oh-my-zsh plugins and use the zinit examples below
44

55
#! This file will not load, remove the return 1 line above to enable this file.
66
#? Below is an example of how to set up Zsh plugins using Zinit

Configs/.local/lib/hyde/hyprlock.sh

Lines changed: 132 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ scrDir=${scrDir:-$HOME/.local/lib/hyde}
1111
confDir="${confDir:-$XDG_CONFIG_HOME}"
1212
cacheDir="${HYDE_CACHE_HOME:-"${XDG_CACHE_HOME}/hyde"}"
1313
WALLPAPER="${cacheDir}/wall.set"
14+
HYPRLOCK_SCOPE_NAME="hyde-${XDG_SESSION_DESKTOP:-unknown}-lockscreen.scope"
15+
1416

1517
USAGE() {
1618
cat <<EOF
@@ -74,12 +76,12 @@ fn_mpris() {
7476
if [ -f "$HOME/.face.icon" ]; then
7577
if ! cmp -s "$HOME/.face.icon" "${THUMB}.png"; then
7678
cp -f "$HOME/.face.icon" "${THUMB}.png"
77-
pkill -USR2 hyprlock >/dev/null 2>&1 # updates the mpris thumbnail
79+
reload_hyprlock
7880
fi
7981
else
8082
if ! cmp -s "$XDG_DATA_HOME/icons/Wallbash-Icon/hyde.png" "${THUMB}.png"; then
8183
cp "$XDG_DATA_HOME/icons/Wallbash-Icon/hyde.png" "${THUMB}.png"
82-
pkill -USR2 hyprlock >/dev/null 2>&1 # updates the mpris thumbnail
84+
reload_hyprlock
8385
fi
8486
fi
8587
exit 1
@@ -116,7 +118,7 @@ mpris_thumb() { # Generate thumbnail for mpris
116118
echo "${artUrl}" >"${THUMB}".lnk
117119
curl -Lso "${THUMB}".art "$artUrl"
118120
magick "${THUMB}.art" -quality 50 "${THUMB}.png"
119-
pkill -USR2 hyprlock >/dev/null 2>&1 # updates the mpris thumbnail
121+
reload_hyprlock
120122
}
121123

122124
fn_cava() {
@@ -133,6 +135,17 @@ fn_art() {
133135
echo "${cacheDir}/landing/mpris.art"
134136
}
135137

138+
find_filepath() {
139+
local filename="${*:-$1}"
140+
local search_dirs=(
141+
"${XDG_CONFIG_HOME:-$HOME/.config}/hypr/hyprlock"
142+
"${XDG_CONFIG_HOME:-$HOME/.config}/hyde/hyprlock"
143+
"${HYPRLOCK_CONF_DIR}"
144+
)
145+
print_log -sec "hyprlock" -stat "Searching for layout" "$filename"
146+
find "${search_dirs[@]}" -type f -name "${filename}*" 2>/dev/null | head -n 1
147+
}
148+
136149
# hyprlock selector
137150
fn_select() {
138151
# Set rofi scaling
@@ -164,7 +177,7 @@ fn_select() {
164177
fi
165178

166179
layout_items="Theme Preference
167-
$layout_items"
180+
${layout_items}"
168181

169182
selected_layout=$(awk -F/ '{print $NF}' <<<"$layout_items" |
170183
rofi -dmenu -i -select "${HYPRLOCK_LAYOUT}" \
@@ -173,29 +186,128 @@ $layout_items"
173186
-theme-str "${font_override}" \
174187
-theme-str "${r_override}" \
175188
-theme-str "$(get_rofi_pos)" \
176-
-theme "${ROFI_HYPRLOCK_STYLE:-clipboard}")
189+
-on-selection-changed "hyde-shell hyprlock.sh --test-preview \"{entry}\"" \
190+
-theme "${ROFI_HYPRLOCK_STYLE:-clipboard}" )
191+
177192
if [ -z "$selected_layout" ]; then
178193
echo "No selection made"
179194
exit 0
180195
fi
181-
set_conf "HYPRLOCK_LAYOUT" "${selected_layout}"
196+
197+
set_conf "HYPRLOCK_LAYOUT" "${selected_layout}"
182198
if [ "$selected_layout" == "Theme Preference" ]; then
183199
selected_layout="theme"
184200
fi
185-
generate_conf "${layout_dir}/${selected_layout}.conf"
186-
"${scrDir}/font.sh" resolve "${layout_dir}/${selected_layout}.conf"
201+
local hyprlock_conf_path
202+
hyprlock_conf_path=$(find_filepath "${selected_layout}")
203+
generate_conf "$hyprlock_conf_path"
204+
"${scrDir}/font.sh" resolve "$hyprlock_conf_path"
187205
fn_profile
188206

189207
# Notify the user
190208
notify-send -i "system-lock-screen" "Hyprlock layout:" "${selected_layout}"
191209

210+
}
211+
212+
check_and_sanitize_process() {
213+
local unit_name="${1:-${HYPRLOCK_SCOPE_NAME}}"
214+
if systemctl --user is-active "${unit_name}" > /dev/null 2>&1; then
215+
systemctl --user stop "${unit_name}" > /dev/null 2>&1
216+
fi
217+
}
218+
219+
reload_hyprlock() {
220+
local unit_name="${2:-${HYPRLOCK_SCOPE_NAME}}"
221+
222+
if systemctl --user is-active "${unit_name}" > /dev/null 2>&1; then
223+
systemctl --user kill -s USR2 "${HYPRLOCK_SCOPE_NAME}" >/dev/null 2>&1
224+
else
225+
pkill -USR2 hyprlock >/dev/null 2>&1
226+
fi
227+
228+
}
229+
230+
append_label_to_file() {
231+
local file="${1}"
232+
233+
cat <<EOF >>"${file}"
234+
label {
235+
text = PREVIEW! Press a key or swipe to exit.
236+
color = rgba(\$wallbash_txt122)
237+
font_size = 50
238+
position = 0, 0
239+
halign = center
240+
valign = top
241+
zindex = 6
242+
}
243+
244+
label {
245+
text = PREVIEW! Press a key or swipe to exit.
246+
color = rgba(\$wallbash_txt122)
247+
font_size = 50
248+
position = 0, 0
249+
halign = center
250+
valign = bottom
251+
zindex = 6
252+
}
253+
254+
label {
255+
text = PREVIEW! Press a key or swipe to exit.
256+
color = rgba(\$wallbash_txt122)
257+
font_size = 50
258+
position = 0, 0
259+
halign = center
260+
valign = center
261+
zindex = 6
262+
}
263+
264+
EOF
265+
266+
}
267+
268+
269+
layout_test() {
270+
print_log -sec "hyprlock" -stat "Test" "Please swipe,press a key or click to exit."
271+
local hyprlock_conf_name="${*:-${1}}"
272+
if [[ "${hyprlock_conf_name}" == "Theme Preference" ]]; then
273+
hyprlock_conf_name="theme"
274+
fi
275+
check_and_sanitize_process
276+
hyprlock_conf_path=$(find_filepath "${hyprlock_conf_name}")
277+
if [ -z "${hyprlock_conf_path}" ]; then
278+
print_log -sec "hyprlock" -stat "Error" "Layout ${hyprlock_conf_name} not found."
279+
exit 1
280+
fi
281+
sleep 2
282+
local temp_path="${XDG_RUNTIME_DIR}/hyde/hyprlock-test.conf"
283+
generate_conf "${hyprlock_conf_path}" "${temp_path}"
284+
append_label_to_file "${temp_path}"
285+
app2unit.sh -S both -u "${HYPRLOCK_SCOPE_NAME}" -t scope -- hyprlock --no-fade-in --immediate-render --grace 99999999 -c "${temp_path}"
286+
rm -f "${temp_path}"
287+
}
288+
289+
rofi_test_preview() {
290+
#? this function provides an anti spam mechanism for the rofi preview
291+
local hyprlock_conf_name="${*:-${1}}"
292+
if [[ "${hyprlock_conf_name}" == "Theme Preference" ]]; then
293+
hyprlock_conf_name="theme"
294+
fi
295+
local unit_name="hyde-${XDG_SESSION_DESKTOP:-unknown}-lockscreen-preview.scope"
296+
check_and_sanitize_process "${unit_name}"
297+
send_notifs "Hyprlock layout: ${hyprlock_conf_name}" "Please swipe, press a key or click to exit." \
298+
-i "system-lock-screen" -t 3000 \
299+
-r 9
300+
app2unit.sh -S both -u "${unit_name}" -t scope -- hyprlock.sh --test "${hyprlock_conf_name}"
301+
302+
192303
}
193304

194305
generate_conf() {
195306
local path="${1:-$confDir/hypr/hyprlock/theme.conf}"
307+
local target_file="${2:-$confDir/hypr/hyprlock.conf}"
196308
local hyde_hyprlock_conf=${SHARE_DIR:-$XDG_DATA_HOME}/hyde/hyprlock.conf
197309

198-
cat <<CONF >"$confDir/hypr/hyprlock.conf"
310+
cat <<CONF >"${target_file}"
199311
#! █░█ █▄█ █▀█ █▀█ █░░ █▀█ █▀▀ █▄▀
200312
#! █▀█ ░█░ █▀▀ █▀▄ █▄▄ █▄█ █▄▄ █░█
201313
@@ -316,12 +428,13 @@ if [ -z "${*}" ]; then
316428
print_log -sec "hyprlock" -stat "setting" " $HYDE_CACHE_HOME/wallpapers/hyprlock.png"
317429
"${scrDir}/wallpaper.sh" -s "$(readlink "${HYDE_THEME_DIR}/wall.set")" --backend hyprlock
318430
fi
319-
pidof hyprlock || hyprlock
431+
check_and_sanitize_process
432+
app2unit.sh -u "${HYPRLOCK_SCOPE_NAME}" -t scope -- hyprlock
320433
exit 0
321434
fi
322435

323436
# Define long options
324-
LONGOPTS="select,background,profile,mpris:,cava,art,help"
437+
LONGOPTS="select,background,profile,mpris:,cava,art,help,test:,test-preview:"
325438

326439
# Parse options
327440
PARSED=$(
@@ -335,6 +448,14 @@ eval set -- "$PARSED"
335448

336449
while true; do
337450
case "$1" in
451+
--test)
452+
layout_test "${2}"
453+
exit 0
454+
;;
455+
--test-preview)
456+
rofi_test_preview "${2}"
457+
exit 0
458+
;;
338459
select | -S | --select)
339460
fn_select
340461
exit 0

Configs/.local/lib/hyde/screenshot.sh

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ save_dir="${2:-$XDG_PICTURES_DIR/Screenshots}"
5151
save_file=$(date +'%y%m%d_%Hh%Mm%Ss_screenshot.png')
5252
annotation_tool=${SCREENSHOT_ANNOTATION_TOOL}
5353
annotation_args=("-o" "${save_dir}/${save_file}" "-f" "${temp_screenshot}")
54+
tesseract_default_language=("eng")
55+
tesseract_languages=("${SCREENSHOT_OCR_TESSERACT_LANGUAGES[@]:-${tesseract_default_language[@]}}")
56+
tesseract_languages+=("osd")
5457

5558
if [[ -z "$annotation_tool" ]]; then
5659
pkg_installed "swappy" && annotation_tool="swappy"
@@ -90,6 +93,54 @@ take_screenshot() {
9093
fi
9194
}
9295

96+
ocr_screenshot() {
97+
local mode=$1
98+
shift
99+
local extra_args=("$@")
100+
101+
# execute grimblast with given args
102+
if "$LIB_DIR/hyde/grimblast" "${extra_args[@]}" copysave "$mode" "$temp_screenshot"; then
103+
if pkg_installed imagemagick; then
104+
magick "${temp_screenshot}" \
105+
-colorspace gray \
106+
-contrast-stretch 0 \
107+
-level 15%,85% \
108+
-resize 400% \
109+
-sharpen 0x1 \
110+
-auto-threshold triangle \
111+
-morphology close diamond:1 \
112+
-deskew 40% \
113+
"${temp_screenshot}"
114+
else
115+
notify-send -a "HyDE Alert" "OCR: imagemagick is not installed, recognition accuracy is reduced" -e -i "dialog-warning"
116+
fi
117+
tesseract_package_prefix="tesseract-data-"
118+
tesseract_packages=("${tesseract_languages[@]/#/$tesseract_package_prefix}")
119+
tesseract_packages+=("tesseract")
120+
for pkg in "${tesseract_packages[@]}"; do
121+
if ! pkg_installed "${pkg}"; then
122+
notify-send -a "HyDE Alert" "$(echo -e "OCR: required package is not installed\n ${pkg}")" -e -i "dialog-error"
123+
return 1
124+
fi
125+
done
126+
tesseract_languages_prepared=$(IFS=+; echo "${tesseract_languages[*]}")
127+
tesseract_output=$(tesseract \
128+
--psm 6 \
129+
--oem 3 \
130+
-l ${tesseract_languages_prepared} \
131+
"${temp_screenshot}" \
132+
stdout
133+
2>/dev/null
134+
)
135+
printf "%s" "$tesseract_output" | wl-copy
136+
notify-send -a "HyDE Alert" "$(echo -e "OCR: ${#tesseract_output} symbols recognized\n\nLanguages used ${tesseract_languages[@]/#/'\n '}")" -i "${temp_screenshot}" -e
137+
rm -f "${temp_screenshot}"
138+
else
139+
notify-send -a "HyDE Alert" "OCR: screenshot error" -e -i "dialog-error"
140+
return 1
141+
fi
142+
}
143+
93144
pre_cmd
94145

95146
case $1 in
@@ -106,23 +157,14 @@ m) # print focused monitor
106157
take_screenshot "output"
107158
;;
108159
sc) #? 󱉶 Use 'tesseract' to scan image then add to clipboard
109-
check_package tesseract-data-eng tesseract
110-
if ! GEOM=$(slurp); then
111-
notify-send -a "HyDE Alert" "OCR preview: Invalid geometry" -e -i "dialog-error"
112-
exit 1
113-
fi
114-
grim -g "${GEOM}" "${temp_screenshot}"
115-
pkg_installed imagemagick && magick "${temp_screenshot}" -sigmoidal-contrast 10,50% "${temp_screenshot}"
116-
tesseract "${temp_screenshot}" - | wl-copy
117-
notify-send -a "HyDE Alert" "OCR preview" -i "${temp_screenshot}" -e
118-
rm -f "${temp_screenshot}"
160+
ocr_screenshot "area" "--freeze"
119161
;;
120162
*) # invalid option
121163
USAGE
122164
;;
123165
esac
124166

125-
[ -f "$temp_screenshot" ] && rm "$temp_screenshot"
167+
[ -f "${temp_screenshot}" ] && rm "${temp_screenshot}"
126168

127169
if [ -f "${save_dir}/${save_file}" ]; then
128170
notify-send -a "HyDE Alert" -i "${save_dir}/${save_file}" "saved in ${save_dir}"

0 commit comments

Comments
 (0)