Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Alternative phrasing: is there a commandline command to allow me to mute the speakers, and unmute them later. Ideally with the ability to fade-in. If I knew how to do that, I can work out how to tie it to a keyboard button. (I know my way around a bash script, but no very little about linux audio.)

The background to the question is that I'm often listening to internet radio (live or recorded) when the phone rings, so I hit mute on my keyboard. After the usually short call I get absorbed in my work and only realize 20 or 30 minutes later that everything is quiet and it has still been playing, but silently. So my idea is I'd hit the two minute mute button, then after two minutes it would come back; if I'm still on the phone I'll hit it again (or stop it properly).

It would also be perfect for when an annoying ad, trailer or traffic bulletin comes on :-)

UPDATE: The suggested answers worked perfectly. Here were how I wired it up to a special key on Ubuntu 10.04/Gnome:

  1. Created a file called /usr/local/bin/mute_for_120_seconds, with basically the below answer in it. Made executable.
  2. System | Preferences | Keyboard Shortcuts
  3. Click Add, Name: "mute_for_120_seconds", Command: "/usr/local/bin/mute_for_120_seconds"
  4. It appears under Custom Shortcuts. Click the shortcut column for it, then press the key combination I want to use.
  5. Close the keyboard shortcuts dialog and test the key.

(My dell notebook has a dedicated mute key. So, I've set AudioMute to be ctrl+XF86AudioMute, and then set my mute_for_120_seconds script to run with the mute key.)

Details: Ubuntu 10.04. Sound Preferences only tells me "Internal Audio, 1 Ouput/1 Input, Analog Stereo Duplex" Audacity's Help|audio Device Info has loads more to say, here is an extract:

==============================
Default capture device number: 8
Default playback device number: 8
==============================
...
==============================
Device ID: 8
Device name: ALSA: default
Input channels: 32
Output channels: 32
Low Input Latency: 0.011610
Low Output Latency: 0.011610
High Input Latency: 0.046440
High Output Latency: 0.046440
Supported Rates:
    8000
    9600
    11025
    12000
    15000
    16000
    22050
    24000
    32000
    44100
    48000
    88200
    96000
    192000
...
share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

amixer is a command-line mixer for the ALSA soundcard driver, this allows you to easily script muting:

!#/bin/sh
amixer set Master mute
sleep 120
amixer set Master unmute

This command-line mixer is available in the alsa-utils package.

share|improve this answer
1  
Now plug the phone line back into the modem that (you never uses any more since getting broadband) and configure it to trigger the mute function. –  Chris Nava Aug 24 '11 at 14:42
1  
Your next exercise is to do the fade out and fade in part. ;-) –  Keith Aug 25 '11 at 3:20
add comment

Here is another way:

amixer set Master mute 
echo amixer set Master unmute | at now + 2 minutes

Or better if you are using xmms2:

nyxmms2 pause
echo nyxmms2 play | at now + 2 minutes
share|improve this answer
    
Thanks, this also works. Thanks for the xmms info too. –  Darren Cook Aug 25 '11 at 2:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.