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
|
|
|
|
|
2018-06-12 15:27:01 +00:00
|
|
|
# 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/')
|
2021-05-15 10:43:43 +00:00
|
|
|
default_timeout="$(cut -d ' ' -f4 <<< "$(xset q | sed -n '25p')")"
|
2020-01-23 20:27:29 +00:00
|
|
|
default_dpms=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}')
|
2018-06-12 15:27:01 +00:00
|
|
|
|
|
|
|
init_filenames() {
|
|
|
|
#$1 resolution
|
|
|
|
|
2020-04-24 11:56:13 +00:00
|
|
|
# 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'
|
2021-05-15 09:36:48 +00:00
|
|
|
time_format='%H:%M:%S'
|
2020-04-24 11:56:13 +00:00
|
|
|
|
|
|
|
# override defaults with config
|
2019-01-06 09:51:49 +00:00
|
|
|
theme_rc="$HOME/.config/betterlockscreenrc"
|
2019-06-13 19:06:08 +00:00
|
|
|
if [ -e "$theme_rc" ]; then
|
2021-05-15 10:43:43 +00:00
|
|
|
# shellcheck disable=SC1090
|
2020-04-24 11:56:13 +00:00
|
|
|
source "$theme_rc"
|
2019-01-06 09:51:49 +00:00
|
|
|
fi
|
|
|
|
|
2018-06-12 15:27:01 +00:00
|
|
|
# create folder in ~/.cache/i3lock directory
|
2018-06-19 17:23:27 +00:00
|
|
|
res_folder="$HOME/.cache/i3lock/$1"
|
|
|
|
folder="$HOME/.cache/i3lock/current"
|
2019-06-13 19:06:08 +00:00
|
|
|
echo "Got" "$@" "$res_folder"
|
2021-05-15 10:43:43 +00:00
|
|
|
if [ ! -d "$folder" ] || [ -n "$2" ]; then
|
2019-06-13 19:06:08 +00:00
|
|
|
rm -rf "$folder"
|
|
|
|
mkdir -p "$res_folder"
|
|
|
|
ln -s "$res_folder" "$folder"
|
2018-06-19 17:23:27 +00:00
|
|
|
fi
|
2018-06-12 15:27:01 +00:00
|
|
|
|
|
|
|
# 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"
|
2019-02-12 03:05:52 +00:00
|
|
|
pixel="$folder/pixel.png" # pixelated image
|
2018-06-12 15:27:01 +00:00
|
|
|
|
|
|
|
# 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"
|
2019-02-12 03:05:52 +00:00
|
|
|
l_pixel="$folder/l_pixel.png"
|
2018-06-12 15:27:01 +00:00
|
|
|
}
|
2017-12-14 03:10:51 +00:00
|
|
|
|
2019-06-13 19:06:08 +00:00
|
|
|
init_filenames "$res"
|
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() {
|
2021-05-15 10:43:43 +00:00
|
|
|
if [ -n "$lock_timeout" ]; then
|
2020-04-24 11:56:13 +00:00
|
|
|
xset dpms "$lock_timeout"
|
2019-05-28 17:48:22 +00:00
|
|
|
fi
|
2021-05-15 10:43:43 +00:00
|
|
|
if [ -n "$(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 \
|
2020-11-21 11:34:56 +00:00
|
|
|
-c 00000000 \
|
2018-01-17 12:25:51 +00:00
|
|
|
-t -i "$1" \
|
2021-05-28 20:21:50 +00:00
|
|
|
--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" \
|
2019-01-30 09:08:43 +00:00
|
|
|
--time-font="$font" --date-font="$font" --layout-font="$font" --verif-font="$font" --wrong-font="$font" \
|
2021-05-28 20:21:50 +00:00
|
|
|
--noinput-text='' --force-clock --pass-media-keys "$lockargs"
|
2019-09-02 19:48:02 +00:00
|
|
|
|
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() {
|
2021-05-15 10:43:43 +00:00
|
|
|
if [ -n "$lock_timeout" ]; then
|
2020-04-24 11:56:13 +00:00
|
|
|
xset dpms "$default_timeout"
|
|
|
|
if [ "$default_dpms" = "Disabled" ]; then
|
|
|
|
xset -dpms
|
|
|
|
fi
|
2019-05-28 17:48:22 +00:00
|
|
|
fi
|
2021-05-15 10:43:43 +00:00
|
|
|
if [ -n "$(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
|
|
|
|
2017-12-10 22:52:33 +00:00
|
|
|
rec_get_random() {
|
2017-12-10 22:55:43 +00:00
|
|
|
dir="$1"
|
|
|
|
if [ ! -d "$dir" ]; then
|
|
|
|
user_input="$dir"
|
|
|
|
return
|
|
|
|
fi
|
2021-05-15 10:43:43 +00:00
|
|
|
dirs=("$dir"*)
|
|
|
|
random_dir="${dirs[RANDOM % ${#dirs[@]}]}"
|
|
|
|
rec_get_random "$random_dir"
|
|
|
|
exit 1
|
2017-12-10 22:52:33 +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
|
2018-08-13 03:53:40 +00:00
|
|
|
lock "$l_dim"
|
2018-04-27 17:18:51 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
blur)
|
|
|
|
# set lockscreen with blurred background
|
2018-08-13 03:53:40 +00:00
|
|
|
lock "$l_blur"
|
2018-04-27 17:18:51 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
dimblur)
|
|
|
|
# set lockscreen with dimmed + blurred background
|
2018-08-13 03:53:40 +00:00
|
|
|
lock "$l_dimblur"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
|
|
|
|
2019-02-12 03:05:52 +00:00
|
|
|
pixel)
|
|
|
|
# set lockscreen with pixelated background
|
|
|
|
lock "$l_pixel"
|
|
|
|
;;
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
*)
|
|
|
|
# default lockscreen
|
|
|
|
lock "$l_resized"
|
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
|
|
|
}
|
|
|
|
|
2019-03-31 13:15:31 +00:00
|
|
|
# $1: number of pixels to convert
|
|
|
|
# $2: 1 for width. 2 for height
|
2018-12-10 21:41:59 +00:00
|
|
|
logical_px() {
|
|
|
|
# get dpi value from xrdb
|
2019-06-13 19:06:08 +00:00
|
|
|
local DPI
|
2021-05-15 10:43:43 +00:00
|
|
|
DPI=$(grep -oP 'Xft.dpi:\s*\K\d+' ~/.Xresources | bc)
|
|
|
|
if [ -n "$DPI" ]; then
|
2019-09-02 19:52:00 +00:00
|
|
|
DPI=$(xdpyinfo | sed -En "s/\s*resolution:\s*([0-9]*)x([0-9]*)\s.*/\\$2/p" | head -n1)
|
|
|
|
fi
|
2019-06-13 19:06:08 +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-06-13 19:06:08 +00:00
|
|
|
echo "$1"
|
2018-12-10 21:41:59 +00:00
|
|
|
else
|
2019-06-13 19:06:08 +00:00
|
|
|
local SCALE
|
|
|
|
SCALE=$(echo "scale=2; $DPI / 96.0" | bc)
|
2018-12-11 23:29:17 +00:00
|
|
|
|
|
|
|
# check if scaling the value is worthy
|
2019-06-13 19:06:08 +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
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
update() {
|
2019-06-13 19:06:08 +00:00
|
|
|
# use
|
2018-11-04 05:22:53 +00:00
|
|
|
background="$1"
|
2017-12-14 03:10:51 +00:00
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
# 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
|
2021-05-15 10:43:43 +00:00
|
|
|
SRA=("${RES//[x+]/ }")
|
2019-06-13 19:06:08 +00:00
|
|
|
CX=$((SRA[2] + $(logical_px 25 1)))
|
|
|
|
CY=$((SRA[1] - $(logical_px 30 2)))
|
2019-03-31 13:15:31 +00:00
|
|
|
rectangles+="rectangle $CX,$CY $((CX+$(logical_px 300 1))),$((CY-$(logical_px 80 2))) "
|
2018-11-04 05:22:53 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# User supplied Image
|
|
|
|
user_image="$folder/user_image.png"
|
|
|
|
|
|
|
|
# create folder
|
2019-06-13 19:06:08 +00:00
|
|
|
if [ ! -d "$folder" ]; then
|
2018-11-04 05:22:53 +00:00
|
|
|
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"
|
2019-06-13 19:06:08 +00:00
|
|
|
if [ ! -f "$user_image" ]; then
|
2018-11-04 05:22:53 +00:00
|
|
|
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
|
2019-02-12 03:05:52 +00:00
|
|
|
echo 'Applying dim, blur, and pixelation effect to resized image'
|
2018-11-04 05:22:53 +00:00
|
|
|
# dim
|
|
|
|
convert "$resized" -fill black -colorize 40% "$dim"
|
|
|
|
|
2019-02-12 03:05:52 +00:00
|
|
|
# pixel
|
|
|
|
convert -scale 10% -scale 1000% "$resized" "$pixel"
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
# 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
|
2019-01-06 09:51:49 +00:00
|
|
|
convert "$resized" -draw "fill #$loginbox $rectangles" "$l_resized"
|
2018-11-04 05:22:53 +00:00
|
|
|
|
|
|
|
# dim
|
2019-01-06 09:51:49 +00:00
|
|
|
convert "$dim" -draw "fill #$loginbox $rectangles" "$l_dim"
|
2018-11-04 05:22:53 +00:00
|
|
|
|
|
|
|
# blur
|
2019-01-06 09:51:49 +00:00
|
|
|
convert "$blur" -draw "fill #$loginbox $rectangles" "$l_blur"
|
2018-11-04 05:22:53 +00:00
|
|
|
|
2019-02-12 03:05:52 +00:00
|
|
|
# dimblur
|
2019-01-06 09:51:49 +00:00
|
|
|
convert "$dimblur" -draw "fill #$loginbox $rectangles" "$l_dimblur"
|
2019-02-12 03:05:52 +00:00
|
|
|
|
|
|
|
# pixel
|
|
|
|
convert "$pixel" -draw "fill #$loginbox $rectangles" "$l_pixel"
|
2018-11-04 05:22:53 +00:00
|
|
|
echo
|
|
|
|
echo 'All required changes have been applied'
|
2017-12-31 16:41:51 +00:00
|
|
|
}
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
|
|
|
|
wallpaper() {
|
|
|
|
case "$1" in
|
|
|
|
'')
|
|
|
|
# set resized image as wallpaper if no argument is supplied by user
|
2020-04-24 11:56:13 +00:00
|
|
|
wallpaper="$resized"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
dim)
|
|
|
|
# set dimmed image as wallpaper
|
2020-04-24 11:56:13 +00:00
|
|
|
wallpaper="$dim"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
blur)
|
|
|
|
# set blurred image as wallpaper
|
2020-04-24 11:56:13 +00:00
|
|
|
wallpaper="$blur"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
dimblur)
|
|
|
|
# set dimmed + blurred image as wallpaper
|
2020-04-24 11:56:13 +00:00
|
|
|
wallpaper="$dimblur"
|
2018-11-04 05:22:53 +00:00
|
|
|
;;
|
2019-02-12 03:05:52 +00:00
|
|
|
|
|
|
|
pixel)
|
|
|
|
# set pixelated image as wallpaper
|
2020-04-24 11:56:13 +00:00
|
|
|
wallpaper="$pixel"
|
2019-02-12 03:05:52 +00:00
|
|
|
;;
|
2018-11-04 05:22:53 +00:00
|
|
|
esac
|
2020-04-24 11:56:13 +00:00
|
|
|
eval "$wallpaper_cmd $wallpaper"
|
2018-11-04 05:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
empty() {
|
2019-06-13 19:06:08 +00:00
|
|
|
if [ -f "$l_dim" ]; 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)'
|
2020-04-24 11:56:13 +00:00
|
|
|
echo ' (The default wallpaper setter is feh, to set your own use the -wc command)'
|
2018-11-04 05:22:53 +00:00
|
|
|
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 ' -r --resolution'
|
|
|
|
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
|
|
|
|
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'
|
2019-05-28 17:48:22 +00:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo ' --off <timeout>'
|
2020-04-24 11:56:13 +00:00
|
|
|
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 <command>'
|
|
|
|
echo ' to set your custom wallpaper setter'
|
|
|
|
echo ' the default is "feh --bg-fill --no-fehbg"'
|
|
|
|
echo ' E.g: betterlockscreen -wc "xwallpaper --zoom" -w'
|
2021-05-15 09:36:48 +00:00
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo ' -tf --time_format <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"'
|
2018-11-04 05:22:53 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
[[ $runsuspend ]] || lockargs="$lockargs -n"
|
2019-06-13 19:06:08 +00:00
|
|
|
if [[ ${2:0:1} = '-' ]]; then
|
|
|
|
shift 1
|
|
|
|
else
|
2020-04-24 11:56:13 +00:00
|
|
|
lockstyle="$2"; shift 2
|
2019-06-13 19:06:08 +00:00
|
|
|
fi
|
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-05-28 17:48:22 +00:00
|
|
|
--off)
|
|
|
|
lock_timeout="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
-r | --resolution)
|
|
|
|
res="$2"
|
2019-06-13 19:06:08 +00:00
|
|
|
init_filenames "$res" force
|
2018-11-04 05:22:53 +00:00
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
|
|
|
-b | --blur)
|
|
|
|
blur_level="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2020-04-24 11:56:13 +00:00
|
|
|
-wc | --wallpaper_cmd)
|
|
|
|
wallpaper_cmd="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2021-05-15 09:36:48 +00:00
|
|
|
-tf | --time_format)
|
|
|
|
time_format="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
--)
|
2019-06-13 19:06:08 +00:00
|
|
|
lockargs="$lockargs ${*:2}"
|
2018-11-04 05:22:53 +00:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
echo "invalid argument: $1"
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2018-11-04 05:22:53 +00:00
|
|
|
exit 0
|