Possible to rename window titles?

Associate
Joined
17 Oct 2002
Posts
2,169
Location
London
At the moment I'm watching the various streams provided by BP of their ROVs working on the Deepwater Horizon site. I have 10 of them opened using vlc and a simple script.

Code:
cvlc http://mfile.akamai.com/97892/live/reflector:44287.asx?bkup=44668 &
cvlc http://mfile.akamai.com/97892/live/reflector:44838.asx?bkup=45135 &
...

This works fine but none of the windows have useful labels and I can't work out which stream is which.

titlesc.jpg


As shown in the above image is there any way grab hold of the window and rename it from "VLC (X11 output)" to "Viking 1" or "Skandi 2" etc.

I'm using Ubuntu Jaunty with Compiz disabled.

Ok, I've found I can rename an existing window using wmctrl
Code:
wmctrl -r <window name> -T <new name>

wmctrl -r "VLC" -T "ROV - name"

But the windows can take a couple to a dozen or more seconds to appear depending how long the stream takes to start. They don't appear at all if the stream is currently down which makes the above approach tricky when trying to open lots of windows with identical names in parallel.

Is there a way to inject a name when executing the cvlc command?
 
Can you not just write a script to launch each stream individually setting the titles as it goes along?

I'd create a file with all the web links in it, one per line and a window title, seperated by a comma, so for example:

streams.txt:
http://mfile.akamai.com/97892/live/reflector:44287.asx?bkup=44668,stream1
http://mfile.akamai.com/97892/live/reflector:44838.asx?bkup=45135,stream2

Then a script to read each line and call vlc and set the window title before moving onto the next one.

I just tested this briefly with random stuff in streams.txt:

Code:
me@mediaserver:~$ cat streams.txt
test,name1
test2,name2

And the following script:

Code:
#!/bin/bash

cat streams.txt | while IFS=, read STREAM NAME
do
cvlc "$STREAM" &
wmctrl -r "VLC" -T "$NAME"
done

wmctrl -l shows:

Code:
0x0320000f  0 mediaserver name1
0x03a0000f  0 mediaserver name2


This should scale to as many windows as you need, it just needs you to maintain the streams.txt file.

Let me know how you get on...?
 
Last edited:
Actually, you can do everything you want using cvlc alone - there are parameters for labelling the window (--video-title), as well as positioning it. Here's the script I've been using to display the complete 12-camera "wall" including labels, hopefully with enough comments to explain what I think I'm doing. Note that rather than having a fixed list of cameras with their ip addresses, I'm using BP's web page (defined as the variable "camList") for the primary links to the 12 cameras, and following those links to where I can get the actual mms: video server link to give to cvlc:

Code:
[FONT="Fixedsys"]#!/bin/bash

camList="http://www.bp.com/genericarticle.do?categoryId=9033572&contentId=7062605"

declare -a CAMS
declare -a NAMES
declare -a LINKS
declare -i i
declare -i horiz
declare -i vert

# Routine to fetch BP's camera list
# Result left in the variable CAMS
getBpList() {
# Fetch the page from BP
CAMS=`curl -s $camList | grep STAGING | sed -ne 's@^.*\(http.*html\).*$@\1@p'`
}

# Routine to extract the camera names from CAMS
# Result left in the variable NAMES
getNames() {
i=0
 for cam in $CAMS; do
   NAMES[$i]=`echo $cam | sed -ne 's@^.*html/\(.*\)\.html.*$@\1@p'`
   i+=1
 done
}

# Routine to go through the camera list and get the actual address of
# the mms stream server.  This takes two different fetches from the web
# Result left in the variable LINKS
getLinks() {
 # For each camera found on BP's camera page
 for cam in $CAMS; do
   # Get the web address they ask windows to go to for MediaPlayer
   link=`curl -s $cam | grep embed | sed -ne 's@^.*src="\(http://mfile.*asx\).*$@\1@p'`
   # Now use that address to find the address of the mms server that will be
   # embedded
   LINKS="$LINKS `curl -s $link | grep HREF | sed -ne 's@^.*HREF=\"\(mms:.*tor:[0-9]*\).*$@\1@p'`"
 done
}

###################################################################
#  Here's the meat
getBpList       # Get camera links from BP
getNames      # Put their names into an array
getLinks        # Get the addresses of the mms servers

i=0
horiz=0
vert=40
for link in $LINKS; do
 cvlc --width 320 --height 240 --video-x $horiz --video-y $vert --video-title="${NAMES[$i]}" $link > /dev/null 2>&1 &
 horiz+=327
 if [ $horiz -ge 1280 ]; then
   horiz=0
   vert+=266
 fi
 i+=1
done[/FONT]
 
Back
Top Bottom