https://wiki.archlinux.org/api.php?action=feedcontributions&user=Popsch&feedformat=atomArchWiki - User contributions [en]2024-03-29T08:14:26ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Cron&diff=222665Cron2012-09-11T17:46:19Z<p>Popsch: used the proper markup for the link to lockrun</p>
<hr />
<div>[[Category:Daemons and system services]]<br />
[[de:Cron]]<br />
[[fr:Cron]]<br />
[[sk:Cron]]<br />
[[zh-CN:Cron]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of the standard task scheduling daemon on GNU/Linux systems.}}<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|Gentoo Linux Cron Guide|http://www.gentoo.org/doc/en/cron-guide.xml}}<br />
{{Article summary end}}<br />
{{Lowercase_title}}<br />
<br />
From [https://en.wikipedia.org/wiki/Cron Wikipedia]:<br />
<br />
'''''cron''' is the time-based job scheduler in Unix-like computer operating systems. cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration [...]''<br />
<br />
== Installation ==<br />
<br />
{{Pkg|cronie}} is installed by default as part of the '''base''' group. Other cron implementations exist if preferred, Gentoo's [http://www.gentoo.org/doc/en/cron-guide.xml Cron Guide] offers comparisons. For example, {{Pkg|fcron}}, {{AUR|bcron}} or {{AUR|vixie-cron}} offer a wider range of features and configuration options.<br />
<br />
{{Note|Until May 2011, the default cron implementation for Arch Linux was {{Pkg|dcron}} (Dillon's Cron), which is still supported and can be installed from the [[official repositories]].}}<br />
<br />
== Configuration ==<br />
<br />
=== Users & autostart ===<br />
<br />
cron should be working upon login on a new system to run root scripts. This can be check by looking at the log in {{ic|/var/log/}}. In order to use crontab application (editor for job entries), users must be members of a designated group {{ic|users}} or {{ic|root}}, of which all users should already be members. To ensure cron starts on boot, add the {{ic|crond}} daemon to the [[Daemon#Starting_on_Boot|daemons]] array of [[rc.conf]], or enable {{ic|cronie.service}} if using [[systemd]].<br />
<br />
=== Handling errors of jobs ===<br />
<br />
Errors can occur during execution of jobs. When this happens, cron registers the '''stderr''' output and attempts to send it as email to the user's spools via the {{ic|sendmail}} command.<br />
<br />
To log these messages use the {{ic|-M}} option in {{ic|/etc/conf.d/crond}} and write a script or install a rudimentary SMTP subsystem (e.g. {{Pkg|esmtp}}):<br />
<br />
# pacman -S esmtp procmail<br />
<br />
After installation configure the routing:<br />
{{hc|/etc/esmtprc|<br />
identity ''myself''@myisp.com<br />
hostname mail.myisp.com:25<br />
username ''"myself"''<br />
password ''"secret"''<br />
starttls enabled<br />
default<br />
mda "/usr/bin/procmail -d %T"<br />
}}<br />
<br />
Procmail needs root privileges to work in delivery mode but it is not an issue if you are running the cronjobs as root anyway.<br />
<br />
To test that everything works correctly, create a file {{ic|message.txt}} with {{ic|"test message"}} in it. <br />
<br />
From the same directory run:<br />
<br />
$ sendmail ''user_name'' < message.txt <br />
<br />
then:<br />
<br />
$ cat /var/spool/mail/''user_name''<br />
<br />
You should now see the test message and the time and date it was sent.<br />
<br />
The error output of all jobs will now be redirected to {{ic|/var/spool/mail/''user_name''}}.<br />
<br />
Due to the privileged issue, it is hard to create and send emails to root (e.g. {{ic|su -c ""}}). You can ask {{ic|esmtp}} to forward all root's email to an ordinary user with:<br />
{{hc|/etc/esmtprc|<br />
2=force_mda="''user-name''"<br />
}}<br />
<br />
{{Note|If the above test didn't work, you may try creating a local configuration in {{ic|~/.esmtprc}} with the same content.<br />
<br />
Run the following command to make sure it has the correct permission: <br />
<br />
$ chmod 710 ~/.esmtprc<br />
<br />
Then repeat the test with {{ic|message.txt}} exactly as before.}}<br />
<br />
== Crontab format ==<br />
<br />
The basic format for a crontab is:<br />
<br />
<minute> <hour> <day_of_month> <month> <day_of_week> <command><br />
<br />
* ''minute'' values can be from 0 to 59.<br />
* ''hour'' values can be from 0 to 23.<br />
* ''day_of_month'' values can be from 1 to 31.<br />
* ''month'' values can be from 1 to 12.<br />
* ''day_of_week'' values can be from 0 to 6, with 0 denoting Sunday.<br />
<br />
Multiple times may be specified with a comma, a range can be given with a hyphen, and the asterisk symbol is a wildcard character. Spaces are used to separate fields. For example, the line:<br />
<br />
*0,*5 9-16 * 1-5,9-12 1-5 ~/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Ic|i_love_cron.sh}} at five minute intervals from 9 AM to 4:55 PM on weekdays except during the summer months (June, July, and August). More examples and advanced configuration techniques can be found below.<br />
<br />
== Basic commands ==<br />
<br />
Crontabs should never be edited directly; instead, users should use the {{ic|crontab}} program to work with their crontabs. To be granted access to this command, user must be a member of the users group (see the {{ic|gpasswd}} command).<br />
<br />
To view their crontabs, users should issue the command:<br />
<br />
$ crontab -l<br />
<br />
To edit their crontabs, they may use:<br />
<br />
$ crontab -e<br />
<br />
To remove their crontabs, they should use:<br />
<br />
$ crontab -r<br />
<br />
If a user has a saved crontab and would like to completely overwrite their old crontab, he or she should use:<br />
<br />
$ crontab ''saved_crontab_filename''<br />
<br />
To overwrite a crontab from the command line ([[Wikipedia:stdin]]), use<br />
<br />
$ crontab - <br />
<br />
To edit somebody else's crontab, issue the following command as root:<br />
<br />
# crontab -u ''username'' -e<br />
<br />
This same format (appending {{ic|-u ''username''}} to a command) works for listing and deleting crontabs as well.<br />
<br />
To use [[nano]] rather than [[vi]] as crontab editor, add the following lines to your shell's initialization file (eg. {{ic|/etc/profile}} or {{ic|/etc/bash.bashrc}}):<br />
<br />
export EDITOR="/usr/bin/nano"<br />
<br />
And restart open shells.<br />
<br />
== Examples ==<br />
<br />
The entry:<br />
<br />
01 * * * * /bin/echo Hello, world!<br />
<br />
runs the command {{Ic|/bin/echo Hello, world!}} on the first minute of every hour of every day of every month (i.e. at 12:01, 1:01, 2:01, etc.)<br />
<br />
Similarly,<br />
<br />
*/5 * * jan mon-fri /bin/echo Hello, world!<br />
<br />
runs the same job every five minutes on weekdays during the month of January (i.e. at 12:00, 12:05, 12:10, etc.)<br />
<br />
As noted in the ''Crontab Format'' section, the line:<br />
<br />
*0,*5 9-16 * 1-5,9-12 1-5 /home/user/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Ic|i_love_cron.sh}} at five minute intervals from 9 AM to 5 PM (excluding 5 PM itself) every weekday (Mon-Fri) of every month except during the summer (June, July, and August).<br />
<br />
== More information ==<br />
<br />
The cron daemon parses a configuration file known as {{ic|crontab}}. Each user on the system can maintain a separate crontab file to schedule commands individually. The root user's crontab is used to schedule system-wide tasks (though users may opt to use {{ic|/etc/crontab}} or the {{ic|/etc/cron.d}} directory, depending on which cron implementation they choose).<br />
<br />
There are slight differences between the crontab formats of the different cron daemons. The default root crontab for dcron looks like this:<br />
<br />
{{hc|/var/spool/cron/root<br />
|2=<nowiki><br />
# root crontab<br />
# DO NOT EDIT THIS FILE MANUALLY! USE crontab -e INSTEAD<br />
<br />
# man 1 crontab for acceptable formats:<br />
# <minute> <hour> <day> <month> <dow> <tags and command><br />
# <@freq> <tags and command><br />
<br />
# SYSTEM DAILY/WEEKLY/... FOLDERS<br />
@hourly ID=sys-hourly /usr/sbin/run-cron /etc/cron.hourly<br />
@daily ID=sys-daily /usr/sbin/run-cron /etc/cron.daily<br />
@weekly ID=sys-weekly /usr/sbin/run-cron /etc/cron.weekly<br />
@monthly ID=sys-monthly /usr/sbin/run-cron /etc/cron.monthly<br />
</nowiki>}}<br />
<br />
These lines exemplify one of the formats that crontab entries can have, namely whitespace-separated fields specifying:<br />
<br />
# @period<br />
# ID=jobname (this tag is specific to dcron)<br />
# command<br />
<br />
The other standard format for crontab entries is:<br />
<br />
# minute<br />
# hour<br />
# day<br />
# month<br />
# day of week<br />
# command<br />
<br />
The crontab files themselves are usually stored as {{ic|/var/spool/cron/username}}. For example, root's crontab is found at {{ic|/var/spool/cron/root}}<br />
<br />
See the crontab [[man page]] for further information and configuration examples.<br />
<br />
== run-parts issue ==<br />
<br />
cronie uses {{ic|run-parts}} to carry out script in {{ic|cron.daily}}/{{ic|cron.weekly}}/{{ic|cron.monthly}}. Be careful that the script name in these won't include a dot (.), e.g. {{ic|backup.sh}}, since {{ic|run-parts}} without options will ignore them (see: {{ic|man run-parts}}).<br />
<br />
== Running Xorg server based applicatoins ==<br />
<br />
If you find that you can't run X apps from cron jobs then use this prefix:<br />
<br />
export DISPLAY=:0.0 ;<br />
<br />
This sets the {{ic|DISPLAY}} variable to the first display, which is usually right<br />
unless you run multiple X servers on your machine.<br />
<br />
If it still doesn't work, then you need to use {{ic|xhost}} to give your user control<br />
over X:<br />
<br />
# xhost +si:localuser:$(whoami)<br />
<br />
== Asynchronous job processing ==<br />
<br />
If you regularly turn off your computer but do not want to miss jobs, there are some solutions available (easiest to hardest):<br />
<br />
===Dcron===<br />
Vanilla dcron supports asynchronous job processing. Just put it with @hourly, @daily, @weekly or @monthly with a jobname, like this:<br />
<br />
@hourly ID=greatest_ever_job echo This job is very useful.<br />
<br />
===Cronwhip===<br />
([https://aur.archlinux.org/packages.php?ID=21079 AUR], [https://bbs.archlinux.org/viewtopic.php?id=57973 forum thread]): Script to automatically run missed cron jobs; works with the default cron implementation, dcron.<br />
<br />
===Anacron===<br />
([https://aur.archlinux.org/packages.php?ID=5196 AUR]): Full replacement for dcron, processes jobs asynchronously.<br />
<br />
== Ensuring exclusivity ==<br />
<br />
If you run potentially long-running jobs (e.g., a backup might all of a sudden run for a long time, because of many changes or a particular slow network connection), then {{AUR|lockrun}} can ensure that the cron job won't start a second time.<br />
<br />
5,35 * * * * /usr/bin/lockrun -n /tmp/lock.backup /root/make-backup.sh</div>Popschhttps://wiki.archlinux.org/index.php?title=Cron&diff=222664Cron2012-09-11T17:41:33Z<p>Popsch: /* Asynchronous job processing */</p>
<hr />
<div>[[Category:Daemons and system services]]<br />
[[de:Cron]]<br />
[[fr:Cron]]<br />
[[sk:Cron]]<br />
[[zh-CN:Cron]]<br />
{{Article summary start}}<br />
{{Article summary text|An overview of the standard task scheduling daemon on GNU/Linux systems.}}<br />
{{Article summary heading|Resources}}<br />
{{Article summary link|Gentoo Linux Cron Guide|http://www.gentoo.org/doc/en/cron-guide.xml}}<br />
{{Article summary end}}<br />
{{Lowercase_title}}<br />
<br />
From [https://en.wikipedia.org/wiki/Cron Wikipedia]:<br />
<br />
'''''cron''' is the time-based job scheduler in Unix-like computer operating systems. cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. It is commonly used to automate system maintenance or administration [...]''<br />
<br />
== Installation ==<br />
<br />
{{Pkg|cronie}} is installed by default as part of the '''base''' group. Other cron implementations exist if preferred, Gentoo's [http://www.gentoo.org/doc/en/cron-guide.xml Cron Guide] offers comparisons. For example, {{Pkg|fcron}}, {{AUR|bcron}} or {{AUR|vixie-cron}} offer a wider range of features and configuration options.<br />
<br />
{{Note|Until May 2011, the default cron implementation for Arch Linux was {{Pkg|dcron}} (Dillon's Cron), which is still supported and can be installed from the [[official repositories]].}}<br />
<br />
== Configuration ==<br />
<br />
=== Users & autostart ===<br />
<br />
cron should be working upon login on a new system to run root scripts. This can be check by looking at the log in {{ic|/var/log/}}. In order to use crontab application (editor for job entries), users must be members of a designated group {{ic|users}} or {{ic|root}}, of which all users should already be members. To ensure cron starts on boot, add the {{ic|crond}} daemon to the [[Daemon#Starting_on_Boot|daemons]] array of [[rc.conf]], or enable {{ic|cronie.service}} if using [[systemd]].<br />
<br />
=== Handling errors of jobs ===<br />
<br />
Errors can occur during execution of jobs. When this happens, cron registers the '''stderr''' output and attempts to send it as email to the user's spools via the {{ic|sendmail}} command.<br />
<br />
To log these messages use the {{ic|-M}} option in {{ic|/etc/conf.d/crond}} and write a script or install a rudimentary SMTP subsystem (e.g. {{Pkg|esmtp}}):<br />
<br />
# pacman -S esmtp procmail<br />
<br />
After installation configure the routing:<br />
{{hc|/etc/esmtprc|<br />
identity ''myself''@myisp.com<br />
hostname mail.myisp.com:25<br />
username ''"myself"''<br />
password ''"secret"''<br />
starttls enabled<br />
default<br />
mda "/usr/bin/procmail -d %T"<br />
}}<br />
<br />
Procmail needs root privileges to work in delivery mode but it is not an issue if you are running the cronjobs as root anyway.<br />
<br />
To test that everything works correctly, create a file {{ic|message.txt}} with {{ic|"test message"}} in it. <br />
<br />
From the same directory run:<br />
<br />
$ sendmail ''user_name'' < message.txt <br />
<br />
then:<br />
<br />
$ cat /var/spool/mail/''user_name''<br />
<br />
You should now see the test message and the time and date it was sent.<br />
<br />
The error output of all jobs will now be redirected to {{ic|/var/spool/mail/''user_name''}}.<br />
<br />
Due to the privileged issue, it is hard to create and send emails to root (e.g. {{ic|su -c ""}}). You can ask {{ic|esmtp}} to forward all root's email to an ordinary user with:<br />
{{hc|/etc/esmtprc|<br />
2=force_mda="''user-name''"<br />
}}<br />
<br />
{{Note|If the above test didn't work, you may try creating a local configuration in {{ic|~/.esmtprc}} with the same content.<br />
<br />
Run the following command to make sure it has the correct permission: <br />
<br />
$ chmod 710 ~/.esmtprc<br />
<br />
Then repeat the test with {{ic|message.txt}} exactly as before.}}<br />
<br />
== Crontab format ==<br />
<br />
The basic format for a crontab is:<br />
<br />
<minute> <hour> <day_of_month> <month> <day_of_week> <command><br />
<br />
* ''minute'' values can be from 0 to 59.<br />
* ''hour'' values can be from 0 to 23.<br />
* ''day_of_month'' values can be from 1 to 31.<br />
* ''month'' values can be from 1 to 12.<br />
* ''day_of_week'' values can be from 0 to 6, with 0 denoting Sunday.<br />
<br />
Multiple times may be specified with a comma, a range can be given with a hyphen, and the asterisk symbol is a wildcard character. Spaces are used to separate fields. For example, the line:<br />
<br />
*0,*5 9-16 * 1-5,9-12 1-5 ~/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Ic|i_love_cron.sh}} at five minute intervals from 9 AM to 4:55 PM on weekdays except during the summer months (June, July, and August). More examples and advanced configuration techniques can be found below.<br />
<br />
== Basic commands ==<br />
<br />
Crontabs should never be edited directly; instead, users should use the {{ic|crontab}} program to work with their crontabs. To be granted access to this command, user must be a member of the users group (see the {{ic|gpasswd}} command).<br />
<br />
To view their crontabs, users should issue the command:<br />
<br />
$ crontab -l<br />
<br />
To edit their crontabs, they may use:<br />
<br />
$ crontab -e<br />
<br />
To remove their crontabs, they should use:<br />
<br />
$ crontab -r<br />
<br />
If a user has a saved crontab and would like to completely overwrite their old crontab, he or she should use:<br />
<br />
$ crontab ''saved_crontab_filename''<br />
<br />
To overwrite a crontab from the command line ([[Wikipedia:stdin]]), use<br />
<br />
$ crontab - <br />
<br />
To edit somebody else's crontab, issue the following command as root:<br />
<br />
# crontab -u ''username'' -e<br />
<br />
This same format (appending {{ic|-u ''username''}} to a command) works for listing and deleting crontabs as well.<br />
<br />
To use [[nano]] rather than [[vi]] as crontab editor, add the following lines to your shell's initialization file (eg. {{ic|/etc/profile}} or {{ic|/etc/bash.bashrc}}):<br />
<br />
export EDITOR="/usr/bin/nano"<br />
<br />
And restart open shells.<br />
<br />
== Examples ==<br />
<br />
The entry:<br />
<br />
01 * * * * /bin/echo Hello, world!<br />
<br />
runs the command {{Ic|/bin/echo Hello, world!}} on the first minute of every hour of every day of every month (i.e. at 12:01, 1:01, 2:01, etc.)<br />
<br />
Similarly,<br />
<br />
*/5 * * jan mon-fri /bin/echo Hello, world!<br />
<br />
runs the same job every five minutes on weekdays during the month of January (i.e. at 12:00, 12:05, 12:10, etc.)<br />
<br />
As noted in the ''Crontab Format'' section, the line:<br />
<br />
*0,*5 9-16 * 1-5,9-12 1-5 /home/user/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Ic|i_love_cron.sh}} at five minute intervals from 9 AM to 5 PM (excluding 5 PM itself) every weekday (Mon-Fri) of every month except during the summer (June, July, and August).<br />
<br />
== More information ==<br />
<br />
The cron daemon parses a configuration file known as {{ic|crontab}}. Each user on the system can maintain a separate crontab file to schedule commands individually. The root user's crontab is used to schedule system-wide tasks (though users may opt to use {{ic|/etc/crontab}} or the {{ic|/etc/cron.d}} directory, depending on which cron implementation they choose).<br />
<br />
There are slight differences between the crontab formats of the different cron daemons. The default root crontab for dcron looks like this:<br />
<br />
{{hc|/var/spool/cron/root<br />
|2=<nowiki><br />
# root crontab<br />
# DO NOT EDIT THIS FILE MANUALLY! USE crontab -e INSTEAD<br />
<br />
# man 1 crontab for acceptable formats:<br />
# <minute> <hour> <day> <month> <dow> <tags and command><br />
# <@freq> <tags and command><br />
<br />
# SYSTEM DAILY/WEEKLY/... FOLDERS<br />
@hourly ID=sys-hourly /usr/sbin/run-cron /etc/cron.hourly<br />
@daily ID=sys-daily /usr/sbin/run-cron /etc/cron.daily<br />
@weekly ID=sys-weekly /usr/sbin/run-cron /etc/cron.weekly<br />
@monthly ID=sys-monthly /usr/sbin/run-cron /etc/cron.monthly<br />
</nowiki>}}<br />
<br />
These lines exemplify one of the formats that crontab entries can have, namely whitespace-separated fields specifying:<br />
<br />
# @period<br />
# ID=jobname (this tag is specific to dcron)<br />
# command<br />
<br />
The other standard format for crontab entries is:<br />
<br />
# minute<br />
# hour<br />
# day<br />
# month<br />
# day of week<br />
# command<br />
<br />
The crontab files themselves are usually stored as {{ic|/var/spool/cron/username}}. For example, root's crontab is found at {{ic|/var/spool/cron/root}}<br />
<br />
See the crontab [[man page]] for further information and configuration examples.<br />
<br />
== run-parts issue ==<br />
<br />
cronie uses {{ic|run-parts}} to carry out script in {{ic|cron.daily}}/{{ic|cron.weekly}}/{{ic|cron.monthly}}. Be careful that the script name in these won't include a dot (.), e.g. {{ic|backup.sh}}, since {{ic|run-parts}} without options will ignore them (see: {{ic|man run-parts}}).<br />
<br />
== Running Xorg server based applicatoins ==<br />
<br />
If you find that you can't run X apps from cron jobs then use this prefix:<br />
<br />
export DISPLAY=:0.0 ;<br />
<br />
This sets the {{ic|DISPLAY}} variable to the first display, which is usually right<br />
unless you run multiple X servers on your machine.<br />
<br />
If it still doesn't work, then you need to use {{ic|xhost}} to give your user control<br />
over X:<br />
<br />
# xhost +si:localuser:$(whoami)<br />
<br />
== Asynchronous job processing ==<br />
<br />
If you regularly turn off your computer but do not want to miss jobs, there are some solutions available (easiest to hardest):<br />
<br />
===Dcron===<br />
Vanilla dcron supports asynchronous job processing. Just put it with @hourly, @daily, @weekly or @monthly with a jobname, like this:<br />
<br />
@hourly ID=greatest_ever_job echo This job is very useful.<br />
<br />
===Cronwhip===<br />
([https://aur.archlinux.org/packages.php?ID=21079 AUR], [https://bbs.archlinux.org/viewtopic.php?id=57973 forum thread]): Script to automatically run missed cron jobs; works with the default cron implementation, dcron.<br />
<br />
===Anacron===<br />
([https://aur.archlinux.org/packages.php?ID=5196 AUR]): Full replacement for dcron, processes jobs asynchronously.<br />
<br />
== Ensuring exclusivity ==<br />
<br />
If you run potentially long-running jobs (e.g., a backup might all of a sudden run for a long time, because of many changes or a particular slow network connection), then [https://aur.archlinux.org/packages.php?ID=24279 lockrun] can ensure that the cron job won't start a second time.<br />
<br />
5,35 * * * * /usr/bin/lockrun -n /tmp/lock.backup /root/make-backup.sh</div>Popschhttps://wiki.archlinux.org/index.php?title=Mutt&diff=221610Mutt2012-09-05T13:38:41Z<p>Popsch: added offlineimap to the related list</p>
<hr />
<div>[[Category:Email Client]]<br />
[[es:Mutt]]<br />
[[it:Mutt]]<br />
[[zh-CN:Mutt]]<br />
[[zh-TW:Mutt]]<br />
{{Article summary start}}<br />
{{Article summary text|A guide on configuring and using Mutt.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|fdm}}<br />
{{Article summary wiki|msmtp}}<br />
{{Article summary wiki|offlineimap}}<br />
{{Article summary end}}<br />
<br />
'''Mutt''' is a text-based mail client renowned for its powerful features. Though over a decade old, Mutt remains the mail client of choice for a great number of power-users. Unfortunately, a default Mutt install is plagued by complex keybindings along with a daunting amount of documentation. This guide will help the average user get Mutt up and running, and begin customizing it to their particular needs.<br />
<br />
==Overview==<br />
Mutt focuses primarily on being a Mail User Agent (MUA), and was originally written to view mail. Later implementations added for retrieval, sending, and filtering mail are simplistic compared to other mail applications and, as such, users may wish to use external applications to extend Mutt's capabilities. <br />
<br />
Nevertheless, the Arch Linux {{Pkg|mutt}} package is compiled with IMAP, POP3 and SMTP support, removing the necessity for external applications.<br />
<br />
This article covers using both native IMAP sending and retrieval, and a setup depending on [[OfflineIMAP]] or [[getmail]] (POP3) to retrieve mail, [[procmail]] to filter it in the case of POP3, and [[msmtp]] to send it.<br />
<br />
==Installing==<br />
[[pacman|Install]] {{Pkg|mutt}}, available in the [[Official Repositories]]. <br />
<br />
Optionally install external helper applications for an IMAP setup, such as {{Pkg|offlineimap}} and {{Pkg|msmtp}}.<br />
<br />
Or (if using POP3) {{Pkg|getmail}} or {{Pkg|fdm}} and {{Pkg|procmail}}.<br />
<br />
{{Note|<br />
*If you just need the authentication methods LOGIN and PLAIN, these are satisfied with the dependency {{Pkg|libsasl}}<br />
*If you want to (or have to) use CRAM-MD5, GSSAPI or DIGEST-MD5, install the package {{Pkg|cyrus-sasl-gssapi}}<br />
*If you are using Gmail as your SMTP server, you may need to install the package {{Pkg|cyrus-sasl}}<br />
}}<br />
<br />
==Configuring==<br />
This section covers IMAP, [[#POP3]], [[#Maildir]] and [[#SMTP]] configuration.<br />
<br />
Note that Mutt will recognize two locations for its configuration file; {{ic|~/.muttrc}} and {{ic|~/.mutt/muttrc}}. Either location will work.<br />
You should also know some prerequisite for Mutt configuration. Its syntax is very close the Bourne Shell. For example, you can get the content of another config file:<br />
source /path/to/other/config/file<br />
You can use variables and assign the result of shell commands to them.<br />
set editor=`echo \$EDITOR`<br />
Here the {{ic|$}} gets escaped so that it does not get substituted by Mutt before being passed to the shell.<br />
Also note the use of the backquotes, as bash syntax {{ic|$(...)}} does not work.<br />
Mutt has a lot of predefined variables, but you can also set your own. User variable '''must begin with "my"!'''<br />
set my_name = "John Doe"<br />
<br />
===IMAP===<br />
''Native and external setups''<br />
<br />
====Using native IMAP support====<br />
The pacman version of Mutt is compiled with IMAP support. At the very least you need to have 4 lines in your muttrc file to be able to access your mail.<br />
<br />
=====imap_user=====<br />
set imap_user=USERNAME<br />
<br />
Continuing with the previous example, remember that Gmail requires your full email address (this is not standard):<br />
set imap_user=your.username@gmail.com<br />
<br />
=====imap_pass=====<br />
If unset, the password will be prompted for.<br />
set imap_pass=SECRET<br />
<br />
=====folder=====<br />
Instead of a local directory which contains all your mail (and directories), use your server (and the highest folder in the hierarchy, if needed).<br />
set folder=imap[s]://imap.server.domain[:port]/[folder/]<br />
<br />
You do not have to use a folder, but it might be convenient if you have all your other folders inside your INBOX, for example. Whatever you set here as your folder can be accessed later in Mutt with just an equal sign (=). Example:<br />
set folder=imaps://imap.gmail.com/<br />
<br />
It should be noted that for several accounts, it is best practice to use different folders -- e.g. for ''account-hook''. If you have several Gmail account, use<br />
set folder=imaps://username@imap.gmail.com/<br />
instead, where your account is ''username@gmail.com''.<br />
<br />
=====spoolfile=====<br />
You can now use '=' or '+' as a substitution for the full {{Ic|folder}} path that was configured above. For example:<br />
set spoolfile=+INBOX<br />
<br />
=====mailboxes=====<br />
Any imap folders that should be checked regularly for new mail should be listed here:<br />
mailboxes =INBOX =family<br />
mailboxes imaps://imap.gmail.com/INBOX imaps://imap.gmail.com/family<br />
<br />
Alternatively, check for all subscribed IMAP folders (as if all were added with a {{Ic|mailboxes}} line):<br />
set imap_check_subscribed<br />
<br />
These two versions are equivalent, but the first is much more convenient. Also, newer Mutt versions are configured by default to include a macro bound to the 'y' key which will allow you to change to any of the folders listed under mailboxes.<br />
<br />
=====Summary=====<br />
Using these options, you will be able to start Mutt, enter your IMAP password, and start reading your mail. Here is a muttrc snippet (for Gmail) with some other lines you might consider adding for better IMAP support.<br />
{{bc|1=<br />
set folder = imaps://imap.gmail.com/<br />
set imap_user = your.username@gmail.com<br />
set imap_pass = your-imap-password<br />
set spoolfile = +INBOX<br />
mailboxes = +INBOX<br />
<br />
# store message headers locally to speed things up<br />
# if hcache is a folder, Mutt will create sub cache folders for each account which may speeds things even more up<br />
set header_cache = ~/.mutt/hcache<br />
<br />
# specify where to save and/or look for postponed messages<br />
set postponed = +[Gmail]/Drafts<br />
<br />
# allow Mutt to open new imap connection automatically<br />
unset imap_passive<br />
<br />
# keep imap connection alive by polling intermittently (time in seconds)<br />
set imap_keepalive = 300<br />
<br />
# how often to check for new mail (time in seconds)<br />
set mail_check = 120<br />
}}<br />
<br />
====External IMAP support====<br />
While IMAP-functionality is built into Mutt, it does not download mail for offline-use. The [[OfflineIMAP]] article describes how to download your emails to a local folder which can then be processed by Mutt.<br />
<br />
Consider using applications such as [[spamassassin]] or [[imapfilter]] to sort mail.<br />
<br />
===POP3===<br />
''Retrieving and sorting mail with external applications''<br />
<br />
====Retrieving mail====<br />
Create the directory {{ic|~/.getmail/}}. Open the file {{ic|~/.getmail/getmailrc}} in your favorite text editor.<br />
<br />
Here is an example {{ic|getmailrc}} used with a gmail account.<br />
{{bc|1=<br />
[retriever]<br />
type = SimplePOP3SSLRetriever<br />
server = pop.gmail.com<br />
username = username@gmail.com<br />
port = 995<br />
password = password<br />
<br />
[destination]<br />
type = Maildir<br />
path = ~/mail/<br />
}}<br />
<br />
You can tweak this to your POP3 service's specification.<br />
<br />
Most people will like to add the following section to their {{ic|getmailrc}} to prevent all the mail on the server being downloaded every time getmail is ran.<br />
{{bc|1=<br />
[options]<br />
read_all = False<br />
}}<br />
<br />
As you can see {{ic|~/.getmail/getmailrc}} contains sensitive information (namely, email account passwords in plain text). You will want to change access permissions to the directory so only the owner can see it:<br />
<br />
$ chmod 700 ~/.getmail<br />
<br />
For this guide we will be storing our mail in the {{ic|maildir}} format. The two main mailbox formats are {{ic|mbox}} and {{ic|maildir}}. The main difference between the two is that {{ic|mbox}} is one file, with all of your mails and their headers stored in it, whereas a {{ic|maildir}} is a directory tree. Each mail is its own file, which will often speed things up.<br />
<br />
A {{ic|maildir}} is just a folder with the folders {{ic|cur}}, {{ic|new}} and {{ic|tmp}} in it.<br />
mkdir -p ~/mail/{cur,new,tmp}<br />
<br />
Now, run getmail. If it works fine, you can create a cronjob for getmail to run every n hours/minutes. Type {{ic|crontab -e}} to edit cronjobs, and enter the following:<br />
*/10 * * * * /usr/bin/getmail<br />
That will run {{ic|getmail}} every 10 minutes.<br />
<br />
Also, to quiet getmail down, we can reduce its verbosity to zero by adding the following to {{ic|getmailrc}}.<br />
{{bc|1=<br />
[options]<br />
verbose = 0<br />
}}<br />
<br />
=====More than one Email account with getmail=====<br />
By default, when you run {{ic|getmail}} the program searches for the file getmailrc created as seen above. If you have more than one mail account you would like to get mail from, then you can create such a file for each email address, and then tell getmail to run using both of them. Obviously if you have two accounts and two files you cannot have both of them called getmailrc. What you do is give them two different names, using myself as an example: I call one personal, and one university. These two files contain content relevant to my personal mail, and my university work mail respectively. Then to get getmail to work on these two files, instead of searching for getmailrc(default), I use the --rcfile switch like so: {{ic|getmail --rcfile university --rcfile personal}} This can work with more files if you have more email accounts, just make sure each file is in the .getmail directory and make sure to alter the cronjob to run the command with the --rcfile switches. E.g.<br />
'''*/30 * * * * /usr/bin/getmail --rcfile university --rcfile personal'''<br />
<br />
Obviously you can call your files whatever you want, providing you include them in the cronjob or shell command, and they are in the .getmail/ directory, getmail will fetch mail from those two accounts.<br />
<br />
====Sorting mail====<br />
[http://www.procmail.org/ Procmail] is an extremely powerful sorting tool. For the purposes of this wiki, we will do some primitive sorting to get started.<br />
<br />
You must edit your getmailrc to pass retrieved mail to procmail:<br />
{{bc|1=<br />
[destination]<br />
type = MDA_external<br />
path = /usr/bin/procmail<br />
}}<br />
<br />
Now, open up {{ic|.procmailrc}} in your favorite editor. The following will sort all mail from the happy-kangaroos mailing list, and all mail from your lovey-dovey friend in their own maildirs.<br />
{{bc|1=<br />
MAILDIR=$HOME/mail<br />
DEFAULT=$MAILDIR/inbox/<br />
LOGFILE=$MAILDIR/log<br />
<br />
:0:<br />
* ^To: happy-kangaroos@nicehost.com<br />
happy-kangaroos/<br />
<br />
:0:<br />
* ^From: loveydovey@iheartyou.net<br />
lovey-dovey/<br />
}}<br />
After you have saved your {{ic|.procmailrc}}, run getmail and see if procmail succeeds in sorting your mail into the appropriate directories.<br />
<br />
{{Note|One easy to make mistake with .procmailrc is the permission. procmail require it to have permission 644 and will not give meaningless error message if you do not.}}<br />
<br />
===Maildir===<br />
Maildir is a generic and standardized format. Almost every MUA is able to handle Maildirs and Mutt's support is excellent. There are just a few simple things that you need to do to get Mutt to use them. Open your muttrc and add the following lines:<br />
{{bc|1=<br />
set mbox_type=Maildir<br />
set folder=$HOME/mail<br />
set spoolfile=+/<br />
set header_cache=~/.hcache<br />
}}<br />
<br />
This is a minimal Configuration that enables you to access your Maildir and checks for new local Mails in INBOX. This configuration also caches the headers of the eMails to speed up directory-listings. It might not be enabled in your build (but it sure is in the Arch-Package). Note that this does not affect OfflineIMAP in any way. It always syncs the all directories on a Server. {{ic|spoolfile}} tells Mutt which local directories to poll for new Mail. You might want to add more Spoolfiles (for example the Directories of Mailing-Lists) and maybe other things. But this is subject to the Mutt manual and beyond the scope of this document.<br />
<br />
===SMTP===<br />
Whether you use POP or IMAP to receive mail you will probably still send mail using SMTP.<br />
<br />
====Using native SMTP support====<br />
The pacman version of Mutt is also compiled with SMTP support. Just check the online manual [http://manual.cream.org/index.cgi/muttrc.5 muttrc], or {{ic|man muttrc}} for more information.<br />
<br />
For example:<br />
{{bc|1=<br />
set my_pass='mysecretpass'<br />
set my_user=myname<br />
<br />
set smtp_url=smtps://$my_user:$my_pass@smtp.domain.tld<br />
set ssl_force_tls = yes<br />
}}<br />
<br />
Note that if your SMTP credentials are the same as your IMAP credentials, than you can use those variables:<br />
<br />
{{bc|1=<br />
set smtp_url=smtps://$imap_user:$imap_pass@smtp.domain.tld<br />
}}<br />
<br />
You may need to tweak the security parameters. If you get an error like<br />
{{ic|SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol}},<br />
then your server most probably uses the SMTP instead of SMTPS.<br />
<br />
{{bc|1=<br />
set smtp_url=smtp://$imap_user:$imap_pass@smtp.domain.tld<br />
}}<br />
<br />
There is other variable that you may need to set. For example for use of STARTTLS:<br />
{{bc|1=<br />
set ssl_starttls = yes<br />
}}<br />
<br />
====External SMTP support====<br />
An external SMTP agent such as [[msmtp]] or [[SSMTP]] can also be used. This section exclusively covers configuring Mutt for msmtp.<br />
<br />
Edit Mutt's configuration file or create it if unpresent:<br />
{{hc|muttrc|2=<br />
set realname='Disgruntled Kangaroo'<br />
<br />
set sendmail="/usr/bin/msmtp"<br />
<br />
set edit_headers=yes<br />
set folder=~/mail<br />
set mbox=+mbox<br />
set spoolfile=+inbox<br />
set record=+sent<br />
set postponed=+drafts<br />
set mbox_type=Maildir<br />
<br />
mailboxes +inbox +lovey-dovey +happy-kangaroos<br />
}}<br />
<br />
====Sending mails from Mutt====<br />
Now, startup {{Ic|mutt}}:<br />
<br />
You should see all the mail in {{ic|~/mail/inbox}}. Press {{keypress|m}} to compose mail; it will use the editor defined by your {{Ic|EDITOR}} environment variable. If this variable is not set, you can fix it before starting Mutt:<br />
$ export EDITOR=your-favorite-editor<br />
$ mutt<br />
<br />
You should store the EDITOR value into your shell resource configuration file (such as [[bashrc]]).<br />
You can also set the editor from Mutt's configuration file:<br />
{{hc|.muttrc|2=<br />
set editor=your-favorite-editor<br />
}}<br />
<br />
For testing purposes, address the letter to yourself. After you have written the letter, save and exit the editor. You will return to Mutt, which will now show information about your e-mail. Press {{keypress|y}} to send it.<br />
<br />
===Multiple accounts===<br />
<br />
Now you should have a working configuration for one account at least. You might wonder how to use several accounts, since we put everything into a single file.<br />
Mutt can handle this thanks to one of its most powerful feature: hooks.<br />
Basically a hook is a command that gets executed before a specific action.<br />
There are several hook availables. For multiple accounts, either account-hooks or folder-hooks are useful. Folder-hooks will run a command before switching folders. Let's give an example with folder-hooks:<br />
<br />
{{bc|1=<br />
folder-hook 'personal' 'source ~/.mutt/personal_config'<br />
folder-hook 'work' 'source ~/.mutt/work_config'<br />
<br />
## Switch to default account on startup.<br />
source "~/.mutt/work_config"<br />
}}<br />
<br />
In that case, all the IMAP/POP3/SMTP config for each account should go to its respective folder.<br />
{{Warning|When one account is setting a variable that is not specified for other accounts, you '''must unset''' it for them, otherwise configuration will overlap and you will most certainly experience unexpected behaviour.}}<br />
<br />
Now all your accounts are set, start Mutt. To switch from one account to another, just change the folder ({{keypress|c}} key). But since you have to type the complete address -- for IMAP/POP3 folders, this may be quite inconvenient -- let's bind some key to it.<br />
<br />
{{bc|<br />
## Shortcuts<br />
macro index <f2> '<sync-mailbox><enter-command>source ~/.mutt/personal_config<enter><change-folder>!<enter>'<br />
macro index <f3> '<sync-mailbox><enter-command>source ~/.mutt/work_config<enter><change-folder>!<enter>'<br />
}}<br />
<br />
===Passwords management===<br />
Keep in mind that writing your password in {{ic|.muttrc}} is a security risk, and it might be of your concern.<br />
The trivial way to keep your passwords safe is not writing them in the config file. Mutt will then prompt for it when needed.<br />
However, this is quiet combersome in the long run, especiallly if you have several accounts.<br />
<br />
Here follows a smart and convenient solution: all your passwords are encrypted into one file and Mutt will prompt for a passphrase on startup only.<br />
Since GPG is a Mutt dependency, we will use it, but you can use any other keyring tool as well (e.g. {{pkg|pwsafe}}).<br />
<br />
First create a pair of public/private keys:<br />
gpg --gen-key<br />
{{Note|Do not leave any blank when giving your full name (surname and given name). Use {{Keypress|_}} or {{Keypress|-}} as a separator}}<br />
If you do not understand this process have a look at [http://en.wikipedia.org/wiki/Asymmetric_cryptography Wikipedia/Asymmetric cryptography].<br />
<br />
Create a file '''in a secure environment''' since it will contain your passwords for a couple of seconds:<br />
{{hc|~/.my-pwds|<nowiki><br />
set my_pw_personal = ****<br />
set my_pw_work = ****</nowiki><br />
}}<br />
<br />
Now encrypt the file:<br />
gpg -e -r <your-name> ~/.my-pwds<br />
Note that <your-name> must match the one you provided at the {{ic|gpg --gen-key}} step.<br />
Now you can wipe your file containing your passwords in clear:<br />
wipe -l2 -x7 -p3 ~/.my-pwds<br />
{{Note|you must first [[pacman|install]] {{Pkg|wipe}} if not already installed}}<br />
Back to your account dedicated files, e.g. {{ic|.mutt/personal_config}}:<br />
{{bc|1=<br />
set imap_pass=$my_pw_personal<br />
# Every time the password is needed, use $my_pw_personal variable.<br />
}}<br />
<br />
And in your {{ic|.muttrc}}, '''before''' you source any account dedicated file:<br />
{{bc|<br />
source "gpg2 -dq ~/.my-pwds.gpg {{ic|<nowiki>|</nowiki>}}"<br />
}}<br />
<br />
* The {{ic|-q}} parameter makes gpg2 quiet which prevents gpg2 output messing with Mutt interface.<br />
* The pipe {{ic|<nowiki>|</nowiki>}} at the end of a string is the Mutt syntax to tell that you want the result of what is preceeding.<br />
<br />
Explanation: when Mutt starts, it will first source the result of the password decryption, that's why it will prompt for a passphrase. Then all passwords will be stored in memory in specific variables for the time Mutt runs. Then when a folder-hook is called, is sets the imap_pass variable to the variable holding the appropriate password. When switching account, the imap_pass variable will be set to another variable holding another password, etc.<br />
<br />
If you use external tools like OfflineIMAP and msmtp, you need to set up an agent (e.g. gpg-agent, see [[GnuPG#gpg-agent]]) to keep the passphrase into cache and thus avoiding those tools always prompting for it.<br />
<br />
==Customizing==<br />
Guides to get you started with using & customizing Mutt : <br />
* [http://mutt.blackfish.org.uk/ My first Mutt] (maintained by Bruno Postle) <br />
* [http://www.therandymon.com/woodnotes/mutt/using-mutt.html The Woodnotes Guide to the Mutt Email Client] (maintained by Randall Wood)<br />
<br />
If you have any Mutt specific questions, feel free to ask in [[ArchChannel|the irc channel]].<br />
<br />
===Printing===<br />
You can install {{AUR|muttprint}} from the [[AUR]] for a fancier printing quality.<br />
In your muttrc file, insert:<br />
set print_command="/usr/bin/muttprint %s -p {PrinterName}"<br />
<br />
===Custom mail headers===<br />
One of the greatest thing in Mutt is that you can have full control over your mail header.<br />
<br />
First, make your headers editable when you write e-mails:<br />
set edit_headers=yes<br />
<br />
Mutt also features a special function {{ic|my_hdr}} for customizing your header. Yes, it is named just like a variable, but in fact it is a function.<br />
<br />
You can clear it completely, which you ''should'' do when switching accounts with different headers, otherwise they will overlap:<br />
unmy_hdr *<br />
<br />
Other variables have also an impact on the headers, so it is wise to clear them before using {{ic|my_hdr}}:<br />
unset use_from<br />
unset use_domain<br />
unset user_agent<br />
<br />
Now, you can add any field you want -- even non-standard one -- to your header using the following syntax:<br />
my_hdr <FIELD>: <VALUE><br />
Note that <VALUE> can be the result of a command.<br />
<br />
Example:<br />
{{bc|<br />
## Extra info.<br />
my_hdr X-Info: Keep It Simple, Stupid.<br />
<br />
## OS Info.<br />
my_hdr X-Operating-System: `uname -s`, kernel `uname -r`<br />
<br />
## This header only appears to MS Outlook users<br />
my_hdr X-Message-Flag: WARNING!! Outlook sucks<br />
<br />
## Custom Mail-User-Agent ID.<br />
my_hdr User-Agent: Every email client sucks, this one just sucks less.<br />
}}<br />
<br />
===Signature block===<br />
Create a .signature in your home directory. Your signature will be appended at the end of your email.<br />
Alternatively you can specify a file in your Mutt configuration:<br />
set signature="path/to/sig/file"<br />
====Random signature====<br />
You can use fortune to add a random signature to Mutt.<br />
{{bc|$ pacman -S fortune-mod}}<br />
<br />
Create a fortune file and then add the following line to your .muttrc:<br />
{{bc|1=set signature="fortune pathtofortunefile&#124;"}}<br />
Note the pipe at the end. It tells Mutt that the specified string is not a file, but a command.<br />
<br />
===Viewing URLs & opening your favorite web browser===<br />
Your should start by creating a .mutt directory in $HOME if not done yet. There, create a file named macros. Insert the following:<br />
macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview'<br />
<br />
Then install {{AUR|urlview}} from the [[AUR]].<br />
<br />
Create a .urlview in $HOME and insert the following:<br />
REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]<br />
COMMAND <your-browser> %s <br />
<br />
When you read an email on the pager, hitting ctrl+b will list all the urls from the email. Navigate up or down with arrow keys and hit enter on the desired url. Your browser will start and go to the selected site.<br />
<br />
Some browser will require additional arguments to work properly. For example, [[Luakit]] will close on Mutt exit. You need to fork it to background, using the {{ic|-n}} parameter:<br />
COMMAND luakit -n %s 2>/dev/null<br />
The {{ic|2>/dev/null}} is to make it quiet, i.e. to prevent useless message printing where you do not want them to.<br />
<br />
*Note - If you have some problems with urlview due to Mutt's url encoding you can try [http://www.memoryhole.net/~kyle/extract_url/ extract_url.pl]<br />
<br />
*Note - If you would like to see a short contextual preview of the content around each URL, try [https://aur.archlinux.org/packages.php?ID=44853 urlscan]. The macro in your muttrc is the same as for urlview (except for the 'urlscan' command). There is no additional configuration required other than ensuring $BROWSER is set.<br />
<br />
===Viewing HTML===<br />
It is possible to pass the html body to an external HTML program and then dump it, keeping email viewing uniform and unobtrusive. Two programs are described here: lynx and w3m.<br />
<br />
Install lynx or w3m:<br />
pacman -S lynx<br />
or<br />
pacman -S w3m<br />
<br />
If {{ic|~/.mutt/mailcap}} does not exist you will need to create it and save the following to it.<br />
text/html; lynx -display_charset=utf-8 -dump %s; nametemplate=%s.html; copiousoutput<br />
or, in case of w3m,<br />
text/html; w3m -I %{charset} -T text/html; copiousoutput;<br />
<br />
Edit muttrc and add the following,<br />
set mailcap_path = ~/.mutt/mailcap<br />
<br />
To automatically open HTML messages in lynx, add this additional line to the muttrc:<br />
auto_view text/html<br />
<br />
The beauty of this is, instead of seeing an html body as source or being opened<br />
by a separate program, in this case lynx, you see the formatted content directly,<br />
and any url links within the email can be displayed with {{keypress|Ctrl+b}}.<br />
<br />
If you receive many emails with multiple or alternate encodings Mutt may default to treating every email as html. To avoid this, add the following variable to your ~/.muttrc to have Mutt default to text when available and use w3m/lynx only when no text version is availble in the email:<br />
alternative_order text/plain text/html<br />
<br />
===Mutt and Vim===<br />
*To limit the width of text to 72 characters, edit your .[[vim]]rc file and add:<br />
au BufRead /tmp/mutt-* set tw=72<br />
<br />
*Another choice is to use Vim's mail filetype plugin to enable other mail-centric options besides 72 character width. Edit {{ic|~/.vim/filetype.vim}}, creating it if unpresent, and add:<br />
{{bc| <br />
augroup filetypedetect<br />
" Mail<br />
autocmd BufRead,BufNewFile *mutt-* setfiletype mail<br />
augroup END<br />
}}<br />
<br />
*To set a different tmp directory, e.g. ~/.tmp, add a line to your muttrc as follows:<br />
set tmpdir="~/.tmp"<br />
<br />
*To reformat a modified text see the Vim context help<br />
:h 10.7<br />
<br />
===Mutt and GNU nano===<br />
[[nano]] is another nice console editor to use with Mutt. <br />
<br />
To limit the width of text to 72 characters, edit your .nanorc file and add:<br />
set fill 72<br />
<br />
Also, in muttrc file, you can specify the line to start editing so that you will skip the mail header:<br />
set editor="nano +7"<br />
<br />
===Mutt and Emacs===<br />
Emacs has a ''mail'' major mode.<br />
To switch to mail-mode automatically when Emacs is called from Mutt, you can add the following to your {{ic|.emacs}}:<br />
{{hc|.emacs|<nowiki><br />
;; Mutt support. <br />
(setq auto-mode-alist<br />
(append<br />
'(("/tmp/mutt.*" . mail-mode)<br />
)<br />
auto-mode-alist)<br />
)</nowiki><br />
}}<br />
<br />
If you usually run Emacs daemon, you may want Mutt to connect to it. Add this to your {{ic|.muttrc}}:<br />
{{hc|.muttrc|<nowiki><br />
set editor="emacsclient -a \"\" -t"</nowiki><br />
}}<br />
<br />
===Colors===<br />
Append sample color definitions to your .muttrc file:<br />
$ cat /usr/share/doc/mutt/samples/colors.linux >> ~/.muttrc<br />
Then adjust to your liking.<br />
The actual color each of these settings will produce depends on the colors set in your [[Xresources|~/.Xresources]] file.<br />
<br />
Alternatively, you can source any file you want containing colors (and thus act as a theme file):<br />
{{bc|<br />
source ~/.mutt/colors.zenburn<br />
}}<br />
<br />
A nice theme example:<br />
{{bc|<nowiki><br />
## Theme kindly inspired from <br />
## http://nongeekshandbook.blogspot.ie/2009/03/mutt-color-configuration.html <br />
<br />
## Colours for items in the index <br />
color index brightcyan black ~N<br />
color index brightred black ~O<br />
color index brightyellow black ~F<br />
color index black green ~T<br />
color index brightred black ~D<br />
mono index bold ~N<br />
mono index bold ~F<br />
mono index bold ~T<br />
mono index bold ~D<br />
<br />
## Highlights inside the body of a message. <br />
<br />
## URLs <br />
color body brightgreen black "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"<br />
color body brightgreen black "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"<br />
mono body bold "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"<br />
mono body bold "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"<br />
<br />
## Email addresses. <br />
color body brightgreen black "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"<br />
<br />
## Header <br />
color header green black "^from:"<br />
color header green black "^to:"<br />
color header green black "^cc:"<br />
color header green black "^date:"<br />
color header yellow black "^newsgroups:"<br />
color header yellow black "^reply-to:"<br />
color header brightcyan black "^subject:"<br />
color header red black "^x-spam-rule:"<br />
color header green black "^x-mailer:"<br />
color header yellow black "^message-id:"<br />
color header yellow black "^Organization:"<br />
color header yellow black "^Organisation:"<br />
color header yellow black "^User-Agent:"<br />
color header yellow black "^message-id: .*pine"<br />
color header yellow black "^X-Fnord:"<br />
color header yellow black "^X-WebTV-Stationery:"<br />
<br />
color header red black "^x-spam-rule:"<br />
color header green black "^x-mailer:"<br />
color header yellow black "^message-id:"<br />
color header yellow black "^Organization:"<br />
color header yellow black "^Organisation:"<br />
color header yellow black "^User-Agent:"<br />
color header yellow black "^message-id: .*pine"<br />
color header yellow black "^X-Fnord:"<br />
color header yellow black "^X-WebTV-Stationery:"<br />
color header yellow black "^X-Message-Flag:"<br />
color header yellow black "^X-Spam-Status:"<br />
color header yellow black "^X-SpamProbe:"<br />
color header red black "^X-SpamProbe: SPAM"<br />
<br />
## Coloring quoted text - coloring the first 7 levels: <br />
color quoted cyan black<br />
color quoted1 yellow black<br />
color quoted2 red black<br />
color quoted3 green black<br />
color quoted4 cyan black<br />
color quoted5 yellow black<br />
color quoted6 red black<br />
color quoted7 green black<br />
<br />
## Default color definitions <br />
#color hdrdefault white green <br />
color signature brightmagenta black<br />
color indicator black cyan<br />
color attachment black green<br />
color error red black<br />
color message white black<br />
color search brightwhite magenta<br />
color status brightyellow blue<br />
color tree brightblue black<br />
color normal white black<br />
color tilde green black<br />
color bold brightyellow black<br />
#color underline magenta black <br />
color markers brightcyan black<br />
<br />
## Colour definitions when on a mono screen <br />
mono bold bold<br />
mono underline underline<br />
mono indicator reverse</nowiki><br />
}}<br />
<br />
===Index Format===<br />
<br />
Here follows a quick example to put in your {{ic|.muttrc}} to customize the Index Format, i.e. the columns displayed in the folder view.<br />
{{bc|<nowiki><br />
set date_format="%y-%m-%d %T"<br />
set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"</nowiki><br />
}}<br />
See the [http://www.mutt.org/doc/manual/manual-6.html Mutt Reference], {{ic|man 3 strftime}} and {{ic|man 3 printf}} for more details.<br />
<br />
===Address aliases===<br />
''Aliases'' is the way Mutt manages contacts.<br />
An alias is '''nickname [longname] <address>'''.<br />
* The '''nickname''' is what you will type in Mutt to get your contact address. One word only, and should be easy to remember.<br />
* The '''longname''' is optional. It may be several words.<br />
* An '''<address>''' must be in a valid form (i.e. with an {{keypress|@}}).<br />
<br />
It is quite simple indeed. Add this to {{ic|.muttrc}}:<br />
{{bc|1=<br />
set alias_file = "~/.mutt/aliases"<br />
set sort_alias = alias<br />
set reverse_alias = yes<br />
source $alias_file<br />
}}<br />
<br />
Explanation:<br />
* {{ic|alias_file}} is the file where the information is getting stored when you add an alias from within Mutt.<br />
* {{ic|sort_alias}} specifies which field to use to sort the alias list when displayed in Mutt. Possible values: alias, address.<br />
* {{ic|reverse_alias}} sorts in reverse order if set to yes.<br />
* {{ic|source $alias_file}} tells Mutt to read aliases on startup. Needed for auto-completion.<br />
<br />
Now all you have to do when prompted {{ic|To:}} is writing the alias instead of the full address. The beauty of it is that you can auto-complete the alias using {{keypress|Tab}}.<br />
Autocompleting a wrong or an empty string will display the full list. You can select the alias as usual, or by typing its index number.<br />
<br />
There is two ways to create aliases:<br />
* From Mutt, press {{keypress|a}} when an e-mail of the targetted person if selected.<br />
* Edit the alias_file manually. The syntax is really simple:<br />
{{bc|<br />
alias nickname Long Name <my-friend@domain.tld><br />
}}<br />
<br />
== Tips and tricks ==<br />
<br />
===Request IMAP mail retrieval manually===<br />
If you do not want to wait for the next automatic IMAP fetching (or if you did not enable it), you might want to fetch mails manually.<br />
There is a mutt command {{ic|imap-fetch-mail}} for that.<br />
Alternatively, you could bind it to a key:<br />
bind index "^" imap-fetch-mail<br />
<br />
===Speed up folders switch===<br />
Add this to your {{ic|.muttrc}}:<br />
{{bc|1=<br />
set sleep_time = 0<br />
}}<br />
<br />
===Use Mutt to send mail from command line===<br />
Man pages will show all available commands and how to use them, but here are a couple of examples. You could use Mutt to send alerts, logs or some other system information, triggered by login through .bash_profile, or as a regular cron job.<br />
<br />
Send a message:<br />
mutt -s "Subject" somejoeorjane@someserver.com < /var/log/somelog<br />
<br />
Send a message with attachment:<br />
mutt -s "Subject" somejoeorjane@someserver.com -a somefile < /tmp/sometext.txt<br />
<br />
===Composing HTML e-mails===<br />
<br />
Since Mutt has nothing of a WYSIWIG client, HTML is quite straightforward, and you can do much more than with all WYSIWIG mail clients around since you edit the source code directly.<br />
Simply write your mail using HTML syntax. For example:<br />
{{bc|<nowiki><br />
This is normal text<br><br />
<b>This is bold text</b></nowiki><br />
}}<br />
Now before sending the mail, use the {{ic|edit-type}} command (default shortcut {{keypress|Ctrl+t}}), and replace {{ic|text/plain}} by {{ic|text/html}}.<br />
<br />
{{Note|HTML e-mails are regarded by many people as useless, cumbersome, and subject to reading issues. Mutt can read HTLM mails with a text browser like w3m or lynx, but it has clearly no advantage over a plain-text e-mail. You should avoid writing HTLM e-mails when possible.}}<br />
<br />
===How to display another email while composing===<br />
A common complaint with Mutt is that when composing a new mail (or reply), you cannot open another mail (i.e. for checking with another correspondent) without closing the current mail (postponing). The following describes a solution:<br />
<br />
First, fire up Mutt as usual. Then, launch another terminal window. Now start a new Mutt with <br />
mutt -R<br />
This starts Mutt in read-only mode, and you can browse other emails at your convenience. It is strongly recommended to always launch a second Mutt in read-only mode, as conflicts will easily arise otherwise.<br />
<br />
Now, this solution calls for a bit of typing, so we would like to automate this. The following works with [[Awesome]], in other WM's or DE's similar solutions are probably available: just google how to add a key binding, and make the desired key execute <br />
$TERM -e mutt -R <br />
where $TERM is your terminal.<br />
<br />
As for Awesome: edit your rc.lua, and add the following on one of the first lines, after terminal = "yourTerminal" etc.<br />
mailview = terminal .. " -e mutt -R"<br />
This automatically uses your preferred terminal, ".." is concatenation in Lua. Note the space before -e.<br />
<br />
Then add the following inside --{{{ Key bindings<br />
awful.key({ modkey, }, "m", function() awful.util.spawn(mailview) end),<br />
<br />
Omit the final comma if this is the last line. You can, of course use another key than "m". Now, save&quit, and check your syntax with <br />
awesome -k<br />
If this is good, restart awesome and give it a try!<br />
<br />
Now, a usage example: Launch Mutt as usual. Start a new mail, and then press "Mod4"+"m". This opens your mailbox in a new terminal, and you can browse around and read other emails. Now, a neat bonus: exit this read-only-Mutt with "q", and the terminal window it created disappears!<br />
<br />
===Mutt-Sidebar===<br />
{{Aur|mutt-sidebar}} - A patch for a list of folders on the left side of the Mutt window.<br />
<br />
[http://www.lunar-linux.org/mutt-sidebar/ mutt-sidebar maintainer website and documentation]<br />
<br />
===Migrating mails from one computer to another===<br />
In case you are transfering your mails to a new machine (copy&paste), you probably need to delete ~/.hcache to make mutt able to read your migrated E-Mails. Otherwise mutt may freeze.<br />
<br />
==Troubleshooting==<br />
<br />
===Backspace does not work in Mutt===<br />
This is a common problem with some xterm-like terminals.<br />
Two solutions:<br />
* Either rebind the key in {{ic|.muttrc}}<br />
bind index,pager ^? previous-page<br />
Note that {{ic|^?}} is one single character representing backspace in [http://en.wikipedia.org/wiki/Caret_notation Caret notation]. To type in Emcas, use {{keypress|Ctrl+q Backspace}}, in Vim {{keypress|Ctrl+v Backspace}}.<br />
<br />
* Or fix your terminal:<br />
$ infocmp > termbs.src <br />
Edit {{ic|termbs.src}} and change {{ic|1= kbs=^H}} to {{ic|1= kbs=\177}}, then: <br />
$ tic -x termbs.src<br />
<br />
== See also ==<br />
* [http://www.mutt.org/ The official Mutt website]<br />
* [http://wiki.mutt.org/ The Mutt wiki]<br />
* [http://pbrisbin.com/posts/two_accounts_in_mutt/ Brisbin's great guide on how to setup different IMAP accounts with Mutt + offlineimap + msmtp]<br />
* [http://home.roadrunner.com/~computertaijutsu/mutt.html A Quick Guide to Mutt]<br />
* [http://pyropus.ca/software/getmail/configuration.html#running Documentation on Configuring Getmail with rcfiles]</div>Popschhttps://wiki.archlinux.org/index.php?title=PulseAudio&diff=198841PulseAudio2012-04-24T15:00:45Z<p>Popsch: /* No mic on ThinkPad T400/T500 */</p>
<hr />
<div>[[Category:Audio/Video]]<br />
[[fr:PulseAudio]]<br />
{{i18n|PulseAudio}}<br />
<br />
{{Article summary start}}<br />
{{Article summary text|'''PulseAudio''' is a general purpose sound server. For a list of features, see [[Wikipedia:PulseAudio#Features]].}}<br />
{{Article summary heading|Related Articles}}<br />
{{Article summary wiki|PulseAudio/Examples}}<br />
{{Article summary end}}<br />
<br />
==Installation==<br />
*Required PKG: {{Pkg|pulseaudio}}<br />
*Optional GUIs: {{Pkg|paprefs}} and {{Pkg|pavucontrol}}<br />
*Optional volume control via mapped keyboard keys: {{AUR|pulseaudio_ctl}}<br />
*Optional console mixer: {{AUR|pamixer-git}}<br />
*Optional system tray icon: {{AUR|pasystray-git}}<br />
<br />
==Running==<br />
{{Note|Pulseaudio requires dbus to function. This is very likely already added in the daemons array, if not consider adding it.}}<br />
{{Note|Most X11 environments start pulseaudio automatically with the X11 session.}}<br />
<br />
In the unlikely event that pulseaudio is not automatically called upon entering X, it can can be started with:<br />
$ pulseaudio --start<br />
<br />
{{Note|if you get the message {{ic|pulseaudio: error while loading shared libraries: libltdl.so.7: cannot open shared object file: No such file or directory}} you need to install {{pkg|libltdl}} }}<br />
<br />
PulseAudio can be stopped with:<br />
$ pulseaudio --kill<br />
<br />
==Equalizer==<br />
<br />
Newer pulseaudio versions have an intergrated 10-band equalizer system. In order to use the equalizer do the following:<br />
<br />
===Load equalizer sink module===<br />
<br />
$ pactl load-module module-equalizer-sink<br />
<br />
===Install and run the gui frontend===<br />
<br />
# pacman -S --needed python2-pyqt<br />
<br />
$ qpaeq<br />
<br />
===Load equalizer module on every boot===<br />
<br />
Edit the file {{ic|/etc/pulse/default.pa}} with your favorite editor and append the following lines:<br />
<br />
### Load the integrated pulseaudio equalizer module<br />
load-module module-equalizer-sink<br />
<br />
==Backend Configuration==<br />
===ALSA===<br />
*Recommended PKG: {{Pkg|pulseaudio-alsa}}<br />
*Optional PKGs: {{Pkg|lib32-libpulse}} and {{Pkg|lib32-alsa-plugins}}<br />
<br />
{{Note|Optional PKGs are needed only if running x86_64 and wanting to have sound for 32 bit programs (like Wine).}}<br />
<br />
For the applications that do not support PulseAudio and support ALSA it is '''recommended''' to install the PulseAudio plugin for ALSA. This package also contains the necessary {{ic|/etc/asound.conf}} for configuring ALSA to use PulseAudio.<br />
<br />
To prevent applications from using ALSA's OSS emulation and bypassing Pulseaudio (thereby preventing other applications from playing sound), make sure the module {{ic|snd_pcm_oss}} is not in the {{ic|MODULES}} array in {{ic|/etc/[[rc.conf]]}}. If it is currently loaded, disable it by executing:<br />
# rmmod snd_pcm_oss<br />
<br />
===OSS===<br />
There are multiple ways of making OSS-only programs play to PulseAudio:<br />
<br />
====osspd====<br />
Recommended PKG: {{Pkg|ossp}}<br />
<br />
Start osspd with:<br />
rc.d start osspd<br />
<br />
Afterwards, add it to DAEMONS in rc.conf.<br />
<br />
====padsp wrapper====<br />
Programs using OSS can work with PulseAudio by starting it with padsp:<br />
<br />
$ padsp OSSprogram<br />
A few examples:<br />
$ padsp aumix<br />
$ padsp sox foo.wav -t ossdsp /dev/dsp<br />
<br />
One can also rename the program OSSprogram-bin and replace it with a script like this: <br />
{{hc|/usr/bin/OSSProgram|<nowiki><br />
#!/bin/sh<br />
if test -x /usr/bin/padsp; then<br />
exec /usr/bin/padsp /usr/bin/OSSprogram-bin "$@"<br />
else<br />
exec /usr/bin/OSSprogram "$@"<br />
fi<br />
</nowiki>}}<br />
<br />
===GStreamer===<br />
To make [[GStreamer]] use PulseAudio, execute {{ic|gstreamer-properties}} (part of ''gnome-media'' package) and select ''PulseAudio Sound Server'' in both Audio Input and Output. Alternatively, this can be done by setting the gconf variables {{ic|/system/gstreamer/0.10/default/audiosink}} to ''pulsesink'' and {{ic|/system/gstreamer/0.10/default/audiosrc}} to ''pulsesrc'':<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosink pulsesink<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/audiosrc pulsesrc<br />
<br />
Some applications (like Rhythmbox) ignore the ''audiosink'' property, but rely instead on ''musicaudiosink'', which cannot be configured using {{ic|gstreamer-properties}} but needs to be manually set using {{ic|gconf-editor}} or the {{ic|gconftool-2}}:<br />
$ gconftool-2 -t string --set /system/gstreamer/0.10/default/musicaudiosink pulsesink<br />
<br />
===OpenAL===<br />
OpenAL Soft should use PulseAudio by default, but can be explicitly configured to do so: {{hc|/etc/openal/alsoft.conf|2=drivers=pulse,alsa}}<br />
<br />
===libao===<br />
Edit the libao configuration file:<br />
{{hc|/etc/libao.conf|2=default_driver=pulse}}<br />
<br />
===ESD===<br />
PulseAudio is a drop-in replacement for the enlightened sound daemon (ESD). While PulseAudio is running, ESD clients should be able to output to it without configuration.<br />
<br />
==Desktop Environments==<br />
===General X11===<br />
{{Note|As mentioned previously, PulseAudio is very likely launched automatically via either {{ic|/etc/X11/xinit/xinitrc.d/pulseaudio}} or the files in {{ic|/etc/xdg/autostart/}} if users have some DE installed.}}<br />
<br />
Check to see of PulseAudio is running:<br />
<br />
$ ps aux | grep pulse<br />
facade 1794 0.0 0.0 360464 6532 ? S<l 15:33 0:00 /usr/bin/pulseaudio --start<br />
facade 1827 0.0 0.0 68888 2608 ? S 15:33 0:00 /usr/lib/pulse/gconf-helper<br />
<br />
If Pulseaudio is not running and users are using X, the following will start PulseAudio with the needed the X11 plugins:<br />
$ start-pulseaudio-x11<br />
<br />
===GNOME===<br />
As of GNOME 3, GNOME fully integrates with PulseAudio and no extra configuration is needed.<br />
<br />
===KDE 3===<br />
PulseAudio is ''not'' a drop-in replacement for aRts. Users of KDE 3 cannot use PulseAudio. However note, recent versions of puleaudio may have eliminated the prohibition:<br />
<br />
See: http://www.pulseaudio.org/wiki/PerfectSetup KDE 3 uses the artsd sound server by default. However, artsd itself can be configured to use an Esound backend. Edit kcmartsrc (either in /etc/kde or /usr/share/config for global configuration or .kde/share/config to configure only one user) like this:<br />
<br />
[Arts]<br />
Arguments=\s-F 10 -S 4096 -a esd -n -s 1 -m artsmessage -c drkonqi -l 3 -f<br />
NetworkTransparent=true<br />
SuspendTime=1<br />
<br />
===KDE 4 and Qt4===<br />
PulseAudio, it will be used by KDE4/Qt4 applications. For more information see the [http://www.pulseaudio.org/wiki/KDE KDE pages in the PulseAudio wiki].<br />
<br />
Additionally, the {{AUR|kdeplasma-addons-applets-veromix}} is available in the AUR as a KDE alternative to pavucontrol.<br />
<br />
===XFCE4===<br />
Applications running under XFCE4 can take advantage of Pulseaudio. To manage Pulseaudio settings can use {{Pkg|pavucontrol}}.<br />
<br />
==Applications==<br />
===Audacious===<br />
[[Audacious]] natively supports PulseAudio. In order to use it, set Audacious Preferences -> Audio -> Current output plugin to 'PulseAudio Output Plugin'.<br />
<br />
===Flashplugin (x86_64 only)===<br />
Users of [[Browser Plugins#Adobe Flash Player|Adobe Flash Player]] browser plugin from the [[Multilib_Project|multilib repository]] need to install {{Pkg|lib32-alsa-plugins}} and {{Pkg|lib32-libcanberra-pulse}}.<br />
<br />
===Java/OpenJDK 6===<br />
Create a wrapper for the java executable using padsp as seen on the [[Java#Java_sound_with_Pulseaudio|Java sound with Pulseaudio]] page.<br />
<br />
===Music Player Daemon (MPD)===<br />
[http://mpd.wikia.com/wiki/PulseAudio configure] [[MPD]] to use PulseAudio.<br />
<br />
===MPlayer===<br />
[[MPlayer]] natively supports PulseAudio output with the "{{ic|-ao pulse}}" option. It can also be configured to default to PulseAudio output, in {{ic|~/.mplayer/config}} for per-user, or {{ic|/etc/mplayer/mplayer.conf}} for system-wide:<br />
{{hc|/etc/mplayer/mplayer.conf|2=ao=pulse}}<br />
<br />
===Skype (x86_64 only)===<br />
Install {{Pkg|lib32-libpulse}}, otherwise the following error will occur when trying to initiate a call: "Problem with Audio Playback".<br />
<br />
==Troubleshooting==<br />
===No sound after install===<br />
====Bad configuration files====<br />
If after starting pulseaudio, the system outputs no sound, it may be necessary to delete the contents of {{ic|~/.pulse}}. Pulseaudio will automatically create new configuration files on its next start.<br />
<br />
====Flash Content====<br />
No sound from flash content may be fixed by installing {{AUR|libflashsupport-pulse}} from the AUR. {{Pkg|lib32-libpulse}} is another PKG users can consider if on a 64-bit Arch and using [multilib]'s flashplugin:<br />
<br />
# pacman -S lib32-libcanberra-pulse lib32-alsa-plugins<br />
<br />
====No cards====<br />
If PulseAudio starts, run {{ic|pacmd list}}. If no cards are reported, make sure that the ALSA devices are not in use:<br />
$ fuser -v /dev/snd/*<br />
$ fuser -v /dev/dsp<br />
<br />
Make sure any applications using the pcm or dsp files are shut down before restarting PulseAudio.<br />
<br />
====The only device shown is "dummy output"====<br />
This may be caused by different reasons, one of them being the .asoundrc file in $HOME is taking precedence over the systemwide /etc/asound.conf.<br />
<br />
The user file is modified also by the tool '''asoundconf''' or by its graphical variant '''asoundconf-gtk''' (the latter is named "Default sound card" in the menu) as soon as it runs. Prevent the effects of .asoundrc altogether by commenting the last line like this:<br />
<br />
#</home/<yourusername>/.asoundrc.asoundconf><br />
<br />
====KDE4====<br />
It may be that another output device set as preferred in phonon. Make sure that every setting reflects the preferred output device at the top, and check the playback streams tab in kmix to make sure that applications are using the device for output.<br />
<br />
====Muted audio device====<br />
If one experiences no audio output via any means while using ALSA, attempt to unmute the sound card. To do this, launch alsamixer and make sure each column has a green 00 under it (this can be toggled by pressing 'm')<br />
$ alsamixer -c 0<br />
<br />
===Bluetooth headset replay problems===<br />
Some user [https://bbs.archlinux.org/viewtopic.php?id=117420 report] huge delays or even no sound when the bluetooth connection does not send any data. This is due to an idle-suspend-module that puts the related sinks/sources automatically into suspend. As this can cause problems with headset, the responsible module can be deactivated. <br />
<br />
1. cp /etc/pulse/default.pa ~/.pulse/default.pa<br />
2. comment out the "load-module module-suspend-on-idle" line in ~/.pulse/default.pa<br />
3. pulseaudio -k && pulseaudio --start<br />
<br />
[http://robert.orzanna.de/2011/08/10/prevent-idle-suspend-with-a-bluetooth-headset-and-a2dp/ More information]<br />
<br />
===Pulse overwrites ALSA settings===<br />
Pulseaudio usually overwrites the ALSA settings- for example set with alsamixer- at start up, even when the alsa daemon is loaded. Since there seems to be no other way to restrict this behaviour, a workaround is to restore the alsa settings again after pulseaudio had started. Add the following command to {{ic|.xinitrc}} {{ic|.bash_login}} or any other autostart file:<br />
<br />
restore_alsa() {<br />
while [ -z "`pidof pulseaudio`" ]; do<br />
sleep 0.5<br />
done<br />
alsactl -f /var/lib/alsa/asound.state restore <br />
}<br />
restore_alsa &<br />
<br />
===Daemon startup failed===<br />
Try resetting PulseAudio. To do that:<br />
$ pulseaudio --kill<br />
$ killall pulseaudio<br />
$ killall -9 pulseaudio<br />
$ rm -rf ~/.pulse*<br />
$ rm -rf /tmp/pulse*<br />
<br />
Afterwards, start PulseAudio again.<br />
<br />
===padevchooser===<br />
If one cannot launch the PulseAudio Device Chooser, first (re)start the Avahi daemon as follows:<br />
$ rc.d restart avahi-daemon<br />
<br />
===Glitches, skips or crackling===<br />
The PulseAudio sound server uses a timer-based audio scheduling instead of the traditional interrupt-driven approach. Timer-based scheduling may expose issues in some ALSA drivers. To turn timer-based scheduling off, replace the line:<br />
load-module module-udev-detect <br />
in {{ic|/etc/pulse/default.pa}} by:<br />
load-module module-udev-detect tsched=0<br />
Then restart the PulseAudio server.<br />
<br />
===Choppy sound===<br />
Choppy sound in pulsaudio can result from wrong settings for the sample rate in {{Ic|/etc/pulse/daemon.conf}}. Try changing the line <br />
; default-sample-rate = 44100<br />
to <br />
default-sample-rate = 48000<br />
and restart the PulseAudio server.<br />
<br />
If one experiences choppy sound in applications using openAL, change the sample rate in /etc/openal/alsoft.conf:<br />
frequency = 48000<br />
<br />
===Volume adjustment does not work properly===<br />
Check:<br />
{{ic|/usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf.common}}<br />
<br />
If the volume does not appear to increment/decrement properly using {{ic|alsamixer}} or {{ic|amixer}}, it may be due to pulseaudio having a larger number of increments (65537 to be exact). Try using larger values when changing volume (e.g. {{ic|amixer set Master 655+}}).<br />
<br />
===Volume gets louder every time a new application is started===<br />
Per default, it seems as if changing the volume in an application sets the global system volume to that level instead of only affecting the respective application. Applications setting their volume on startup will therefore cause the system volume to "jump".<br />
<br />
Fix this by uncommenting <br />
flat-volumes = no<br />
in<br />
/etc/pulse/daemon.conf<br />
and then restarting PulseAudio by executing<br />
pulseaudio -k<br />
<br />
When Pulse comes back after a few seconds, applications will not alter the global system volume anymore but have their own volume level again.<br />
<br />
{{Note|A previously installed and removed pulseaudio-equalizer may leave behind remnants of the setup in {{Ic|$HOME/.pulse/default.pa}} which can also cause maximized volume trouble. Comment that out as needed.}}<br />
<br />
===No mic on ThinkPad T400/T500/T420===<br />
Run<br />
alsamixer -c 0<br />
Maximize the volume of/unmute the "Internal Mic".<br />
<br />
Once you see the device with<br />
arecord -l<br />
you might still need to adjust the settings. The microphone and the audio jack are duplexed. Set the configuration of the internal audio in pavucontrol to ''Analog Stereo Duplex''.<br />
<br />
===No mic input on Acer Aspire One===<br />
Install pavucontrol, unlink the microphone channels and turn down the left one to 0.<br />
Reference: http://getsatisfaction.com/jolicloud/topics/deaf_internal_mic_on_acer_aspire_one#reply_2108048<br />
<br />
===Sound output is only mono on M-Audio Audiophile 2496 sound card===<br />
Add the following to /etc/pulseaudio/default.pa:<br />
load-module module-alsa-sink sink_name=delta_out device=hw:M2496 format=s24le channels=10 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7<br />
load-module module-alsa-source source_name=delta_in device=hw:M2496 format=s24le channels=12 channel_map=left,right,aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9<br />
set-default-sink delta_out<br />
set-default-source delta_in<br />
<br />
===Static Noise in Microphone Recording===<br />
If we are getting static noise in skype, gnome-sound-recorder, arecord, etc.'s recordings then the sound card samplerate is incorrect. That is why there is static noise in linux microphone recordings. To fix this We need to set sample-rate in /etc/pulse/daemon.conf for the sound hardware.<br />
<br />
====1. Determine soundcards in the system====<br />
This requires alsa-utils and related packages to be installed:<br />
$ arecord --list-devices<br />
<br />
output:<br />
**** List of CAPTURE Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: ALC888 Analog [ALC888 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 2: ALC888 Analog [ALC888 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
<br />
soundcard is hw:0,0<br />
<br />
====2. Determine sampling-rate of the sound card====<br />
arecord -f dat -r 60000 -D hw:0,0 -d 5 test.wav<br />
<br />
output:<br />
"Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo<br />
Warning: rate is not accurate (requested = 60000Hz, '''got = 96000Hz''')<br />
please, try the plug plugin<br />
<br />
observe, the '''got = 96000Hz''', this is the max sample-rate of our card.<br />
<br />
====3. Setting the soundcard's sampling rate into pulse audio configuration====<br />
the default sample-rate in pulseaudio is<br />
grep "sample-rate" /etc/pulse/daemon.conf<br />
<br />
output:<br />
; default-sample-rate = 44100<br />
<br />
It is 44100 and is disabled. Let us set our sound card's settings into pulseaudio configuation file<br />
su -c "sed 's/; default-sample-rate = 44100/default-sample-rate = 96000/g' -i /etc/pulse/daemon.conf"<br />
<br />
Let us verify the changes to deamon.conf<br />
grep "sample-rate" /etc/pulse/daemon.conf <br />
output:<br />
default-sample-rate = 96000<br />
and it is done.<br />
<br />
====4. Restart pulseaudio to apply the new settings====<br />
pulseaudio --kill<br />
pulseaudio --start<br />
<br />
====5. Finally check by recording and playing it back====<br />
Let us record some voice using mic for say 10 seconds. Make sure the mic is not muted and all<br />
arecord -f cd -d 10 test-mic.wav<br />
<br />
After 10 seconds, let us play the recording...<br />
aplay test-mic.wav<br />
<br />
Now hopefully, there is no static noise in microphone recording anymore.<br />
<br />
=== My Bluetooth device is paired but does not play any sound ===<br />
[[Bluetooth#My_device_is_paired_but_no_sound_is_played_from_it|See the article in Bluetooth section]]<br />
<br />
=== Subwoofer stops working after end of every song ===<br />
Known issue: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/494099<br />
<br />
To fix this, must edit: {{ic|/etc/pulse/daemon.conf}} and enable {{ic|enable-lfe-remixing}} :<br />
{{hc|/etc/pulse/daemon.conf|<nowiki><br />
enable-lfe-remixing = yes<br />
</nowiki>}}<br />
<br />
=== Pulseaudio uses wrong microphone ===<br />
If Pulseaudio uses the wrong microphone, and changing the Input Device with Pavucontrol did not help, take a look at alsamixer. It seems that Pavucontrol does not always set the input source correctly.<br><br />
Run:<br />
<br />
$ alsamixer<br />
<br />
press F6 and choose your sound card, e.g. HDA Intel. Now press F5 to display all items. Try to find the item: {{ic|Input Source}}. With the up/down arrow keys you are able to change the input source. <br><br />
Now try if the correct microphone is used for recording.<br />
<br />
==External links==<br />
*[http://www.pulseaudio.org/wiki/PerfectSetup http://www.pulseaudio.org/wiki/PerfectSetup] - A good guide to make your configuration perfect<br />
*[http://www.alsa-project.org/main/index.php/Asoundrc http://www.alsa-project.org/main/index.php/Asoundrc] - Alsa wiki on .asoundrc<br />
*[http://www.pulseaudio.org/ http://www.pulseaudio.org/] - PulseAudio official site<br />
*[http://www.pulseaudio.org/wiki/FAQ http://www.pulseaudio.org/wiki/FAQ] - PulseAudio FAQ</div>Popsch