Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom blur level #93

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ Usage
-h, --help This help menu.

-d, --desktop Attempt to minimize all windows before locking. Requires wmctrl.


-b <blurlevel>, --blur <blurlevel> Set a custom blur level.
Default: 1.5

-g, --greyscale Set background to greyscale instead of color.

-p, --pixelate Pixelate the background instead of blur, runs faster.
Expand Down
20 changes: 17 additions & 3 deletions lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ scriptpath=$(readlink -f -- "$0")
scriptpath=${scriptpath%/*}

hue=(-level "0%,100%,0.6")
effect=(-filter Gaussian -resize 20% -define "filter:sigma=1.5" -resize 500.5%)
blur_level="1.5"
# default system sans-serif font
font=$(convert -list font | awk "{ a[NR] = \$2 } /family: $(fc-match sans -f "%{family}\n")/ { print a[NR-1]; exit }")
image=$(mktemp --suffix=.png)
Expand All @@ -22,6 +22,9 @@ options="Options:

-d, --desktop Attempt to minimize all windows before locking.

-b <blurlevel>, --blur <blurlevel> Set a custom blur level.
Default: ${blur_level}

-g, --greyscale Set background to greyscale instead of color.

-p, --pixelate Pixelate the background instead of blur, runs faster.
Expand All @@ -44,7 +47,7 @@ options="Options:
# move pipefail down as for some reason "convert -list font" returns 1
set -o pipefail
trap 'rm -f "$image"' EXIT
temp="$(getopt -o :hdnpglt:f: -l desktop,help,listfonts,nofork,pixelate,greyscale,text:,font: --name "$0" -- "$@")"
temp="$(getopt -o :hdnpglt:f:b: -l desktop,help,listfonts,nofork,pixelate,greyscale,text:,font:,blur: --name "$0" -- "$@")"
eval set -- "$temp"

# l10n support
Expand All @@ -63,13 +66,20 @@ case "${LANG:-}" in
* ) text="Type password to unlock" ;; # Default to English
esac

set_effect=true
while true ; do
case "$1" in
-h|--help)
printf "Usage: %s [options]\n\n%s\n\n" "${0##*/}" "$options"; exit 1 ;;
-d|--desktop) desktop=$(command -V wmctrl) ; shift ;;
-b|--blur)
case "$2" in
""|[[:alpha:]]*) shift 2 ;;
-*) shift ;;
*) blur_level="$2" ; shift 2 ;;
esac ;;
-g|--greyscale) hue=(-level "0%,100%,0.6" -set colorspace Gray -separate -average) ; shift ;;
-p|--pixelate) effect=(-scale 10% -scale 1000%) ; shift ;;
-p|--pixelate) effect=(-scale 10% -scale 1000%) ; set_effect=false ; shift ;;
-f|--font)
case "$2" in
"") shift 2 ;;
Expand All @@ -85,6 +95,10 @@ while true ; do
esac
done

if "$set_effect"; then
effect=(-filter Gaussian -resize 20% -define "filter:sigma=${blur_level}" -resize 500.5%)
fi

if "$shot_custom" && [[ $# -gt 0 ]]; then
shot=("$@");
fi
Expand Down