From 20ab92c2bb1194ecf9a36a760d6dbaa018768ff0 Mon Sep 17 00:00:00 2001 From: AUTplayed Date: Sun, 10 Dec 2017 23:25:05 +0100 Subject: [PATCH 1/3] adjusted readme --- README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 030837f..bd12698 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ # better_lockscreen A simple lock script for i3lock + Most of i3lock script out there converts your defined image to add blur, glitch or dim effect to image and it feels so slow and btw who needs dynamic lock background, its not like I change lockscreen background every 5 minutes. I wanted something that was fast and still should have all the effects I want for lockscreen background. + This script generates or already caches the variant for your custom images before hand so they can be later used any number of time as lockscreen background, without the need to apply same effect again and again @@ -15,9 +17,9 @@ Screenshots or it didnt happen... :P ![scrot2](https://github.com/pavanjadhaw/betterlockscreen.demo/raw/master/scrots/scrot2.png "scrot2.png") -### demo.mp4 +### Demo -* [demo.mp4](https://www.youtube.com/watch?v=9Ng5FZwnn6M&feature=youtu.be) - youtube.com +* [Demonstration](https://www.youtube.com/watch?v=9Ng5FZwnn6M&feature=youtu.be) - youtube.com ## Getting Started @@ -89,14 +91,18 @@ chmod +x lock.sh --- -grab your fav image for lockscreen background +### Load/Update the image cache + +Grab your favourite image for lockscreen background ``` ./lock.sh -u path/to/image.img +``` -# OR use wallaper.jpg supplied from this repo +Or supply a directory with images, and a random one will be used -./lock.sh -u wallaper.jpg +``` +./lock.sh -u path/to/imagedir ``` --- From 1c59e5930959ee0f77cce679b193494ebcaf2be2 Mon Sep 17 00:00:00 2001 From: AUTplayed Date: Sun, 10 Dec 2017 23:52:33 +0100 Subject: [PATCH 2/3] added recursive function for getting a random file --- lock.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lock.sh b/lock.sh index 5a7ef13..7f1b0ac 100755 --- a/lock.sh +++ b/lock.sh @@ -57,6 +57,17 @@ postlock() { pkill -u "$USER" -USR2 dunst } +rec_get_random() { + dir="$1" + if [ ! -d "$dir" ]; then + user_input="$dir" + return + fi + dir=($dir/*) + dir=${dir[RANDOM % ${#dir[@]}]} + rec_get_random "$dir" +} + # Options case "$1" in @@ -98,6 +109,7 @@ case "$1" in echo " -u --update" echo " to update image cache, you should do this before using any other options" echo " Ex: ./lock.sh -u path/to/image.png when image.png is custom background" + echo " Or you can use ./lock.sh -u path/to/imagedir and a random file will be selected" echo echo echo " -l --lock" @@ -198,12 +210,8 @@ case "$1" in 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 - + rec_get_random "$2" + # get user image cp "$user_input" "$user_image" if [ ! -f $user_image ]; then From fade2d5bbdda4f8254d79add2efc96611267d4bf Mon Sep 17 00:00:00 2001 From: AUTplayed Date: Sun, 10 Dec 2017 23:55:43 +0100 Subject: [PATCH 3/3] fixed intendation --- lock.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lock.sh b/lock.sh index 7f1b0ac..7aebb9b 100755 --- a/lock.sh +++ b/lock.sh @@ -58,14 +58,14 @@ 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" + dir="$1" + if [ ! -d "$dir" ]; then + user_input="$dir" + return + fi + dir=($dir/*) + dir=${dir[RANDOM % ${#dir[@]}]} + rec_get_random "$dir" } @@ -109,7 +109,7 @@ case "$1" in echo " -u --update" echo " to update image cache, you should do this before using any other options" echo " Ex: ./lock.sh -u path/to/image.png when image.png is custom background" - echo " Or you can use ./lock.sh -u path/to/imagedir and a random file will be selected" + echo " Or you can use ./lock.sh -u path/to/imagedir and a random file will be selected" echo echo echo " -l --lock"