-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrotate
executable file
·92 lines (67 loc) · 1.67 KB
/
rotate
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/ksh
#Daniel Molina
##Creeme, no quieres saber para que uso este script
##Si es absurdamente ineficiente de forma intencionada
print_uso(){
cat <<EOF
Script para usos extraños y singulares que es mejor no explicar
Uso: ./rotate [-f fichero a reproducir] [-p path] [-r ruta ficheros a rotar] [--play reproducir despues de rotar]
OJO!!! no pongas / al final de las rutas o seguramente petará
pruebalo con while true ; do ./rotate --play ; done y echate unas risas
EOF
}
PLAY=0
PTH=/home/dmolinao/alla
FICH=activo.wav
REPRODUCIENDO=$PTH/$FICH
ROTATE=$PTH/infidel
WAVS=$(ls -1 $ROTATE/*wav | wc -l | cut -d" " -f1)
TURNO=$(echo $(($RANDOM%$WAVS)))
print_uso(){
cat <<EOF
Script para usos extraños y singulares que es mejor no explicar
Uso: ./rotate [-f fichero a reproducir] [-p path] [-r ruta ficheros a rotar] [--play reproducir despues de rotar]
OJO!!! no pongas / al final de las rutas o seguramente petará
pruebalo con while true ; do ./rotate --play ; done y echate unas risas
Valores por defecto:
path general=$PTH
path de rotados=$ROTATE
cantidad de wavs=$WAVS
EOF
}
while [ $# -gt 0 ];
do
case $1 in
"--play") PLAY=1
shift
;;
"-f") FICH=$2
shift
;;
"-p") PTH=$2
shift
;;
"-r") ROTATE=$2
shift
;;
"-h") print_uso
exit
;;
*)
shift
esac
done
i=1
until [ $i -gt $WAVS ]; do
FICHERO[$i]=`ls -1 $ROTATE/*wav | sed -n $(($i))p`
i=$(($i+1))
done
TURNO=$(echo $(($RANDOM%$WAVS)))
while [ $TURNO -eq 0 ]; do
TURNO=$(echo $(($RANDOM%$WAVS)))
done
cp -f ${FICHERO[$TURNO]} $REPRODUCIENDO > /dev/null
if [ "$PLAY" -eq 1 ]; then
paplay $REPRODUCIENDO &
fi
exit