aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Jadhaw <pavanjadhaw96@gmail.com>2017-12-11 00:55:30 +0000
committerGitHub <noreply@github.com>2017-12-11 00:55:30 +0000
commit03af70078911bdc5afd86ab291a62e3c0a33df15 (patch)
tree14c2ff6e67a20fd2f833a145555bd03a1ee0fd2c
parente802862b35ea51e915be3f4e1da91c8f0139691e (diff)
parentfade2d5bbdda4f8254d79add2efc96611267d4bf (diff)
Merge pull request #7 from AUTplayed/master
Now recursively select random file, and adjusted README
-rw-r--r--README.md16
-rwxr-xr-xlock.sh20
2 files changed, 25 insertions, 11 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
```
---
diff --git a/lock.sh b/lock.sh
index 5a7ef13..7aebb9b 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