-
Notifications
You must be signed in to change notification settings - Fork 0
/
wall_changer.sh
executable file
·66 lines (47 loc) · 1.67 KB
/
wall_changer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
folder=$HOME/anime/
extensions='.jpeg|.webp|.jpg|.png'
pic=$( ls $folder | shuf -n 1 )
# pics=$( ls $folder )
#
# pic_array=()
# for file in $pics; do
# pic_array+=($file)
# done
#
# n=$(( $RANDOM % ${#pic_array[@]} ))
#
# pic=$folder${pic_array[n]}
#
# # functionality to add a picture to a file
echo $folder$pic >> $HOME/.wallpapers.txt
wal -qi $folder$pic
# if [ -f $pic ]; then
# wal -qi $folder$pic
# else
# pic=$( ls $folder | shuf -n 1 )
# fi
if [[ $total_lines -gt 10 ]]; then
cat `head -n 10 $file | tail -n 5` > $file
fi
# some command I'd love to remember
# find ~/pictures/ -type f -iname '*.jpg' | xargs -I '{}' convert '{}' -resize 150x150 -quality 100
# '{}'.png
# no_of_pics=$(cat -n pics.txt | tail -1 | cut -bd ' ' -f 1)
# echo $n
# some self notes
# Generating random numbers -->
# echo $Random /# Pretty simple...
# seeding a randomly generated number...
# RANDOM = 1 -> Now the random number generated by $RANDOM will always be the same number
# Generating random numbers through nanoseconds....
# RANDOM=$(date +%s%N | cut -b10-19) -> It is a much better random generator entropy as it is based on seconds and nanoseconds time.
# for numbers in a range...
# echo $(( $RANDOM % 113 + 1)) -> Generates a random number between 1 and 113
# echo $(( $RANDOM % 20 + 5)) -> Generates a random number between 5 and 25
# echo $(( $RANDOM % 400 + 100)) -> Generates a random number between 100 and 500
# You get the gist...
# could also be done in this manner...
# echo $[ $RANDOM % 117 + 1 ] -> for generating a random number between 1 and 117
# echo $[ $RANDOM % 114 + 17 ] -> for generating a random number between 17 and 131
# and so on and so forth