file seach from pulseaudio module list


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting file seach from pulseaudio module list
# 1  
Old 09-21-2012
file seach from pulseaudio module list

Hi Guys,I admit my knowledge in this area is awful, Smilie
I'm trying to get the alsa card number from within the text
returned by running
pactl list cards
Alsa card numbers from running aplay -l and above do not match.
I'm attempting to get a match on the PA card list with the type of sound card, and then once the card is found by matching "alsa.card ="n", where n is the card number with the alsa card number from aplay -l, which I have stored as a variable .
Then when the PA card is identified to get the module number.

The first few lines returned by "pactl list cards" are:-
Card #0
Name: alsa_card.pci-0000_00_1b.0
Driver: module-alsa-card.c
Owner Module: 4
Properties:
alsa.card = "0"

If it was all on the same line I could use grep, but I'm a bit stuck.

Could someone suggest a way of doing this and point me in the right direction please.

The end action from this is to unload a pulseaudio module, so there is no contention when running another app.

Thanks
Richard

---------- Post updated at 03:54 PM ---------- Previous update was at 03:21 PM ----------

Why is it when you ask for help, an alternative way is found !!
By using "pactl list short modules"
each module info is space delimited, which allows grep to be used,

ie
$ pactl list short modules|grep 'device_id'
4 module-alsa-card device_id="0" name="pci-0000_00_1b.0" card_name="alsa_card.pci-0000_00_1b.0" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes card_properties="module-udev-detect.discovered=1"

The wanted is the "4" at the start of the line .So awk can be piped to to get it.

On this laptop there is only one sound card, on the other there are four.

---------- Post updated at 04:19 PM ---------- Previous update was at 03:54 PM ----------

Sorry a bit more and I'm stuck again.
running
[richard@g8jvm ~]$ pactl list short modules|grep device_id= |awk '{print $1}'
4
5
6
7
this returns the four module IDs OK
BUT

running
pactl list short modules | grep device_id="0"|awk '{print $1}'

returns nothing, the correct value would be "4"

I'd like to replace the "0" with the variable $Hw, which is the
Alsa card number.

Not sure how to do this. any help appreciated
TIA
# 2  
Old 09-22-2012
Please re-post the sample output of the command and required input with CODE-TAGS.
Its really hard to guess the actual output with the sample above.

Thanks.
# 3  
Old 09-22-2012
Hi thanks for the reply.
I've managed to get that bit functioning with
Code:
Card='device_id="'
# get the ALSA card number for M-Audio D66 card
         S1=`aplay -l|grep M66|grep -v grep |awk '{print $2}'| sed 's/\:$//'`

device=$Card$S1                         
 echo "ALSA Card Number=" $S1
 mod=`pactl list short modules| grep $device |awk '{print $1}'`
 echo "Pulseaudio Module =" $mod        
pactl unload-module $mod                
 echo "Module" $mod " has been unloaded"

That works, but once run the next time the module isn't there and $mod is returned with a null value.

maybe if I add before the
Code:
pactl unload-module $mod

something like
Code:
if  [ !  $mod == 0 ] ; then pactl unload-module $mod
    echo " Module unloaded"
  else
    echo " no module to unload"
fi

That would do the job BUT
it doesn't like the "else" statement, and I'm still learning.

Thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Seach for a string following a particular string in a file

All, I have a file like ; ... covers bhjl; ... khkjhk.. covers vjgj; .. bvjhy.. bkhk.. covers bjhk; Now I want to search all strings that follows covers and then write them in a new file. I want to use perl script for that. Output file should conatian: bhjl vjgj bjhk Regards... (8 Replies)
Discussion started by: Anamika08
8 Replies

2. UNIX for Dummies Questions & Answers

How do I list kernel module parameter values?

Hi, I have problem with parameter configuration. My question is after the configuration, how to check if successfully change the value or not? I saw someone has the same question, and followed his steps. Original thread:... (3 Replies)
Discussion started by: skybb
3 Replies

3. UNIX for Dummies Questions & Answers

Seach and Replace

Our email address is changing and I need to update 4000 htm pages. I was told I command was something like this Eg) find docs/700_799/ -name "*.htm" -type f | xargs perl -pi -e 's/\/company-information\/legal-and-regulatory/\/legal-and-regulatory/g' Is there away of not changing the date... (1 Reply)
Discussion started by: mchelle_99
1 Replies

4. Linux

How to convert Linux Kernel built-in module into a loadable module

Hi all, I am working on USB data monitoring on Fedora Core 9. Kernel 2.6.25 has a built-in module (the one that isn't loadable, but compiles and links statically with the kernel during compilation) to snoop USB data. It is in <kernel_source_code>/drivers/usb/mon/. I need to know if I can... (0 Replies)
Discussion started by: anitemp
0 Replies

5. Shell Programming and Scripting

Seach for Record

Below is an example of a file with some records... each record start with P1 till the next P1. If I search for something like "4,4545:" then I want all the records with "4,4545:" to be removed from original file and copied to a temp file. P1 1,123455654444 2,7126817361873 3,2134128282828... (5 Replies)
Discussion started by: xtravel
5 Replies
Login or Register to Ask a Question