unified indentation, removed duplicate code (#50)

This commit is contained in:
Philipp Hemmelmayr 2018-04-27 19:18:51 +02:00 committed by Pavan Jadhaw
parent 368b30495d
commit 3217a0b564

View file

@ -52,7 +52,7 @@ lock() {
--ringvercolor=$foreground --ringwrongcolor=$foreground --indpos="x+280:h-70" \ --ringvercolor=$foreground --ringwrongcolor=$foreground --indpos="x+280:h-70" \
--radius=20 --ring-width=4 --veriftext="" --wrongtext="" \ --radius=20 --ring-width=4 --veriftext="" --wrongtext="" \
--verifcolor="$foreground" --timecolor="$foreground" --datecolor="$foreground" \ --verifcolor="$foreground" --timecolor="$foreground" --datecolor="$foreground" \
--noinputtext="" --force-clock $lockargs --noinputtext="" --force-clock $lockargs
} }
postlock() { postlock() {
@ -70,10 +70,42 @@ rec_get_random() {
rec_get_random "$dir" rec_get_random "$dir"
} }
lockselect() {
case "$1" in
"")
# default lockscreen
prelock
lock "$l_resized" && $2
postlock
;;
dim)
# lockscreen with dimmed background
prelock
lock "$l_dim" && $2
postlock
;;
blur)
# set lockscreen with blurred background
prelock
lock "$l_blur" && $2
postlock
;;
dimblur)
# set lockscreen with dimmed + blurred background
prelock
lock "$l_dimblur" && $2
postlock
;;
esac
}
usage() { usage() {
echo "Important : Update the image cache, Ex: betterlockscreen -u path/to/image.jpg" echo "Important : Update the image cache, Ex: betterlockscreen -u path/to/image.jpg"
echo " Image cache must be updated to initially configure or update wallpaper used" echo " Image cache must be updated to initially configure or update wallpaper used"
echo echo
echo echo
echo "See : https://github.com/pavanjadhaw/betterlockscreen for additional info..." echo "See : https://github.com/pavanjadhaw/betterlockscreen for additional info..."
@ -81,67 +113,64 @@ usage() {
echo echo
echo "Options:" echo "Options:"
echo echo
echo " -h --help" echo " -h --help"
echo " For help. Ex: betterlockscreen -h or betterlockscreen --help" echo " For help. Ex: betterlockscreen -h or betterlockscreen --help"
echo echo
echo echo
echo " -u --update" echo " -u --update"
echo " to update image cache, you should do this before using any other options" echo " to update image cache, you should do this before using any other options"
echo " Ex: betterlockscreen -u path/to/image.png when image.png is custom background"
echo " Ex: betterlockscreen -u path/to/image.png when image.png is custom background" echo " Or you can use betterlockscreen -u path/to/imagedir and a random file will be selected"
echo " Or you can use betterlockscreen -u path/to/imagedir and a random file will be selected"
echo echo
echo echo
echo " -l --lock" echo " -l --lock"
echo " to lock screen, Ex. betterlockscreen -l" echo " to lock screen, Ex. betterlockscreen -l"
echo " you can also use dimmed or blurred background for lockscreen" echo " you can also use dimmed or blurred background for lockscreen"
echo " Ex: betterlockscreen -l dim (for dimmed background)" echo " Ex: betterlockscreen -l dim (for dimmed background)"
echo " Ex: betterlockscreen -l blur (for blurred background)" echo " Ex: betterlockscreen -l blur (for blurred background)"
echo " Ex: betterlockscreen -l dimblur (for dimmed + blurred background)" echo " Ex: betterlockscreen -l dimblur (for dimmed + blurred background)"
echo echo
echo echo
echo " -s --suspend" echo " -s --suspend"
echo " to suspend system and lock screen, Ex. betterlockscreen -s" echo " to suspend system and lock screen, Ex. betterlockscreen -s"
echo " you can also use dimmed or blurred background for lockscreen" echo " you can also use dimmed or blurred background for lockscreen"
echo " Ex: betterlockscreen -s dim (for dimmed background)" echo " Ex: betterlockscreen -s dim (for dimmed background)"
echo " Ex: betterlockscreen -s blur (for blurred background)" echo " Ex: betterlockscreen -s blur (for blurred background)"
echo " Ex: betterlockscreen -s dimblur (for dimmed + blurred background)" echo " Ex: betterlockscreen -s dimblur (for dimmed + blurred background)"
echo echo
echo echo
echo " -w --wall" echo " -w --wall"
echo " you can also set lockscreen background as wallpaper" echo " you can also set lockscreen background as wallpaper"
echo " to set wallpaper. Ex betterlockscreen -w or betterlockscreen --wall" echo " to set wallpaper. Ex betterlockscreen -w or betterlockscreen --wall"
echo " you can also use dimmed or blurred variants" echo " you can also use dimmed or blurred variants"
echo " Ex: betterlockscreen -w dim (for dimmed wallpaper)" echo " Ex: betterlockscreen -w dim (for dimmed wallpaper)"
echo " Ex: betterlockscreen -w blur (for blurred wallpaper)" echo " Ex: betterlockscreen -w blur (for blurred wallpaper)"
echo " Ex: betterlockscreen -w dimblur (for dimmed + blurred wallpaper)" echo " Ex: betterlockscreen -w dimblur (for dimmed + blurred wallpaper)"
echo echo
echo echo
echo " -r --resolution" echo " -r --resolution"
echo " to be used after -u" echo " to be used after -u"
echo " used to set a custom resolution for the image cache." echo " used to set a custom resolution for the image cache."
echo " Ex: betterlockscreen -u path/to/image.png -r 1920x1080" echo " Ex: betterlockscreen -u path/to/image.png -r 1920x1080"
echo " Ex: betterlockscreen -u path/to/image.png --resolution 3840x1080" echo " Ex: betterlockscreen -u path/to/image.png --resolution 3840x1080"
echo echo
echo " -b --blur" echo
echo " to be used after -u" echo " -b --blur"
echo " used to set blur intensity. Default to 1." echo " to be used after -u"
echo " Ex: betterlockscreen -u path/to/image.png -b 3" echo " used to set blur intensity. Default to 1."
echo " Ex: betterlockscreen -u path/to/image.png --blur 0.5" echo " Ex: betterlockscreen -u path/to/image.png -b 3"
echo echo " Ex: betterlockscreen -u path/to/image.png --blur 0.5"
} }
# Options # Options
case "$1" in case "$1" in
"") "")
if [ ! -f $l_dim ]; then if [ ! -f $l_dim ]; then
echo "Important : Update the image cache, Ex. betterlockscreen -u path/to/image.jpg" echo "Important : Update the image cache, Ex. betterlockscreen -u path/to/image.jpg"
echo echo
echo " Image cache must be updated to initially configure or update wallpaper used" echo " Image cache must be updated to initially configure or update wallpaper used"
echo echo
echo "See also : For other set of options and help use help command." echo "See also : For other set of options and help use help command."
echo "Ex. betterlockscreen -h or betterlockscreen --help" echo "Ex. betterlockscreen -h or betterlockscreen --help"
@ -165,76 +194,18 @@ case "$1" in
-h | --help) -h | --help)
usage usage
;; ;;
-l | --lock) -l | --lock)
lockargs="-n" lockargs="-n"
case "$2" in lockselect "$2"
"")
# default lockscreen
prelock
lock "$l_resized"
postlock
;;
dim)
# lockscreen with dimmed background
prelock
lock "$l_dim"
postlock
;;
blur)
# set lockscreen with blurred background
prelock
lock "$l_blur"
postlock
;;
dimblur)
# set lockscreen with dimmed + blurred background
prelock
lock "$l_dimblur"
postlock
;;
esac
;; ;;
-s | --suspend) -s | --suspend)
case "$2" in lockselect "$2" "systemctl suspend"
"")
# default lockscreen
prelock
lock "$l_resized" && systemctl suspend
postlock
;;
dim)
# lockscreen with dimmed background
prelock
lock "$l_dim" && systemctl suspend
postlock
;;
blur)
# set lockscreen with blurred background
prelock
lock "$l_blur" && systemctl suspend
postlock
;;
dimblur)
# set lockscreen with dimmed + blurred background
prelock
lock "$l_dimblur" && systemctl suspend
postlock
;;
esac
;; ;;
-w | --wall) -w | --wall)
case "$2" in case "$2" in
"") "")
@ -270,18 +241,18 @@ case "$1" in
# parse update arguments # parse update arguments
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
-r | --resolution ) -r | --resolution )
y_res="$2" y_res="$2"
shift 2 shift 2
;; ;;
-b | --blur ) -b | --blur )
blur_level="$2" blur_level="$2"
shift 2 shift 2
;; ;;
*) *)
shift ;; shift ;;
esac esac
done done
rectangles=" " rectangles=" "
@ -335,26 +306,26 @@ case "$1" in
blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc)
blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc)
convert "$resized" \ convert "$resized" \
-filter Gaussian \ -filter Gaussian \
-resize "$blur_shrink%" \ -resize "$blur_shrink%" \
-define "filter:sigma=$blur_sigma" \ -define "filter:sigma=$blur_sigma" \
-resize "$y_res^" -gravity center -extent "$y_res" \ -resize "$y_res^" -gravity center -extent "$y_res" \
"$blur" "$blur"
# dimblur # dimblur
convert "$dim" \ convert "$dim" \
-filter Gaussian \ -filter Gaussian \
-resize "$blur_shrink%" \ -resize "$blur_shrink%" \
-define "filter:sigma=$blur_sigma" \ -define "filter:sigma=$blur_sigma" \
-resize "$y_res^" -gravity center -extent "$y_res" \ -resize "$y_res^" -gravity center -extent "$y_res" \
"$dimblur" "$dimblur"
# lockscreen backgrounds # lockscreen backgrounds
echo echo
echo "Caching images for faster screen locking" echo "Caching images for faster screen locking"
# resized # resized
convert "$resized" -draw "fill rgba(0, 0, 0, 0.4) $rectangles" "$l_resized" convert "$resized" -draw "fill rgba(0, 0, 0, 0.4) $rectangles" "$l_resized"
# dim # dim
convert "$dim" -draw "fill rgba(0, 0, 0, 0.4) $rectangles" "$l_dim" convert "$dim" -draw "fill rgba(0, 0, 0, 0.4) $rectangles" "$l_dim"
@ -367,5 +338,9 @@ case "$1" in
echo echo
echo "All required changes have been applied" echo "All required changes have been applied"
;; ;;
*)
echo "invalid argument"
;;
esac esac