Browse Source

just-play-something: reindent, shellcheck

Matteo Cypriani 1 year ago
parent
commit
ff3da6cdee
1 changed files with 11 additions and 10 deletions
  1. 11
    10
      audio/just-play-something.sh

+ 11
- 10
audio/just-play-something.sh View File

@@ -19,28 +19,29 @@
19 19
 
20 20
 #set -x
21 21
 
22
-TIME="/usr/bin/time 2>&1"
23
-
24 22
 # Returns a random number between 1 and its first argument
25 23
 random()
26 24
 {
27
-  MAX=$1
28
-  RAND=0`(echo $$ ; /usr/bin/time ps 2>&1 ; date) | md5sum | sed 's/[a-z]//g' | sed -r 's/(.{8}).*/\1/'`
29
-  expr $RAND % $MAX + 1
25
+    max=$1
26
+    rand=0$( (echo $$ ; /usr/bin/time ps 2>&1 ; date) \
27
+        | md5sum | sed 's/[a-z]//g' | sed -r 's/(.{8}).*/\1/')
28
+    echo $((rand % max + 1))
30 29
 }
31 30
 
32 31
 # If we can't reach the server, restart it
33 32
 if ! mpc >/dev/null 2>&1 ; then
34
-  /etc/init.d/mpd restart
33
+    /etc/init.d/mpd restart
35 34
 fi
36 35
 
37 36
 # If the playlist is empty, add a random album to the playlist
38 37
 if [ "$(mpc playlist 2>/dev/null)" = "" ] ; then
39
-  NB_ALBUMS=`mpc list Album | wc -l`
40
-  RAND_ALBUM_NUM=`random $NB_ALBUMS`
41
-  RANDOM_ALBUM=`mpc list Album | sed -n ${RAND_ALBUM_NUM}p`
42
-  mpc findadd Album "$RANDOM_ALBUM"
38
+    NB_ALBUMS=$(mpc list Album | wc -l)
39
+    RAND_ALBUM_NUM=$(random "$NB_ALBUMS")
40
+    RANDOM_ALBUM="$(mpc list Album | sed -n "${RAND_ALBUM_NUM}p")"
41
+    mpc findadd Album "$RANDOM_ALBUM"
43 42
 fi
44 43
 
45 44
 # Start playing or toggle pause
46 45
 mpc toggle >/dev/null 2>&1
46
+
47
+# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4

Loading…
Cancel
Save