&input_idle is now overriden by &mplayer_running.
authorlace <>
Fri, 29 Dec 2006 09:04:19 +0000 (09:04 +0000)
committerlace <>
Fri, 29 Dec 2006 09:04:19 +0000 (09:04 +0000)
bin/fup

diff --git a/bin/fup b/bin/fup
index 05f5d06..cdc8c50 100755 (executable)
--- a/bin/fup
+++ b/bin/fup
@@ -159,6 +159,32 @@ sub input_idle()
        return $time_diff>$INPUT_IDLE;
 }
 
+sub mplayer_running()
+{
+       local *F;
+       open F,"/proc/net/unix" or die;
+       my %unix;
+       <F>;
+       while (<F>) {
+               /^(?:\S+\s+){6}(\d+)\s/ or die;
+               $unix{$1}=1;
+               }
+       close F or die;
+
+       local $_;
+       while (</proc/*/exe>) {
+               (my $fdname=$_)=~s{/exe$}{/fd};
+               $_=readlink or next;
+               m{/mplayer$} or next;
+               while (<$fdname/*>) {
+                       $_=readlink or next;
+                       my $inode=/^\Qsocket:[\E(\d+)\Q]\E$/ or next;
+                       return 1 if $unix{$1};
+                       }
+               }
+       return;
+}
+
 for (;;) {
        local *F;
        open F,"/proc/net/dev" or die;
@@ -171,15 +197,18 @@ for (;;) {
                $on_now=0 if ($rx-$rx_last) > $RX_THRESHOLD;
                $on_now=0 if ($tx-$tx_last) > $TX_THRESHOLD;
                }
-       $on_now=1 if my $input_idle=input_idle();
+       my $input_idle=input_idle();
+       my $mplayer_running=mplayer_running() if $input_idle;
+       $on_now=1 if $input_idle && !$mplayer_running;
        $rx_last=$rx;
        $tx_last=$tx;
        push @history,$on_now;
        my $print=$on_now;
        $print=($on_now ? "." : "v") if $input_idle;
+       $print="M" if $mplayer_running;
        $print="*" if $ignore_read;
        print($print);
-       history(1,($input_idle ? 0 : $STABILIZE_ON));
+       history(1,($input_idle && !$mplayer_running ? 0 : $STABILIZE_ON));
        history(0,$STABILIZE_OFF);
        $ignore_read=$ignore_write;
        $ignore_write=0;