• The forum software that supports hummy.tv will be upgraded to XenForo 2.3 on Wednesday the 20th of November 2024 starting at 7pm

    There will be some periods where the forum is unavailable, please bear with us. More details can be found in the upgrade thread.

Detecting time-shift usage

/df

Well-Known Member
Here's an algorithm that may be useful to detect what the system is doing based on usage of the time-shift index file 0.nts. I couldn't see that this was being used but quite possibly it's old news that I've missed.

The idea is that the humaxtv process only uses the index file when broadcast TV is being shown on-screen, either live or in time-shift, as follows:
  • if it has the index file open for read and write, it's showing live TV;
  • if it has the index file open for read (twice) and write, it's showing time-shift (maybe under Menu, or screensaver, but not Portal home, as starting the Portal cancels time-shift);
  • if it's not using the file, the system is showing something else: a Portal app or playing media, or screensaver;
  • other results haven't been seen in not very extensive testing.
This example Jim code for the CF, which may be plundered at will, shows the idea in action.
Code:
#!/mod/bin/jimsh

source /mod/webif/lib/setup

proc {system tsrdir} {} {
    return [file normalize [file join "/mod/.." [expr {[system model] == "HDR" ? "Tsr" : ".tsr" }]]]
}

proc showTsrStatus {} {{notOpen "lsof: no file use located:"}} {
    if {! [catch {exec lsof -V -Ff -c humaxtv -a [file join [system tsrdir] "0.nts"] 2>@1} out]} {
        switch [llength [split $out "\n"]] {
        3 { # process, r+w FDs
        puts "Watching live or Portal home\n"}
        4 { # process, r+r+w FDs -- opening Portal cancels time-shift pause/play
        puts "Time-shift pause or play\n"}
        default {puts "Weirdly: $out"}
        }
    } elseif {[string equal -length [string length $notOpen] $out $notOpen]} {
        # index file not in use
        puts "Playing media or in Portal app\n"
    } else {
        # weirdly #2
        puts "Weirdly, lsof failed:  $out"
    }
}
 
Last edited:
Back
Top