Skip to content

Commit c021302

Browse files
authored
Merge branch 'dev' into replace-cat-with-bat
2 parents 7906c0a + c9ebeae commit c021302

File tree

3 files changed

+262
-12
lines changed

3 files changed

+262
-12
lines changed

β€Ž.all-contributorsrcβ€Ž

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,130 @@
2525
"code",
2626
"doc"
2727
]
28+
},
29+
{
30+
"login": "prasanthrangan",
31+
"name": "Tittu",
32+
"avatar_url": "https://avatars.githubusercontent.com/u/106020512?v=4",
33+
"profile": "https://github.com/prasanthrangan",
34+
"contributions": [
35+
"code",
36+
"doc"
37+
]
38+
},
39+
{
40+
"login": "dieBakterie",
41+
"name": "dieBakterie",
42+
"avatar_url": "https://avatars.githubusercontent.com/u/50206827?v=4",
43+
"profile": "https://github.com/dieBakterie",
44+
"contributions": [
45+
"code",
46+
"test",
47+
"doc"
48+
]
49+
},
50+
{
51+
"login": "richen604",
52+
"name": "Richard Henninger",
53+
"avatar_url": "https://avatars.githubusercontent.com/u/56615615?v=4",
54+
"profile": "https://github.com/richen604",
55+
"contributions": [
56+
"code",
57+
"test",
58+
"doc"
59+
]
60+
},
61+
{
62+
"login": "Guillaumecoi",
63+
"name": "Guillaume Coigniez",
64+
"avatar_url": "https://avatars.githubusercontent.com/u/120651399?v=4",
65+
"profile": "https://github.com/Guillaumecoi",
66+
"contributions": [
67+
"code",
68+
"test",
69+
"doc"
70+
]
71+
},
72+
{
73+
"login": "heeeeeeeeeeh",
74+
"name": "Silvestre Espinoza",
75+
"avatar_url": "https://avatars.githubusercontent.com/u/90989842?v=4",
76+
"profile": "https://github.com/heeeeeeeeeeh",
77+
"contributions": [
78+
"code",
79+
"test",
80+
"doc"
81+
]
82+
},
83+
{
84+
"login": "prime-run",
85+
"name": "prime-run",
86+
"avatar_url": "https://avatars.githubusercontent.com/u/158470661?v=4",
87+
"profile": "https://github.com/prime-run",
88+
"contributions": [
89+
"code",
90+
"test",
91+
"doc"
92+
]
93+
},
94+
{
95+
"login": "T-Crypt",
96+
"name": "Trevin",
97+
"avatar_url": "https://avatars.githubusercontent.com/u/132922589?v=4",
98+
"profile": "https://github.com/T-Crypt",
99+
"contributions": [
100+
"code",
101+
"test",
102+
"doc"
103+
]
104+
},
105+
{
106+
"login": "Prof-Shiba",
107+
"name": "ProfShiba",
108+
"avatar_url": "https://avatars.githubusercontent.com/u/166961473?v=4",
109+
"profile": "https://github.com/Prof-Shiba",
110+
"contributions": [
111+
"test"
112+
]
113+
},
114+
{
115+
"login": "amit-0i",
116+
"name": "amit",
117+
"avatar_url": "https://avatars.githubusercontent.com/u/208910917?v=4",
118+
"profile": "https://github.com/amit-0i",
119+
"contributions": [
120+
"test"
121+
]
122+
},
123+
{
124+
"login": "UnaTried",
125+
"name": "UnaTried",
126+
"avatar_url": "https://avatars.githubusercontent.com/u/103455203?v=4",
127+
"profile": "http://unatried.com",
128+
"contributions": [
129+
"test"
130+
]
131+
},
132+
{
133+
"login": "Metalhearf",
134+
"name": "Metalhearf",
135+
"avatar_url": "https://avatars.githubusercontent.com/u/6446231?v=4",
136+
"profile": "https://metalhearf.fr",
137+
"contributions": [
138+
"code",
139+
"test",
140+
"doc"
141+
]
142+
},
143+
{
144+
"login": "zeerayne",
145+
"name": "Ilya Bogdanov",
146+
"avatar_url": "https://avatars.githubusercontent.com/u/13994839?v=4",
147+
"profile": "https://github.com/zeerayne",
148+
"contributions": [
149+
"bug",
150+
"code"
151+
]
28152
}
29153
],
30154
"contributorsPerLine": 7,

β€ŽCHANGELOG.mdβ€Ž

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
2020
tesseract_languages = ["eng"]
2121
```
2222
To use text recognition bind `hyde-shell screenshot sc` to any hotkey.
23-
23+
- Hyprlock: Added hyprlock preview
24+
25+
### Fixed
26+
27+
- Hyprlock: fix hyprlock crashing by handling it as a systemd scope unit
28+
2429
## v25.9.1
2530

2631
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.

β€Ž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

0 commit comments

Comments
Β (0)