Skip to content

Instantly share code, notes, and snippets.

@Naedri
Last active February 1, 2023 22:49
Show Gist options
  • Save Naedri/5fffc83b84b1ce1fbde27eae108404b0 to your computer and use it in GitHub Desktop.
Save Naedri/5fffc83b84b1ce1fbde27eae108404b0 to your computer and use it in GitHub Desktop.

Revisions

  1. Naedri revised this gist Feb 1, 2023. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions alarm.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,8 @@
    #!/bin/bash

    # To lock session if needed
    # loginctl lock-session

    echo && date
    echo 'Starting alarm.sh'

  2. Naedri revised this gist Feb 1, 2023. 3 changed files with 16 additions and 16 deletions.
    6 changes: 3 additions & 3 deletions alarm_trigger.sh → alarm.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    echo && date
    echo 'Starting alarm_trigger.sh'
    echo 'Starting alarm.sh'

    SOUND_PERCENT=150
    SOUND_FREQUENCY=1000
    @@ -16,7 +16,7 @@ pactl set-sink-volume $DEFAULT_SINK $SOUND_PERCENT%
    trap printout SIGINT
    printout() {
    echo ""
    echo "$count loop(s) have been necessary."
    echo "Alarm has stopped after $count loop(s)."
    exit
    }
    while :
    @@ -28,4 +28,4 @@ pactl set-sink-volume $DEFAULT_SINK $SOUND_PERCENT%
    )

    echo && date
    echo "Finishing alarm_trigger.sh"
    echo "Finishing alarm.sh"
    13 changes: 0 additions & 13 deletions alarm_stop.sh
    Original file line number Diff line number Diff line change
    @@ -1,13 +0,0 @@
    #!/bin/bash

    echo && date
    echo 'Starting alarm_stop.sh'

    for pid in $(ps aux | grep "alarm_trigger.sh" | awk '{print $2}'); do kill -9 $pid; done

    sleep 1s

    for pid in $(ps aux | grep "speaker-test" | awk '{print $2}'); do kill -9 $pid; done

    echo && date
    echo "Finishing alarm_stop.sh"
    13 changes: 13 additions & 0 deletions stop.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/bash

    echo && date
    echo 'Starting stop.sh'

    for pid in $(ps aux | grep "alarm.sh" | awk '{print $2}'); do kill -9 $pid; done

    sleep 1s

    for pid in $(ps aux | grep "speaker-test" | awk '{print $2}'); do kill -9 $pid; done

    echo && date
    echo "Finishing stop.sh"
  3. Naedri revised this gist Feb 1, 2023. 2 changed files with 15 additions and 2 deletions.
    13 changes: 13 additions & 0 deletions alarm_stop.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/bash

    echo && date
    echo 'Starting alarm_stop.sh'

    for pid in $(ps aux | grep "alarm_trigger.sh" | awk '{print $2}'); do kill -9 $pid; done

    sleep 1s

    for pid in $(ps aux | grep "speaker-test" | awk '{print $2}'); do kill -9 $pid; done

    echo && date
    echo "Finishing alarm_stop.sh"
    4 changes: 2 additions & 2 deletions alarm.sh → alarm_trigger.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #!/bin/bash

    echo && date
    echo 'Starting alarm.sh'
    echo 'Starting alarm_trigger.sh'

    SOUND_PERCENT=150
    SOUND_FREQUENCY=1000
    @@ -28,4 +28,4 @@ pactl set-sink-volume $DEFAULT_SINK $SOUND_PERCENT%
    )

    echo && date
    echo "Finishing alarm.sh"
    echo "Finishing alarm_trigger.sh"
  4. Naedri revised this gist Feb 1, 2023. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions alarm.sh
    Original file line number Diff line number Diff line change
    @@ -1,13 +1,9 @@
    #!/bin/bash

    # https://doc.ubuntu-fr.org/tutoriel/script_shell
    # https://doc.ubuntu-fr.org/projets/ecole/scripting/initiation_au_shell
    # https://stackoverflow.com/questions/46816904/bash-break-out-of-loop-with-ctrl-c-but-continue-with-script

    echo && date
    echo 'Starting alarm.sh'

    SOUND_PERCENT=20
    SOUND_PERCENT=150
    SOUND_FREQUENCY=1000
    SOUND_DURATION=0.4s
    SOUND_PAUSE=0.1s
    @@ -19,6 +15,7 @@ pactl set-sink-volume $DEFAULT_SINK $SOUND_PERCENT%
    (
    trap printout SIGINT
    printout() {
    echo ""
    echo "$count loop(s) have been necessary."
    exit
    }
  5. Naedri created this gist Feb 1, 2023.
    34 changes: 34 additions & 0 deletions alarm.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    #!/bin/bash

    # https://doc.ubuntu-fr.org/tutoriel/script_shell
    # https://doc.ubuntu-fr.org/projets/ecole/scripting/initiation_au_shell
    # https://stackoverflow.com/questions/46816904/bash-break-out-of-loop-with-ctrl-c-but-continue-with-script

    echo && date
    echo 'Starting alarm.sh'

    SOUND_PERCENT=20
    SOUND_FREQUENCY=1000
    SOUND_DURATION=0.4s
    SOUND_PAUSE=0.1s

    DEFAULT_SINK=`pactl get-default-sink`
    pactl set-sink-mute $DEFAULT_SINK 0
    pactl set-sink-volume $DEFAULT_SINK $SOUND_PERCENT%

    (
    trap printout SIGINT
    printout() {
    echo "$count loop(s) have been necessary."
    exit
    }
    while :
    do
    ((count++))
    speaker-test --frequency $SOUND_FREQUENCY --test sine & sleep $SOUND_DURATION && kill -9 $!
    sleep $SOUND_PAUSE
    done
    )

    echo && date
    echo "Finishing alarm.sh"