terminal bash command question, how to monitor grep and repeat command infinitely?

Discussion in 'PC Hardware, Software and Displays' started by orangpelupa, Nov 11, 2021.

  1. orangpelupa

    orangpelupa Elite Bug Hunter
    Legend Veteran

    Joined:
    Oct 14, 2008
    Messages:
    10,109
    Likes Received:
    2,989
    so the context:

    I want to make a bash terminal command that will launch VLC to stream a video, and then when VLC is no longer in the foreground (VLC automatically goes to the background when the stream is interrupted too long), it will repeat the command to launch VLC to stream again.

    I got the working separate command codes, but I don't have any idea how to make these work into one command that keeps repeating.

    1. To launch VLC and starts streaming:
    Code:
    am start -a android.intent.action.VIEW -d rtsp://theurl
    This will launch/bring to the foreground the default app for RTSP (in this case, VLC) and starts streaming.

    2. To check whether VLC is still in the foreground or not
    Code:
    dumpsys activity activities | sed -e '/mResumedActivity/!d' -e '/vlc/!d'
    This will return something like this when VLC is in the foreground.

    Code:
     mResumedActivity: ActivityRecord{b43545d u0 org.videolan.vlc/.gui.video.VideoPlayerActivity t11827}
    and will return nothing in the terminal if VLC is not in the foreground.

    so maybe the code will be doing something like this?

    every 1 second, check for VLC is in the foreground or not (using code number 2). If VLC is not in the foreground, launch vlc with the streaming URL (using code number 1).

    i posted this question here too https://superuser.com/questions/168...peated-after-an-activity-no-longer-foreground
     
  2. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    17,658
    Likes Received:
    5,074
    Why not use a program ?
    back in the dial up days BT would auto disconnect you every 2 hours (you were allowed to reconnect, it was just to stop people leaving it connected 24/7)
    this was no good if you wanted to download something overnight so I used a program that every 2 hours 1 minute would click on the reconnect button.
    cant remember what it was called it had 2 methods of clicking on the button the fist was just an X/Y co ordinate system the other was by detecting the identifier of the control and sending windows the correct api message.
    try one of these
    https://push-the-freakin-button.en.softonic.com
    https://windowsreport.com/software-automate-mouse-clicks/

    ps: is this just because your too lazy to click on vlc ?
     
    #2 Davros, Nov 11, 2021
    Last edited: Nov 11, 2021
  3. orangpelupa

    orangpelupa Elite Bug Hunter
    Legend Veteran

    Joined:
    Oct 14, 2008
    Messages:
    10,109
    Likes Received:
    2,989
    The vlc will be running unattended. Thus I need it to auto recover when the stream gets interrupted.

    Anyway I've found a string of commands that works on the superuser post I linked above. Someone also replied with a supposedly better command but I hadn't get the chance to try whether it work or not.
     
  4. Davros

    Legend

    Joined:
    Jun 7, 2004
    Messages:
    17,658
    Likes Received:
    5,074
    vlc is also open source so if you can program you can fix it yourself
     
Loading...

Share This Page

  • About Us

    Beyond3D has been around for over a decade and prides itself on being the best place on the web for in-depth, technically-driven discussion and analysis of 3D graphics hardware. If you love pixels and transistors, you've come to the right place!

    Beyond3D is proudly published by GPU Tools Ltd.
Loading...