2017-12-31 06:15:50 +00:00
|
|
|
#!/usr/bin/env bash
|
2017-12-07 18:51:34 +00:00
|
|
|
|
2017-12-08 06:01:03 +00:00
|
|
|
# Author : Pavan Jadhaw
|
|
|
|
# Github Profile : https://github.com/pavanjadhaw
|
|
|
|
# Project Repository : https://github.com/pavanjadhaw/betterlockscreen
|
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
init_config () {
|
|
|
|
|
2019-02-09 19:03:45 +00:00
|
|
|
# user configuration file
|
2019-02-09 17:40:27 +00:00
|
|
|
USER_CONF="$HOME/.config/betterlockscreenrc"
|
|
|
|
if [ -e $USER_CONF ]; then
|
|
|
|
source "$USER_CONF"
|
2019-02-09 19:03:45 +00:00
|
|
|
# default configuration options
|
2019-02-09 17:40:27 +00:00
|
|
|
else
|
2019-02-09 19:03:45 +00:00
|
|
|
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
|
2019-01-31 04:24:57 +00:00
|
|
|
|
2019-02-09 19:03:45 +00:00
|
|
|
CACHE_DIR="$HOME/.cache/i3lock"
|
|
|
|
CUR_DIR="$CACHE_DIR/current"
|
2018-06-12 15:27:01 +00:00
|
|
|
|
2019-02-09 19:03:45 +00:00
|
|
|
# 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"
|
2019-02-13 04:41:32 +00:00
|
|
|
CUR_W_PIXEL="$CUR_DIR/wall_pixel.png"
|
2018-06-12 15:27:01 +00:00
|
|
|
|
2019-02-09 19:03:45 +00:00
|
|
|
# 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"
|
2019-02-13 04:41:32 +00:00
|
|
|
CUR_L_PIXEL="$CUR_DIR/lock_pixel.png"
|
2018-06-12 15:27:01 +00:00
|
|
|
}
|
2019-02-09 17:40:27 +00:00
|
|
|
init_config
|
2017-12-14 03:10:51 +00:00
|
|
|
|
2017-12-07 18:51:34 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2017-12-09 01:03:02 +00:00
|
|
|
prelock() {
|
2019-01-31 04:24:57 +00:00
|
|
|
if [ ! -z "$(pidof dunst)" ]; then
|
2018-09-17 13:33:41 +00:00
|
|
|
pkill -u "$USER" -USR1 dunst
|
|
|
|
fi
|
2017-12-09 01:03:02 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2017-12-09 01:03:02 +00:00
|
|
|
lock() {
|
|
|
|
#$1 image path
|
2019-01-06 09:51:49 +00:00
|
|
|
|
2021-05-18 15:26:53 +00:00
|
|
|
i3lock \
|
2019-02-09 17:40:27 +00:00
|
|
|
-i "$1" \
|
2019-05-28 17:48:39 +00:00
|
|
|
--screen "$display_on" \
|
|
|
|
--timepos='ix-170:iy-0' \
|
|
|
|
--datepos='ix-240:iy+25' \
|
2019-01-31 04:24:57 +00:00
|
|
|
--clock --date-align 1 --datestr "$locktext" \
|
|
|
|
--insidecolor=$insidecolor --ringcolor=$ringcolor --line-uses-inside \
|
|
|
|
--keyhlcolor=$keyhlcolor --bshlcolor=$bshlcolor --separatorcolor=$separatorcolor \
|
|
|
|
--insidevercolor=$insidevercolor --insidewrongcolor=$insidewrongcolor \
|
2019-05-28 17:48:39 +00:00
|
|
|
--ringvercolor=$ringvercolor --ringwrongcolor=$ringwrongcolor --indpos='x+280:y+h-70' \
|
2019-01-31 04:24:57 +00:00
|
|
|
--radius=20 --ring-width=4 --veriftext='' --wrongtext='' \
|
|
|
|
--verifcolor="$verifcolor" --timecolor="$timecolor" --datecolor="$datecolor" \
|
2019-01-30 09:08:43 +00:00
|
|
|
--time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \
|
2019-01-31 04:24:57 +00:00
|
|
|
--noinputtext='' --force-clock $lockargs
|
2017-12-09 01:03:02 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2017-12-09 01:03:02 +00:00
|
|
|
postlock() {
|
2019-01-31 04:24:57 +00:00
|
|
|
if [ ! -z "$(pidof dunst)" ] ; then
|
2018-09-17 13:33:41 +00:00
|
|
|
pkill -u "$USER" -USR2 dunst
|
|
|
|
fi
|
2017-12-09 01:03:02 +00:00
|
|
|
}
|
2017-12-08 06:01:03 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2018-04-27 17:18:51 +00:00
|
|
|
lockselect() {
|
2018-11-04 05:22:53 +00:00
|
|
|
prelock
|
2018-04-27 17:18:51 +00:00
|
|
|
case "$1" in
|
|
|
|
dim)
|
|
|
|
# lockscreen with dimmed background
|
2019-02-09 17:40:27 +00:00
|
|
|
lock "$CUR_L_DIM"
|
2018-04-27 17:18:51 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
blur)
|
|
|
|
# set lockscreen with blurred background
|
2019-02-09 17:40:27 +00:00
|
|
|
lock "$CUR_L_BLUR"
|
2018-04-27 17:18:51 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
dimblur)
|
|
|
|
# set lockscreen with dimmed + blurred background
|
2019-02-09 17:40:27 +00:00
|
|
|
lock "$CUR_L_DIMBLUR"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
|
|
|
|
2019-02-13 04:41:32 +00:00
|
|
|
pixel)
|
|
|
|
# set lockscreen with pixelated background
|
|
|
|
lock "$CUR_L_PIXEL"
|
|
|
|
;;
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
*)
|
|
|
|
# default lockscreen
|
2019-02-09 17:40:27 +00:00
|
|
|
lock "$CUR_L_RESIZE"
|
2018-04-27 17:18:51 +00:00
|
|
|
;;
|
|
|
|
esac
|
2018-11-04 05:22:53 +00:00
|
|
|
postlock
|
2018-04-27 17:18:51 +00:00
|
|
|
}
|
|
|
|
|
2018-12-10 21:41:59 +00:00
|
|
|
logical_px() {
|
|
|
|
# get dpi value from xrdb
|
2019-01-31 04:24:57 +00:00
|
|
|
local DPI=$(xrdb -query | awk '/Xft.dpi/ {print $2}')
|
2019-02-09 17:40:27 +00:00
|
|
|
|
2018-12-11 23:29:17 +00:00
|
|
|
# return the default value if no DPI is set
|
2019-01-05 17:44:47 +00:00
|
|
|
if [ -z "$DPI" ]; then
|
2019-01-31 04:24:57 +00:00
|
|
|
echo $1
|
2018-12-10 21:41:59 +00:00
|
|
|
else
|
2019-01-31 04:24:57 +00:00
|
|
|
local SCALE=$(echo "scale=2; $DPI / 96.0" | bc)
|
2018-12-11 23:29:17 +00:00
|
|
|
|
|
|
|
# check if scaling the value is worthy
|
2019-01-31 04:24:57 +00:00
|
|
|
if [ $(echo "$SCALE > 1.25" | bc -l) -eq 0 ]; then
|
|
|
|
echo $1
|
2018-12-11 23:29:17 +00:00
|
|
|
else
|
|
|
|
echo "$SCALE * $1 / 1" | bc
|
|
|
|
fi
|
2018-12-10 21:41:59 +00:00
|
|
|
fi
|
|
|
|
}
|
2017-12-08 06:01:03 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
# get total resolution
|
|
|
|
# 1600x900
|
|
|
|
get_total_size () {
|
|
|
|
TOTAL_SIZE=$(xdpyinfo | grep -w "dimensions" | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/')
|
|
|
|
}
|
2017-12-14 03:10:51 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
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
|
|
|
|
}
|
2018-11-04 05:22:53 +00:00
|
|
|
|
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
get_user_wall() {
|
|
|
|
local path="$1"
|
|
|
|
if [ ! -d "$path" ]; then
|
|
|
|
USER_WALL="$path"
|
|
|
|
return
|
2018-11-04 05:22:53 +00:00
|
|
|
fi
|
2019-02-09 17:40:27 +00:00
|
|
|
dir=("$path"/*)
|
|
|
|
dir="${dir[RANDOM % ${#dir[@]}]}"
|
|
|
|
get_user_wall "$dir"
|
|
|
|
}
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
resize_and_render () {
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
# arguments
|
|
|
|
local base=$1
|
|
|
|
local path=$2
|
|
|
|
local resolution=$3
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
# wallpaper
|
|
|
|
RES_RESIZE="$2/resize.png"
|
2019-02-13 04:41:32 +00:00
|
|
|
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
|
2019-02-09 17:40:27 +00:00
|
|
|
RES_DIM="$2/dim.png"
|
|
|
|
RES_BLUR="$2/blur.png"
|
|
|
|
RES_DIMBLUR="$2/dimblur.png"
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
# defaults
|
|
|
|
[[ $blur_level ]] || blur_level=1
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
echo "Resizing original and applying effects..."
|
|
|
|
|
|
|
|
# apply resize
|
|
|
|
eval convert "$base" -resize "$resolution""^" -gravity center -extent "$resolution" "$RES_RESIZE"
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 19:03:45 +00:00
|
|
|
# apply dim
|
|
|
|
eval convert "$RES_RESIZE" -fill black -colorize 40% "$RES_DIM"
|
2019-02-09 17:40:27 +00:00
|
|
|
|
2019-02-09 19:03:45 +00:00
|
|
|
# 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"
|
2019-02-09 17:40:27 +00:00
|
|
|
|
|
|
|
# apply dimblur
|
|
|
|
eval convert "$RES_DIM" \
|
2018-11-04 05:22:53 +00:00
|
|
|
-filter Gaussian \
|
|
|
|
-resize "$blur_shrink%" \
|
|
|
|
-define "filter:sigma=$blur_sigma" \
|
2019-02-09 17:40:27 +00:00
|
|
|
-resize "$resolution^" -gravity center -extent "$resolution" \
|
|
|
|
"$RES_DIMBLUR"
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-13 04:41:32 +00:00
|
|
|
# pixelate
|
|
|
|
eval convert "$RES_RESIZE" \
|
|
|
|
-scale 10% \
|
|
|
|
-scale 1000% \
|
|
|
|
"$RES_PIXEL"
|
2019-02-09 17:40:27 +00:00
|
|
|
}
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
# delete and recreate directory
|
|
|
|
purge_cache () {
|
|
|
|
if [[ -d "$1" ]]; then
|
|
|
|
rm -r "$1"
|
|
|
|
fi
|
|
|
|
mkdir -p "$1"
|
|
|
|
}
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
# update locker and wallpaper images
|
|
|
|
update () {
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
wallpaper=$1
|
|
|
|
rectangles=" "
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
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)))
|
2019-05-28 17:48:39 +00:00
|
|
|
CY=$((${SRA[3]} + ${SRA[1]} - $(logical_px 30)))
|
2019-02-09 17:40:27 +00:00
|
|
|
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 "
|
2019-02-13 04:41:32 +00:00
|
|
|
PARAM_PIXEL="$PARAM_PIXEL $RES_PIXEL -geometry $DPOS -composite "
|
2019-02-09 17:40:27 +00:00
|
|
|
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
|
2019-02-13 04:41:32 +00:00
|
|
|
cp $RES_PIXEL $CUR_W_PIXEL
|
2019-02-09 17:40:27 +00:00
|
|
|
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
|
2019-02-13 04:41:32 +00:00
|
|
|
convert -size $TOTAL_SIZE 'xc:black' $CUR_W_PIXEL
|
2019-02-09 17:40:27 +00:00
|
|
|
|
|
|
|
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
|
2019-02-13 04:41:32 +00:00
|
|
|
convert $CUR_W_PIXEL $PARAM_PIXEL $CUR_W_PIXEL
|
2019-02-09 17:40:27 +00:00
|
|
|
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"
|
2019-02-13 04:41:32 +00:00
|
|
|
convert "$CUR_W_PIXEL" -draw "fill #$loginbox $rectangles" "$CUR_L_PIXEL"
|
2017-12-31 16:41:51 +00:00
|
|
|
}
|
2019-02-09 19:03:45 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
|
|
|
|
wallpaper() {
|
2019-02-09 17:40:27 +00:00
|
|
|
local fopt
|
2019-02-09 23:11:24 +00:00
|
|
|
get_display_list
|
|
|
|
if [ "$span_image" = true ] || [[ "${#DLIST[@]}" -gt 1 ]]; then
|
2019-02-09 17:40:27 +00:00
|
|
|
fopt="--no-xinerama"
|
|
|
|
fi
|
2018-11-04 05:22:53 +00:00
|
|
|
case "$1" in
|
|
|
|
'')
|
|
|
|
# set resized image as wallpaper if no argument is supplied by user
|
2019-02-09 17:40:27 +00:00
|
|
|
feh --bg-fill "$fopt" "$CUR_W_RESIZE"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
dim)
|
|
|
|
# set dimmed image as wallpaper
|
2019-02-09 17:40:27 +00:00
|
|
|
feh --bg-fill "$fopt" "$CUR_W_DIM"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
blur)
|
|
|
|
# set blurred image as wallpaper
|
2019-02-09 17:40:27 +00:00
|
|
|
feh --bg-fill "$fopt" "$CUR_W_BLUR"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
dimblur)
|
|
|
|
# set dimmed + blurred image as wallpaper
|
2019-02-09 17:40:27 +00:00
|
|
|
feh --bg-fill "$fopt" "$CUR_W_DIMBLUR"
|
2019-02-12 03:05:52 +00:00
|
|
|
;;
|
2019-02-13 04:41:32 +00:00
|
|
|
|
|
|
|
pixel)
|
|
|
|
# set pixelated image as wallpaper
|
|
|
|
feh --bg-fill "$fopt" "$CUR_W_PIXEL"
|
|
|
|
;;
|
2018-11-04 05:22:53 +00:00
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
empty() {
|
2019-02-09 17:40:27 +00:00
|
|
|
if [ -f $CUR_L_RESIZE ]; then
|
2018-11-04 05:22:53 +00:00
|
|
|
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.'
|
2018-09-17 13:33:41 +00:00
|
|
|
fi
|
2018-11-04 05:22:53 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2019-02-09 17:40:27 +00:00
|
|
|
echo ' -d --display'
|
2018-11-04 05:22:53 +00:00
|
|
|
echo ' to be used after -u'
|
2019-02-09 17:40:27 +00:00
|
|
|
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'
|
2018-11-04 05:22:53 +00:00
|
|
|
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'
|
|
|
|
}
|
|
|
|
|
2018-09-17 13:33:41 +00:00
|
|
|
|
2017-12-31 16:41:51 +00:00
|
|
|
# Options
|
2018-11-04 05:22:53 +00:00
|
|
|
[[ "$1" = '' ]] && empty
|
2017-12-09 01:03:02 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
for arg in "$@"; do
|
|
|
|
[[ "${arg:0:1}" = '-' ]] || continue
|
2017-12-09 01:03:02 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
case "$1" in
|
|
|
|
-h | --help)
|
|
|
|
usage
|
|
|
|
break
|
|
|
|
;;
|
2017-12-09 01:03:02 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
-s | --suspend)
|
|
|
|
runsuspend=true
|
|
|
|
;&
|
|
|
|
|
|
|
|
-l | --lock)
|
|
|
|
runlock=true
|
2019-01-31 04:24:57 +00:00
|
|
|
[[ $runsuspend ]] || lockargs="$lockargs -n"
|
|
|
|
[[ ${2:0:1} = '-' ]] && shift 1 || { lockstyle="$2"; shift 2; }
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
2017-12-09 01:03:02 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
-w | --wall | --wallpaper)
|
|
|
|
wallpaper "$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2017-12-09 01:03:02 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
-u | --update)
|
|
|
|
runupdate=true
|
|
|
|
imagepath="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
2017-12-09 01:03:02 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
-t | --text)
|
|
|
|
locktext="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
-d | --display)
|
|
|
|
display_on="$2"
|
2018-11-04 05:22:53 +00:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
--span)
|
|
|
|
span_image=true
|
|
|
|
shift 1
|
|
|
|
;;
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
-b | --blur)
|
|
|
|
blur_level="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
|
|
|
--)
|
2019-01-31 04:24:57 +00:00
|
|
|
lockargs="$lockargs ${@:2}"
|
2018-11-04 05:22:53 +00:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "invalid argument: $1"
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2019-02-09 17:40:27 +00:00
|
|
|
# some defaults
|
|
|
|
[[ $display_on ]] || display_on=0
|
|
|
|
[[ $span_image ]] || span_image=false
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
# Run image generation
|
|
|
|
[[ $runupdate ]] && update "$imagepath"
|
2018-04-27 17:18:51 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
# Activate lockscreen
|
|
|
|
[[ $runlock ]] && lockselect "$lockstyle" && \
|
|
|
|
{ [[ $runsuspend ]] && systemctl suspend; }
|
2018-09-15 18:06:56 +00:00
|
|
|
|
2019-01-31 04:24:57 +00:00
|
|
|
exit 0
|