From 3df1808280a8611b73827f3f35d29d5e1ca73763 Mon Sep 17 00:00:00 2001 From: Pavan Jadhaw Date: Thu, 31 Jan 2019 09:54:57 +0530 Subject: [PATCH 01/36] [main] add ability to choose on which screen clock is shown for multimonitor setup --- README.md | 3 + betterlockscreen | 214 +++++++++++------------------------- examples/betterlockscreenrc | 1 + 3 files changed, 69 insertions(+), 149 deletions(-) diff --git a/README.md b/README.md index 00c21f7..242ee14 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,9 @@ If you have installed betterlockscreen from AUR package, then you can copy defau cp /usr/share/doc/betterlockscreen/examples/betterlockscreenrc ~/.config ``` +For multimonitor setups, now you can choose which monitor the clock is displayed on +modify screennumber in betterlockscreenrc accordingly. Its zero based i.e 0 = screen 1 + ### Usage Run `betterlockscreen` and point it to either a directory (`betterlockscreen -u "path/to/dir"`) or an image (`betterlockscreen -u "/path/to/img.jpg"`) and that's all. `betterlockscreen` will change update its cache with image you provided. diff --git a/betterlockscreen b/betterlockscreen index 9c21ec7..3ffb808 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -6,46 +6,42 @@ # find your resolution so images can be resized to match your screen resolution res=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') -default_timeout="$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')")" -default_dpms=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}') +locktext='Type password to unlock...' + init_filenames() { #$1 resolution - # copy this block to ~/.config/betterlockscreenrc" to customize - insidecolor=00000000 - ringcolor=ffffffff - keyhlcolor=d23c3dff - bshlcolor=d23c3dff - separatorcolor=00000000 - insidevercolor=00000000 - insidewrongcolor=d23c3dff - ringvercolor=ffffffff - ringwrongcolor=ffffffff - verifcolor=ffffffff - timecolor=ffffffff - datecolor=ffffffff - loginbox=00000066 - font="sans-serif" - locktext='Type password to unlock...' - wallpaper_cmd='feh --bg-fill --no-fehbg' - time_format='%H:%M:%S' - - # override defaults with config + # custom i3lock colors theme_rc="$HOME/.config/betterlockscreenrc" - if [ -e "$theme_rc" ]; then - # shellcheck disable=SC1090 - source "$theme_rc" + if [ -e $theme_rc ]; then + source "$theme_rc" + else + # copy this block to ~/.config/betterlockscreenrc" to customize + screennumber=0 + insidecolor=00000000 + ringcolor=ffffffff + keyhlcolor=d23c3dff + bshlcolor=d23c3dff + separatorcolor=00000000 + insidevercolor=00000000 + insidewrongcolor=d23c3dff + ringvercolor=ffffffff + ringwrongcolor=ffffffff + verifcolor=ffffffff + timecolor=ffffffff + datecolor=ffffffff + loginbox=00000066 + font="sans-serif" fi # create folder in ~/.cache/i3lock directory res_folder="$HOME/.cache/i3lock/$1" folder="$HOME/.cache/i3lock/current" - echo "Got" "$@" "$res_folder" - if [ ! -d "$folder" ] || [ -n "$2" ]; then - rm -rf "$folder" - mkdir -p "$res_folder" - ln -s "$res_folder" "$folder" + echo "Got" $@ $res_folder + if [ ! -d $folder -o -n "$2" ]; then + rm -f $folder + ln -s $res_folder $folder fi # ratio for rectangle to be drawn for time background on lockscreen @@ -61,29 +57,21 @@ init_filenames() { dim="$folder/dim.png" # image with subtle overlay of black blur="$folder/blur.png" # blurred version dimblur="$folder/dimblur.png" - pixel="$folder/pixel.png" # pixelated image # lockscreen images (images to be used as lockscreen background) l_resized="$folder/l_resized.png" l_dim="$folder/l_dim.png" l_blur="$folder/l_blur.png" l_dimblur="$folder/l_dimblur.png" - l_pixel="$folder/l_pixel.png" } -init_filenames "$res" +init_filenames $res prelock() { - if [ -n "$lock_timeout" ]; then - xset dpms "$lock_timeout" - fi - if [ -n "$(pidof dunst)" ]; then + if [ ! -z "$(pidof dunst)" ]; then pkill -u "$USER" -USR1 dunst fi - if [[ "$runsuspend" = "true" ]]; then - lockargs="$lockargs -n" - fi } @@ -91,31 +79,23 @@ lock() { #$1 image path i3lock \ - -c 00000000 \ - -t -i "$1" \ - --time-pos='x+110:h-70' \ - --date-pos='x+43:h-45' \ - --clock --date-align 1 --date-str "$locktext" --time-str "$time_format" \ - --inside-color=$insidecolor --ring-color=$ringcolor --line-uses-inside \ - --keyhl-color=$keyhlcolor --bshl-color=$bshlcolor --separator-color=$separatorcolor \ - --insidever-color=$insidevercolor --insidewrong-color=$insidewrongcolor \ - --ringver-color=$ringvercolor --ringwrong-color=$ringwrongcolor --ind-pos='x+280:h-70' \ - --radius=20 --ring-width=4 --verif-text='' --wrong-text='' \ - --verif-color="$verifcolor" --time-color="$timecolor" --date-color="$datecolor" \ + -t -i "$1" --screen=$screennumber \ + --timepos='x+110:h-70' \ + --datepos='x+43:h-45' \ + --clock --date-align 1 --datestr "$locktext" \ + --insidecolor=$insidecolor --ringcolor=$ringcolor --line-uses-inside \ + --keyhlcolor=$keyhlcolor --bshlcolor=$bshlcolor --separatorcolor=$separatorcolor \ + --insidevercolor=$insidevercolor --insidewrongcolor=$insidewrongcolor \ + --ringvercolor=$ringvercolor --ringwrongcolor=$ringwrongcolor --indpos='x+280:h-70' \ + --radius=20 --ring-width=4 --veriftext='' --wrongtext='' \ + --verifcolor="$verifcolor" --timecolor="$timecolor" --datecolor="$datecolor" \ --time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \ - --noinput-text='' --force-clock --pass-media-keys "$lockargs" - + --noinputtext='' --force-clock $lockargs } postlock() { - if [ -n "$lock_timeout" ]; then - xset dpms "$default_timeout" - if [ "$default_dpms" = "Disabled" ]; then - xset -dpms - fi - fi - if [ -n "$(pidof dunst)" ] ; then + if [ ! -z "$(pidof dunst)" ] ; then pkill -u "$USER" -USR2 dunst fi } @@ -127,9 +107,9 @@ rec_get_random() { user_input="$dir" return fi - dirs=("$dir"/*) - random_dir="${dirs[RANDOM % ${#dirs[@]}]}" - rec_get_random "$random_dir" + dir=("$dir"/*) + dir="${dir[RANDOM % ${#dir[@]}]}" + rec_get_random "$dir" } @@ -151,11 +131,6 @@ lockselect() { lock "$l_dimblur" ;; - pixel) - # set lockscreen with pixelated background - lock "$l_pixel" - ;; - *) # default lockscreen lock "$l_resized" @@ -164,26 +139,19 @@ lockselect() { postlock } -# $1: number of pixels to convert -# $2: 1 for width. 2 for height logical_px() { # get dpi value from xrdb - local DPI - DPI=$(grep -oP 'Xft.dpi:\s*\K\d+' ~/.Xresources | bc) - if [ -z "$DPI" ]; then - DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$2/p" | head -n1) - fi + local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') # return the default value if no DPI is set if [ -z "$DPI" ]; then - echo "$1" + echo $1 else - local SCALE - SCALE=$(echo "scale=2; $DPI / 96.0" | bc) + local SCALE=$(echo "scale=2; $DPI / 96.0" | bc) # check if scaling the value is worthy - if [ "$(echo "$SCALE > 1.25" | bc -l)" -eq 0 ]; then - echo "$1" + if [ $(echo "$SCALE > 1.25" | bc -l) -eq 0 ]; then + echo $1 else echo "$SCALE * $1 / 1" | bc fi @@ -200,19 +168,17 @@ update() { rectangles=" " SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*') for RES in $SR; do - # shellcheck disable=SC2206 SRA=(${RES//[x+]/ }) - - CX=$((SRA[2] + $(logical_px 25 1))) - CY=$((SRA[1] - $(logical_px 30 2))) - rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300 1))),$((CY-$(logical_px 80 2))) " + CX=$((${SRA[2]} + $(logical_px 25))) + CY=$((${SRA[1]} - $(logical_px 30))) + rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " done # User supplied Image user_image="$folder/user_image.png" # create folder - if [ ! -d "$folder" ]; then + if [ ! -d $folder ]; then echo "Creating '$folder' directory to cache processed images." mkdir -p "$folder" fi @@ -222,7 +188,7 @@ update() { # get user image cp "$user_input" "$user_image" - if [ ! -f "$user_image" ]; then + if [ ! -f $user_image ]; then echo 'Please specify the path to the image you would like to use' exit 1 fi @@ -242,13 +208,10 @@ update() { convert "$orig_wall" -resize "$res""^" -gravity center -extent "$res" "$resized" echo - echo 'Applying dim, blur, and pixelation effect to resized image' + echo 'Applying dim and blur effect to resized image' # dim convert "$resized" -fill black -colorize 40% "$dim" - # pixel - convert -scale 10% -scale 1000% "$resized" "$pixel" - # blur blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) @@ -280,11 +243,8 @@ update() { # blur convert "$blur" -draw "fill #$loginbox $rectangles" "$l_blur" - # dimblur + # blur convert "$dimblur" -draw "fill #$loginbox $rectangles" "$l_dimblur" - - # pixel - convert "$pixel" -draw "fill #$loginbox $rectangles" "$l_pixel" echo echo 'All required changes have been applied' } @@ -294,35 +254,29 @@ wallpaper() { case "$1" in '') # set resized image as wallpaper if no argument is supplied by user - wallpaper="$resized" + feh --bg-fill $resized ;; dim) # set dimmed image as wallpaper - wallpaper="$dim" + feh --bg-fill $dim ;; blur) # set blurred image as wallpaper - wallpaper="$blur" + feh --bg-fill $blur ;; dimblur) # set dimmed + blurred image as wallpaper - wallpaper="$dimblur" - ;; - - pixel) - # set pixelated image as wallpaper - wallpaper="$pixel" + feh --bg-fill $dimblur ;; esac - eval "$wallpaper_cmd $wallpaper" } empty() { - if [ -f "$l_dim" ]; then + if [ -f $l_dim ]; then echo -e "\nSeems you haven't provided any arguments. See below for usage details." else echo 'Important: Update the image cache (e.g. betterlockscreen -u path/to/image.jpg).' @@ -378,7 +332,6 @@ usage() { echo ' -w --wall' echo ' you can also set lockscreen background as wallpaper' echo ' to set wallpaper (e.g. betterlockscreen -w or betterlockscreen --wall)' - echo ' (The default wallpaper setter is feh, to set your own use the -wc command)' echo ' you can also use dimmed or blurred variants.' echo ' E.g: betterlockscreen -w dim (for dimmed wallpaper)' echo ' E.g: betterlockscreen -w blur (for blurred wallpaper)' @@ -403,24 +356,6 @@ usage() { echo ' to set custom lockscreen text (max 31 chars)' echo " E.g: betterlockscreen -l dim -t \"Don't touch my machine!\"" echo ' E.g: betterlockscreen --text "Hi, user!" -s blur' - echo - echo - echo ' --off ' - echo ' to set custom monitor turn off timeout for lockscreen' - echo ' timeout is in seconds' - echo ' E.g: betterlockscreen -l dim --off 5' - echo - echo - echo ' -wc --wallpaper_cmd ' - echo ' to set your custom wallpaper setter' - echo ' the default is "feh --bg-fill --no-fehbg"' - echo ' E.g: betterlockscreen -wc "xwallpaper --zoom" -w' - echo - echo - echo ' -tf --time_format ' - echo ' to set the time format used by i3lock-color' - echo ' see the i3lock or strftime man pages for more details.' - echo ' E.g: betterlockscreen -l dim -tf "%I:%M %p"' } @@ -442,12 +377,8 @@ for arg in "$@"; do -l | --lock) runlock=true - - if [[ ${2:0:1} = '-' ]]; then - shift 1 - else - lockstyle="$2"; shift 2 - fi + [[ $runsuspend ]] || lockargs="$lockargs -n" + [[ ${2:0:1} = '-' ]] && shift 1 || { lockstyle="$2"; shift 2; } ;; -w | --wall | --wallpaper) @@ -466,14 +397,9 @@ for arg in "$@"; do shift 2 ;; - --off) - lock_timeout="$2" - shift 2 - ;; - -r | --resolution) res="$2" - init_filenames "$res" force + init_filenames $res force shift 2 ;; @@ -482,18 +408,8 @@ for arg in "$@"; do shift 2 ;; - -wc | --wallpaper_cmd) - wallpaper_cmd="$2" - shift 2 - ;; - - -tf | --time_format) - time_format="$2" - shift 2 - ;; - --) - lockargs="$lockargs ${*:2}" + lockargs="$lockargs ${@:2}" break ;; @@ -511,4 +427,4 @@ done [[ $runlock ]] && lockselect "$lockstyle" && \ { [[ $runsuspend ]] && systemctl suspend; } -exit 0 +exit 0 \ No newline at end of file diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index 8ca0110..61f9bf0 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -1,5 +1,6 @@ # configuration file for betterlockscreen +screennumber=0 insidecolor=00000000 ringcolor=ffffffff keyhlcolor=d23c3dff From e5e891786e1b0eabbb8e8e4821210e18218214b9 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Sat, 9 Feb 2019 11:40:27 -0600 Subject: [PATCH 02/36] Multi-monitor rewrite * init_filenames -> init_config - remove -t from i3lock call since we make image for total resolution + add --screen to i3lock call to show time and ring on that screen * rec_get_random -> get_user_wall + get_total_size retuns total combined resolution + get_display_list returns list of screens (number name geometry) + resize_and_render resize, dim, blur, dimblur image for each screen + purge_cache delete and recreate cache directories * update completely rewritten to support multi-monitor - arg --resolution; isn't needed + arg --display; screen to display loginbox (default: 0) + rc display_on; screen to display loginbox (default: 0) + arg --span; span image across all screens (default: false) + rc span_image; span image across all screens (default: false) --- betterlockscreen | 497 ++++++++++++++++++++++++++++++----------------- 1 file changed, 323 insertions(+), 174 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 3ffb808..4cc0fe7 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -4,68 +4,52 @@ # Github Profile : https://github.com/pavanjadhaw # Project Repository : https://github.com/pavanjadhaw/betterlockscreen -# find your resolution so images can be resized to match your screen resolution -res=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') -locktext='Type password to unlock...' +init_config () { + # user configuration file + USER_CONF="$HOME/.config/betterlockscreenrc" + if [ -e $USER_CONF ]; then + source "$USER_CONF" + # default configuration options + else + insidecolor=00000000 + ringcolor=ffffffff + keyhlcolor=d23c3dff + bshlcolor=d23c3dff + separatorcolor=00000000 + insidevercolor=00000000 + insidewrongcolor=d23c3dff + ringvercolor=ffffffff + ringwrongcolor=ffffffff + verifcolor=ffffffff + timecolor=ffffffff + datecolor=ffffffff + loginbox=00000066 + locktext='Type password to unlock...' + font="sans-serif" + display_on=0 + span_image=false + fi -init_filenames() { - #$1 resolution + CACHE_DIR="$HOME/.cache/i3lock" + CUR_DIR="$CACHE_DIR/current" - # custom i3lock colors - theme_rc="$HOME/.config/betterlockscreenrc" - if [ -e $theme_rc ]; then - source "$theme_rc" - else - # copy this block to ~/.config/betterlockscreenrc" to customize - screennumber=0 - insidecolor=00000000 - ringcolor=ffffffff - keyhlcolor=d23c3dff - bshlcolor=d23c3dff - separatorcolor=00000000 - insidevercolor=00000000 - insidewrongcolor=d23c3dff - ringvercolor=ffffffff - ringwrongcolor=ffffffff - verifcolor=ffffffff - timecolor=ffffffff - datecolor=ffffffff - loginbox=00000066 - font="sans-serif" - fi + # wallpaper + CUR_W_RESIZE="$CUR_DIR/wall_resize.png" + CUR_W_DIM="$CUR_DIR/wall_dim.png" + CUR_W_BLUR="$CUR_DIR/wall_blur.png" + CUR_W_DIMBLUR="$CUR_DIR/wall_dimblur.png" - # create folder in ~/.cache/i3lock directory - res_folder="$HOME/.cache/i3lock/$1" - folder="$HOME/.cache/i3lock/current" - echo "Got" $@ $res_folder - if [ ! -d $folder -o -n "$2" ]; then - rm -f $folder - ln -s $res_folder $folder - fi + # locker + CUR_L_RESIZE="$CUR_DIR/lock_resize.png" + CUR_L_DIM="$CUR_DIR/lock_dim.png" + CUR_L_BLUR="$CUR_DIR/lock_blur.png" + CUR_L_DIMBLUR="$CUR_DIR/lock_dimblur.png" - # ratio for rectangle to be drawn for time background on lockscreen - # Original Image - orig_wall="$folder/wall.png" - - # Versions (from here) - # You can use these images to set different versions as wallpaper - # lockscreen background. - resized="$folder/resized.png" # resized image for your resolution - - # images to be used as wallpaper - dim="$folder/dim.png" # image with subtle overlay of black - blur="$folder/blur.png" # blurred version - dimblur="$folder/dimblur.png" - - # lockscreen images (images to be used as lockscreen background) - l_resized="$folder/l_resized.png" - l_dim="$folder/l_dim.png" - l_blur="$folder/l_blur.png" - l_dimblur="$folder/l_dimblur.png" + _RE="([0-9]+)x([0-9]+)\\+([0-9]+)\\+([0-9]+)" # Regex to find display dimensions } +init_config -init_filenames $res prelock() { @@ -79,7 +63,8 @@ lock() { #$1 image path i3lock \ - -t -i "$1" --screen=$screennumber \ + -i "$1" \ + --screen "$display_on" \ --timepos='x+110:h-70' \ --datepos='x+43:h-45' \ --clock --date-align 1 --datestr "$locktext" \ @@ -101,39 +86,27 @@ postlock() { } -rec_get_random() { - dir="$1" - if [ ! -d "$dir" ]; then - user_input="$dir" - return - fi - dir=("$dir"/*) - dir="${dir[RANDOM % ${#dir[@]}]}" - rec_get_random "$dir" -} - - lockselect() { prelock case "$1" in dim) # lockscreen with dimmed background - lock "$l_dim" + lock "$CUR_L_DIM" ;; blur) # set lockscreen with blurred background - lock "$l_blur" + lock "$CUR_L_BLUR" ;; dimblur) # set lockscreen with dimmed + blurred background - lock "$l_dimblur" + lock "$CUR_L_DIMBLUR" ;; *) # default lockscreen - lock "$l_resized" + lock "$CUR_L_RESIZE" ;; esac postlock @@ -142,7 +115,7 @@ lockselect() { logical_px() { # get dpi value from xrdb local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') - + # return the default value if no DPI is set if [ -z "$DPI" ]; then echo $1 @@ -158,125 +131,287 @@ logical_px() { fi } -update() { - # use - background="$1" - - # default blur level; fallback to 1 - [[ $blur_level ]] || blur_level=1 - - rectangles=" " - SR=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*') - for RES in $SR; do - SRA=(${RES//[x+]/ }) - CX=$((${SRA[2]} + $(logical_px 25))) - CY=$((${SRA[1]} - $(logical_px 30))) - rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " - done - - # User supplied Image - user_image="$folder/user_image.png" - - # create folder - if [ ! -d $folder ]; then - echo "Creating '$folder' directory to cache processed images." - mkdir -p "$folder" - fi - - # get random file in dir if passed argument is a dir - rec_get_random "$background" - - # get user image - cp "$user_input" "$user_image" - if [ ! -f $user_image ]; then - echo 'Please specify the path to the image you would like to use' - exit 1 - fi - - # replace orignal with user image - cp "$user_image" "$orig_wall" - rm "$user_image" - - echo 'Generating alternate images based on the image you specified,' - echo 'please wait this might take few seconds...' - - # wallpapers - - echo - echo 'Converting provided image to match your resolution...' - # resize image - convert "$orig_wall" -resize "$res""^" -gravity center -extent "$res" "$resized" - - echo - echo 'Applying dim and blur effect to resized image' - # dim - convert "$resized" -fill black -colorize 40% "$dim" - - # blur - 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 "$res^" -gravity center -extent "$res" \ - "$blur" - - # dimblur - convert "$dim" \ - -filter Gaussian \ - -resize "$blur_shrink%" \ - -define "filter:sigma=$blur_sigma" \ - -resize "$res^" -gravity center -extent "$res" \ - "$dimblur" - - # lockscreen backgrounds - - echo - echo 'Caching images for faster screen locking' - # resized - convert "$resized" -draw "fill #$loginbox $rectangles" "$l_resized" - - # dim - convert "$dim" -draw "fill #$loginbox $rectangles" "$l_dim" - - # blur - convert "$blur" -draw "fill #$loginbox $rectangles" "$l_blur" - - # blur - convert "$dimblur" -draw "fill #$loginbox $rectangles" "$l_dimblur" - echo - echo 'All required changes have been applied' +# get total resolution +# 1600x900 +get_total_size () { + TOTAL_SIZE=$(xdpyinfo | grep -w "dimensions" | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') } +get_display_list () { + local DNUM=0 + mapfile -t DARR < <( xrandr --listactivemonitors ) + for DISP in "${DARR[@]:1}"; do + (( DNUM++ )) + DISP=$(echo $DISP | sed -r 's/\/[0-9]*//g') + IFS=' ' read -r -a LINE <<< "$DISP" + DLIST+=("$DNUM ${LINE[3]} ${LINE[2]}") + done +} + + +get_user_wall() { + local path="$1" + if [ ! -d "$path" ]; then + USER_WALL="$path" + return + fi + dir=("$path"/*) + dir="${dir[RANDOM % ${#dir[@]}]}" + get_user_wall "$dir" +} + +resize_and_render () { + + # arguments + local base=$1 + local path=$2 + local resolution=$3 + + # wallpaper + RES_RESIZE="$2/resize.png" + RES_DIM="$2/dim.png" + RES_BLUR="$2/blur.png" + RES_DIMBLUR="$2/dimblur.png" + + # defaults + [[ $blur_level ]] || blur_level=1 + + echo "Resizing original and applying effects..." + + # apply resize + eval convert "$base" -resize "$resolution""^" -gravity center -extent "$resolution" "$RES_RESIZE" + + # apply dim + eval convert "$RES_RESIZE" -fill black -colorize 40% "$RES_DIM" + + # apply blur + blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) + blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) + eval convert "$RES_RESIZE" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$resolution^" -gravity center -extent "$resolution" \ + "$RES_BLUR" + + # apply dimblur + eval convert "$RES_DIM" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$resolution^" -gravity center -extent "$resolution" \ + "$RES_DIMBLUR" + +} + +# delete and recreate directory +purge_cache () { + if [[ -d "$1" ]]; then + rm -r "$1" + fi + mkdir -p "$1" +} + +# update locker and wallpaper images +update () { + + wallpaper=$1 + rectangles=" " + + get_user_wall "$wallpaper" # Returns USER_WALL + echo "Original: $USER_WALL" + + get_display_list # Returns DLIST + get_total_size # Return TOTAL_SIZE + + # create base images per display + for DISP in "${DLIST[@]}"; do + DNUM="$(cut -d" " -f1 <<<"${DISP}")" + DDEV="$(cut -d" " -f2 <<<"${DISP}")" + DGEO=($(cut -d" " -f3 <<<"${DISP}")) + DRES=(${DGEO[0]//[+]/ }) + DPOS="+${DRES[1]}+${DRES[2]}" + DPATH="$CACHE_DIR/$DNUM-$DDEV" + + #get_geometry $DGEO # Returns SCREEN_* + if [[ $DNUM -eq "$display_on" ]] || [[ "$display_on" -eq 0 ]]; then + SRA=(${DGEO//[x+]/ }) + CX=$((${SRA[2]} + $(logical_px 25))) + CY=$((${SRA[1]} - $(logical_px 30))) + rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " + fi + + echo "Found: $DDEV ($DNUM)" + echo "Resolution: ${DRES[0]}" + + purge_cache $DPATH + + # we only need one set of images when spanning + if [ "$span_image" = true ] && [ $DNUM -gt 1 ]; then + continue + fi + + if [ "$span_image" = true ]; then + # render wallpaper at total display size (3840x1080) + resize_and_render $USER_WALL $DPATH $TOTAL_SIZE + else + # render wallpaper at each display size + resize_and_render $USER_WALL $DPATH ${DRES[0]} + # add to parameters for position on canvas + PARAM_RESIZE="$PARAM_RESIZE $RES_RESIZE -geometry $DPOS -composite " + PARAM_DIM="$PARAM_DIM $RES_DIM -geometry $DPOS -composite " + PARAM_BLUR="$PARAM_BLUR $RES_BLUR -geometry $DPOS -composite " + PARAM_DIMBLUR="$PARAM_DIMBLUR $RES_DIMBLUR -geometry $DPOS -composite " + fi + + done + + purge_cache $CUR_DIR + + if [ "$span_image" = true ] || [ ${#DLIST[@]} -lt 2 ]; then + echo "Copying final wallpaper images..." + cp $RES_RESIZE $CUR_W_RESIZE + cp $RES_DIM $CUR_W_DIM + cp $RES_BLUR $CUR_W_BLUR + cp $RES_DIMBLUR $CUR_W_DIMBLUR + else + echo "Creating canvas: $TOTAL_SIZE" + convert -size $TOTAL_SIZE 'xc:black' $CUR_W_RESIZE + convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIM + convert -size $TOTAL_SIZE 'xc:black' $CUR_W_BLUR + convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIMBLUR + + echo "Rendering final wallpaper images..." + convert $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE + convert $CUR_W_DIM $PARAM_DIM $CUR_W_DIM + convert $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR + convert $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR + fi + + echo "Rendering final locker images..." + convert "$CUR_W_RESIZE" -draw "fill #$loginbox $rectangles" "$CUR_L_RESIZE" + convert "$CUR_W_DIM" -draw "fill #$loginbox $rectangles" "$CUR_L_DIM" + convert "$CUR_W_BLUR" -draw "fill #$loginbox $rectangles" "$CUR_L_BLUR" + convert "$CUR_W_DIMBLUR" -draw "fill #$loginbox $rectangles" "$CUR_L_DIMBLUR" +} +#update () { +# +# wallpaper=$1 +# rectangles=" " +# +# get_user_wall "$wallpaper" # Returns USER_WALL +# echo "Original: $USER_WALL" +# +# get_display_list # Returns DLIST +# get_total_size # Return TOTAL_SIZE +# +# [[ $display_on ]] || display_on=0 +# +# # create base images per display +# for DISP in "${DLIST[@]}"; do +# DNUM="$(cut -d" " -f1 <<<"${DISP}")" +# DDEV="$(cut -d" " -f2 <<<"${DISP}")" +# DGEO="$(cut -d" " -f3 <<<"${DISP}")" +# DPATH="$CACHE_DIR/$DNUM-$DDEV" +# +# if [[ $DNUM -eq $display_on ]] || [[ $display_on -eq 0 ]]; then +# SRA=(${DGEO//[x+]/ }) +# CX=$((${SRA[2]} + $(logical_px 25))) +# CY=$((${SRA[1]} - $(logical_px 30))) +# echo "cx $CX" +# echo "cy $CY" +# rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " +# echo "rect $rectangles" +# fi +# +# echo "Found: $DDEV ($DNUM)" +# echo "Resolution: $DRES" +# +# purge_cache $DPATH +# +# # we only need one set of images when spanning +# if [ "$span_image" = true ] && [ $DNUM -gt 1 ]; then +# continue +# fi +# +# if [ "$span_image" = true ]; then +# # create one image to span across multiple displays +# resize_and_render $USER_WALL $DPATH $TOTAL_SIZE +# else +# # create images for each display to combine later +# resize_and_render $USER_WALL $DPATH $DRES +# PARAM_RESIZE="$PARAM_RESIZE $RES_RESIZE -geometry +${DGEO[0]}+${DGEO[2]} -composite " +# PARAM_DIM="$PARAM_DIM $RES_DIM -geometry +${DGEO[0]}+${DGEO[2]} -composite " +# PARAM_BLUR="$PARAM_BLUR $RES_BLUR -geometry +${DGEO[0]}+${DGEO[2]} -composite " +# PARAM_DIMBLUR="$PARAM_DIMBLUR $RES_DIMBLUR -geometry +${DGEO[0]}+${DGEO[2]} -composite " +# fi +# +# done +# +# purge_cache $CUR_DIR +# +# if [ "$span_image" = true ] && [ ${#DLIST[@]} -lt 2 ]; then +# echo "Copying final wallpaper images...xx" +# cp $RES_RESIZE $CUR_W_RESIZE +# cp $RES_DIM $CUR_W_DIM +# cp $RES_BLUR $CUR_W_BLUR +# cp $RES_DIMBLUR $CUR_W_DIMBLUR +# else +# echo "Creating canvas: $TOTAL_SIZE" +# convert -size $TOTAL_SIZE 'xc:black' $CUR_W_RESIZE +# convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIM +# convert -size $TOTAL_SIZE 'xc:black' $CUR_W_BLUR +# convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIMBLUR +# +# echo "Rendering final wallpaper images..." +# convert $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE +# convert $CUR_W_DIM $PARAM_DIM $CUR_W_DIM +# convert $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR +# convert $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR +# fi +# +# echo "Rendering final locker images..." +# echo "$rectangles" +# convert $CUR_W_RESIZE -draw "fill #$loginbox $rectangles" $CUR_L_RESIZE +# convert $CUR_W_DIM -draw "fill #$loginbox $rectangles" $CUR_L_DIM +# convert $CUR_W_BLUR -draw "fill #$loginbox $rectangles" $CUR_L_BLUR +# convert $CUR_W_DIMBLUR -draw "fill #$loginbox $rectangles" $CUR_L_DIMBLUR +# +# echo "... Complete!" +#} + wallpaper() { + local fopt + if [ "$span_image" = true ]; then + fopt="--no-xinerama" + fi case "$1" in '') # set resized image as wallpaper if no argument is supplied by user - feh --bg-fill $resized + feh --bg-fill "$fopt" "$CUR_W_RESIZE" ;; dim) # set dimmed image as wallpaper - feh --bg-fill $dim + feh --bg-fill "$fopt" "$CUR_W_DIM" ;; blur) # set blurred image as wallpaper - feh --bg-fill $blur + feh --bg-fill "$fopt" "$CUR_W_BLUR" ;; dimblur) # set dimmed + blurred image as wallpaper - feh --bg-fill $dimblur + feh --bg-fill "$fopt" "$CUR_W_DIMBLUR" ;; esac } empty() { - if [ -f $l_dim ]; then + if [ -f $CUR_L_RESIZE ]; then echo -e "\nSeems you haven't provided any arguments. See below for usage details." else echo 'Important: Update the image cache (e.g. betterlockscreen -u path/to/image.jpg).' @@ -338,11 +473,17 @@ usage() { echo ' E.g: betterlockscreen -w dimblur (for dimmed + blurred wallpaper)' echo echo - echo ' -r --resolution' + echo ' -d --display' echo ' to be used after -u' - echo ' used to set a custom resolution for the image cache.' - echo ' E.g: betterlockscreen -u path/to/image.png -r 1920x1080' - echo ' E.g: betterlockscreen -u path/to/image.png --resolution 3840x1080' + echo ' used to set which screen to display login box.' + echo ' E.g: betterlockscreen -u path/to/image.png -d 1' + echo ' E.g: betterlockscreen -u path/to/image.png --display 2' + echo + echo + echo ' --span' + echo ' to be used after -u' + echo ' used to create wall and locker images that span multiple displays.' + echo ' E.g: betterlockscreen -u path/to/image.png --span' echo echo echo ' -b --blur' @@ -397,12 +538,16 @@ for arg in "$@"; do shift 2 ;; - -r | --resolution) - res="$2" - init_filenames $res force + -d | --display) + display_on="$2" shift 2 ;; + --span) + span_image=true + shift 1 + ;; + -b | --blur) blur_level="$2" shift 2 @@ -420,6 +565,10 @@ for arg in "$@"; do esac done +# some defaults +[[ $display_on ]] || display_on=0 +[[ $span_image ]] || span_image=false + # Run image generation [[ $runupdate ]] && update "$imagepath" From e74dec7848c259a4434d508b592d31d552317b91 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Sat, 9 Feb 2019 13:03:45 -0600 Subject: [PATCH 03/36] Removed commented code and fix spacing issues --- betterlockscreen | 175 ++++++++++++----------------------------------- 1 file changed, 45 insertions(+), 130 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 4cc0fe7..31bce17 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -6,47 +6,46 @@ init_config () { - # user configuration file + # user configuration file USER_CONF="$HOME/.config/betterlockscreenrc" if [ -e $USER_CONF ]; then source "$USER_CONF" - # default configuration options + # default configuration options else - insidecolor=00000000 - ringcolor=ffffffff - keyhlcolor=d23c3dff - bshlcolor=d23c3dff - separatorcolor=00000000 - insidevercolor=00000000 - insidewrongcolor=d23c3dff - ringvercolor=ffffffff - ringwrongcolor=ffffffff - verifcolor=ffffffff - timecolor=ffffffff - datecolor=ffffffff - loginbox=00000066 - locktext='Type password to unlock...' - font="sans-serif" - display_on=0 - span_image=false - fi + insidecolor=00000000 + ringcolor=ffffffff + keyhlcolor=d23c3dff + bshlcolor=d23c3dff + separatorcolor=00000000 + insidevercolor=00000000 + insidewrongcolor=d23c3dff + ringvercolor=ffffffff + ringwrongcolor=ffffffff + verifcolor=ffffffff + timecolor=ffffffff + datecolor=ffffffff + loginbox=00000066 + locktext='Type password to unlock...' + font="sans-serif" + display_on=0 + span_image=false + fi - CACHE_DIR="$HOME/.cache/i3lock" - CUR_DIR="$CACHE_DIR/current" + CACHE_DIR="$HOME/.cache/i3lock" + CUR_DIR="$CACHE_DIR/current" - # wallpaper - CUR_W_RESIZE="$CUR_DIR/wall_resize.png" - CUR_W_DIM="$CUR_DIR/wall_dim.png" - CUR_W_BLUR="$CUR_DIR/wall_blur.png" - CUR_W_DIMBLUR="$CUR_DIR/wall_dimblur.png" + # wallpaper + CUR_W_RESIZE="$CUR_DIR/wall_resize.png" + CUR_W_DIM="$CUR_DIR/wall_dim.png" + CUR_W_BLUR="$CUR_DIR/wall_blur.png" + CUR_W_DIMBLUR="$CUR_DIR/wall_dimblur.png" - # locker - CUR_L_RESIZE="$CUR_DIR/lock_resize.png" - CUR_L_DIM="$CUR_DIR/lock_dim.png" - CUR_L_BLUR="$CUR_DIR/lock_blur.png" - CUR_L_DIMBLUR="$CUR_DIR/lock_dimblur.png" + # locker + CUR_L_RESIZE="$CUR_DIR/lock_resize.png" + CUR_L_DIM="$CUR_DIR/lock_dim.png" + CUR_L_BLUR="$CUR_DIR/lock_blur.png" + CUR_L_DIMBLUR="$CUR_DIR/lock_dimblur.png" - _RE="([0-9]+)x([0-9]+)\\+([0-9]+)\\+([0-9]+)" # Regex to find display dimensions } init_config @@ -64,7 +63,7 @@ lock() { i3lock \ -i "$1" \ - --screen "$display_on" \ + --screen "$display_on" \ --timepos='x+110:h-70' \ --datepos='x+43:h-45' \ --clock --date-align 1 --datestr "$locktext" \ @@ -182,18 +181,18 @@ resize_and_render () { # apply resize eval convert "$base" -resize "$resolution""^" -gravity center -extent "$resolution" "$RES_RESIZE" - # apply dim - eval convert "$RES_RESIZE" -fill black -colorize 40% "$RES_DIM" + # apply dim + eval convert "$RES_RESIZE" -fill black -colorize 40% "$RES_DIM" - # apply blur - blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) - blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) - eval convert "$RES_RESIZE" \ - -filter Gaussian \ - -resize "$blur_shrink%" \ - -define "filter:sigma=$blur_sigma" \ - -resize "$resolution^" -gravity center -extent "$resolution" \ - "$RES_BLUR" + # apply blur + blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) + blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) + eval convert "$RES_RESIZE" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$resolution^" -gravity center -extent "$resolution" \ + "$RES_BLUR" # apply dimblur eval convert "$RES_DIM" \ @@ -295,91 +294,7 @@ update () { convert "$CUR_W_BLUR" -draw "fill #$loginbox $rectangles" "$CUR_L_BLUR" convert "$CUR_W_DIMBLUR" -draw "fill #$loginbox $rectangles" "$CUR_L_DIMBLUR" } -#update () { -# -# wallpaper=$1 -# rectangles=" " -# -# get_user_wall "$wallpaper" # Returns USER_WALL -# echo "Original: $USER_WALL" -# -# get_display_list # Returns DLIST -# get_total_size # Return TOTAL_SIZE -# -# [[ $display_on ]] || display_on=0 -# -# # create base images per display -# for DISP in "${DLIST[@]}"; do -# DNUM="$(cut -d" " -f1 <<<"${DISP}")" -# DDEV="$(cut -d" " -f2 <<<"${DISP}")" -# DGEO="$(cut -d" " -f3 <<<"${DISP}")" -# DPATH="$CACHE_DIR/$DNUM-$DDEV" -# -# if [[ $DNUM -eq $display_on ]] || [[ $display_on -eq 0 ]]; then -# SRA=(${DGEO//[x+]/ }) -# CX=$((${SRA[2]} + $(logical_px 25))) -# CY=$((${SRA[1]} - $(logical_px 30))) -# echo "cx $CX" -# echo "cy $CY" -# rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " -# echo "rect $rectangles" -# fi -# -# echo "Found: $DDEV ($DNUM)" -# echo "Resolution: $DRES" -# -# purge_cache $DPATH -# -# # we only need one set of images when spanning -# if [ "$span_image" = true ] && [ $DNUM -gt 1 ]; then -# continue -# fi -# -# if [ "$span_image" = true ]; then -# # create one image to span across multiple displays -# resize_and_render $USER_WALL $DPATH $TOTAL_SIZE -# else -# # create images for each display to combine later -# resize_and_render $USER_WALL $DPATH $DRES -# PARAM_RESIZE="$PARAM_RESIZE $RES_RESIZE -geometry +${DGEO[0]}+${DGEO[2]} -composite " -# PARAM_DIM="$PARAM_DIM $RES_DIM -geometry +${DGEO[0]}+${DGEO[2]} -composite " -# PARAM_BLUR="$PARAM_BLUR $RES_BLUR -geometry +${DGEO[0]}+${DGEO[2]} -composite " -# PARAM_DIMBLUR="$PARAM_DIMBLUR $RES_DIMBLUR -geometry +${DGEO[0]}+${DGEO[2]} -composite " -# fi -# -# done -# -# purge_cache $CUR_DIR -# -# if [ "$span_image" = true ] && [ ${#DLIST[@]} -lt 2 ]; then -# echo "Copying final wallpaper images...xx" -# cp $RES_RESIZE $CUR_W_RESIZE -# cp $RES_DIM $CUR_W_DIM -# cp $RES_BLUR $CUR_W_BLUR -# cp $RES_DIMBLUR $CUR_W_DIMBLUR -# else -# echo "Creating canvas: $TOTAL_SIZE" -# convert -size $TOTAL_SIZE 'xc:black' $CUR_W_RESIZE -# convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIM -# convert -size $TOTAL_SIZE 'xc:black' $CUR_W_BLUR -# convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIMBLUR -# -# echo "Rendering final wallpaper images..." -# convert $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE -# convert $CUR_W_DIM $PARAM_DIM $CUR_W_DIM -# convert $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR -# convert $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR -# fi -# -# echo "Rendering final locker images..." -# echo "$rectangles" -# convert $CUR_W_RESIZE -draw "fill #$loginbox $rectangles" $CUR_L_RESIZE -# convert $CUR_W_DIM -draw "fill #$loginbox $rectangles" $CUR_L_DIM -# convert $CUR_W_BLUR -draw "fill #$loginbox $rectangles" $CUR_L_BLUR -# convert $CUR_W_DIMBLUR -draw "fill #$loginbox $rectangles" $CUR_L_DIMBLUR -# -# echo "... Complete!" -#} + wallpaper() { local fopt From c6064ff970a8e823b81e1ad98c95ee37e5a2b2c4 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Sat, 9 Feb 2019 17:11:24 -0600 Subject: [PATCH 04/36] Fix for wallpaper(), always span multi-monitor --- betterlockscreen | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/betterlockscreen b/betterlockscreen index 31bce17..cef703c 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -298,7 +298,8 @@ update () { wallpaper() { local fopt - if [ "$span_image" = true ]; then + get_display_list + if [ "$span_image" = true ] || [[ "${#DLIST[@]}" -gt 1 ]]; then fopt="--no-xinerama" fi case "$1" in From 41d43f63231fc897374391c0578c79b2bc4c95ea Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Sat, 9 Feb 2019 17:25:01 -0600 Subject: [PATCH 05/36] Update README and example config --- README.md | 96 +++++++++++++++---------------------- examples/betterlockscreenrc | 6 +-- 2 files changed, 40 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 242ee14..9079e0b 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,20 @@ -# Betterlockscreen -> fast and sweet looking lockscreen for linux systems with effects! +# betterlockscreen -
- GitHub release (latest by date including pre-releases) - GitHub release (latest by date) - GitHub Workflow Status (master) - GitHub Workflow Status (next) - -
+> simple, minimal lockscreen -
-

You want to support us?

+Betterlockscreen allows you to cache images with different filters and lockscreen with blazing speed. - GitHub Repo stars - GitHub forks - -
-
+## Example + +> lockscreen with blurred effect + +```sh +betterlockscreen --lock blur +``` ![scrot2](https://github.com/pavanjadhaw/betterlockscreen.demo/raw/master/scrots/scrot2.png 'scrot2.png') -
+ +> [Watch some of the features of betterlockscreen in action](https://www.youtube.com/watch?v=9Ng5FZwnn6M&feature=youtu.be) ## Table of Contents @@ -51,7 +46,7 @@ images as lockscreen background depending on argument provided by user. > Note: Make sure your system has all dependencies satisfied -- [i3lock-color](https://github.com/Raymo111/i3lock-color) - i3lock fork with additional features(`>= 2.13.c.3`) +- [i3lock-color](https://github.com/PandorasFox/i3lock-color) - i3lock fork with additional features( >= 2.11-c ) - [imagemagick](https://www.imagemagick.org/script/index.php) - To apply effects to images - [xdpyinfo](https://www.x.org/archive/X11R7.7/doc/man/man1/xdpyinfo.1.xhtml), [xrandr](https://www.x.org/wiki/Projects/XRandR/), [bc](https://www.gnu.org/software/bc/) and [feh](https://feh.finalrewind.org/) - To find screen resolution, set custom blur level and wallpaper handling. @@ -101,14 +96,6 @@ export PATH="${PATH}:${HOME}/.local/bin/" UtkarshVerma was so kind to provide an installation script for debian based systems, ![check it out here](https://github.com/UtkarshVerma/installer-scripts). -#### Void Linux - -##### xbps repository - -`betterlockscreen` is available in official Void's repository as `betterlockscreen`. - -Installing using `xbps` (will automatically install all required dependencies): `xbps-install -S betterlockscreen` - ### Configuration You can customise various colors for betterlockscreen, copy config file from examples directory to `~/.config/betterlockscreenrc` and edit it accordingly. @@ -130,33 +117,33 @@ Run `betterlockscreen` and point it to either a directory (`betterlockscreen -u ```sh usage: betterlockscreen [-u "path/to/img.jpg"] [-l "dim, blur or dimblur"] - [-w "dim, blur, pixel or dimblur"] [-t "custom text"] [-s "lockscreen and suspend"] - [-r "resolution"] [-b "factor"] [--off ] + [-w "dim, blur, or dimblur"] [-t "custom text"] [-s "lockscreen and suspend"] + [-r "resolution"] [-b "factor"] betterlockscreen - faster and sweet looking lockscreen for linux systems. required: - -u, --update "path/to/img.jpg" caches all required images + -u, --update "path/to/img.jpg" caches all required images usage: - -l, --lock effect-name - locks with provided effect - -w, --wall effect-name - set desktop background with provided effect - -s, --suspend effect-name - lockscreen and suspend + -l, --lock effect-name + locks with provided effect + -w, --wall effect-name + set desktop background with provided effect + -s, --suspend effect-name + lockscreen and suspend - Available effects: - dim, blur, pixel or dimblur + Available effects: + dim, blur or dimblur - -t, --text "custom text" - set custom lockscreen text - -b, blur 0.0 - 1.0 - set blur range - -r, --resolution res - uses a custom resolution - --off, --off - sets custom monitor timeout ( in seconds) + -t, --text "custom text" + set custom lockscreen text + -b, blur 0.0 - 1.0 + set blur range + -d, --display 0-9 + screen to display loginbox + --span + span multiple screens Usage examples: @@ -171,13 +158,10 @@ betterlockscreen -u path/to/directory -r 1920x1080 -b 0.5 betterlockscreen -l dim # lockscreen with dim effect 4. Lockscreen with custom text -betterlockscreen -l pixel -t "custom lockscreen text" +betterlockscreen -l dim -t "custom lockscreen text" 5. Set desktop background betterlockscreen -w blur # set desktop background with blur effect - -6. Lockscreeen with custom monitor off timeout -betterlockscreen --off 5 -l blur # set monitor off lockscreen timeout (5 seconds) ``` ### Set desktop background on startup @@ -227,9 +211,10 @@ alt + shift + x ``` ### Lockscreen when suspended(systemd service) + ```sh # move service file to proper dir (the aur package does this for you) -cp betterlockscreen@.service /usr/lib/systemd/system/ +cp betterlockscreen@.service /etc/systemd/system/ # enable systemd service systemctl enable betterlockscreen@$USER @@ -237,17 +222,12 @@ systemctl enable betterlockscreen@$USER # disable systemd service systemctl disable betterlockscreen@$USER + # Note: Now you can call systemctl suspend to suspend your system # and betterlockscreen service will be activated # so when your system wakes your screen will be locked. ``` -**Hint:** The systemd-unit expects betterlockscreen to be installed in "/usr/local/bin", so maybe you want to check or change this! - -Resources and more informations: - * https://gist.github.com/Raymo111/91ffd256b7aca6a85e8a99d6331d3b7b - * https://github.com/Raymo111/i3lock-color/issues/174#issuecomment-687149213 - --- ### Countributing @@ -269,7 +249,7 @@ Betterlockscreen is under [MIT](https://github.com/pavanjadhaw/betterlockscreen/ - Hat tip to anyone who's code was used - Thanks to those who contributed to make it better -- Inspiration - [r/unixporn](https://www.reddit.com/r/unixporn) +- Inspiration - r/unixporn [logo]: .github/hero.png -[website]: https://mdxjs.com +[website]: https://mdxjs.com \ No newline at end of file diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index 61f9bf0..f4b65b5 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -1,6 +1,5 @@ # configuration file for betterlockscreen -screennumber=0 insidecolor=00000000 ringcolor=ffffffff keyhlcolor=d23c3dff @@ -15,6 +14,5 @@ timecolor=ffffffff datecolor=ffffffff loginbox=00000066 font="sans-serif" -locktext='Type password to unlock...' -lock_timeout=5 -time_format='%H:%M:%S' +display_on=0 +span_image=false From 49ce9ae7fa81565795c380a6719f5b809cf6f049 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Tue, 12 Feb 2019 22:41:32 -0600 Subject: [PATCH 06/36] add pixel effect --- betterlockscreen | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/betterlockscreen b/betterlockscreen index cef703c..0a098d3 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -39,13 +39,14 @@ init_config () { CUR_W_DIM="$CUR_DIR/wall_dim.png" CUR_W_BLUR="$CUR_DIR/wall_blur.png" CUR_W_DIMBLUR="$CUR_DIR/wall_dimblur.png" + CUR_W_PIXEL="$CUR_DIR/wall_pixel.png" # locker CUR_L_RESIZE="$CUR_DIR/lock_resize.png" CUR_L_DIM="$CUR_DIR/lock_dim.png" CUR_L_BLUR="$CUR_DIR/lock_blur.png" CUR_L_DIMBLUR="$CUR_DIR/lock_dimblur.png" - + CUR_L_PIXEL="$CUR_DIR/lock_pixel.png" } init_config @@ -103,6 +104,11 @@ lockselect() { lock "$CUR_L_DIMBLUR" ;; + pixel) + # set lockscreen with pixelated background + lock "$CUR_L_PIXEL" + ;; + *) # default lockscreen lock "$CUR_L_RESIZE" @@ -169,6 +175,13 @@ resize_and_render () { # wallpaper RES_RESIZE="$2/resize.png" + RES_DIM="$2/dim.png" + RES_BLUR="$2/blur.png" + RES_DIMBLUR="$2/dimblur.png" + RES_PIXEL="$2/pixel.png" + + # defaults + [[ $blur_level ]] || blur_level=1 RES_DIM="$2/dim.png" RES_BLUR="$2/blur.png" RES_DIMBLUR="$2/dimblur.png" @@ -202,6 +215,11 @@ resize_and_render () { -resize "$resolution^" -gravity center -extent "$resolution" \ "$RES_DIMBLUR" + # pixelate + eval convert "$RES_RESIZE" \ + -scale 10% \ + -scale 1000% \ + "$RES_PIXEL" } # delete and recreate directory @@ -262,6 +280,7 @@ update () { PARAM_DIM="$PARAM_DIM $RES_DIM -geometry $DPOS -composite " PARAM_BLUR="$PARAM_BLUR $RES_BLUR -geometry $DPOS -composite " PARAM_DIMBLUR="$PARAM_DIMBLUR $RES_DIMBLUR -geometry $DPOS -composite " + PARAM_PIXEL="$PARAM_PIXEL $RES_PIXEL -geometry $DPOS -composite " fi done @@ -274,18 +293,21 @@ update () { cp $RES_DIM $CUR_W_DIM cp $RES_BLUR $CUR_W_BLUR cp $RES_DIMBLUR $CUR_W_DIMBLUR + cp $RES_PIXEL $CUR_W_PIXEL else echo "Creating canvas: $TOTAL_SIZE" convert -size $TOTAL_SIZE 'xc:black' $CUR_W_RESIZE convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIM convert -size $TOTAL_SIZE 'xc:black' $CUR_W_BLUR convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIMBLUR + convert -size $TOTAL_SIZE 'xc:black' $CUR_W_PIXEL echo "Rendering final wallpaper images..." convert $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE convert $CUR_W_DIM $PARAM_DIM $CUR_W_DIM convert $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR convert $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR + convert $CUR_W_PIXEL $PARAM_PIXEL $CUR_W_PIXEL fi echo "Rendering final locker images..." @@ -293,6 +315,7 @@ update () { convert "$CUR_W_DIM" -draw "fill #$loginbox $rectangles" "$CUR_L_DIM" convert "$CUR_W_BLUR" -draw "fill #$loginbox $rectangles" "$CUR_L_BLUR" convert "$CUR_W_DIMBLUR" -draw "fill #$loginbox $rectangles" "$CUR_L_DIMBLUR" + convert "$CUR_W_PIXEL" -draw "fill #$loginbox $rectangles" "$CUR_L_PIXEL" } @@ -322,6 +345,11 @@ wallpaper() { # set dimmed + blurred image as wallpaper feh --bg-fill "$fopt" "$CUR_W_DIMBLUR" ;; + + pixel) + # set pixelated image as wallpaper + feh --bg-fill "$fopt" "$CUR_W_PIXEL" + ;; esac } From dcc9166703d496fb2c118fb2489758b3133aaabf Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Tue, 28 May 2019 12:48:39 -0500 Subject: [PATCH 07/36] Fix loginbox position for vertical arrangements (#123) --- betterlockscreen | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 0a098d3..bbb0b93 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -64,14 +64,14 @@ lock() { i3lock \ -i "$1" \ - --screen "$display_on" \ - --timepos='x+110:h-70' \ - --datepos='x+43:h-45' \ + --screen "$display_on" \ + --timepos='ix-170:iy-0' \ + --datepos='ix-240:iy+25' \ --clock --date-align 1 --datestr "$locktext" \ --insidecolor=$insidecolor --ringcolor=$ringcolor --line-uses-inside \ --keyhlcolor=$keyhlcolor --bshlcolor=$bshlcolor --separatorcolor=$separatorcolor \ --insidevercolor=$insidevercolor --insidewrongcolor=$insidewrongcolor \ - --ringvercolor=$ringvercolor --ringwrongcolor=$ringwrongcolor --indpos='x+280:h-70' \ + --ringvercolor=$ringvercolor --ringwrongcolor=$ringwrongcolor --indpos='x+280:y+h-70' \ --radius=20 --ring-width=4 --veriftext='' --wrongtext='' \ --verifcolor="$verifcolor" --timecolor="$timecolor" --datecolor="$datecolor" \ --time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \ @@ -255,7 +255,7 @@ update () { if [[ $DNUM -eq "$display_on" ]] || [[ "$display_on" -eq 0 ]]; then SRA=(${DGEO//[x+]/ }) CX=$((${SRA[2]} + $(logical_px 25))) - CY=$((${SRA[1]} - $(logical_px 30))) + CY=$((${SRA[3]} + ${SRA[1]} - $(logical_px 30))) rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " fi From 741567fa3ed67565f1d1667c9e1de51ddfa42292 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Sun, 30 May 2021 18:46:01 -0500 Subject: [PATCH 08/36] Prepare to merge (#228) * Fix loginbox position for vertical arrangements * Fix tabs everywhere * 110 Automatically deduce DPI * 118 Add description for Void Linux installation * 119 Add Timeout Option * Update README for multi-monitor * Keep original directory * Update README * Rename project files * Always use defaults * Rewrite update() and get_display_list() * Add lock_timeout to defaults * Fix ExecStart in systemd unit * Update README * Fix bad variable name in wallpaper() * Remove quoting, it breaks things * Fix paths and canvas color * Effects now are optional to speed up updating cache * Fix fx_dimblur() * Add shadow to loginbox (#3) * Add create_loginbox(), add loginshadow option * Add loginshadow option to example config * Add solid color background effect (#4) * Use array and fix quoting * Add color effect, create solid color backgrounds * Update README * Add more arguments and options (#5) * New arguments and config options * Update usage more * Update README * Minor text edits * Relocate config and cache (#6) * Move config and cache directories * Make sure cache dir exists * Reorder defaults, clarify options and theme * Reformat example config * Moved example config * Update header info * Fix quoting in DEFAULT_TIMEOUT * Rewrite usage() * Touch up comments and some syntax * Update README, fix usage * Fix passing arguments to i3lock lockargs needs to be an array so that it can expand to multiple arguments (preferable to using wordsplitting or eval instead). * Scale loginbox based on DPI Fixes jeffmhubbard/multilockscreen#7. * Add failsafe to lock screen when images not found (#13) * Add optional description box (#10) * Add optional description box The box is located in the bottom right corner of the lock screen image and contains a custom description message (e.g. to present a name for random images or to display additional information) Added option: --desc * Adapt description to i3lock date font * Description font queried like in i3lock-color * description: force normal upright font style * added support for dimpixel effect (#16) * added support for using different images on different displays (#17) * added support for using different images on different displays * fixed list creation when passed a single image * reworked how WALL_LIST is generated * Fix span output (#19) * Make output reflect one set of images is processed * Return only 1 image when spanning * Correct output in a few spots * Add fancy output (#20) * Add echo wrapper to prefix output * Fix typo * Update README.md (#21) * Fixes misspelled fn (#22) * Escape spaces in path for IM (#24) * Minor fixes (#26) * Better parsing --lock args * Add --pass-media-keys * Add --pass-screen-keys and --pass-power-keys * Fix insanely short default timeout * Make error text transparent * Call init_config later, update example config (#27) Reading config file later allows users to define custom functions in config (prelock, postlock, etc) Updated docs with example usage * Fix suspend (#30) * Fix borked logic in --lock arg that breaks suspend * Don't check before all arguments read * Use `dunstctl` to (un)pause the dunst pre/post-lock. (#31) Please be aware that, the use of dunstctl means that users will be forced to have dunst v1.5.0 or newer installed. * Update LICENSE * Disable DPMS after unlocking if it was originally disabled (#32) * feat[multilockscreen]: Add --show-layout option (#36) * Only change DPMS timeout if Enabled (#38) * Fix #40 (#41) Don't wait for `prelock()` and `postlock()` to complete * Add bgcolor option to set i3lock --color (#44) Closes #43 * Update systemd unit (#45) * Fix options name for i3color-lock release 2.13.c.3 (#49) With release 2.13.c.3 i3color-lock has added dashes before color, pos, size, etc. https://github.com/Raymo111/i3lock-color/releases/tag/2.13.c.3 * Add checklist * Rename script * Extra files from upstream * Update README Keep most of betterlockscreen README. Replaced configuration, usage, and usage examples. * Update example config * Fix branding, paths, etc * Add wallpaper_cmd and time_format, long arg only * Fix quoting, remove unused variable Co-authored-by: Fox Kiester Co-authored-by: Richard Co-authored-by: Sheeets <31318683+sheeets@users.noreply.github.com> Co-authored-by: Paul Zeinlinger Co-authored-by: Luc Caspar Co-authored-by: R. David Dunphy Co-authored-by: Artem Vasenin Co-authored-by: Nicolas Serafini --- README.md | 147 +++-- TODO.md | 9 + betterlockscreen | 1096 ++++++++++++++++++++++------------- examples/betterlockscreenrc | 33 +- 4 files changed, 836 insertions(+), 449 deletions(-) create mode 100644 TODO.md diff --git a/README.md b/README.md index 9079e0b..01d5644 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ betterlockscreen --lock blur ![scrot2](https://github.com/pavanjadhaw/betterlockscreen.demo/raw/master/scrots/scrot2.png 'scrot2.png') -> [Watch some of the features of betterlockscreen in action](https://www.youtube.com/watch?v=9Ng5FZwnn6M&feature=youtu.be) +> [Watch some of the features of betterlockscreen in action](https://youtu.be/9Ng5FZwnn6M) ## Table of Contents @@ -46,7 +46,7 @@ images as lockscreen background depending on argument provided by user. > Note: Make sure your system has all dependencies satisfied -- [i3lock-color](https://github.com/PandorasFox/i3lock-color) - i3lock fork with additional features( >= 2.11-c ) +- [i3lock-color](https://github.com/Raymo111/i3lock-color) - i3lock fork with additional features(`>= 2.13.c.3`) - [imagemagick](https://www.imagemagick.org/script/index.php) - To apply effects to images - [xdpyinfo](https://www.x.org/archive/X11R7.7/doc/man/man1/xdpyinfo.1.xhtml), [xrandr](https://www.x.org/wiki/Projects/XRandR/), [bc](https://www.gnu.org/software/bc/) and [feh](https://feh.finalrewind.org/) - To find screen resolution, set custom blur level and wallpaper handling. @@ -96,74 +96,129 @@ export PATH="${PATH}:${HOME}/.local/bin/" UtkarshVerma was so kind to provide an installation script for debian based systems, ![check it out here](https://github.com/UtkarshVerma/installer-scripts). +#### Void Linux + +##### xbps repository + +`betterlockscreen` is available in official Void's repository as `betterlockscreen`. + +Installing using `xbps` (will automatically install all required dependencies): `xbps-install -S betterlockscreen` + ### Configuration You can customise various colors for betterlockscreen, copy config file from examples directory to `~/.config/betterlockscreenrc` and edit it accordingly. If configuration file is not found then default configurations will be used. +```ini +# default options +display_on=0 +span_image=false +lock_timeout=300 +fx_list=(dim blur dimblur pixel dimpixel color) +dim_level=40 +blur_level=1 +pixel_scale=10,1000 +solid_color=333333 + +# theme options +loginbox=00000066 +loginshadow=00000000 +locktext="Type password to unlock..." +font="sans-serif" +ringcolor=ffffffff +insidecolor=00000000 +separatorcolor=00000000 +ringvercolor=ffffffff +insidevercolor=00000000 +ringwrongcolor=ffffffff +insidewrongcolor=d23c3dff +keyhlcolor=d23c3dff +bshlcolor=d23c3dff +verifcolor=ffffffff +timecolor=ffffffff +datecolor=ffffffff +wallpaper_cmd="feh --bg-fill --no-fehbg" +time_format="%H:%M:%S" +``` If you have installed betterlockscreen from AUR package, then you can copy default config from docs ```sh cp /usr/share/doc/betterlockscreen/examples/betterlockscreenrc ~/.config ``` -For multimonitor setups, now you can choose which monitor the clock is displayed on -modify screennumber in betterlockscreenrc accordingly. Its zero based i.e 0 = screen 1 - ### Usage Run `betterlockscreen` and point it to either a directory (`betterlockscreen -u "path/to/dir"`) or an image (`betterlockscreen -u "/path/to/img.jpg"`) and that's all. `betterlockscreen` will change update its cache with image you provided. ```sh -usage: betterlockscreen [-u "path/to/img.jpg"] [-l "dim, blur or dimblur"] - [-w "dim, blur, or dimblur"] [-t "custom text"] [-s "lockscreen and suspend"] - [-r "resolution"] [-b "factor"] +Usage: betterlockscreen [-u ] [-l ] [-w ] -betterlockscreen - faster and sweet looking lockscreen for linux systems. + -u --update + Update lock screen image -required: - -u, --update "path/to/img.jpg" caches all required images + -l --lock + Lock screen with cached image -usage: - -l, --lock effect-name - locks with provided effect - -w, --wall effect-name - set desktop background with provided effect - -s, --suspend effect-name - lockscreen and suspend + -w --wall + Set wallpaper with cached image - Available effects: - dim, blur or dimblur +Additional arguments: - -t, --text "custom text" - set custom lockscreen text - -b, blur 0.0 - 1.0 - set blur range - -d, --display 0-9 - screen to display loginbox - --span - span multiple screens + --display + Set display to draw loginbox + --span + Scale image to span multiple displays -Usage examples: -1. Updating image cache(required) -betterlockscreen -u ~/Pictures/Forests.png # caches given image -betterlockscreen -u ~/Pictures # caches random image from ~/Pictures directory + --off + Turn display off after N minutes -2. Custom resolution and blur range -betterlockscreen -u path/to/directory -r 1920x1080 -b 0.5 + --fx + List of effects to apply -3. Lockscreen -betterlockscreen -l dim # lockscreen with dim effect + -- + Pass following arguments to i3lock -4. Lockscreen with custom text -betterlockscreen -l dim -t "custom lockscreen text" +Effects arguments: -5. Set desktop background -betterlockscreen -w blur # set desktop background with blur effect + --dim + Dim image N percent (0-100) + + --blur + Blur image N amount (0.0-1.0) + + --pixel + Pixelate image with N shrink and N grow (unsupported) + + --color + Solid color background with HEX ``` + +#### Usage examples: +1. Update image cache with random image +`betterlockscreen -u ~/Wallpapers` + +2. Update image cache with only dim and pixel effects +`betterlockscreen -u ~/Wallpapers/image.png --fx dim,pixel` + +3. Update image cache with random image, multiple monitors, login on 1, spanning +`betterlockscreen -u ~/Wallpapers/Dual/ --display 1 --span` + +4. Update image cache with solid background only (ignore errors) +`betterlockscreen -u . --fx color --color 5833ff` + +5. Update image cache with different background images +`betterlockscreen -u ~/Wallpapers/image1.png -u ~/Wallpapers/image2.png` + +6. Lock screen with blur effect +`betterlockscreen --lock blur` + +7. Lock screen with multiple monitors, spanning +`betterlockscreen -l dimblur --display 1 --span` + + ### Set desktop background on startup Add this line to `.xinitrc`. @@ -211,10 +266,9 @@ alt + shift + x ``` ### Lockscreen when suspended(systemd service) - ```sh # move service file to proper dir (the aur package does this for you) -cp betterlockscreen@.service /etc/systemd/system/ +cp betterlockscreen@.service /usr/lib/systemd/system/ # enable systemd service systemctl enable betterlockscreen@$USER @@ -222,12 +276,17 @@ systemctl enable betterlockscreen@$USER # disable systemd service systemctl disable betterlockscreen@$USER - # Note: Now you can call systemctl suspend to suspend your system # and betterlockscreen service will be activated # so when your system wakes your screen will be locked. ``` +**Hint:** The systemd-unit expects betterlockscreen to be installed in "/usr/local/bin", so maybe you want to check or change this! + +Resources and more informations: + * https://gist.github.com/Raymo111/91ffd256b7aca6a85e8a99d6331d3b7b + * https://github.com/Raymo111/i3lock-color/issues/174#issuecomment-687149213 + --- ### Countributing @@ -249,7 +308,7 @@ Betterlockscreen is under [MIT](https://github.com/pavanjadhaw/betterlockscreen/ - Hat tip to anyone who's code was used - Thanks to those who contributed to make it better -- Inspiration - r/unixporn +- Inspiration - [r/unixporn](https://www.reddit.com/r/unixporn) [logo]: .github/hero.png [website]: https://mdxjs.com \ No newline at end of file diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..f49854f --- /dev/null +++ b/TODO.md @@ -0,0 +1,9 @@ +# merge checklist + +* rename script +* fix paths +* s/multilockscreen/betterlockscreen/ +* combine READMEs +* update example rc +* check CLI args +* ensure feature parity diff --git a/betterlockscreen b/betterlockscreen index bbb0b93..f908c82 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -6,220 +6,438 @@ init_config () { - # user configuration file + # default options + display_on=0 + span_image=false + lock_timeout=300 + fx_list=(dim blur dimblur pixel dimpixel color) + dim_level=40 + blur_level=1 + pixel_scale=10,1000 + solid_color=333333 + description="" + + # default theme + loginbox=00000066 + loginshadow=00000000 + locktext="Type password to unlock..." + font="sans-serif" + ringcolor=ffffffff + insidecolor=00000000 + separatorcolor=00000000 + ringvercolor=ffffffff + insidevercolor=00000000 + ringwrongcolor=ffffffff + insidewrongcolor=d23c3dff + keyhlcolor=d23c3dff + bshlcolor=d23c3dff + verifcolor=ffffffff + timecolor=ffffffff + datecolor=ffffffff + layoutcolor=ffffffff + nocolor=00000000 + bgcolor=000000ff + wallpaper_cmd="feh --bg-fill --no-fehbg" + time_format="%H:%M:%S" + + # read user config USER_CONF="$HOME/.config/betterlockscreenrc" - if [ -e $USER_CONF ]; then + if [ -e "$USER_CONF" ]; then + # shellcheck source=/dev/null source "$USER_CONF" - # default configuration options - else - insidecolor=00000000 - ringcolor=ffffffff - keyhlcolor=d23c3dff - bshlcolor=d23c3dff - separatorcolor=00000000 - insidevercolor=00000000 - insidewrongcolor=d23c3dff - ringvercolor=ffffffff - ringwrongcolor=ffffffff - verifcolor=ffffffff - timecolor=ffffffff - datecolor=ffffffff - loginbox=00000066 - locktext='Type password to unlock...' - font="sans-serif" - display_on=0 - span_image=false - fi + fi - CACHE_DIR="$HOME/.cache/i3lock" - CUR_DIR="$CACHE_DIR/current" + # paths + CACHE_DIR="$HOME/.cache/i3lock" + CUR_DIR="$CACHE_DIR/current" - # wallpaper - CUR_W_RESIZE="$CUR_DIR/wall_resize.png" - CUR_W_DIM="$CUR_DIR/wall_dim.png" - CUR_W_BLUR="$CUR_DIR/wall_blur.png" - CUR_W_DIMBLUR="$CUR_DIR/wall_dimblur.png" - CUR_W_PIXEL="$CUR_DIR/wall_pixel.png" + # wallpaper + CUR_W_RESIZE="$CUR_DIR/wall_resize.png" + CUR_W_DIM="$CUR_DIR/wall_dim.png" + CUR_W_BLUR="$CUR_DIR/wall_blur.png" + CUR_W_DIMBLUR="$CUR_DIR/wall_dimblur.png" + CUR_W_PIXEL="$CUR_DIR/wall_pixel.png" + CUR_W_DIMPIXEL="$CUR_DIR/wall_dimpixel.png" + CUR_W_COLOR="$CUR_DIR/wall_color.png" - # locker - CUR_L_RESIZE="$CUR_DIR/lock_resize.png" - CUR_L_DIM="$CUR_DIR/lock_dim.png" - CUR_L_BLUR="$CUR_DIR/lock_blur.png" - CUR_L_DIMBLUR="$CUR_DIR/lock_dimblur.png" - CUR_L_PIXEL="$CUR_DIR/lock_pixel.png" + # lockscreen + CUR_L_RESIZE="$CUR_DIR/lock_resize.png" + CUR_L_DIM="$CUR_DIR/lock_dim.png" + CUR_L_BLUR="$CUR_DIR/lock_blur.png" + CUR_L_DIMBLUR="$CUR_DIR/lock_dimblur.png" + CUR_L_PIXEL="$CUR_DIR/lock_pixel.png" + CUR_L_DIMPIXEL="$CUR_DIR/lock_dimpixel.png" + CUR_L_COLOR="$CUR_DIR/lock_color.png" + + # Original DPMS timeout + DEFAULT_TIMEOUT=$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')") + # Original DPMS status + DEFAULT_DPMS=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}') } -init_config - - +# called before screen is locked prelock() { - if [ ! -z "$(pidof dunst)" ]; then - pkill -u "$USER" -USR1 dunst - fi + + # set dpms timeout + if [ "$DEFAULT_DPMS" == "Enabled" ]; then + xset dpms "$lock_timeout" + fi + # pause dunst + if command -v dunstctl &>/dev/null + then + dunstctl set-paused true + fi + if [[ "$runsuspend" = "true" ]]; then + lockargs="$lockargs -n" + fi } - +# lock screen with specified image lock() { - #$1 image path - i3lock \ - -i "$1" \ - --screen "$display_on" \ - --timepos='ix-170:iy-0' \ - --datepos='ix-240:iy+25' \ - --clock --date-align 1 --datestr "$locktext" \ - --insidecolor=$insidecolor --ringcolor=$ringcolor --line-uses-inside \ - --keyhlcolor=$keyhlcolor --bshlcolor=$bshlcolor --separatorcolor=$separatorcolor \ - --insidevercolor=$insidevercolor --insidewrongcolor=$insidewrongcolor \ - --ringvercolor=$ringvercolor --ringwrongcolor=$ringwrongcolor --indpos='x+280:y+h-70' \ - --radius=20 --ring-width=4 --veriftext='' --wrongtext='' \ - --verifcolor="$verifcolor" --timecolor="$timecolor" --datecolor="$datecolor" \ - --time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \ - --noinputtext='' --force-clock $lockargs + echof act "Locking screen..." + + local image="$1" + + i3lock \ + -i "$image" \ + -c "$bgcolor" \ + --screen "$display_on" \ + --time-pos="ix-170:iy-0" --time-str "$time_format" \ + --date-pos="ix-240:iy+25" \ + --layout-pos="ix-90:iy-0" --layout-align 1 --layout-color="$layoutcolor" "$keylayout" \ + --clock --date-align 1 --date-str "$locktext" \ + --inside-color="$insidecolor" --ring-color="$ringcolor" --line-uses-inside \ + --keyhl-color="$keyhlcolor" --bshl-color="$bshlcolor" --separator-color=$separatorcolor \ + --insidever-color="$insidevercolor" --insidewrong-color="$insidewrongcolor" \ + --ringver-color="$ringvercolor" --ringwrong-color="$ringwrongcolor" --ind-pos="x+280:y+h-70" \ + --radius=20 --ring-width=4 --verif-text="" --wrong-text="" --wrong-color="$nocolor" \ + --verif-color="$verifcolor" --time-color="$timecolor" --date-color="$datecolor" \ + --time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \ + --noinput-text="" --force-clock --pass-media-keys --pass-screen-keys --pass-power-keys \ + "${lockargs[@]}" +} + +# in case image isn't found +failsafe() { + + echof act "Locking screen... (FAILSAFE MODE)" + + local bgcolor="000000" + local text="ffffffff" + local error="ff0000" + + i3lock \ + -c "$bgcolor" \ + --screen "$display_on" \ + --time-pos="ix-170:iy-0" \ + --date-pos="ix-240:iy+25" \ + --clock --date-align 1 --date-str "$locktext" \ + --ind-pos="x+280:y+h-70" \ + --radius=20 --ring-width=4 --verif-text="" --wrong-text="" --wrong-color="$error" \ + --verif-color="$text" --time-color="$text" --date-color="$text" \ + --time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \ + --noinput-text="" --force-clock } +# called after screen is unlocked postlock() { - if [ ! -z "$(pidof dunst)" ] ; then - pkill -u "$USER" -USR2 dunst - fi + + # restore default dpms timeout + if [ "$DEFAULT_DPMS" == "Enabled" ]; then + xset dpms "$DEFAULT_TIMEOUT" + fi + + # unpause dunst + if command -v dunstctl &>/dev/null + then + dunstctl set-paused false + fi } +# select effect and lock screen lockselect() { - prelock - case "$1" in - dim) - # lockscreen with dimmed background - lock "$CUR_L_DIM" - ;; - blur) - # set lockscreen with blurred background - lock "$CUR_L_BLUR" - ;; + echof act "Running prelock..." + prelock & - dimblur) - # set lockscreen with dimmed + blurred background - lock "$CUR_L_DIMBLUR" - ;; + case "$1" in + dim) if [ -f "$CUR_L_DIM" ]; then lock "$CUR_L_DIM"; else failsafe; fi ;; + blur) if [ -f "$CUR_L_BLUR" ]; then lock "$CUR_L_BLUR"; else failsafe; fi ;; + dimblur) if [ -f "$CUR_L_DIMBLUR" ]; then lock "$CUR_L_DIMBLUR"; else failsafe; fi ;; + pixel) if [ -f "$CUR_L_PIXEL" ]; then lock "$CUR_L_PIXEL"; else failsafe; fi ;; + dimpixel) if [ -f "$CUR_L_DIMPIXEL" ]; then lock "$CUR_L_DIMPIXEL"; else failsafe; fi ;; + color) if [ -f "$CUR_L_COLOR" ]; then lock "$CUR_L_COLOR"; else failsafe; fi ;; + *) if [ -f "$CUR_L_RESIZE" ]; then lock "$CUR_L_RESIZE"; else failsafe; fi ;; + esac - pixel) - # set lockscreen with pixelated background - lock "$CUR_L_PIXEL" - ;; - - *) - # default lockscreen - lock "$CUR_L_RESIZE" - ;; - esac - postlock + echof act "Running postlock..." + postlock & } +# calculate adjustments for hidpi displays logical_px() { - # get dpi value from xrdb - local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}') - - # return the default value if no DPI is set - if [ -z "$DPI" ]; then - echo $1 - else - local SCALE=$(echo "scale=2; $DPI / 96.0" | bc) - # check if scaling the value is worthy - if [ $(echo "$SCALE > 1.25" | bc -l) -eq 0 ]; then - echo $1 - else - echo "$SCALE * $1 / 1" | bc - fi - fi + # $1: number of pixels to convert + # $2: 1 for width. 2 for height + local pixels="$1" + local direction="$2" + + # get dpi value from xdpyinfo + local DPI + DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$direction/p" | head -n1) + + # return the default value if no DPI is set + if [ -z "$DPI" ]; then + echo "$pixels" + else + local SCALE + SCALE=$(echo "scale=2; $DPI / 96.0" | bc) + + # check if scaling the value is worthy + if [ "$(echo "$SCALE > 1.25" | bc -l)" -eq 0 ]; then + echo "$pixels" + else + echo "$SCALE * $pixels / 1" | bc + fi + fi } -# get total resolution -# 1600x900 +# get total resolution, sets $TOTAL_SIZE get_total_size () { TOTAL_SIZE=$(xdpyinfo | grep -w "dimensions" | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') } - +# get list of displays, sets $DISPLAY_LIST get_display_list () { - local DNUM=0 - mapfile -t DARR < <( xrandr --listactivemonitors ) - for DISP in "${DARR[@]:1}"; do - (( DNUM++ )) - DISP=$(echo $DISP | sed -r 's/\/[0-9]*//g') - IFS=' ' read -r -a LINE <<< "$DISP" - DLIST+=("$DNUM ${LINE[3]} ${LINE[2]}") + local count=0 + mapfile -t displays < <(xrandr --listactivemonitors) + for display in "${displays[@]:1}"; do + ((count++)) + display="$(echo "$display" | sed -r 's/\/[0-9]*//g')" + IFS=' ' read -r -a info <<< "$display" + DISPLAY_LIST+=("$count ${info[3]} ${info[2]}") done } +# populate $WALL_LIST depending on number of displays and images passed +get_wall_list() { -get_user_wall() { - local path="$1" - if [ ! -d "$path" ]; then - USER_WALL="$path" - return - fi - dir=("$path"/*) - dir="${dir[RANDOM % ${#dir[@]}]}" - get_user_wall "$dir" + local paths=("$@") + declare -ga WALL_LIST + + # multiple images and spanning conflict, bail out + if [ "${#paths[@]}" -gt 1 ] && [ "$span_image" = true ]; then + echof err "Can't use --span with multiple images!" + exit 1 + fi + + # if spanning return 1 image + if [ "$span_image" = true ]; then + get_image "${paths[0]}" + + # if # paths is 1 + elif [ "${#paths[@]}" -eq 1 ]; then + for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do + # add same image to $WALL_LIST for each display + get_image "${paths[0]}" + done + + # if # of paths equals # of displays + elif [ ${#paths[@]} -eq "${#DISPLAY_LIST[@]}" ]; then + for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do + # add each image to $WALL_LIST + get_image "${paths[$i]}" + done + + # if # of paths differ from # of display, bail out + else + echof err "${#paths[@]} images provided for ${#DISPLAY_LIST[@]} displays!" + exit 1 + fi } +# get image path, append to $WALL_LIST +get_image() { + + local path="$1" + + # we have a file + if [ -f "$path" ]; then + WALL_LIST+=("$path") + return + # we have a directory + elif [ -d "$path" ]; then + dir=("$path"/*) + rdir="${dir[RANDOM % ${#dir[@]}]}" + get_image "$rdir" # <-- calls itself + # not file or directory, bail out + else + echof err "invalid path: $path" + exit 1 + fi + +} + +# scale base image and generate effects resize_and_render () { - # arguments - local base=$1 - local path=$2 - local resolution=$3 + local base="$1" + local path="$2" + local resolution="$3" - # wallpaper - RES_RESIZE="$2/resize.png" - RES_DIM="$2/dim.png" - RES_BLUR="$2/blur.png" - RES_DIMBLUR="$2/dimblur.png" - RES_PIXEL="$2/pixel.png" + # resource paths + RES_RESIZE="$path/resize.png" + RES_DIM="$path/dim.png" + RES_BLUR="$path/blur.png" + RES_DIMBLUR="$path/dimblur.png" + RES_PIXEL="$path/pixel.png" + RES_DIMPIXEL="$path/dimpixel.png" + RES_COLOR="$path/color.png" - # defaults - [[ $blur_level ]] || blur_level=1 - RES_DIM="$2/dim.png" - RES_BLUR="$2/blur.png" - RES_DIMBLUR="$2/dimblur.png" + # resize + base_resize "$base" "$RES_RESIZE" "$resolution" - # defaults - [[ $blur_level ]] || blur_level=1 + # effects + for effect in "${fx_list[@]}"; do + case $effect in + dim) fx_dim "$RES_RESIZE" "$RES_DIM";; + blur) fx_blur "$RES_RESIZE" "$RES_BLUR" "$resolution";; + dimblur) fx_dimblur "$RES_RESIZE" "$RES_DIMBLUR" "$resolution";; + pixel) fx_pixel "$RES_RESIZE" "$RES_PIXEL";; + dimpixel) fx_dimpixel "$RES_RESIZE" "$RES_DIMPIXEL";; + color) fx_color "$RES_COLOR" "$resolution";; + esac + done - echo "Resizing original and applying effects..." +} - # apply resize - eval convert "$base" -resize "$resolution""^" -gravity center -extent "$resolution" "$RES_RESIZE" +# apply resize +base_resize() { - # apply dim - eval convert "$RES_RESIZE" -fill black -colorize 40% "$RES_DIM" + local input="$1" + local output="$2" + local size="$3" - # apply blur - blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) - blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) - eval convert "$RES_RESIZE" \ - -filter Gaussian \ - -resize "$blur_shrink%" \ - -define "filter:sigma=$blur_sigma" \ - -resize "$resolution^" -gravity center -extent "$resolution" \ - "$RES_BLUR" + echof act "Resizing base image..." + eval convert "$input" \ + -resize "$size""^" \ + -gravity center \ + -extent "$size" \ + "$output" +} - # apply dimblur - eval convert "$RES_DIM" \ - -filter Gaussian \ - -resize "$blur_shrink%" \ - -define "filter:sigma=$blur_sigma" \ - -resize "$resolution^" -gravity center -extent "$resolution" \ - "$RES_DIMBLUR" +# apply dim +fx_dim() { + local input="$1" + local output="$2" - # pixelate - eval convert "$RES_RESIZE" \ - -scale 10% \ - -scale 1000% \ - "$RES_PIXEL" + echof act "Rendering 'dim' effect..." + eval convert "$input" \ + -fill black -colorize "$dim_level"% \ + "$output" +} + +# apply blur +fx_blur() { + local input="$1" + local output="$2" + local size="$3" + + echof act "Rendering 'blur' effect..." + blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) + blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) + eval convert "$input" \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$size^" -gravity center -extent "$size" \ + "$output" +} + +# apply dimblur +fx_dimblur() { + local input="$1" + local output="$2" + local size="$3" + + echof act "Rendering 'dimblur' effect..." + blur_shrink=$(echo "scale=2; 20 / $blur_level" | bc) + blur_sigma=$(echo "scale=2; 0.6 * $blur_level" | bc) + eval convert "$input" \ + -fill black -colorize "$dim_level"% \ + -filter Gaussian \ + -resize "$blur_shrink%" \ + -define "filter:sigma=$blur_sigma" \ + -resize "$size^" -gravity center -extent "$size" \ + "$output" +} + +# pixelate +fx_pixel() { + local input="$1" + local output="$2" + + echof act "Rendering 'pixel' effect..." + IFS=',' read -ra range <<< "$pixel_scale" + eval convert "$input" \ + -scale "${range[0]}"% -scale "${range[1]}"% \ + "$output" +} + +# apply dimpixel +fx_dimpixel() { + local input="$1" + local output="$2" + + echof act "Rendering 'dimpixel' effect..." + IFS=',' read -ra range <<< "$pixel_scale" + eval convert "$input" \ + -fill black -colorize "$dim_level"% \ + -scale "${range[0]}"% -scale "${range[1]}"% \ + "$output" +} + +# create solid color +fx_color() { + local output="$1" + local size="$2" + + echof act "Rendering 'color' effect..." + eval convert -size "$size" canvas:\#"$solid_color" "$RES_COLOR" +} + +# create loginbox rectangle, set $RECTANGLE +create_loginbox () { + RECTANGLE="$CUR_DIR/rectangle.png" + local shadow="$CUR_DIR/shadow.png" + local width height + width=$(logical_px 300 1) + height=$(logical_px 80 2) + convert -size "$width"x"$height" xc:\#"$loginbox" -fill none $RECTANGLE + convert $RECTANGLE \ + \( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \ + -background none -layers merge +repage $shadow + composite -compose Dst_Out -gravity center \ + $RECTANGLE $shadow -alpha Set $shadow + convert $shadow $RECTANGLE -geometry +10+10 -composite $RECTANGLE + [[ $shadow ]] && rm $shadow +} + +# create rectangle with description, set $DESCRECT +create_description () { + DESCRECT="$CUR_DIR/description.png" + local shadow="$CUR_DIR/shadow.png" + convert -background none -family "$(fc-match "$font" family)" -style Normal -pointsize 14 -fill \#"$datecolor" label:"\ $description\ " -bordercolor \#"$loginbox" -border 10 $DESCRECT + convert $DESCRECT \ + \( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \ + -background none -layers merge +repage $shadow + composite -compose Dst_Out -gravity center \ + $DESCRECT $shadow -alpha Set $shadow + convert $shadow $DESCRECT -geometry +10+10 -composite $DESCRECT + [[ $shadow ]] && rm $shadow } # delete and recreate directory @@ -227,297 +445,387 @@ purge_cache () { if [[ -d "$1" ]]; then rm -r "$1" fi - mkdir -p "$1" + mkdir -p "$1" } -# update locker and wallpaper images +# update lockscreen and wallpaper images update () { - wallpaper=$1 - rectangles=" " + local images=("$@") - get_user_wall "$wallpaper" # Returns USER_WALL - echo "Original: $USER_WALL" + echof act "Updating image cache..." + mkdir -p "$CACHE_DIR" &>/dev/null - get_display_list # Returns DLIST - get_total_size # Return TOTAL_SIZE + get_display_list # DISPLAY_LIST + get_total_size # TOTAL_SIZE + echof info "Detected ${#DISPLAY_LIST[@]} display(s) @ $TOTAL_SIZE total resolution" - # create base images per display - for DISP in "${DLIST[@]}"; do - DNUM="$(cut -d" " -f1 <<<"${DISP}")" - DDEV="$(cut -d" " -f2 <<<"${DISP}")" - DGEO=($(cut -d" " -f3 <<<"${DISP}")) - DRES=(${DGEO[0]//[+]/ }) - DPOS="+${DRES[1]}+${DRES[2]}" - DPATH="$CACHE_DIR/$DNUM-$DDEV" + get_wall_list "${images[@]}" # WALL_LIST + echof info "Original image(s): ${WALL_LIST[*]##*/}" - #get_geometry $DGEO # Returns SCREEN_* - if [[ $DNUM -eq "$display_on" ]] || [[ "$display_on" -eq 0 ]]; then - SRA=(${DGEO//[x+]/ }) - CX=$((${SRA[2]} + $(logical_px 25))) - CY=$((${SRA[3]} + ${SRA[1]} - $(logical_px 30))) - rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300))),$((CY-$(logical_px 80))) " + # Prepare description box to obtain width for positioning + local descwidth + local descheight + if [ -z "$description" ]; then + descwidth=0 + descheight=0 + else + create_description + descwidth=$(identify -format "%[fx:w]" "$DESCRECT") + descheight=$(identify -format "%[fx:h]" "$DESCRECT") + fi + + for ((i=0; i<${#DISPLAY_LIST[@]}; i++)); do + display="${DISPLAY_LIST[$i]}" + USER_WALL="${WALL_LIST[$i]}" + + # escape spaces for IM + if echo "$USER_WALL" | grep -E -q "[[:space:]]"; then + USER_WALL="${USER_WALL// /\\ }" fi - echo "Found: $DDEV ($DNUM)" - echo "Resolution: ${DRES[0]}" + IFS=' ' read -r -a dinfo <<< "$display" + local id="${dinfo[0]}" + local device="${dinfo[1]}" + local geometry="${dinfo[2]}" - purge_cache $DPATH + read -r -a cols <<< "${geometry//[x+-]/ }" + local position="${geometry#*${cols[1]}}" + local resolution="${geometry%${position}*}" - # we only need one set of images when spanning - if [ "$span_image" = true ] && [ $DNUM -gt 1 ]; then - continue + if [[ $id -eq "$display_on" ]] || [[ "$display_on" -eq 0 ]]; then + + IFS='x' read -r -a dimension <<< "$resolution" + res_x="${dimension[0]}" + res_y="${dimension[1]}" + read -r -a val <<< "${position//[+-]/ }" + read -r -a sym <<< "${position//[0-9]/ }" + pos_x="${sym[0]}${val[0]}" + pos_y="${sym[1]}${val[1]}" + + rect_x=$((pos_x + $(logical_px 15 1))) + rect_y=$((pos_y + res_y - $(logical_px 120 2))) + positions+=("+$((rect_x))+$((rect_y))") + + descrect_x=$((pos_x + res_x - descwidth - $(logical_px 15 1))) + descrect_y=$((pos_y + res_y - descheight - $(logical_px 20 2))) + positions_desc+=("+$((descrect_x))+$((descrect_y))") fi + local path="$CACHE_DIR/$id-$device" + purge_cache "$path" + if [ "$span_image" = true ]; then - # render wallpaper at total display size (3840x1080) - resize_and_render $USER_WALL $DPATH $TOTAL_SIZE + if [ "$id" -gt 1 ]; then + continue + else + device="[span]" + id="*" + resolution="$TOTAL_SIZE" + fi + fi + + echof info "Processing display: $device ($id)" + echof info "Resolution: $resolution" + + if [ "$span_image" = true ]; then + resize_and_render "$USER_WALL" "$path" "$resolution" else - # render wallpaper at each display size - resize_and_render $USER_WALL $DPATH ${DRES[0]} - # add to parameters for position on canvas - PARAM_RESIZE="$PARAM_RESIZE $RES_RESIZE -geometry $DPOS -composite " - PARAM_DIM="$PARAM_DIM $RES_DIM -geometry $DPOS -composite " - PARAM_BLUR="$PARAM_BLUR $RES_BLUR -geometry $DPOS -composite " - PARAM_DIMBLUR="$PARAM_DIMBLUR $RES_DIMBLUR -geometry $DPOS -composite " - PARAM_PIXEL="$PARAM_PIXEL $RES_PIXEL -geometry $DPOS -composite " + resize_and_render "$USER_WALL" "$path" "$resolution" + + PARAM_RESIZE="$PARAM_RESIZE $RES_RESIZE -geometry $position -composite " + PARAM_DIM="$PARAM_DIM $RES_DIM -geometry $position -composite " + PARAM_BLUR="$PARAM_BLUR $RES_BLUR -geometry $position -composite " + PARAM_DIMBLUR="$PARAM_DIMBLUR $RES_DIMBLUR -geometry $position -composite " + PARAM_PIXEL="$PARAM_PIXEL $RES_PIXEL -geometry $position -composite " + PARAM_DIMPIXEL="$PARAM_DIMPIXEL $RES_DIMPIXEL -geometry $position -composite " + PARAM_COLOR="$PARAM_COLOR $RES_COLOR -geometry $position -composite " fi done - purge_cache $CUR_DIR + purge_cache "$CUR_DIR" - if [ "$span_image" = true ] || [ ${#DLIST[@]} -lt 2 ]; then - echo "Copying final wallpaper images..." - cp $RES_RESIZE $CUR_W_RESIZE - cp $RES_DIM $CUR_W_DIM - cp $RES_BLUR $CUR_W_BLUR - cp $RES_DIMBLUR $CUR_W_DIMBLUR - cp $RES_PIXEL $CUR_W_PIXEL + if [ "$span_image" = true ] || [ ${#DISPLAY_LIST[@]} -lt 2 ]; then + echof act "Rendering final wallpaper images..." + [[ -f "$RES_RESIZE" ]] && cp $RES_RESIZE $CUR_W_RESIZE + [[ -f "$RES_DIM" ]] && cp $RES_DIM $CUR_W_DIM + [[ -f "$RES_BLUR" ]] && cp $RES_BLUR $CUR_W_BLUR + [[ -f "$RES_DIMBLUR" ]] && cp $RES_DIMBLUR $CUR_W_DIMBLUR + [[ -f "$RES_PIXEL" ]] && cp $RES_PIXEL $CUR_W_PIXEL + [[ -f "$RES_DIMPIXEL" ]] && cp $RES_DIMPIXEL $CUR_W_DIMPIXEL + [[ -f "$RES_COLOR" ]] && cp $RES_COLOR $CUR_W_COLOR else - echo "Creating canvas: $TOTAL_SIZE" - convert -size $TOTAL_SIZE 'xc:black' $CUR_W_RESIZE - convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIM - convert -size $TOTAL_SIZE 'xc:black' $CUR_W_BLUR - convert -size $TOTAL_SIZE 'xc:black' $CUR_W_DIMBLUR - convert -size $TOTAL_SIZE 'xc:black' $CUR_W_PIXEL + echof act "Creating canvas: $TOTAL_SIZE" + [[ -f "$RES_RESIZE" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_RESIZE + [[ -f "$RES_DIM" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIM + [[ -f "$RES_BLUR" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_BLUR + [[ -f "$RES_DIMBLUR" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMBLUR + [[ -f "$RES_PIXEL" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_PIXEL + [[ -f "$RES_DIMPIXEL" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMPIXEL + [[ -f "$RES_COLOR" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_COLOR - echo "Rendering final wallpaper images..." - convert $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE - convert $CUR_W_DIM $PARAM_DIM $CUR_W_DIM - convert $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR - convert $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR - convert $CUR_W_PIXEL $PARAM_PIXEL $CUR_W_PIXEL + echof act "Rendering final wallpaper images..." + [[ -f "$CUR_W_RESIZE" ]] && convert $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE + [[ -f "$CUR_W_DIM" ]] && convert $CUR_W_DIM $PARAM_DIM $CUR_W_DIM + [[ -f "$CUR_W_BLUR" ]] && convert $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR + [[ -f "$CUR_W_DIMBLUR" ]] && convert $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR + [[ -f "$CUR_W_PIXEL" ]] && convert $CUR_W_PIXEL $PARAM_PIXEL $CUR_W_PIXEL + [[ -f "$CUR_W_DIMPIXEL" ]] && convert $CUR_W_DIMPIXEL $PARAM_DIMPIXEL $CUR_W_DIMPIXEL + [[ -f "$CUR_W_COLOR" ]] && convert $CUR_W_COLOR $PARAM_COLOR $CUR_W_COLOR fi - echo "Rendering final locker images..." - convert "$CUR_W_RESIZE" -draw "fill #$loginbox $rectangles" "$CUR_L_RESIZE" - convert "$CUR_W_DIM" -draw "fill #$loginbox $rectangles" "$CUR_L_DIM" - convert "$CUR_W_BLUR" -draw "fill #$loginbox $rectangles" "$CUR_L_BLUR" - convert "$CUR_W_DIMBLUR" -draw "fill #$loginbox $rectangles" "$CUR_L_DIMBLUR" - convert "$CUR_W_PIXEL" -draw "fill #$loginbox $rectangles" "$CUR_L_PIXEL" + echof act "Rendering final lockscreen images..." + + create_loginbox + for pos in "${positions[@]}"; do + PARAM_RECT="$PARAM_RECT $RECTANGLE -geometry $pos -composite " + done + + if [ ! -z "$description" ]; then + create_description + for descpos in "${positions_desc[@]}"; do + PARAM_RECT="$PARAM_RECT $DESCRECT -geometry $descpos -composite " + done + fi + + [[ -f "$CUR_W_RESIZE" ]] && convert $CUR_W_RESIZE $PARAM_RECT $CUR_L_RESIZE + [[ -f "$CUR_W_DIM" ]] && convert $CUR_W_DIM $PARAM_RECT $CUR_L_DIM + [[ -f "$CUR_W_BLUR" ]] && convert $CUR_W_BLUR $PARAM_RECT $CUR_L_BLUR + [[ -f "$CUR_W_DIMBLUR" ]] && convert $CUR_W_DIMBLUR $PARAM_RECT $CUR_L_DIMBLUR + [[ -f "$CUR_W_PIXEL" ]] && convert $CUR_W_PIXEL $PARAM_RECT $CUR_L_PIXEL + [[ -f "$CUR_W_DIMPIXEL" ]] && convert $CUR_W_DIMPIXEL $PARAM_RECT $CUR_L_DIMPIXEL + [[ -f "$CUR_W_COLOR" ]] && convert $CUR_W_COLOR $PARAM_RECT $CUR_L_COLOR + + [[ $RECTANGLE ]] && rm "$RECTANGLE" + [[ $DESCRECT ]] && rm "$DESCRECT" + + echof ok "Done" + } - +# set wallpaper with effect wallpaper() { - local fopt + + local effect="$1" + + # make wallpaper span displays get_display_list - if [ "$span_image" = true ] || [[ "${#DLIST[@]}" -gt 1 ]]; then - fopt="--no-xinerama" + if [ "$span_image" = true ] || [[ "${#DISPLAY_LIST[@]}" -gt 1 ]]; then + wallpaper_cmd="$wallpaper_cmd --no-xinerama" fi - case "$1" in - '') - # set resized image as wallpaper if no argument is supplied by user - feh --bg-fill "$fopt" "$CUR_W_RESIZE" - ;; - dim) - # set dimmed image as wallpaper - feh --bg-fill "$fopt" "$CUR_W_DIM" - ;; - - blur) - # set blurred image as wallpaper - feh --bg-fill "$fopt" "$CUR_W_BLUR" - ;; - - dimblur) - # set dimmed + blurred image as wallpaper - feh --bg-fill "$fopt" "$CUR_W_DIMBLUR" - ;; - - pixel) - # set pixelated image as wallpaper - feh --bg-fill "$fopt" "$CUR_W_PIXEL" - ;; - esac + # set wallpaper + case "$effect" in + dim) wallpaper="$CUR_W_DIM";; + blur) wallpaper="$CUR_W_BLUR";; + dimblur) wallpaper="$CUR_W_DIMBLUR";; + pixel) wallpaper="$CUR_W_PIXEL";; + dimpixel) wallpaper="$CUR_W_DIMPIXEL";; + color) wallpaper="$CUR_W_COLOR";; + *) wallpaper="$CUR_W_RESIZE";; + esac + eval "$wallpaper_cmd $wallpaper" } +# wrap echo with fancy prefix +echof() { -empty() { - if [ -f $CUR_L_RESIZE ]; then - echo -e "\nSeems you haven't provided any arguments. See below for usage details." - else - echo 'Important: Update the image cache (e.g. betterlockscreen -u path/to/image.jpg).' - echo - echo ' Image cache must be updated to initially configure or update the wallpaper used.' - fi + local prefix="$1" + local message="$2" - echo - echo 'For other sets of options and help, use the help command.' - echo 'e.g. betterlockscreen -h or betterlockscreen --help' - echo - echo 'See: https://github.com/pavanjadhaw/betterlockscreen for additional info...' - exit 1 + case "$prefix" in + header) msgpfx="[\e[1;95mB\e[m]";; + info) msgpfx="[\e[1;97m=\e[m]";; + act) msgpfx="[\e[1;92m*\e[m]";; + ok) msgpfx="[\e[1;93m+\e[m]";; + error) msgpfx="[\e[1;91m!\e[m]";; + *) msgpfx="";; + esac + echo -e "$msgpfx $message" } - +# help message usage() { - echo 'Important: Update the image cache (e.g. 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...' - echo - echo - echo 'Options:' - echo - echo ' -h --help' - echo ' For help (e.g. 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 ' E.g: 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 (e.g. betterlockscreen -l)' - echo ' you can also use dimmed or blurred background for lockscreen.' - echo ' E.g: betterlockscreen -l dim (for dimmed background)' - echo ' E.g: betterlockscreen -l blur (for blurred background)' - echo ' E.g: betterlockscreen -l dimblur (for dimmed + blurred background)' - echo - echo - echo ' -s --suspend' - echo ' to suspend system and lock screen (e.g. betterlockscreen -s)' - echo ' you can also use dimmed or blurred background for lockscreen.' - echo ' E.g: betterlockscreen -s dim (for dimmed background)' - echo ' E.g: betterlockscreen -s blur (for blurred background)' - echo ' E.g: 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 (e.g. betterlockscreen -w or betterlockscreen --wall)' - echo ' you can also use dimmed or blurred variants.' - echo ' E.g: betterlockscreen -w dim (for dimmed wallpaper)' - echo ' E.g: betterlockscreen -w blur (for blurred wallpaper)' - echo ' E.g: betterlockscreen -w dimblur (for dimmed + blurred wallpaper)' - echo - echo - echo ' -d --display' - echo ' to be used after -u' - echo ' used to set which screen to display login box.' - echo ' E.g: betterlockscreen -u path/to/image.png -d 1' - echo ' E.g: betterlockscreen -u path/to/image.png --display 2' - echo - echo - echo ' --span' - echo ' to be used after -u' - echo ' used to create wall and locker images that span multiple displays.' - echo ' E.g: betterlockscreen -u path/to/image.png --span' - echo - echo - echo ' -b --blur' - echo ' to be used after -u' - echo ' used to set blur intensity. Default to 1.' - echo ' E.g: betterlockscreen -u path/to/image.png -b 3' - echo ' E.g: betterlockscreen -u path/to/image.png --blur 0.5' - echo - echo - echo ' -t --text' - echo ' to set custom lockscreen text (max 31 chars)' - echo " E.g: betterlockscreen -l dim -t \"Don't touch my machine!\"" - echo ' E.g: betterlockscreen --text "Hi, user!" -s blur' + echo + echo "Usage: betterlockscreen [-u ] [-l ] [-w ]" + echo + echo " -u --update " + echo " Update lock screen image" + echo + echo " -l --lock " + echo " Lock screen with cached image" + echo + echo " -w --wall " + echo " Set wallpaper with cached image" + echo + echo "Additional arguments:" + echo + echo " --display " + echo " Set display to draw loginbox" + echo + echo " --span" + echo " Scale image to span multiple displays" + echo + echo " --off " + echo " Turn display off after N minutes" + echo + echo " --fx " + echo " List of effects to generate" + echo + echo " --desc " + echo " Set a description for the new lock screen image" + echo " (Only has an effect in combination with --update)" + echo + echo " --show-layout" + echo " Show current keyboard layout" + echo + echo " --wallpaper-cmd " + echo " to set your custom wallpaper setter" + echo + echo " --time-format " + echo " to set the time format used by i3lock-color" + echo + echo " -- " + echo " Pass additional arguments to i3lock" + echo + echo "Effects arguments:" + echo + echo " --dim " + echo " Dim image N percent (0-100)" + echo + echo " --blur " + echo " Blur image N amount (0.0-1.0)" + echo + echo " --pixel " + echo " Pixelate image with N shrink and N grow (unsupported)" + echo + echo " --color " + echo " Solid color background with HEX" + echo + exit 1 } +echof header "betterlockscreen" -# Options -[[ "$1" = '' ]] && empty +init_config +# show usage when no arguments passed +[[ "$1" = "" ]] && usage + +# process arguments +lockargs=() for arg in "$@"; do - [[ "${arg:0:1}" = '-' ]] || continue + [[ "${arg:0:1}" = '-' ]] || continue - case "$1" in - -h | --help) - usage - break - ;; + case "$1" in + -u | --update) + runupdate=true + imagepaths+=("$2") + shift 2 + ;; - -s | --suspend) - runsuspend=true - ;& + -s | --suspend) + runsuspend=true + ;& - -l | --lock) - runlock=true - [[ $runsuspend ]] || lockargs="$lockargs -n" - [[ ${2:0:1} = '-' ]] && shift 1 || { lockstyle="$2"; shift 2; } - ;; + -l | --lock) + runlock=true + if [[ ${2:0:1} = '-' ]]; then + shift 1 + else + lockstyle="$2"; shift 2 + fi + ;; - -w | --wall | --wallpaper) - wallpaper "$2" - shift 2 - ;; + -w | --wall) + wallpaper "$2" + shift 2 + ;; - -u | --update) - runupdate=true - imagepath="$2" - shift 2 - ;; + --wallpaper-cmd) + wallpaper_cmd="$2" + shift 2 + ;; - -t | --text) - locktext="$2" - shift 2 - ;; + --time-format) + time_format="$2" + shift 2 + ;; - -d | --display) - display_on="$2" - shift 2 - ;; + --display) + display_on="$2" + shift 2 + ;; - --span) - span_image=true + --span) + span_image=true shift 1 - ;; + ;; - -b | --blur) - blur_level="$2" - shift 2 - ;; + --off) + lock_timeout="$2" + shift 2 + ;; - --) - lockargs="$lockargs ${@:2}" - break - ;; + --text) + locktext="$2" + shift 2 + ;; - *) - echo "invalid argument: $1" - break - ;; - esac + --show-layout) + keylayout="--keylayout 2"; + shift 1 + ;; + + --fx) + IFS=',' read -ra fx_list <<< "$2" + shift 2 + ;; + + --dim) + dim_level="$2" + shift 2 + ;; + + --blur) + blur_level="$2" + shift 2 + ;; + + --pixel) + pixel_scale="$2" + shift 2 + ;; + + --color) + solid_color="${2//\#/}" + shift 2 + ;; + + --desc) + description="$2" + shift 2 + ;; + + --) + lockargs+=("${@:2}") + break + ;; + + -h | --help | *) + usage + break + ;; + esac done -# some defaults -[[ $display_on ]] || display_on=0 -[[ $span_image ]] || span_image=false - # Run image generation -[[ $runupdate ]] && update "$imagepath" +[[ $runupdate ]] && update "${imagepaths[@]}" # Activate lockscreen +[[ $runsuspend ]] || lockargs+=(-n) [[ $runlock ]] && lockselect "$lockstyle" && \ - { [[ $runsuspend ]] && systemctl suspend; } + { [[ $runsuspend ]] && systemctl suspend; } exit 0 \ No newline at end of file diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index f4b65b5..fedde94 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -1,18 +1,29 @@ -# configuration file for betterlockscreen +# ~/.config/betterlockscreenrc -insidecolor=00000000 +# default options +display_on=0 +span_image=false +lock_timeout=5 +fx_list=(dim blur dimblur pixel dimpixel color) +dim_level=40 +blur_level=1 +pixel_scale=10,1000 +solid_color=333333 + +# default theme +loginbox=00000066 +loginshadow=00000000 +locktext="Type password to unlock..." +font="sans-serif" ringcolor=ffffffff +insidecolor=00000000 +separatorcolor=00000000 +ringvercolor=ffffffff +insidevercolor=00000000 +ringwrongcolor=ffffffff +insidewrongcolor=d23c3dff keyhlcolor=d23c3dff bshlcolor=d23c3dff -separatorcolor=00000000 -insidevercolor=00000000 -insidewrongcolor=d23c3dff -ringvercolor=ffffffff -ringwrongcolor=ffffffff verifcolor=ffffffff timecolor=ffffffff datecolor=ffffffff -loginbox=00000066 -font="sans-serif" -display_on=0 -span_image=false From c025de7b8f2707b553e0049408a96ce22aecf328 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Sun, 30 May 2021 18:55:59 -0500 Subject: [PATCH 09/36] Delete TODO.md --- TODO.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 TODO.md diff --git a/TODO.md b/TODO.md deleted file mode 100644 index f49854f..0000000 --- a/TODO.md +++ /dev/null @@ -1,9 +0,0 @@ -# merge checklist - -* rename script -* fix paths -* s/multilockscreen/betterlockscreen/ -* combine READMEs -* update example rc -* check CLI args -* ensure feature parity From 66d975915922c462c86cce37818a4e4a567f9d26 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Fri, 4 Jun 2021 15:49:35 -0500 Subject: [PATCH 10/36] Get DPI from xrdb, fixes #236 (#237) `multi-monitor` branch did not check for user set DPI in Xresources. It does now. Also, rather than parsing .Xresources file, we instead query xrdb to get the current value. --- betterlockscreen | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index f908c82..568f94b 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -184,24 +184,30 @@ logical_px() { # $2: 1 for width. 2 for height local pixels="$1" local direction="$2" + local dpi - # get dpi value from xdpyinfo - local DPI - DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$direction/p" | head -n1) + # use DPI set by user in .Xresources + dpi=$(xrdb -q | grep -oP '^\s*Xft.dpi:\s*\K\d+' | bc) - # return the default value if no DPI is set - if [ -z "$DPI" ]; then - echo "$pixels" - else - local SCALE - SCALE=$(echo "scale=2; $DPI / 96.0" | bc) + # or get dpi value from xdpyinfo + if [ -z "$dpi" ]; then + dpi=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$direction/p" | head -n1) + fi + + # adjust scaling + if [ -n "$dpi" ]; then + local scale + scale=$(echo "scale=2; $dpi / 96.0" | bc) # check if scaling the value is worthy - if [ "$(echo "$SCALE > 1.25" | bc -l)" -eq 0 ]; then + if [ "$(echo "$scale > 1.25" | bc -l)" -eq 0 ]; then echo "$pixels" else - echo "$SCALE * $pixels / 1" | bc + echo "$scale * $pixels / 1" | bc fi + else + # return the default value if no DPI is set + echo "$pixels" fi } From a64ce8f441e16b11a9acf9336e3e84f4f0fd05b5 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Sat, 5 Jun 2021 07:24:45 -0500 Subject: [PATCH 11/36] Left-align time string (#238) --- betterlockscreen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/betterlockscreen b/betterlockscreen index 568f94b..c9152ad 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -103,7 +103,7 @@ lock() { -i "$image" \ -c "$bgcolor" \ --screen "$display_on" \ - --time-pos="ix-170:iy-0" --time-str "$time_format" \ + --time-pos="ix-240:iy-0" --time-align 1 --time-str "$time_format" \ --date-pos="ix-240:iy+25" \ --layout-pos="ix-90:iy-0" --layout-align 1 --layout-color="$layoutcolor" "$keylayout" \ --clock --date-align 1 --date-str "$locktext" \ From 321b8e8c5fbf494e559be014ca02a55df106dea3 Mon Sep 17 00:00:00 2001 From: Sourav Das Date: Mon, 7 Jun 2021 03:43:44 +0530 Subject: [PATCH 12/36] Don't change state of dunst on unlock if paused on lock (#233) * Fix: Don't change state of dunst on unlock if paused on lock (credits to @souravdas142) --- betterlockscreen | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index c9152ad..84974b3 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -40,6 +40,9 @@ init_config () { wallpaper_cmd="feh --bg-fill --no-fehbg" time_format="%H:%M:%S" + # Storing current state of dunst before locking + dunst_paused_state="$(dunstctl is-paused)" + # read user config USER_CONF="$HOME/.config/betterlockscreenrc" if [ -e "$USER_CONF" ]; then @@ -82,8 +85,8 @@ prelock() { if [ "$DEFAULT_DPMS" == "Enabled" ]; then xset dpms "$lock_timeout" fi - # pause dunst - if command -v dunstctl &>/dev/null + # If dusnt is already paused don't pause it again + if [[ -e "$(command -v dunstctl)" && "$dunst_paused_state" == "false" ]] then dunstctl set-paused true fi @@ -149,8 +152,8 @@ postlock() { xset dpms "$DEFAULT_TIMEOUT" fi - # unpause dunst - if command -v dunstctl &>/dev/null + # If dunst already paused before locking don't unpause dunst + if [[ -e "$(command -v dunstctl)" && "$dunst_paused_state" == "false" ]] then dunstctl set-paused false fi From d1d19e1ff028db6ecca50fb3d7131b5cb8637d8e Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Thu, 17 Jun 2021 16:53:32 -0500 Subject: [PATCH 13/36] Clear shellcheck errors --- betterlockscreen | 90 ++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 84974b3..55259a9 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -418,35 +418,35 @@ fx_color() { eval convert -size "$size" canvas:\#"$solid_color" "$RES_COLOR" } -# create loginbox rectangle, set $RECTANGLE +# create loginbox rectangle, set "$RECTANGLE" create_loginbox () { RECTANGLE="$CUR_DIR/rectangle.png" local shadow="$CUR_DIR/shadow.png" local width height width=$(logical_px 300 1) height=$(logical_px 80 2) - convert -size "$width"x"$height" xc:\#"$loginbox" -fill none $RECTANGLE - convert $RECTANGLE \ + convert -size "$width"x"$height" xc:\#"$loginbox" -fill none "$RECTANGLE" + convert "$RECTANGLE" \ \( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \ - -background none -layers merge +repage $shadow + -background none -layers merge +repage "$shadow" composite -compose Dst_Out -gravity center \ - $RECTANGLE $shadow -alpha Set $shadow - convert $shadow $RECTANGLE -geometry +10+10 -composite $RECTANGLE - [[ $shadow ]] && rm $shadow + "$RECTANGLE" "$shadow" -alpha Set "$shadow" + convert "$shadow" "$RECTANGLE" -geometry +10+10 -composite "$RECTANGLE" + [[ "$shadow" ]] && rm "$shadow" } -# create rectangle with description, set $DESCRECT +# create rectangle with description, set "$DESCRECT" create_description () { DESCRECT="$CUR_DIR/description.png" local shadow="$CUR_DIR/shadow.png" - convert -background none -family "$(fc-match "$font" family)" -style Normal -pointsize 14 -fill \#"$datecolor" label:"\ $description\ " -bordercolor \#"$loginbox" -border 10 $DESCRECT - convert $DESCRECT \ + convert -background none -family "$(fc-match "$font" family)" -style Normal -pointsize 14 -fill \#"$datecolor" label:"\ $description\ " -bordercolor \#"$loginbox" -border 10 "$DESCRECT" + convert "$DESCRECT" \ \( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \ - -background none -layers merge +repage $shadow + -background none -layers merge +repage "$shadow" composite -compose Dst_Out -gravity center \ - $DESCRECT $shadow -alpha Set $shadow - convert $shadow $DESCRECT -geometry +10+10 -composite $DESCRECT - [[ $shadow ]] && rm $shadow + "$DESCRECT" "$shadow" -alpha Set "$shadow" + convert "$shadow" "$DESCRECT" -geometry +10+10 -composite "$DESCRECT" + [[ "$shadow" ]] && rm "$shadow" } # delete and recreate directory @@ -557,31 +557,31 @@ update () { if [ "$span_image" = true ] || [ ${#DISPLAY_LIST[@]} -lt 2 ]; then echof act "Rendering final wallpaper images..." - [[ -f "$RES_RESIZE" ]] && cp $RES_RESIZE $CUR_W_RESIZE - [[ -f "$RES_DIM" ]] && cp $RES_DIM $CUR_W_DIM - [[ -f "$RES_BLUR" ]] && cp $RES_BLUR $CUR_W_BLUR - [[ -f "$RES_DIMBLUR" ]] && cp $RES_DIMBLUR $CUR_W_DIMBLUR - [[ -f "$RES_PIXEL" ]] && cp $RES_PIXEL $CUR_W_PIXEL - [[ -f "$RES_DIMPIXEL" ]] && cp $RES_DIMPIXEL $CUR_W_DIMPIXEL - [[ -f "$RES_COLOR" ]] && cp $RES_COLOR $CUR_W_COLOR + [[ -f "$RES_RESIZE" ]] && cp "$RES_RESIZE" "$CUR_W_RESIZE" + [[ -f "$RES_DIM" ]] && cp "$RES_DIM" "$CUR_W_DIM" + [[ -f "$RES_BLUR" ]] && cp "$RES_BLUR" "$CUR_W_BLUR" + [[ -f "$RES_DIMBLUR" ]] && cp "$RES_DIMBLUR" "$CUR_W_DIMBLUR" + [[ -f "$RES_PIXEL" ]] && cp "$RES_PIXEL" "$CUR_W_PIXEL" + [[ -f "$RES_DIMPIXEL" ]] && cp "$RES_DIMPIXEL" "$CUR_W_DIMPIXEL" + [[ -f "$RES_COLOR" ]] && cp "$RES_COLOR" "$CUR_W_COLOR" else echof act "Creating canvas: $TOTAL_SIZE" - [[ -f "$RES_RESIZE" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_RESIZE - [[ -f "$RES_DIM" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIM - [[ -f "$RES_BLUR" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_BLUR - [[ -f "$RES_DIMBLUR" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMBLUR - [[ -f "$RES_PIXEL" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_PIXEL - [[ -f "$RES_DIMPIXEL" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMPIXEL - [[ -f "$RES_COLOR" ]] && convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_COLOR + [[ -f "$RES_RESIZE" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_RESIZE" + [[ -f "$RES_DIM" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIM" + [[ -f "$RES_BLUR" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_BLUR" + [[ -f "$RES_DIMBLUR" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMBLUR" + [[ -f "$RES_PIXEL" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_PIXEL" + [[ -f "$RES_DIMPIXEL" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_DIMPIXEL" + [[ -f "$RES_COLOR" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_COLOR" echof act "Rendering final wallpaper images..." - [[ -f "$CUR_W_RESIZE" ]] && convert $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE - [[ -f "$CUR_W_DIM" ]] && convert $CUR_W_DIM $PARAM_DIM $CUR_W_DIM - [[ -f "$CUR_W_BLUR" ]] && convert $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR - [[ -f "$CUR_W_DIMBLUR" ]] && convert $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR - [[ -f "$CUR_W_PIXEL" ]] && convert $CUR_W_PIXEL $PARAM_PIXEL $CUR_W_PIXEL - [[ -f "$CUR_W_DIMPIXEL" ]] && convert $CUR_W_DIMPIXEL $PARAM_DIMPIXEL $CUR_W_DIMPIXEL - [[ -f "$CUR_W_COLOR" ]] && convert $CUR_W_COLOR $PARAM_COLOR $CUR_W_COLOR + [[ -f "$CUR_W_RESIZE" ]] && convert "$CUR_W_RESIZE" "$PARAM_RESIZE" "$CUR_W_RESIZE" + [[ -f "$CUR_W_DIM" ]] && convert "$CUR_W_DIM" "$PARAM_DIM" "$CUR_W_DIM" + [[ -f "$CUR_W_BLUR" ]] && convert "$CUR_W_BLUR" "$PARAM_BLUR" "$CUR_W_BLUR" + [[ -f "$CUR_W_DIMBLUR" ]] && convert "$CUR_W_DIMBLUR" "$PARAM_DIMBLUR" "$CUR_W_DIMBLUR" + [[ -f "$CUR_W_PIXEL" ]] && convert "$CUR_W_PIXEL" "$PARAM_PIXEL" "$CUR_W_PIXEL" + [[ -f "$CUR_W_DIMPIXEL" ]] && convert "$CUR_W_DIMPIXEL" "$PARAM_DIMPIXEL" "$CUR_W_DIMPIXEL" + [[ -f "$CUR_W_COLOR" ]] && convert "$CUR_W_COLOR" "$PARAM_COLOR" "$CUR_W_COLOR" fi echof act "Rendering final lockscreen images..." @@ -591,23 +591,23 @@ update () { PARAM_RECT="$PARAM_RECT $RECTANGLE -geometry $pos -composite " done - if [ ! -z "$description" ]; then + if [ -n "$description" ]; then create_description for descpos in "${positions_desc[@]}"; do PARAM_RECT="$PARAM_RECT $DESCRECT -geometry $descpos -composite " done fi - [[ -f "$CUR_W_RESIZE" ]] && convert $CUR_W_RESIZE $PARAM_RECT $CUR_L_RESIZE - [[ -f "$CUR_W_DIM" ]] && convert $CUR_W_DIM $PARAM_RECT $CUR_L_DIM - [[ -f "$CUR_W_BLUR" ]] && convert $CUR_W_BLUR $PARAM_RECT $CUR_L_BLUR - [[ -f "$CUR_W_DIMBLUR" ]] && convert $CUR_W_DIMBLUR $PARAM_RECT $CUR_L_DIMBLUR - [[ -f "$CUR_W_PIXEL" ]] && convert $CUR_W_PIXEL $PARAM_RECT $CUR_L_PIXEL - [[ -f "$CUR_W_DIMPIXEL" ]] && convert $CUR_W_DIMPIXEL $PARAM_RECT $CUR_L_DIMPIXEL - [[ -f "$CUR_W_COLOR" ]] && convert $CUR_W_COLOR $PARAM_RECT $CUR_L_COLOR + [[ -f "$CUR_W_RESIZE" ]] && convert "$CUR_W_RESIZE" "$PARAM_RECT" "$CUR_L_RESIZE" + [[ -f "$CUR_W_DIM" ]] && convert "$CUR_W_DIM" "$PARAM_RECT" "$CUR_L_DIM" + [[ -f "$CUR_W_BLUR" ]] && convert "$CUR_W_BLUR" "$PARAM_RECT" "$CUR_L_BLUR" + [[ -f "$CUR_W_DIMBLUR" ]] && convert "$CUR_W_DIMBLUR" "$PARAM_RECT" "$CUR_L_DIMBLUR" + [[ -f "$CUR_W_PIXEL" ]] && convert "$CUR_W_PIXEL" "$PARAM_RECT" "$CUR_L_PIXEL" + [[ -f "$CUR_W_DIMPIXEL" ]] && convert "$CUR_W_DIMPIXEL" "$PARAM_RECT" "$CUR_L_DIMPIXEL" + [[ -f "$CUR_W_COLOR" ]] && convert "$CUR_W_COLOR" "$PARAM_RECT" "$CUR_L_COLOR" - [[ $RECTANGLE ]] && rm "$RECTANGLE" - [[ $DESCRECT ]] && rm "$DESCRECT" + [[ "$RECTANGLE" ]] && rm "$RECTANGLE" + [[ "$DESCRECT" ]] && rm "$DESCRECT" echof ok "Done" From 62b800224802264a5dc159a6b77d2946ce614d04 Mon Sep 17 00:00:00 2001 From: Basti Date: Sun, 20 Jun 2021 22:21:15 +0200 Subject: [PATCH 14/36] Add current github-workflow from master (#243) --- .github/workflows/shellcheck.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml new file mode 100644 index 0000000..48038d4 --- /dev/null +++ b/.github/workflows/shellcheck.yml @@ -0,0 +1,16 @@ +name: ShellCheck + +on: [push, pull_request] + +jobs: + shellcheck: + name: ShellCheck + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run ShellCheck + uses: ludeeus/action-shellcheck@master + with: + severity: style From 95bd5767ae4c4e26e3ba33f9844cc916530d7b89 Mon Sep 17 00:00:00 2001 From: Basti Date: Sun, 20 Jun 2021 23:15:43 +0200 Subject: [PATCH 15/36] Use XDG_* variables for directories and /home/sebtm* only as fallback (ported from #184) (#244) --- betterlockscreen | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 55259a9..edf2cfd 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -44,14 +44,14 @@ init_config () { dunst_paused_state="$(dunstctl is-paused)" # read user config - USER_CONF="$HOME/.config/betterlockscreenrc" + USER_CONF="${XDG_CONFIG_HOME:-$HOME/.config}/betterlockscreenrc" if [ -e "$USER_CONF" ]; then # shellcheck source=/dev/null source "$USER_CONF" fi # paths - CACHE_DIR="$HOME/.cache/i3lock" + CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/betterlockscreen" CUR_DIR="$CACHE_DIR/current" # wallpaper From 6cc1fc16dff1adaa9978b5e529d90e8d1239d076 Mon Sep 17 00:00:00 2001 From: Basti Date: Mon, 21 Jun 2021 20:23:31 +0200 Subject: [PATCH 16/36] Issue-231: Add -v/--version (#246) --- betterlockscreen | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/betterlockscreen b/betterlockscreen index edf2cfd..6d3ed94 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -50,6 +50,9 @@ init_config () { source "$USER_CONF" fi + # Please make sure to adjust this before release! + VERSION="@VERSION@" + # paths CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/betterlockscreen" CUR_DIR="$CACHE_DIR/current" @@ -817,6 +820,23 @@ for arg in "$@"; do shift 2 ;; + -v | --version) + echo + echo "Version: $VERSION" + i3lock-color --version + convert --version + + if [[ -x "$(command -v dunstctl)" ]]; then + dunstctl debug + fi + + if [[ -x "$(command -v feh)" ]]; then + feh --version + fi + + break + ;; + --) lockargs+=("${@:2}") break From 3c76a7ebfe6ab02b098cdb586a084717aed04644 Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Mon, 21 Jun 2021 21:41:01 -0500 Subject: [PATCH 17/36] Fixed issue with --update failing due to quoting --- betterlockscreen | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 6d3ed94..6647f7d 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -560,13 +560,13 @@ update () { if [ "$span_image" = true ] || [ ${#DISPLAY_LIST[@]} -lt 2 ]; then echof act "Rendering final wallpaper images..." - [[ -f "$RES_RESIZE" ]] && cp "$RES_RESIZE" "$CUR_W_RESIZE" - [[ -f "$RES_DIM" ]] && cp "$RES_DIM" "$CUR_W_DIM" - [[ -f "$RES_BLUR" ]] && cp "$RES_BLUR" "$CUR_W_BLUR" - [[ -f "$RES_DIMBLUR" ]] && cp "$RES_DIMBLUR" "$CUR_W_DIMBLUR" - [[ -f "$RES_PIXEL" ]] && cp "$RES_PIXEL" "$CUR_W_PIXEL" - [[ -f "$RES_DIMPIXEL" ]] && cp "$RES_DIMPIXEL" "$CUR_W_DIMPIXEL" - [[ -f "$RES_COLOR" ]] && cp "$RES_COLOR" "$CUR_W_COLOR" + [[ -f "$RES_RESIZE" ]] && eval "cp $RES_RESIZE $CUR_W_RESIZE" + [[ -f "$RES_DIM" ]] && eval "cp $RES_DIM $CUR_W_DIM" + [[ -f "$RES_BLUR" ]] && eval "cp $RES_BLUR $CUR_W_BLUR" + [[ -f "$RES_DIMBLUR" ]] && eval "cp $RES_DIMBLUR $CUR_W_DIMBLUR" + [[ -f "$RES_PIXEL" ]] && eval "cp $RES_PIXEL $CUR_W_PIXEL" + [[ -f "$RES_DIMPIXEL" ]] && eval "cp $RES_DIMPIXEL $CUR_W_DIMPIXEL" + [[ -f "$RES_COLOR" ]] && eval "cp $RES_COLOR $CUR_W_COLOR" else echof act "Creating canvas: $TOTAL_SIZE" [[ -f "$RES_RESIZE" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_RESIZE" @@ -578,13 +578,13 @@ update () { [[ -f "$RES_COLOR" ]] && eval "convert -size $TOTAL_SIZE 'xc:blue' $CUR_W_COLOR" echof act "Rendering final wallpaper images..." - [[ -f "$CUR_W_RESIZE" ]] && convert "$CUR_W_RESIZE" "$PARAM_RESIZE" "$CUR_W_RESIZE" - [[ -f "$CUR_W_DIM" ]] && convert "$CUR_W_DIM" "$PARAM_DIM" "$CUR_W_DIM" - [[ -f "$CUR_W_BLUR" ]] && convert "$CUR_W_BLUR" "$PARAM_BLUR" "$CUR_W_BLUR" - [[ -f "$CUR_W_DIMBLUR" ]] && convert "$CUR_W_DIMBLUR" "$PARAM_DIMBLUR" "$CUR_W_DIMBLUR" - [[ -f "$CUR_W_PIXEL" ]] && convert "$CUR_W_PIXEL" "$PARAM_PIXEL" "$CUR_W_PIXEL" - [[ -f "$CUR_W_DIMPIXEL" ]] && convert "$CUR_W_DIMPIXEL" "$PARAM_DIMPIXEL" "$CUR_W_DIMPIXEL" - [[ -f "$CUR_W_COLOR" ]] && convert "$CUR_W_COLOR" "$PARAM_COLOR" "$CUR_W_COLOR" + [[ -f "$CUR_W_RESIZE" ]] && eval "convert $CUR_W_RESIZE $PARAM_RESIZE $CUR_W_RESIZE" + [[ -f "$CUR_W_DIM" ]] && eval "convert $CUR_W_DIM $PARAM_DIM $CUR_W_DIM" + [[ -f "$CUR_W_BLUR" ]] && eval "convert $CUR_W_BLUR $PARAM_BLUR $CUR_W_BLUR" + [[ -f "$CUR_W_DIMBLUR" ]] && eval "convert $CUR_W_DIMBLUR $PARAM_DIMBLUR $CUR_W_DIMBLUR" + [[ -f "$CUR_W_PIXEL" ]] && eval "convert $CUR_W_PIXEL $PARAM_PIXEL $CUR_W_PIXEL" + [[ -f "$CUR_W_DIMPIXEL" ]] && eval "convert $CUR_W_DIMPIXEL $PARAM_DIMPIXEL $CUR_W_DIMPIXEL" + [[ -f "$CUR_W_COLOR" ]] && eval "convert $CUR_W_COLOR $PARAM_COLOR $CUR_W_COLOR" fi echof act "Rendering final lockscreen images..." @@ -601,13 +601,13 @@ update () { done fi - [[ -f "$CUR_W_RESIZE" ]] && convert "$CUR_W_RESIZE" "$PARAM_RECT" "$CUR_L_RESIZE" - [[ -f "$CUR_W_DIM" ]] && convert "$CUR_W_DIM" "$PARAM_RECT" "$CUR_L_DIM" - [[ -f "$CUR_W_BLUR" ]] && convert "$CUR_W_BLUR" "$PARAM_RECT" "$CUR_L_BLUR" - [[ -f "$CUR_W_DIMBLUR" ]] && convert "$CUR_W_DIMBLUR" "$PARAM_RECT" "$CUR_L_DIMBLUR" - [[ -f "$CUR_W_PIXEL" ]] && convert "$CUR_W_PIXEL" "$PARAM_RECT" "$CUR_L_PIXEL" - [[ -f "$CUR_W_DIMPIXEL" ]] && convert "$CUR_W_DIMPIXEL" "$PARAM_RECT" "$CUR_L_DIMPIXEL" - [[ -f "$CUR_W_COLOR" ]] && convert "$CUR_W_COLOR" "$PARAM_RECT" "$CUR_L_COLOR" + [[ -f "$CUR_W_RESIZE" ]] && eval "convert $CUR_W_RESIZE $PARAM_RECT $CUR_L_RESIZE" + [[ -f "$CUR_W_DIM" ]] && eval "convert $CUR_W_DIM $PARAM_RECT $CUR_L_DIM" + [[ -f "$CUR_W_BLUR" ]] && eval "convert $CUR_W_BLUR $PARAM_RECT $CUR_L_BLUR" + [[ -f "$CUR_W_DIMBLUR" ]] && eval "convert $CUR_W_DIMBLUR $PARAM_RECT $CUR_L_DIMBLUR" + [[ -f "$CUR_W_PIXEL" ]] && eval "convert $CUR_W_PIXEL $PARAM_RECT $CUR_L_PIXEL" + [[ -f "$CUR_W_DIMPIXEL" ]] && eval "convert $CUR_W_DIMPIXEL $PARAM_RECT $CUR_L_DIMPIXEL" + [[ -f "$CUR_W_COLOR" ]] && eval "convert $CUR_W_COLOR $PARAM_RECT $CUR_L_COLOR" [[ "$RECTANGLE" ]] && rm "$RECTANGLE" [[ "$DESCRECT" ]] && rm "$DESCRECT" From 709933350c02f3f9e2956de26016aaf15adc091f Mon Sep 17 00:00:00 2001 From: Basti Date: Wed, 30 Jun 2021 16:35:00 +0200 Subject: [PATCH 18/36] Check for dunstctl once as dunst is optional dependency (#250) --- betterlockscreen | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 6647f7d..0fb0046 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -40,9 +40,6 @@ init_config () { wallpaper_cmd="feh --bg-fill --no-fehbg" time_format="%H:%M:%S" - # Storing current state of dunst before locking - dunst_paused_state="$(dunstctl is-paused)" - # read user config USER_CONF="${XDG_CONFIG_HOME:-$HOME/.config}/betterlockscreenrc" if [ -e "$USER_CONF" ]; then @@ -79,6 +76,10 @@ init_config () { DEFAULT_TIMEOUT=$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')") # Original DPMS status DEFAULT_DPMS=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}') + + # Dunst + DUNST_INSTALLED=false && [[ -e "$(command -v dunstctl)" ]] && DUNST_INSTALLED=true + DUNST_IS_PAUSED=false && [[ "$DUNST_INSTALLED" == "true" ]] && DUNST_IS_PAUSED=$(dunstctl is-paused) } # called before screen is locked @@ -88,11 +89,12 @@ prelock() { if [ "$DEFAULT_DPMS" == "Enabled" ]; then xset dpms "$lock_timeout" fi + # If dusnt is already paused don't pause it again - if [[ -e "$(command -v dunstctl)" && "$dunst_paused_state" == "false" ]] - then + if [[ "$DUNST_INSTALLED" == "true" && "$DUNST_IS_PAUSED" == "false" ]]; then dunstctl set-paused true fi + if [[ "$runsuspend" = "true" ]]; then lockargs="$lockargs -n" fi @@ -156,8 +158,7 @@ postlock() { fi # If dunst already paused before locking don't unpause dunst - if [[ -e "$(command -v dunstctl)" && "$dunst_paused_state" == "false" ]] - then + if [[ "$DUNST_INSTALLED" == "true" && "$DUNST_IS_PAUSED" == "false" ]]; then dunstctl set-paused false fi } From 8ab40b5af2de162f8cad9b84d035a913f0aa7cfe Mon Sep 17 00:00:00 2001 From: Basti Date: Wed, 30 Jun 2021 16:35:12 +0200 Subject: [PATCH 19/36] Determinate i3lock-color binary automatically with i3lock-color/i3lock or quit with error (#252) --- betterlockscreen | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 0fb0046..2f6a6b5 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -6,6 +6,16 @@ init_config () { + # resolve i3lock-color binary + i3lockcolor_bin="$(command -v i3lock-color)" + + if [[ (! -e "$i3lockcolor_bin") && (-e "$(command -v i3lock)") ]]; then + i3lockcolor_bin="$(command -v i3lock)" + else + echo "Can not find locker-binary as 'i3lock' or 'i3lock-color', please make sure it is in your \$PATH!" + exit 1 + fi + # default options display_on=0 span_image=false @@ -107,7 +117,7 @@ lock() { local image="$1" - i3lock \ + $i3lockcolor_bin \ -i "$image" \ -c "$bgcolor" \ --screen "$display_on" \ @@ -135,7 +145,7 @@ failsafe() { local text="ffffffff" local error="ff0000" - i3lock \ + $i3lockcolor_bin \ -c "$bgcolor" \ --screen "$display_on" \ --time-pos="ix-170:iy-0" \ @@ -824,7 +834,7 @@ for arg in "$@"; do -v | --version) echo echo "Version: $VERSION" - i3lock-color --version + $i3lockcolor_bin --version convert --version if [[ -x "$(command -v dunstctl)" ]]; then From 2b31627d594254a5e4580e8dfd7859eb7bc6dbf3 Mon Sep 17 00:00:00 2001 From: Basti Date: Wed, 30 Jun 2021 16:35:39 +0200 Subject: [PATCH 20/36] Reformat and improve documentation, add install-script (#242) --- CONTRIBUTING.md | 11 +-- LICENSE | 20 +--- README.md | 236 +++++++++++++++++++++-------------------------- betterlockscreen | 2 +- install.sh | 101 ++++++++++++++++++++ 5 files changed, 215 insertions(+), 155 deletions(-) create mode 100755 install.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 29feeb7..1f99a52 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,13 +1,10 @@ -# Contributing to betterlockscreen +# Contributing to Betterlockscreen -Thanks for taking your time to contribute! +Thanks for taking your time to contribute! First off, any and all contributions are welcome. -First off, any and all contributions are welcome. +Secondly, if your pull request or issue is in any way related to the [AUR package](https://aur.archlinux.org/packages/betterlockscreen-git/), please notify the maintainer @Maik93 via a mention (like used here with the @) in your comment. -Secondly, if your pull request or issue is in any way related to the [AUR package](https://aur.archlinux.org/packages/betterlockscreen-git/), -please notify the maintainer @Maik93 via a mention (like used here with the @) in your comment. - -Also, in case of adding new dependencies, please notify @Maik93 and @m1m3-50. +Also, in case of adding new dependencies, please notify @Maik93. For nix-users: We include a nix-shell for development :-) diff --git a/LICENSE b/LICENSE index f9e7aa7..1249907 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,9 @@ MIT License -Copyright (c) 2017 Pavan Jadhaw +Copyright (c) 2017-2021 Pavan Jadhaw, and others (https://github.com/pavanjadhaw/betterlockscreen/graphs/contributors) -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index 01d5644..578a62c 100644 --- a/README.md +++ b/README.md @@ -1,153 +1,131 @@ -# betterlockscreen +# Betterlockscreen +> fast and sweet looking lockscreen for linux systems with effects! -> simple, minimal lockscreen +
+ GitHub release (latest by date including pre-releases) + GitHub release (latest by date) + GitHub Workflow Status (master) + GitHub Workflow Status (multi-monitor) -Betterlockscreen allows you to cache images with different filters and lockscreen with blazing speed. + GitHub milestone + GitHub commits since latest release (by date) for a branch + +
-## Example +
+

You want to support us?

-> lockscreen with blurred effect - -```sh -betterlockscreen --lock blur -``` + GitHub Repo stars + GitHub forks + +
+
![scrot2](https://github.com/pavanjadhaw/betterlockscreen.demo/raw/master/scrots/scrot2.png 'scrot2.png') - -> [Watch some of the features of betterlockscreen in action](https://youtu.be/9Ng5FZwnn6M) +
## Table of Contents -- [about](#about) -- [how it works](#how-it-works) -- [requirements](#requirements) -- [installation](#installation) -- [configuration](#configuration) -- [usage](#usage) -- [background](#set-desktop-background-on-startup) -- [keybinding](#keybindings) -- [lockscreen on suspend](#lockscreen-when-suspendedsystemd-service) +- [About](#about) +- [How it works](#how-it-works) +- [System Requirements](#system-requirements) +- [Installation](#installation) +- [Configuration](#configuration) +- [Usage](#usage) +- [Background](#background) +- [Keybinding](#keybindings) +- [Lockscreen on sleep/suspend with systemd](#systemd) -### About +## About -Most of i3lock wrapper scripts out there takes an image, adds some effect and locks the screen -adding effects, overall experience doesn't feel natural given delay of 2-3 seconds. -Who would like a delay of 2-3 seconds while locking screen? +Most of i3lock wrapper-scripts out there take an image, add some effect(s) then lock with the modified image as locker-background. Overall experience doesn't feel natural given delay of 2-3 seconds. -So betterlockscreen was my attempt to solve this problem, as we dont need to change lockscreen background frequently -this script caches images with effect so overall experience is simple and as fast as native i3lock. +> Who would like a delay of 2-3 seconds while locking screen? -### How it works +So Betterlockscreen was my attempt to solve this problem, as we dont need to change lockscreen background frequently this script caches images with effect so overall experience is simple and as fast as native i3lock. -The script takes image adds various effects and caches those images in special directory and then uses those -images as lockscreen background depending on argument provided by user. +## How it works -### Requirements +The script takes a directory or image, adds various effects and caches the images in special directory. Those cached images will be used as locker-background depending on configuration provided by user. + +## System Requirements + +* [i3lock-color](https://github.com/Raymo111/i3lock-color) `>= 2.13.c.3` +* [ImageMagick](https://imagemagick.org/) +* xdpyinfo, xrandr, xrdb and xset from [X.Org](https://www.x.org/) +* (Optional) [Dunst](https://dunst-project.org/) +* (Optional) [feh](https://feh.finalrewind.org/) for wallpaper-functionality > Note: Make sure your system has all dependencies satisfied -- [i3lock-color](https://github.com/Raymo111/i3lock-color) - i3lock fork with additional features(`>= 2.13.c.3`) -- [imagemagick](https://www.imagemagick.org/script/index.php) - To apply effects to images -- [xdpyinfo](https://www.x.org/archive/X11R7.7/doc/man/man1/xdpyinfo.1.xhtml), [xrandr](https://www.x.org/wiki/Projects/XRandR/), [bc](https://www.gnu.org/software/bc/) and [feh](https://feh.finalrewind.org/) - To find screen resolution, set custom blur level and wallpaper handling. - -### Installation - -> manual installation - -```sh -git clone https://github.com/pavanjadhaw/betterlockscreen -cd betterlockscreen -cp betterlockscreen ~/.local/bin/ -``` - -

OR

- -```sh -# or wget the script ~12KB -wget -O betterlockscreen https://git.io/fASUJ -chmod u+x betterlockscreen -cp betterlockscreen ~/.local/bin/ -``` - -```sh -# Add betterlockscreen to PATH: -# (In your .bashrc, .zshrc etc) -export PATH="${PATH}:${HOME}/.local/bin/" -``` - +## Installation ### Package Manager -#### Arch Linux + + Packaging status + -###### Installing dependencies(not required if using betterlockscreen aur package) +Betterlockscreen is available via package manager on some linux-distributions, if you miss your favorite one you can follow along with our [installation-script](#installation-script) or [manual-installation](#manual-installation). -`pacman -S imagemagick feh xorg-xrandr xorg-xdpyinfo` +If you are using **Arch Linux**, you can install the AUR package +[betterlockscreen](https://aur.archlinux.org/packages/betterlockscreen/) to get the latest +version, or [betterlockscreen-git](https://aur.archlinux.org/packages/betterlockscreen-git/) for the most up-to-date (unstable) changes. -- i3lock-color - `trizen -S i3lock-color` +If you are using **Void Linux**, you can install [betterlockscreen](https://github.com/void-linux/void-packages/blob/master/srcpkgs/betterlockscreen/template) using `xbps-install -S betterlockscreen`. -#### Aur package +If you are using **NixOS**, [betterlockscreen](https://search.nixos.org/packages?query=betterlockscreen) is available in both the [stable](https://github.com/NixOS/nixpkgs/blob/nixos-21.05/pkgs/misc/screensavers/betterlockscreen/default.nix) and [unstable](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/misc/screensavers/betterlockscreen/default.nix) channels and can be installed with the command `nix-env -iA nixos.betterlockscreen`. -`betterlockscreen` is available in the Arch User repos as `betterlockscreen` and `betterlockscreen-git`. +### Installation Script -- betterlockscreen - `trizen -S betterlockscreen` -- betterlockscreen-git - `trizen -S betterlockscreen-git` +We have created an automatic [install-script](https://github.com/pavanjadhaw/betterlockscreen/blob/master/install.sh) for Betterlockscreen. The script is very simple and takes three parameters: + * ``: (string) 'user' installs to '~/.local/bin/', 'system' installs to '/usr/local/bin' + * `[]`: (string) defaults to 'latest' which will determinate the latest tag from git or specified branch/tag + * `[]`: (boolean) defaults to 'false' - Whether to copy and enable system-service. -#### Debian and derivatives - -UtkarshVerma was so kind to provide an installation script for debian based systems, ![check it out here](https://github.com/UtkarshVerma/installer-scripts). - -#### Void Linux - -##### xbps repository - -`betterlockscreen` is available in official Void's repository as `betterlockscreen`. - -Installing using `xbps` (will automatically install all required dependencies): `xbps-install -S betterlockscreen` - -### Configuration - -You can customise various colors for betterlockscreen, copy config file from examples directory to `~/.config/betterlockscreenrc` and edit it accordingly. - -If configuration file is not found then default configurations will be used. - -```ini -# default options -display_on=0 -span_image=false -lock_timeout=300 -fx_list=(dim blur dimblur pixel dimpixel color) -dim_level=40 -blur_level=1 -pixel_scale=10,1000 -solid_color=333333 - -# theme options -loginbox=00000066 -loginshadow=00000000 -locktext="Type password to unlock..." -font="sans-serif" -ringcolor=ffffffff -insidecolor=00000000 -separatorcolor=00000000 -ringvercolor=ffffffff -insidevercolor=00000000 -ringwrongcolor=ffffffff -insidewrongcolor=d23c3dff -keyhlcolor=d23c3dff -bshlcolor=d23c3dff -verifcolor=ffffffff -timecolor=ffffffff -datecolor=ffffffff -wallpaper_cmd="feh --bg-fill --no-fehbg" -time_format="%H:%M:%S" +For system-installation: +```sh +wget https://git.io/JZyxV -O - -q | bash -- system ``` + +For user-installation: +```sh +wget https://git.io/JZyxV -O - -q | bash -- user +``` + +Please note: The [git.io](https://git.io/)-URL is just a short-url for the [master/install.sh](https://raw.githubusercontent.com/pavanjadhaw/betterlockscreen/master/install.sh). + +### Manual Installation + +Ỳou can download the latest release [here](https://github.com/pavanjadhaw/betterlockscreen/releases), please ensure to fullfill the [system-requirements](#system-requirements)! + +You will need to copy "betterlockscreen" to you desired binary-directory, if you want to use the systemd-service you will need to copy the service-file from "system/" to the desired location on your system. + +Example (Ubuntu): +```sh +wget https://github.com/pavanjadhaw/betterlockscreen/archive/refs/heads/master.zip +unzip master.zip + +cd betterlockscreen-master/ +chmod u+x betterlockscreen +cp betterlockscreen /usr/local/bin/ + +cp system/betterlockscreen@.service /usr/lib/systemd/system/ +systemctl enable betterlockscreen@$USER +``` + +## Configuration + +You can customize betterlockscreen for your needs, copy the config file from the examples-directory to `~/.config/betterlockscreenrc` and edit it accordingly. + +If no configuration-file is found, then the default configurations (which is equal to the example but currently hardcoded) will be used. + If you have installed betterlockscreen from AUR package, then you can copy default config from docs ```sh cp /usr/share/doc/betterlockscreen/examples/betterlockscreenrc ~/.config ``` -### Usage +## Usage Run `betterlockscreen` and point it to either a directory (`betterlockscreen -u "path/to/dir"`) or an image (`betterlockscreen -u "/path/to/img.jpg"`) and that's all. `betterlockscreen` will change update its cache with image you provided. @@ -196,7 +174,7 @@ Effects arguments: ``` -#### Usage examples: +#### Examples 1. Update image cache with random image `betterlockscreen -u ~/Wallpapers` @@ -219,7 +197,7 @@ Effects arguments: `betterlockscreen -l dimblur --display 1 --span` -### Set desktop background on startup +## Background Add this line to `.xinitrc`. @@ -231,7 +209,7 @@ betterlockscreen -w dim source ~/.fehbg ``` -#### i3wm +### i3wm Add this line to `~/.config/i3/config` @@ -243,11 +221,11 @@ exec --no-startup-id betterlockscreen -w dim exec --no-startup-id source ~/.fehbg ``` -### Keybindings +## Keybindings To lockscreen using keyboard shortcut -#### i3wm +### i3wm Add this line to your `~/.config/i3/config` @@ -255,7 +233,7 @@ Add this line to your `~/.config/i3/config` bindsym $mod+shift+x exec betterlockscreen -l dim ``` -#### bspwm +### bspwm Add this line to your `~/.config/sxhkd/sxhkdrc` @@ -265,7 +243,8 @@ alt + shift + x betterlockscreen -l dim ``` -### Lockscreen when suspended(systemd service) +

Systemd-Service: Lockscreen after sleep/suspend

+ ```sh # move service file to proper dir (the aur package does this for you) cp betterlockscreen@.service /usr/lib/systemd/system/ @@ -289,13 +268,11 @@ Resources and more informations: --- -### Countributing +## Countributing Thanks to all the amazing people for all your wonderful PRs, issues and ideas! -[![](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/images/0)](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/links/0)[![](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/images/1)](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/links/1)[![](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/images/2)](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/links/2)[![](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/images/3)](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/links/3)[![](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/images/4)](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/links/4)[![](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/images/5)](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/links/5)[![](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/images/6)](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/links/6)[![](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/images/7)](https://sourcerer.io/fame/pavanjadhaw/pavanjadhaw/betterlockscreen/links/7) - -## How can I support developers? +How can I support developers? - Star our GitHub repo :star: - Create pull requests, submit bugs, suggest new features or documentation updates :wrench: @@ -304,11 +281,8 @@ Thanks to all the amazing people for all your wonderful PRs, issues and ideas! Betterlockscreen is under [MIT](https://github.com/pavanjadhaw/betterlockscreen/blob/master/LICENSE) license. -## Feel free to use and distribute +### Feel free to use and distribute - Hat tip to anyone who's code was used - Thanks to those who contributed to make it better - Inspiration - [r/unixporn](https://www.reddit.com/r/unixporn) - -[logo]: .github/hero.png -[website]: https://mdxjs.com \ No newline at end of file diff --git a/betterlockscreen b/betterlockscreen index 2f6a6b5..7458573 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -729,7 +729,7 @@ usage() { exit 1 } -echof header "betterlockscreen" +echof header "Betterlockscreen" init_config diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..8623e30 --- /dev/null +++ b/install.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash + +echof() { + local colorReset="\033[0m" + local prefix="$1" + local message="$2" + + case "$prefix" in + header) msgpfx="[\e[1;95mB\e[m]" color="";; + info) msgpfx="[\e[1;97m=\e[m]" color="\033[0;34m";; + act) msgpfx="[\e[1;92m*\e[m]" color="";; + ok) msgpfx="[\e[1;93m+\e[m]" color="\033[0;32m";; + error) msgpfx="[\e[1;91m!\e[m]" color="\033[0;31m";; + *) msgpfx="" color="";; + esac + echo -e "$msgpfx $color $message $colorReset" +} + +case $1 in + system) + BL_INSTALL_DIR="/usr/local/bin" + ;; + + user) + BL_INSTALL_DIR="$HOME/.local/bin" + + if [[ ! -d $BL_INSTALL_DIR ]]; then + mkdir -p "$BL_INSTALL_DIR" + fi + ;; + + *) + echo "Usage: $0 [] []" + echo " : (string) 'user' installs to '~/.local/bin/', 'system' installs to '/usr/local/bin'" + echo " : (string) defaults to 'latest' which will determinate the latest tag from git or specified branch/tag" + echo " : (boolean) defaults to 'false' - Whether to copy and enable system-service" + echo -e "\nPlease note: The order of the parameters *is* relevant, if you want to set '' you need to specify '' as well!" + exit 1 + ;; +esac + +echof header "Betterlockscreen-Setup" + +if [[ ! -w $BL_INSTALL_DIR ]]; then + echof error "Unable to write to '$BL_INSTALL_DIR'!" + exit 1 +fi + +echof info "Checking system-requirements..." + +declare -A DEPS +DEPS["ImageMagick"]="convert" +DEPS["i3lock-color"]="i3lock-color" +DEPS["xdpyinfo"]="xdpyinfo" +DEPS["xrdb"]="xrdb" +DEPS["xset"]="xset" + +for key in "${!DEPS[@]}"; do + [[ ! -e "$(command -v ${DEPS[$key]})" ]] && echof error "Missing '$key'!" && exit 1 +done + +echof ok "done!" + +VERSION=$2 +if [[ $VERSION == "" ]] || [[ $VERSION == "latest" ]]; then + echof info "Determinate latest release... " + VERSION=$(git describe --tags "$(git rev-list --tags --max-count=1)") + echof ok "done! ($VERSION)" +fi + +BLI_TEMP_DIR=$(mktemp -d) + +git clone -b "$VERSION" https://github.com/pavanjadhaw/betterlockscreen "$BLI_TEMP_DIR" &>/dev/null +cd "$BLI_TEMP_DIR" || exit 1 + +echof info "Installing Betterlockscreen to '$BL_INSTALL_DIR'... " +cp betterlockscreen "$BL_INSTALL_DIR" +echof ok "done!" + +if [[ $3 == "true" ]]; then + SYSTEMD_SERVICE_DIR="/usr/lib/systemd/system" + + echof info "Installing/enable sytemd-service... " + + if [[ ! -w $SYSTEMD_SERVICE_DIR ]]; then + echof error "\nUnable to write to '$SYSTEMD_SERVICE_DIR'!" + exit 1 + fi + + cp system/betterlockscreen@.service $SYSTEMD_SERVICE_DIR + systemctl enable betterlockscreen@"$USER" + + echof ok "done!" +fi + +if [[ $PATH != *"$BL_INSTALL_DIR"* ]]; then + echof error "Please ensure to add 'export PATH=\"\$PATH:/home/\$USER/.local/bin\"' to your shell-config!\033[0m" +fi + +echof ok "Install completed successfully!" +exit 0 From 906259dd2bd9661bfac6b47a7308d9e44bb30034 Mon Sep 17 00:00:00 2001 From: Basti Date: Wed, 30 Jun 2021 18:45:12 +0200 Subject: [PATCH 21/36] Fixes --lock not working with autodetection when started from zsh, avoids autodetect because of stability issues (#254) --- betterlockscreen | 14 ++++---------- examples/betterlockscreenrc | 1 + 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 7458573..e8c0c57 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -6,16 +6,6 @@ init_config () { - # resolve i3lock-color binary - i3lockcolor_bin="$(command -v i3lock-color)" - - if [[ (! -e "$i3lockcolor_bin") && (-e "$(command -v i3lock)") ]]; then - i3lockcolor_bin="$(command -v i3lock)" - else - echo "Can not find locker-binary as 'i3lock' or 'i3lock-color', please make sure it is in your \$PATH!" - exit 1 - fi - # default options display_on=0 span_image=false @@ -57,6 +47,10 @@ init_config () { source "$USER_CONF" fi + if [[ ! -v $i3lockcolor_bin ]]; then + i3lockcolor_bin="i3lock-color" + fi + # Please make sure to adjust this before release! VERSION="@VERSION@" diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index fedde94..cf62114 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -9,6 +9,7 @@ dim_level=40 blur_level=1 pixel_scale=10,1000 solid_color=333333 +# i3lockcolor_bin="" # (manually set full path to i3lock-color) # default theme loginbox=00000066 From a320ab3ff939e1cbe750ecb451aa273dc4e1a4d4 Mon Sep 17 00:00:00 2001 From: Basti Date: Wed, 30 Jun 2021 18:45:21 +0200 Subject: [PATCH 22/36] Improve/docs ci naming (#253) * Fixes --lock not working with autodetection when started from zsh, avoids autodetect because of stability issues * Prepare docs/workflow-config for merge-state --- .github/workflows/shellcheck.yml | 16 ---------------- README.md | 5 ++--- 2 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 .github/workflows/shellcheck.yml diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml deleted file mode 100644 index 48038d4..0000000 --- a/.github/workflows/shellcheck.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: ShellCheck - -on: [push, pull_request] - -jobs: - shellcheck: - name: ShellCheck - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Run ShellCheck - uses: ludeeus/action-shellcheck@master - with: - severity: style diff --git a/README.md b/README.md index 578a62c..4c96835 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,8 @@
GitHub release (latest by date including pre-releases) GitHub release (latest by date) - GitHub Workflow Status (master) - GitHub Workflow Status (multi-monitor) - + GitHub Workflow Status (master) + GitHub Workflow Status (multi-monitor) GitHub milestone GitHub commits since latest release (by date) for a branch From 682e056aec731b3eb76fdd005722bedd5c44a0b3 Mon Sep 17 00:00:00 2001 From: Basti Date: Wed, 30 Jun 2021 20:33:00 +0200 Subject: [PATCH 23/36] Fix default feh-command to match doc behaviour (#257) --- betterlockscreen | 2 +- examples/betterlockscreenrc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/betterlockscreen b/betterlockscreen index e8c0c57..ffd8fe3 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -37,7 +37,7 @@ init_config () { layoutcolor=ffffffff nocolor=00000000 bgcolor=000000ff - wallpaper_cmd="feh --bg-fill --no-fehbg" + wallpaper_cmd="feh --bg-fill" time_format="%H:%M:%S" # read user config diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index cf62114..3396776 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -9,6 +9,7 @@ dim_level=40 blur_level=1 pixel_scale=10,1000 solid_color=333333 +wallpaper_cmd="feh --bg-fill" # i3lockcolor_bin="" # (manually set full path to i3lock-color) # default theme From be2d9a90dda40f52950de20c589f8c17011d5058 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Wed, 30 Jun 2021 20:41:46 +0200 Subject: [PATCH 24/36] Fix i3lockcolor_bin (#251) --- betterlockscreen | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index ffd8fe3..8b9a8e8 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -16,6 +16,7 @@ init_config () { pixel_scale=10,1000 solid_color=333333 description="" + i3lockcolor_bin="i3lock-color" # default theme loginbox=00000066 @@ -47,10 +48,6 @@ init_config () { source "$USER_CONF" fi - if [[ ! -v $i3lockcolor_bin ]]; then - i3lockcolor_bin="i3lock-color" - fi - # Please make sure to adjust this before release! VERSION="@VERSION@" From ad329ee1958d939caad2462b022b8448a61fbe7c Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Wed, 30 Jun 2021 20:48:02 +0200 Subject: [PATCH 25/36] missing file --- examples/betterlockscreenrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index 3396776..b8cf6dc 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -10,7 +10,7 @@ blur_level=1 pixel_scale=10,1000 solid_color=333333 wallpaper_cmd="feh --bg-fill" -# i3lockcolor_bin="" # (manually set full path to i3lock-color) +# i3lockcolor_bin="i3lock-color" # Manually set command for i3lock-color # default theme loginbox=00000066 From 17bf536969b0563b4b0ba403e1b3842ec2c7cfe4 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Wed, 30 Jun 2021 22:30:48 +0200 Subject: [PATCH 26/36] Adjust lock_timeout to default --- examples/betterlockscreenrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index b8cf6dc..aaa0724 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -3,7 +3,7 @@ # default options display_on=0 span_image=false -lock_timeout=5 +lock_timeout=300 fx_list=(dim blur dimblur pixel dimpixel color) dim_level=40 blur_level=1 From 7c1f480a4d5c321e988e7b2177ba4568ad7f1e4e Mon Sep 17 00:00:00 2001 From: "Jeff M. Hubbard" Date: Wed, 30 Jun 2021 15:43:49 -0500 Subject: [PATCH 27/36] Reworked loginbox (#249) * Redesigned loginbox, theme errors, add keylayout See #225 and #229 Always display --keylayout Wrong, verif, and modif messages are displayed Added all pass-thru keys options * Adjust positioning of verif/wrong-pos according feedback Co-authored-by: Sebastian Sellmeier --- betterlockscreen | 166 ++++++++++++++++++++++++++++-------- examples/betterlockscreenrc | 9 +- 2 files changed, 136 insertions(+), 39 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 8b9a8e8..41bfaec 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -30,13 +30,15 @@ init_config () { insidevercolor=00000000 ringwrongcolor=ffffffff insidewrongcolor=d23c3dff + timecolor=ffffffff + time_format="%H:%M:%S" + greetercolor=ffffffff + layoutcolor=ffffffff keyhlcolor=d23c3dff bshlcolor=d23c3dff verifcolor=ffffffff - timecolor=ffffffff - datecolor=ffffffff - layoutcolor=ffffffff - nocolor=00000000 + wrongcolor=d23c3dff + modifcolor=d23c3dff bgcolor=000000ff wallpaper_cmd="feh --bg-fill" time_format="%H:%M:%S" @@ -107,23 +109,68 @@ lock() { echof act "Locking screen..." local image="$1" + local fontlg=32 + local fontmd=16 + local fontsm=12 $i3lockcolor_bin \ - -i "$image" \ - -c "$bgcolor" \ + --image "$image" \ + --color "$bgcolor" \ --screen "$display_on" \ - --time-pos="ix-240:iy-0" --time-align 1 --time-str "$time_format" \ - --date-pos="ix-240:iy+25" \ - --layout-pos="ix-90:iy-0" --layout-align 1 --layout-color="$layoutcolor" "$keylayout" \ - --clock --date-align 1 --date-str "$locktext" \ - --inside-color="$insidecolor" --ring-color="$ringcolor" --line-uses-inside \ - --keyhl-color="$keyhlcolor" --bshl-color="$bshlcolor" --separator-color=$separatorcolor \ - --insidever-color="$insidevercolor" --insidewrong-color="$insidewrongcolor" \ - --ringver-color="$ringvercolor" --ringwrong-color="$ringwrongcolor" --ind-pos="x+280:y+h-70" \ - --radius=20 --ring-width=4 --verif-text="" --wrong-text="" --wrong-color="$nocolor" \ - --verif-color="$verifcolor" --time-color="$timecolor" --date-color="$datecolor" \ - --time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \ - --noinput-text="" --force-clock --pass-media-keys --pass-screen-keys --pass-power-keys \ + --ind-pos="x+310:y+h-80" \ + --radius=25 \ + --ring-width=5 \ + --inside-color="$insidecolor" \ + --ring-color="$ringcolor" \ + --separator-color=$separatorcolor \ + --insidever-color="$insidevercolor" \ + --insidewrong-color="$insidewrongcolor" \ + --ringver-color="$ringvercolor" \ + --ringwrong-color="$ringwrongcolor" \ + --line-uses-inside \ + --keyhl-color="$keyhlcolor" \ + --bshl-color="$bshlcolor" \ + --clock --force-clock \ + --time-pos="ix-265:iy-10" \ + --time-align 1 \ + --time-str "$time_format" \ + --time-color="$timecolor" \ + --time-font="$font" \ + --time-size="$fontlg" \ + --date-str "" \ + --greeter-pos="ix-265:iy+12" \ + --greeter-align 1 \ + --greeter-text "$locktext" \ + --greeter-color="$greetercolor" \ + --greeter-font="$font" \ + --greeter-size="$fontmd" \ + --layout-pos="ix-265:iy+32" \ + --layout-align 1 \ + --layout-color="$layoutcolor" \ + --layout-font="$font" \ + --layout-size="$fontsm" \ + --keylayout "${keylayout:-0}" \ + --verif-pos="ix+35:iy-34" \ + --verif-align 2 \ + --verif-text="Verifying..." \ + --verif-color="$verifcolor" \ + --verif-font="$font" \ + --verif-size="$fontsm" \ + --wrong-pos="ix+24:iy-34" \ + --wrong-align 2 \ + --wrong-text="Failure!" \ + --wrong-color="$wrongcolor" \ + --wrong-font="$font" \ + --wrong-size="$fontsm" \ + --modif-pos="ix+45:iy+43" \ + --modif-align 2 \ + --modif-size="$fontsm" \ + --modif-color="$modifcolor" \ + --noinput-text="" \ + --pass-media-keys \ + --pass-screen-keys \ + --pass-volume-keys \ + --pass-power-keys \ "${lockargs[@]}" } @@ -132,21 +179,66 @@ failsafe() { echof act "Locking screen... (FAILSAFE MODE)" - local bgcolor="000000" - local text="ffffffff" - local error="ff0000" + local fontlg=32 + local fontmd=16 + local fontsm=12 $i3lockcolor_bin \ - -c "$bgcolor" \ - --screen "$display_on" \ - --time-pos="ix-170:iy-0" \ - --date-pos="ix-240:iy+25" \ - --clock --date-align 1 --date-str "$locktext" \ - --ind-pos="x+280:y+h-70" \ - --radius=20 --ring-width=4 --verif-text="" --wrong-text="" --wrong-color="$error" \ - --verif-color="$text" --time-color="$text" --date-color="$text" \ - --time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \ - --noinput-text="" --force-clock + --color "$bgcolor" \ + --ind-pos="x+310:y+h-80" \ + --radius=25 \ + --ring-width=5 \ + --inside-color="$insidecolor" \ + --ring-color="$ringcolor" \ + --separator-color=$separatorcolor \ + --insidever-color="$insidevercolor" \ + --insidewrong-color="$insidewrongcolor" \ + --ringver-color="$ringvercolor" \ + --ringwrong-color="$ringwrongcolor" \ + --line-uses-inside \ + --keyhl-color="$keyhlcolor" \ + --bshl-color="$bshlcolor" \ + --clock --force-clock \ + --time-pos="ix-265:iy-10" \ + --time-align 1 \ + --time-str "$time_format" \ + --time-color="$timecolor" \ + --time-font="$font" \ + --time-size="$fontlg" \ + --date-str "" \ + --greeter-pos="ix-265:iy+12" \ + --greeter-align 1 \ + --greeter-text "$locktext" \ + --greeter-color="$greetercolor" \ + --greeter-font="$font" \ + --greeter-size="$fontmd" \ + --layout-pos="ix-265:iy+32" \ + --layout-align 1 \ + --layout-color="$layoutcolor" \ + --layout-font="$font" \ + --layout-size="$fontsm" \ + --keylayout "${keylayout:-0}" \ + --verif-pos="ix+45:iy-35" \ + --verif-align 2 \ + --verif-text="Verifying..." \ + --verif-color="$verifcolor" \ + --verif-font="$font" \ + --verif-size="$fontsm" \ + --wrong-pos="ix+45:iy-35" \ + --wrong-align 2 \ + --wrong-text="Failure!" \ + --wrong-color="$wrongcolor" \ + --wrong-font="$font" \ + --wrong-size="$fontsm" \ + --modif-pos="ix+45:iy+43" \ + --modif-align 2 \ + --modif-size="$fontsm" \ + --modif-color="$modifcolor" \ + --noinput-text="" \ + --pass-media-keys \ + --pass-screen-keys \ + --pass-volume-keys \ + --pass-power-keys } @@ -428,8 +520,8 @@ create_loginbox () { RECTANGLE="$CUR_DIR/rectangle.png" local shadow="$CUR_DIR/shadow.png" local width height - width=$(logical_px 300 1) - height=$(logical_px 80 2) + width=$(logical_px 340 1) + height=$(logical_px 100 2) convert -size "$width"x"$height" xc:\#"$loginbox" -fill none "$RECTANGLE" convert "$RECTANGLE" \ \( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \ @@ -444,7 +536,7 @@ create_loginbox () { create_description () { DESCRECT="$CUR_DIR/description.png" local shadow="$CUR_DIR/shadow.png" - convert -background none -family "$(fc-match "$font" family)" -style Normal -pointsize 14 -fill \#"$datecolor" label:"\ $description\ " -bordercolor \#"$loginbox" -border 10 "$DESCRECT" + convert -background none -family "$(fc-match "$font" family)" -style Normal -pointsize 14 -fill \#"$greetercolor" label:"\ $description\ " -bordercolor \#"$loginbox" -border 10 "$DESCRECT" convert "$DESCRECT" \ \( -clone 0 -background \#"$loginshadow" -shadow 100x5+0+0 \) +swap \ -background none -layers merge +repage "$shadow" @@ -518,7 +610,7 @@ update () { pos_y="${sym[1]}${val[1]}" rect_x=$((pos_x + $(logical_px 15 1))) - rect_y=$((pos_y + res_y - $(logical_px 120 2))) + rect_y=$((pos_y + res_y - $(logical_px 140 2))) positions+=("+$((rect_x))+$((rect_y))") descrect_x=$((pos_x + res_x - descwidth - $(logical_px 15 1))) @@ -788,8 +880,8 @@ for arg in "$@"; do ;; --show-layout) - keylayout="--keylayout 2"; - shift 1 + keylayout="$2"; + shift 2 ;; --fx) diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index aaa0724..e602ebc 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -24,8 +24,13 @@ ringvercolor=ffffffff insidevercolor=00000000 ringwrongcolor=ffffffff insidewrongcolor=d23c3dff +timecolor=ffffffff +time_format="%H:%M:%S" +greetercolor=ffffffff +layoutcolor=ffffffff keyhlcolor=d23c3dff bshlcolor=d23c3dff verifcolor=ffffffff -timecolor=ffffffff -datecolor=ffffffff +wrongcolor=d23c3dff +modifcolor=d23c3dff +bgcolor=000000ff From 0a81e77d8d9a7be635f379958d303dc3c627c971 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Wed, 30 Jun 2021 22:53:10 +0200 Subject: [PATCH 28/36] Improve --version command --- betterlockscreen | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/betterlockscreen b/betterlockscreen index 41bfaec..9673f87 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -51,7 +51,7 @@ init_config () { fi # Please make sure to adjust this before release! - VERSION="@VERSION@" + VERSION="4.0.0" # paths CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/betterlockscreen" @@ -83,6 +83,9 @@ init_config () { # Dunst DUNST_INSTALLED=false && [[ -e "$(command -v dunstctl)" ]] && DUNST_INSTALLED=true DUNST_IS_PAUSED=false && [[ "$DUNST_INSTALLED" == "true" ]] && DUNST_IS_PAUSED=$(dunstctl is-paused) + + # Feh + FEH_INSTALLED=false && [[ -e "$(command -v feh)" ]] && FEH_INSTALLED=true } # called before screen is locked @@ -916,15 +919,15 @@ for arg in "$@"; do -v | --version) echo - echo "Version: $VERSION" + echo "Betterlockscreen: version: $VERSION (dunst: $DUNST_INSTALLED, feh: $FEH_INSTALLED)" $i3lockcolor_bin --version convert --version - if [[ -x "$(command -v dunstctl)" ]]; then + if [[ "$DUNST_INSTALLED" == "true" ]]; then dunstctl debug fi - if [[ -x "$(command -v feh)" ]]; then + if [[ "$FEH_INSTALLED" == "true" ]]; then feh --version fi From 6ac1f74a94aad195eda88fed4d5c6751b84de6c5 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Thu, 1 Jul 2021 18:10:15 +0200 Subject: [PATCH 29/36] Prepare for release v4.0.0-beta1 --- README.md | 2 +- betterlockscreen | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4c96835..2936e59 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ GitHub Workflow Status (master) GitHub Workflow Status (multi-monitor) GitHub milestone - GitHub commits since latest release (by date) for a branch + GitHub commits since latest release (by date) for a branch
diff --git a/betterlockscreen b/betterlockscreen index 9673f87..807de75 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -51,7 +51,7 @@ init_config () { fi # Please make sure to adjust this before release! - VERSION="4.0.0" + VERSION="4.0.0-beta1" # paths CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/betterlockscreen" @@ -919,7 +919,7 @@ for arg in "$@"; do -v | --version) echo - echo "Betterlockscreen: version: $VERSION (dunst: $DUNST_INSTALLED, feh: $FEH_INSTALLED)" + echo "Betterlockscreen: version: v$VERSION (dunst: $DUNST_INSTALLED, feh: $FEH_INSTALLED)" $i3lockcolor_bin --version convert --version From 68e474393d9f87be7e78e7fa868d95a49a31ce19 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Thu, 1 Jul 2021 18:41:50 +0200 Subject: [PATCH 30/36] Fixup docs Update readme to show beta-release, rename workflow-config (cherry picked from commit 4a95562740bee221061156110b6f60bac969eb55) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2936e59..a656baa 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@
GitHub release (latest by date including pre-releases) GitHub release (latest by date) - GitHub Workflow Status (master) - GitHub Workflow Status (multi-monitor) + GitHub Workflow Status (master) + GitHub Workflow Status (next) GitHub milestone GitHub commits since latest release (by date) for a branch From 4ef273cf5ebfc862a73cef107339decea5871ed6 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Wed, 21 Jul 2021 01:42:54 +0200 Subject: [PATCH 31/36] Add gento-install to readme from #264 thanks to @mjkalyan --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a656baa..066720c 100644 --- a/README.md +++ b/README.md @@ -70,9 +70,11 @@ If you are using **Arch Linux**, you can install the AUR package [betterlockscreen](https://aur.archlinux.org/packages/betterlockscreen/) to get the latest version, or [betterlockscreen-git](https://aur.archlinux.org/packages/betterlockscreen-git/) for the most up-to-date (unstable) changes. -If you are using **Void Linux**, you can install [betterlockscreen](https://github.com/void-linux/void-packages/blob/master/srcpkgs/betterlockscreen/template) using `xbps-install -S betterlockscreen`. +If you are using **Gentoo Linux**, you can install `betterlockscreen` from Gentoo's [GURU overlay](https://wiki.gentoo.org/wiki/Project:GURU) using `emerge x11-misc/betterlockscreen`. -If you are using **NixOS**, [betterlockscreen](https://search.nixos.org/packages?query=betterlockscreen) is available in both the [stable](https://github.com/NixOS/nixpkgs/blob/nixos-21.05/pkgs/misc/screensavers/betterlockscreen/default.nix) and [unstable](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/misc/screensavers/betterlockscreen/default.nix) channels and can be installed with the command `nix-env -iA nixos.betterlockscreen`. +If you are using **NixOS**, [betterlockscreen](https://search.nixos.org/packages?query=betterlockscreen) is available in both the [stable](https://github.com/NixOS/nixpkgs/blob/nixos-21.05/pkgs/misc/screensavers/betterlockscreen/default.nix) and [unstable](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/misc/screensavers/betterlockscreen/default.nix) channels and can be installed using `nix-env -iA nixos.betterlockscreen`. + +If you are using **Void Linux**, you can install [betterlockscreen](https://github.com/void-linux/void-packages/blob/master/srcpkgs/betterlockscreen/template) using `xbps-install -S betterlockscreen`. ### Installation Script From 6537717ab1b1cf560c69964394c41eac8d0c9d38 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Wed, 21 Jul 2021 01:57:08 +0200 Subject: [PATCH 32/36] Updated CONTRIBUTING.md and according section in README.md to avoid duplicate text --- CONTRIBUTING.md | 8 +++----- README.md | 7 +------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1f99a52..0907149 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,11 +1,9 @@ # Contributing to Betterlockscreen -Thanks for taking your time to contribute! First off, any and all contributions are welcome. +Thanks to all the amazing people for all your wonderful PRs, issues and ideas, all contributions are welcome! -Secondly, if your pull request or issue is in any way related to the [AUR package](https://aur.archlinux.org/packages/betterlockscreen-git/), please notify the maintainer @Maik93 via a mention (like used here with the @) in your comment. +We are using [next](https://github.com/pavanjadhaw/betterlockscreen/tree/next) as our development-branch and master for the latest stable release. Please provide your pull-requests based on our next-branch. -Also, in case of adding new dependencies, please notify @Maik93. - -For nix-users: We include a nix-shell for development :-) +For Nix-Users: We provide a nix-shell for development :-) Thanks diff --git a/README.md b/README.md index 066720c..7a029a4 100644 --- a/README.md +++ b/README.md @@ -271,12 +271,7 @@ Resources and more informations: ## Countributing -Thanks to all the amazing people for all your wonderful PRs, issues and ideas! - -How can I support developers? - -- Star our GitHub repo :star: -- Create pull requests, submit bugs, suggest new features or documentation updates :wrench: +Please see [CONTRIBUTING.md](CONTRIBUTING.md). ## License From 583ad3468f6b3c8e0ec6d5074fcc82edd52850cd Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Sat, 7 Aug 2021 01:18:44 +0200 Subject: [PATCH 33/36] Add code to autodetect if i3lock-color is available under its name or i3lock and validate custom values from config, extend copyright matching LICENSE --- betterlockscreen | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/betterlockscreen b/betterlockscreen index 807de75..17b4e43 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -1,9 +1,13 @@ #!/usr/bin/env bash -# Author : Pavan Jadhaw +# Author : Copyright (c) 2017-2021 Pavan Jadhaw, and others (https://github.com/pavanjadhaw/betterlockscreen/graphs/contributors) # Github Profile : https://github.com/pavanjadhaw # Project Repository : https://github.com/pavanjadhaw/betterlockscreen +cmd_exists () { + command -v "$1" >/dev/null +} + init_config () { # default options @@ -18,6 +22,10 @@ init_config () { description="" i3lockcolor_bin="i3lock-color" + if ! cmd_exists "i3lockcolor_bin" && cmd_exists "i3lock"; then + i3lockcolor_bin="i3lock" + fi + # default theme loginbox=00000066 loginshadow=00000000 @@ -50,6 +58,11 @@ init_config () { source "$USER_CONF" fi + if ! cmd_exists "$i3lockcolor_bin"; then + echof error "Unable to find i3lock-color binary under detected/configured name: '$i3lockcolor_bin'!" + exit + fi + # Please make sure to adjust this before release! VERSION="4.0.0-beta1" From f452ef0ec47b858db855316fb14587e3bf68221a Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Sat, 7 Aug 2021 01:25:30 +0200 Subject: [PATCH 34/36] Prepare release v4.0.0-beta2 with autodetection of i3lock-color binary-name (i3lock-color/i3lock) --- README.md | 2 +- betterlockscreen | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7a029a4..e54572b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ GitHub Workflow Status (master) GitHub Workflow Status (next) GitHub milestone - GitHub commits since latest release (by date) for a branch + GitHub commits since latest release (by date) for a branch
diff --git a/betterlockscreen b/betterlockscreen index 17b4e43..7965410 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -64,7 +64,7 @@ init_config () { fi # Please make sure to adjust this before release! - VERSION="4.0.0-beta1" + VERSION="4.0.0-beta2" # paths CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/betterlockscreen" From 7157b045645df1ada33af5d0e21418b202bb84cd Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Sat, 7 Aug 2021 14:48:15 +0200 Subject: [PATCH 35/36] Fix installer to also detect i3lock-color if command is i3lock --- install.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 8623e30..8adc691 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,9 @@ #!/usr/bin/env bash +cmd_exists () { + command -v "$1" >/dev/null +} + echof() { local colorReset="\033[0m" local prefix="$1" @@ -55,8 +59,12 @@ DEPS["xdpyinfo"]="xdpyinfo" DEPS["xrdb"]="xrdb" DEPS["xset"]="xset" +if ! cmd_exists DEPS["i3lock-color"] && cmd_exists "i3lock"; then + DEPS["i3lock-color"]="i3lock" +fi + for key in "${!DEPS[@]}"; do - [[ ! -e "$(command -v ${DEPS[$key]})" ]] && echof error "Missing '$key'!" && exit 1 + [[ ! -e "$(command -v ${DEPS[$key]})" ]] && echof error "Missing '$key' under binary named '${DEPS[$key]}'!" && exit 1 done echof ok "done!" From c3fcd2d6f77c83d94660ad56d39aae20e2b66c59 Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Mon, 9 Aug 2021 23:11:04 +0200 Subject: [PATCH 36/36] Prepare release for stable v4.0.0 --- README.md | 4 ++-- betterlockscreen | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e54572b..6723467 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,8 @@ GitHub release (latest by date) GitHub Workflow Status (master) GitHub Workflow Status (next) - GitHub milestone - GitHub commits since latest release (by date) for a branch + GitHub milestone + GitHub commits since latest release (by date) for a branch diff --git a/betterlockscreen b/betterlockscreen index 7965410..c0f3768 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -64,7 +64,7 @@ init_config () { fi # Please make sure to adjust this before release! - VERSION="4.0.0-beta2" + VERSION="4.0.0" # paths CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/betterlockscreen"