Restart audio after waking from suspend

  • mglae I'm sorry but I don't fully understand your question. Are you saying I might be running 2 scripts ? I never did erase the one you helped me with back in Dec 2019. It worked for a short time then stopped working. ghtester helped me on this thread to get it working again. I don't know if both scripts or just 1 is working.

    I don't know my way around the SSH Console using Putty that well, so you'll need to explain in step by step fashion.

  • You may be running the same script twice.

    In post 24 kodiresume.service was introduced starting 99-toggle_rate.power too. In addition the script is started if the old mechanism is still working.

    You can test with (use your favorite delay):

    Bash
    #!/bin/sh
    case "$1" in
       post)
         echo Power_script
         sleep 5
         xrandr -display :0 --output HDMI1 --mode 1920x1080 --rate 59.94
         sleep 5
         xrandr -display :0 --output HDMI1 --mode 1920x1080 --rate 60
         ;;
    esac

    and test with journalctl|grep Power_script after suspend/resume.

  • Exactly what does "journalctl|grep Power_script" do ?

    Am I supposed to run that command after suspend/resume in the SSH console using Putty ? What results am I to expect ?

    How do I know if I am running the script twice ?

  • The output of services is logged into the journal.

    journalctl is printing the log. grep is looking for a string. With echo Power_script an unique string is logged every time the script is executed.

    When running the command after resume the number of lines found count how often the script was executed.

  • login as: root

    [email protected]'s password:

    ##############################################

    # LibreELEC #

    # LibreELEC – Just enough OS for KODI #

    ##############################################

    LibreELEC (official): 9.95.2 (Generic.x86_64)

    LibreELEC:~ # journalctl|grep Power_script

    LibreELEC:~ # echo Power_script

    Power_script

    LibreELEC:~ # ^C

    LibreELEC:~ # journalctl|grep Power_script

    LibreELEC:~ # ^C

    LibreELEC:~ # echo Power_script

    Power_script

    LibreELEC:~ # journalctl|grep Power_script

    LibreELEC:~ #

    I'm not sure if I did it correctly, so I ran it a few times. I don't see any result.

    Edit: I just realized that I didn't add echo Power_script as stated in post #38

    Oh well - even if I am running the script twice, it's working now every time.

    Edited once, last by blueribb (May 6, 2021 at 4:35 PM).

  • OK - so I ran journalctl and the complete log was shown. I typed "q" to exit the log. I still don't know if the script is running twice or not. I'm afraid this stuff is just beyond my comprehension. Thanks for the help but I'm afraid I don't understand most of what your are offering.

    Without step by step instructions, I'm lost most of the time.

  • Thought you got it in post 41.

    1. Insert echo Power_script into script.
    2. Suspend/resume
    3. Execute journalctl|grep Power_script. The number of lines seen is the number how often the script was executed.
  • LibreELEC (official): 9.95.2 (Generic.x86_64)

    LibreELEC:~ # journalctl|grep Power_script

    May 06 17:50:23 LibreELEC systemd-sleep[26925]: Power_script

    May 06 17:50:27 LibreELEC sh[26937]: Power_script

    LibreELEC:~ #

    It looks like there are 2 lines. The first line contains a 4 second delay (2 X 2sec), right ?

    Can I delete the bottom one ?

    How ?

  • The delay is 2+2s sec from the script. IMO you can reduce the second sleep, but test it. The sleep command even accepts delays below one second like sleep 0.5.

    To disable the additional service of post 24:

    Code
    systemctl disable kodiresume.service
  • I am having this exact problem. Is there any consensus on what causes it?

    I can only guess, but maybe the developers would know more. The HDMI "handshake" or "Driver Initialization" may vary from a cold boot, reboot or waking from resume.