diff --git a/lock b/lock index 81d0489..2c0354f 100755 --- a/lock +++ b/lock @@ -3,6 +3,10 @@ # Dependencies: imagemagick, i3lock-color-git, scrot, wmctrl (optional) set -o errexit -o noclobber -o nounset +# get path where the script is located to find the lock icon +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%) # default system sans-serif font @@ -10,6 +14,7 @@ font="$(convert -list font | awk "{ a[NR] = \$2 } /family: $(fc-match sans -f "% image="$(mktemp).png" shot=(import -window root) desktop="" +param_add=("") shot_custom=false options="Options: @@ -29,6 +34,8 @@ options="Options: Note: this option will not lock the screen, it displays the list and exits immediately. + -n, --nofork Do not fork i3lock after starting. + -- Must be last option. Set command to use for taking a screenshot. Default is 'import -window root'. Using 'scrot' or 'maim' will increase script speed and allow setting @@ -37,7 +44,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 :hdpglt:f: -l desktop,help,listfonts,pixelate,greyscale,text:,font: --name "$0" -- "$@")" +temp="$(getopt -o :hdnpglt:f: -l desktop,help,listfonts,nofork,pixelate,greyscale,text:,font: --name "$0" -- "$@")" eval set -- "$temp" # l10n support @@ -72,6 +79,7 @@ while true ; do -l|--listfonts) convert -list font | awk -F: '/Font: / { print $2 }' | sort -du | command -- ${PAGER:-less} exit 0 ;; + -n|--nofork) param_add=(--nofork) ; shift ;; --) shift; shot_custom=true; break ;; *) echo "error" ; exit 1 ;; esac @@ -83,10 +91,6 @@ fi command -- "${shot[@]}" "$image" -# get path where the script is located to find the lock icon -scriptpath=$(readlink -f -- "$0") -scriptpath=${scriptpath%/*} - value="60" #brightness value to compare to color=$(convert "$image" -gravity center -crop 100x100+0+0 +repage -colorspace hsb \ @@ -116,9 +120,9 @@ convert "$image" "${hue[@]}" "${effect[@]}" -font "$font" -pointsize 26 -fill "$ ${desktop} ${desktop:+-k on} # try to use a forked version of i3lock with prepared parameters -if ! i3lock -n "${param[@]}" -i "$image" > /dev/null 2>&1; then +if ! i3lock "${param_add[@]}" "${param[@]}" -i "$image" > /dev/null 2>&1; then # We have failed, lets get back to stock one - i3lock -n -i "$image" + i3lock "${param_add[@]}" -i "$image" fi # As above, if we were passed -d/--desktop, we'll attempt to restore all windows