From ed0b3da264b0cc96d26948285e920b02b1c6c5b8 Mon Sep 17 00:00:00 2001 From: dabruh <11458706-dabruh@users.noreply.gitlab.com> Date: Fri, 10 Jun 2022 17:30:12 +0200 Subject: [PATCH] Implemented blurred lock screen. --- .installer/packages | 4 ++-- .local/bin/i3exit | 31 ++++++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.installer/packages b/.installer/packages index 5a6200f..b574d32 100644 --- a/.installer/packages +++ b/.installer/packages @@ -1,6 +1,6 @@ pacman-any:i3-gaps,feh,i3status,network-manager-applet,pasystray,xautolock,inotify-tools,xss-lock,noto-fonts-emoji pacman-any:gst-libav,phonon-qt5-gstreamer,gst-plugins-good,qt5-quickcontrols,qt5-graphicaleffects,qt5-multimedia -pacman-any:code,vim,ufw +pacman-any:code,vim,ufw,scrot pacman-laptop:brightnessctl aur-any:picom-git,flashfocus-git,sddm-theme-aerial-git @@ -9,7 +9,7 @@ apt-any:libxext-dev,libxcb1-dev,libxcb-damage0-dev,libxcb-xfixes0-dev,libxcb-sha apt-any:python3,python3-pip apt-any:libxcb-render0-dev,libffi-dev,python-dev,python-cffi apt-any:sddm,gstreamer1.0-libav,phonon4qt5-backend-gstreamer,gstreamer1.0-plugins-good,qml-module-qtquick-controls,qml-module-qtgraphicaleffects,qml-module-qtmultimedia,qt5-default -apt-any:codium,vim,ufw +apt-any:codium,vim,ufw,scrot apt-laptop:brightnessctl pip-any:flashfocus diff --git a/.local/bin/i3exit b/.local/bin/i3exit index 1c261f0..02ae60d 100755 --- a/.local/bin/i3exit +++ b/.local/bin/i3exit @@ -7,20 +7,40 @@ # with openrc use loginctl [[ $(cat /proc/1/comm) == "systemd" ]] && logind=systemctl || logind=loginctl +LOCK_SCREEN_BLUR=${LOCK_SCREEN_BLUR:-false} LOCK_SCREEN_COLOR=${LOCK_SCREEN_COLOR:-29414f} +_lock() { + i3lock -c "$LOCK_SCREEN_COLOR" +} + +_unlock() { + pkill -u "$USER" -f "i3lock -(c|i) " +} + lock() { - if command -v blurlock >/dev/null; then - blurlock - return 0 + local screen=/tmp/screenshot.png blurred=/tmp/screenshotblur.png + + _lock # Lock immediately + + if $LOCK_SCREEN_BLUR; then + # Take screenshot and blur it + scrot -q 100 $screen || return 1 # Larger file size, but faster + convert -scale 10% -blur 0x1.25 -resize 1000% $screen $blurred || return 1 + rm $screen + + # Now try to replace the solid color with the blurred image. + _unlock + i3lock -i $blurred || _lock fi - i3lock --color="$LOCK_SCREEN_COLOR" + # Add a small delay to prevent possible race conditions with suspend + sleep 1 } case "$1" in lock) - lock + lock; echo $? ;; logout) i3-msg exit @@ -51,6 +71,7 @@ case "$1" in echo "== ! i3exit: missing or invalid argument ! ==" $0 help exit 2 + ;; esac exit 0