5

Is there an app to mute the computer say 10PM to 7:30AM? (On Android devices I use: phone silencer app )

gertvdijk
  • 67,947
  • 2
    We do that from command line. See this duplicate: http://askubuntu.com/questions/26068/how-do-you-mute-from-the-command-line All you need to do is toss the command in /etc/crontab with a time stamp. – Rinzwind Jan 02 '13 at 19:50
  • I don't think that's a close enough dupe. OP needs help scripting this. – Tom Brossman Jan 02 '13 at 21:04

1 Answers1

6

Following the link in the comments of @Rinzwind: How do you mute from the command line?

Use crontab to mute and unmute the computer at night as follows:

Open a terminal by pressing Ctrl+Alt+T and enter one of the the following lines to edit the /etc/cron.d file:

For a regular user, use the following command:

crontab -e

For system-wide solution, use the following command:

sudo crontab -e

At the end of the resulting file add the following two lines:

00 22 * * * amixer set Master mute
29 07 * * * amixer set Master unmute

Press Ctrl+X and then Y to save and exit crontab.

Explanations:

Each line in crontab has five time-and-date fields, followed by a command, followed by a newline character ('\n'). The fields are separated by spaces. The five time-and-date fields cannot contain spaces. The five time-and-date fields are as follows:

  1. minute (0-59),
  2. hour (0-23, 0 = midnight),
  3. day (1-31),
  4. month (1-12),
  5. weekday (0-6, 0 = Sunday).

See the CronHowto in Ubuntu Help for more details.

Note: This will not work if the machine is off at the predefined time. For example, if power goes off at 9PM and comes back at 11PM, audio will not be muted when the power comes back.

Hope this helps

user68186
  • 33,360