You are not logged in.

#1 2006-10-28 02:45:07

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Bash: XMMS InfoPipe Grabber

Just a  little script I am working on to grab information from InfoPipe within bash. Yes, I know theres a perl script which is probably better than my little bash script, but I figure, why use python, when simple bash can do it faster tongue. I am mainly writing this for my conky section that grabs my xmms info tongue

#!/bin/bash

#Xmms InfoPipe grabber v0.1
#twiistedkaos <twiistedkaos>

pipe='/tmp/xmms-info_'$USER'.0'

case "$1" in
    title|Title)
        cat $pipe | grep -m 1 -w -a "Title:" | cut -d":" -f2
        ;;
    time|Time)
        cat $pipe | grep -m 1 -w -a "Time:" | cut -d" " -f2
        ;;
    tunes|Tunes)
        cat $pipe | grep -m 1 -w -a "Tunes in playlist:" | cut -d":" -f2
        ;;
    current-tune|Current-Tune)
        cat $pipe | grep -m 1 -w -a "Currently playing:" | cut -d":" -f2
        ;;
    position|Position)
        cat $pipe | grep -m 1 -w -a "Position:" | cut -d" " -f3
        ;;
    xmms|XMMS)
        cat $pipe | grep -m 1 -w -a "XMMS protocol version:" | cut -d":" -f2
        ;;
    InfoPipe|infopipe)
        cat $pipe | grep -m 1 -w -a "InfoPipe Plugin version:" | cut -d":" -f2
        ;;
    status|Status)
        cat $pipe | grep -m 1 -w -a "Status:" | cut -d ":" -f2
        ;;
esac

If anyone has any improvement ideas, please be sure to let me know smile

Offline

#2 2006-10-28 04:16:35

byte
Member
From: Düsseldorf (DE)
Registered: 2006-05-01
Posts: 2,046

Re: Bash: XMMS InfoPipe Grabber

Just some cosmetics: use 'grep ... $pipe | cut ...' instead of 'cat $pipe | grep ... | cut ...'


1000

Offline

#3 2006-10-28 13:49:43

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: Bash: XMMS InfoPipe Grabber

perl != python. python would be faster than bash.

you're spawning a lot of processes in that script, which would slow it down a lot.

Offline

#4 2006-10-28 18:11:45

twiistedkaos
Member
Registered: 2006-05-20
Posts: 666

Re: Bash: XMMS InfoPipe Grabber

iphitus wrote:

perl != python. python would be faster than bash.

you're spawning a lot of processes in that script, which would slow it down a lot.

Hehe indeed, but Bash was easier at the time. I am currently re-writting it in python tongue

Offline

Board footer

Powered by FluxBB