Restart audio after waking from suspend

  • I'm sorry but I have no idea how to exit the nano editor. The green cursor is now at the end of:

    File Name to Write: /storage/.coinfig/sleep.d/99-toggle_rate.power <cursor here

  • That worked. I opened the file again to check and the changes were there. ☺

    I turned off (suspend) my Intel NUC and turned it back on but NO AUDIO

    Oh well - back to the drawing board

    Thanks for the help

  • Yes, I did that. Still no audio until I manually toggle the refresh rate. Maybe something else in the script is outdated or need a tweak.

    Note: If I'm watching TV and switch to Libreelec, then audio is always working.

  • Perhaps you could try this from SSH console:

    1) make sure your current script is executable:

    Code
    chmod +x /storage/.config/sleep.d/99-toggle_rate.power

    2) test after resume from suspend if your script works:

    Code
    /storage/.config/sleep.d/99-toggle_rate.power post

    3) if it works as expected, create the service which should run your script after resume from suspend:

    4) enable the service and test if it works:

    Code
    cd /storage/.config/system.d/
    systemctl enable kodiresume.service

    I am not sure if it's error free but can't test it in my (different) environment completely. So it's up to you.

  • Can I cut and paste #3 & 4 or does each line get entered separately ?


    I ran #1 and 2 and got this:

    warning: output HDMI-1 not found, ignoring

    warning: output HDMI-1 not found, ignoring

    Should I change it back to HDMI1 ?

    Edited 2 times, last by blueribb: Merged a post created by blueribb into this post. (May 3, 2021 at 12:15 AM).

  • I just ran this and it worked:

    Code

    Code
    xrandr -display :0 --output HDMI1 --mode 1920x1080 --rate 59.94
    xrandr -display :0 --output HDMI1 --mode 1920x1080 --rate 60
  • OK, so edit the /storage/.config/sleep.d/99-toggle_rate.power script to it's original form ( to have HDMI1 there) and continue with steps 3 - 4, each block separately (select all lines in each block 3 - 4) copy & paste to SSH console.

    Edited once, last by ghtester (May 3, 2021 at 12:28 AM).

  • OK - I ran #3 and then #4

    Here's the response from #4:

    Created symlink /storage/.config/system.d/suspend.target.wants/kodiresume.servic

    e - /storage/.config/system.d/kodiresume.service.

    Is that the correct response ?

  • I think so.

    Then test with suspend / resume.

    In every case, this must work when run manually (to restore audio after resume):

    /storage/.config/sleep.d/99-toggle_rate.power post

  • Update: I turned on my Intel NUC tonight and NO AUDIO. I ran the script mentioned in post #29 and the screen blinked and the audio returned. I wonder why the script didn't work when I fired up the NUC from resume ? Is it possible to add a delay to the script - maybe 5 seconds or more ?

    If not, is it possible to run this script with a button on my remote ? (Harmony 665)

  • Yes, try to edit the script to this form:

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

    It's also possible to run the script by Remote Control but it needs some more configuration.

    At first, try to run the irw command in SSH console, then push your favorite button(s) on Remote Control and put a response(s) here (if any).

    Exit from irw by pushing CTRL+C.

    In case there were no responses, the preferred key needs to be mapped first so it would need even more tasks to do... Then try to run this command and put a response here: cat /storage/.config/rc_maps.cfg

    Let me know results and then I could tell you more.

    Edited 10 times, last by ghtester (May 4, 2021 at 5:35 AM).

  • I added the 5 + 5 second delay using nano and saved it. I tested it this morning. It came on with no sound and then the screen blinked and sound was there ☺

    If this continues to work, I may experiment with smaller delays.

    Thanks again for the help. I'll update this thread if necessary.

  • blueribb Are you only using /storage/.config/sleep.d/99-toggle_rate.power or is the service still installed?

    If yes, it is possible the script is twice. You can verify this by adding a echo Power_script and checking with journalctl|grep Power_script afterwaers.