From: Giulio Maestrini Date: Fri, 23 Dec 2022 15:09:56 +0000 (+0100) Subject: Aggiunti script Aurora X-Git-Url: https://git.devmsg.it/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a45032428c1715fd622c9381f5559f26935e8f12;p=giulio%2F.git Aggiunti script Aurora --- diff --git a/aurora/color.sh b/aurora/color.sh new file mode 100755 index 0000000..5d95efc --- /dev/null +++ b/aurora/color.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# run as root + +function blu { + gpioset 0 101=1 + gpioset 0 99=1 + gpioset 0 97=1 + gpioset 0 140=0 +} + +function bianco { + gpioset 0 101=1 + gpioset 0 99=0 + gpioset 0 97=0 + gpioset 0 140=0 +} + +function fuxia { + gpioset 0 101=1 + gpioset 0 99=0 + gpioset 0 97=1 + gpioset 0 140=0 +} + +function acqua { + gpioset 0 101=1 + gpioset 0 99=1 + gpioset 0 97=0 + gpioset 0 140=0 +} + +function verde { + gpioset 0 101=1 + gpioset 0 99=1 + gpioset 0 97=0 + gpioset 0 140=1 +} + +function arancio { + gpioset 0 101=1 + gpioset 0 99=0 + gpioset 0 97=1 + gpioset 0 140=1 +} + +function giallo { + gpioset 0 101=1 + gpioset 0 99=0 + gpioset 0 97=0 + gpioset 0 140=1 +} + +function off { + gpioset 0 101=0 + gpioset 0 99=0 + gpioset 0 97=0 + gpioset 0 140=0 +} + + +for (( i=0; i<40; i++ )) +do + rnd=$(shuf -i 1-7 -n 1) + case $rnd in + + "1") + blu + ;; + + "2") + bianco + ;; + + "3") + fuxia + ;; + + "4") + acqua + ;; + + "5") + verde + ;; + + "6") + arancio + ;; + + *) + giallo + ;; + esac + + sleep 15 +done + +off diff --git a/aurora/init_mpd_1.sh b/aurora/init_mpd_1.sh new file mode 100755 index 0000000..fcf26a6 --- /dev/null +++ b/aurora/init_mpd_1.sh @@ -0,0 +1,3 @@ +#!/bin/bash +# start mpd daemon +mpd diff --git a/aurora/init_mpd_2.sh b/aurora/init_mpd_2.sh new file mode 100755 index 0000000..044299a --- /dev/null +++ b/aurora/init_mpd_2.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# lights ON +/bin/bash /home/ubuntu/scripts/color.sh & + +# update database and load playlist +mpc update +mpc load aurora +mpc repeat + +# play a random entry of the playlist +sup=$(mpc playlist | wc -l) +rnd=$(shuf -i 1-"$sup" -n 1) +mpc play "$rnd" +sleep 600 + +# FADE OUT +# save current volume +vol=$(mpc vol | cut -d " " -f 2 | tr -d "%") +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 + +# stop and reset +mpc stop +mpc vol "$vol" diff --git a/aurora/replay.sh b/aurora/replay.sh new file mode 100755 index 0000000..9799933 --- /dev/null +++ b/aurora/replay.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# lights ON +/bin/bash /home/ubuntu/scripts/color.sh & + +# replay +mpc play +sleep 600 + +# FADE OUT +# save current volume +vol=$(mpc vol | cut -d " " -f 2 | tr -d "%") +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 +sleep 1 +mpc volume -10 + +# stop and reset +mpc stop +mpc vol "$vol" diff --git a/aurora/song+.sh b/aurora/song+.sh new file mode 100755 index 0000000..1b699a9 --- /dev/null +++ b/aurora/song+.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# run as root + +function action { + # check if music is playing + mpc | grep playing + status=$? + #if YES + if [ "$status" == 0 ]; then + mpc next + #if NO + else + mpc play + fi +} + +for((;;)) +do + gpiomon --bias pull-down -s -n 1 -r 0 108 && action + sleep 0.7 +done diff --git a/aurora/song-.sh b/aurora/song-.sh new file mode 100755 index 0000000..94a2b6c --- /dev/null +++ b/aurora/song-.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# run as root + +function action { + # check if music is playing + mpc | grep playing + status=$? + #if YES + if [ "$status" == 0 ]; then + mpc prev + #if NO + else + mpc play + fi +} + +for((;;)) +do + gpiomon --bias pull-down -s -n 1 -r 0 109 && action + sleep 0.7 +done diff --git a/aurora/vol+.sh b/aurora/vol+.sh new file mode 100755 index 0000000..94144f0 --- /dev/null +++ b/aurora/vol+.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# run as root + +function action { + # check if music is playing + mpc | grep playing + status=$? + #if YES + if [ "$status" == 0 ]; then + mpc volume +10 + #if NO + else + mpc play + fi +} + +for((;;)) +do + gpiomon --bias pull-down -s -n 1 -r 0 111 && action + sleep 0.7 +done diff --git a/aurora/vol-.sh b/aurora/vol-.sh new file mode 100755 index 0000000..f0c95bd --- /dev/null +++ b/aurora/vol-.sh @@ -0,0 +1,21 @@ +#!/bin/bash +# run as root + +function action { + # check if music is playing + mpc | grep playing + status=$? + #if YES + if [ "$status" == 0 ]; then + mpc volume -10 + #if NO + else + mpc play + fi +} + +for((;;)) +do + gpiomon --bias pull-down -s -n 1 -r 0 113 && action + sleep 0.7 +done