
Yêu cầu cài thêm:
grim: để chụp màn hình.ImageMagick: để sửa ảnh.
-
Tạo script
~/.local/bin/lock_screen.shvới nội dung:#!/bin/bash # Take screenshot grim /tmp/screen.png # Pixelate it convert /tmp/screen.png -scale 10% -scale 1000% /tmp/screen.png # Optional: Add a overlay image at center # convert /tmp/screen.png <your_image> -gravity center -composite -matte /tmp/screen.png # Lock screen hyprlock -
Thêm quyền chạy:
chmod +x ~/.local/bin/lock_screen.sh -
Sửa file
~/.config/hypr/hyprlock.confđể dùng file/tmp/screen.pngnhư hình nền khóa:background { path = /tmp/screen.png } -
Sửa file
~/.config/hypr/hyprland.confgọi scriptlock_screen.shkhi bấm Window+L:# Lock screen when press $mainMod + L bind = $mainMod, L, exec, ~/.local/bin/lock_screen.sh -
Sửa
~/.config/hypr/hypridle.confđể dùnglock_screen.shkhi tự động khóa màn hình:general { lock_cmd = pidof hyprlock | ~/.local/bin/lock_screen.sh before_sleep_cmd = loginctl lock-session after_sleep_cmd = hyprctl dispatch dpms on } listener { timeout = 300 on-timeout = loginctl lock-session } listener { timeout = 360 on-timeout = hyprctl dispatch dpms off on-resume = hyprctl dispatch dpms on }
Bình luận