mirror of
https://git.adityakumar.xyz/betterlockscreen-openrc.git
synced 2024-11-09 18:49:45 +00:00
Added random image of dir when a dir is passed (#6)
If the user passes a directory when updating via-u <dir> then this code selects a random file from the directory and uses it instead. This is useful so one can update the lock image on boot and have a random image every reboot (Adds variety)
This commit is contained in:
parent
5b2378200b
commit
e802862b35
1 changed files with 8 additions and 1 deletions
9
lock.sh
9
lock.sh
|
@ -197,8 +197,15 @@ case "$1" in
|
||||||
mkdir -p "$folder"
|
mkdir -p "$folder"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# get random file in dir if passed argument is a dir
|
||||||
|
user_input=$2
|
||||||
|
if [ -d $user_input ]; then
|
||||||
|
user_input=($user_input/*)
|
||||||
|
user_input=${user_input[RANDOM % ${#user_input[@]}]}
|
||||||
|
fi
|
||||||
|
|
||||||
# get user image
|
# get user image
|
||||||
cp "$2" "$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"
|
echo "Please specify the path to the image you would like to use"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in a new issue