Prev: Music server
Next: Firefox 3.6.3 changed tab behavior
From: J G Miller on 16 Apr 2010 13:13 Op Vrijdag, 16 April, 2010 18:20:09h +0200, Houghi schreef: > 1) Is /dev/video0 busy or not. Surely you want to use fuser? For example: > fuser /dev/snd/controlC0 /dev/snd/controlC0: 4255 -----------------------------------<snip>-------------------------- #! /bin/sh device="/dev/video0" pid="`fuser ${device} 2>&1 | sed -e 's|'"${device}"':[ ]*||'`" if [ -z "${pid}" ] then echo "system device ${device} is not busy" ... whatever else you want to do else echo "system device ${device} is busy and is being used by process ${pid}" ... whatever else you want to do fi exit 0 --------------------------------------<snip>--------------------------------------- Note that in the sed expression in the [] there should be a <SPACE> and a <TAB> to mop up any white space.
From: Malcolm on 16 Apr 2010 13:15 On Fri, 16 Apr 2010 18:20:09 +0200 houghi <houghi(a)houghi.org.invalid> wrote: > I am trying to work out the following and get it into a parameter in > bash: > 1) Is /dev/video0 busy or not. > I get the following: > houghi(a)penne : head -n 1 /dev/video0 > head: error reading `/dev/video0': Device or resource busy > > How can I get that error message in a variable? Hi You could just use stderr (Device or resource busy) error number 16 as an exit code? -- Cheers Malcolm ��� (Linux Counter #276890) SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 2.6.27.45-0.1-default up 1 day 4:54, 4 users, load average: 2.21, 0.91, 0.50 GPU GeForce 8600 GTS Silent - CUDA Driver Version: 195.36.15
From: J G Miller on 16 Apr 2010 15:16 Op Vrijdag, 16 April, 2010 20:47:57 +0200, Houghi schreef: > so only the ability to see what MPlayer is playing as movie Assuming it is a file, you could get this from the command line argument if it was invoked as "mplayer filename" cat /proc/${mplayer_pid}/cmdline See now why having the PID of the process keeping /dev/video0 busy might be a good thing to have in your script? Or you could do a lsof | egrep mplayer and eliminate all the shared libraries etc and what is left will be the file which it is playing. If your media files are always under a particular directory, then that would be more direct with lsof | egrep mplayer | egrep path_to_media_files > The frequency is not 100% correct as it always ends with .25000 Chop it off with cut or sed.
From: JT on 19 Apr 2010 03:51 On 16/04/10 22:16, houghi wrote: > J G Miller wrote: > >> Assuming it is a file, you could get this from the command line >> argument if it was invoked as "mplayer filename" >> >> cat /proc/${mplayer_pid}/cmdline >> > That won't work as I will start it with `mplayer /dev/video0` and then > open a movie. However /proc/${mplayer_pid}/fd will have the file in > question. > > >> See now why having the PID of the process keeping /dev/video0 >> busy might be a good thing to have in your script? >> > For /dev/video0 the PID is not importand. Either it is used, or it > isn't. Retrieving the PID does not mean anything. > > >> Or you could do a lsof | egrep mplayer and eliminate >> all the shared libraries etc and what is left will be the file >> which it is playing. If your media files are always under >> a particular directory, then that would be more direct with >> >> lsof | egrep mplayer | egrep path_to_media_files >> > No, they are not in one specific directory. > I got it working with: > basename `lsof |grep ^gmplayer|grep REG|grep 10u|awk '{print $NF}'` > > However doing some tests it is clear that this is useless information. > If I get: A_BRIDGE_TO_FAR_D1245_VAM_03.avi it does not mean anything. > > Sure, the name of the movie is clear, but not that it is one of the > extra's. So the only thing I could do is make a database with all the > files, look up with the file (including the directory) if I can find it > and then retrieve the apropriate inforamtion. > > Way too much work. Thanks anyway. > > houghi > Good work, maybe 'dbus' or the like might help to query mplayer for more info? -- Kind regards, JT
From: JT on 19 Apr 2010 11:08 On 19/04/10 15:32, houghi wrote: > JT wrote: > >> Good work, maybe 'dbus' or the like might help to query mplayer for more >> info? >> > Could be, but I have no idea where to start. And all that a search has > brought up with dbus is gnome-mplayer, which I do not have. > > I looked with qdbusviewer and found nothing that looked like mplayer. > > houghi > 't Was only an idea, sorry to put you on the wrong track. Dbus doesn't show mplayer here either, hadn't checked that. I tried 'lsof', which does give a listing of all open files by process when using 'lsof -p <pid-of-your-player>'. Maybe that helps? -- Kind regards, JT
|
Pages: 1 Prev: Music server Next: Firefox 3.6.3 changed tab behavior |