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