https://wiki.archlinux.org/api.php?action=feedcontributions&user=Hongy19&feedformat=atomArchWiki - User contributions [en]2024-03-29T10:03:26ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=HiDPI&diff=776863HiDPI2023-05-03T04:53:36Z<p>Hongy19: /* GDK 3 (GTK 3) */ highlight GDK_SCALE only work for x11,not for wayland</p>
<hr />
<div>[[Category:Graphics]]<br />
[[ja:HiDPI]]<br />
[[zh-hans:HiDPI]]<br />
{{Related articles start}}<br />
{{Related|Font configuration}}<br />
{{Related articles end}}<br />
HiDPI (High Dots Per Inch) displays, also known by Apple's "[[wikipedia:Retina Display|Retina Display]]" marketing name, are screens with a high resolution in a relatively small format. They are mostly found in high-end laptops and monitors.<br />
<br />
Not all software behaves well in high-resolution mode yet. Here are listed most common tweaks which make work on a HiDPI screen more pleasant.<br />
<br />
== Desktop environments ==<br />
<br />
=== GNOME ===<br />
<br />
To enable HiDPI, navigate to ''Settings > Devices > Displays > Scale'' and choose an appropriate value. Or, use gsettings:<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "[{'Gdk/WindowScalingFactor', <2>}]"<br />
$ gsettings set org.gnome.desktop.interface scaling-factor 2<br />
<br />
{{Note|1=GNOME only allows integer scaling numbers to be set. 1 = 100%, 2 = 200%, etc. See [[#Fractional scaling]] below.}}<br />
<br />
==== Fractional scaling ====<br />
<br />
A setting of {{ic|2, 3, etc}}, which is all you can do with {{ic|scaling-factor}}, may not be ideal for certain HiDPI displays and smaller screens (e.g. small tablets). Fractional scaling is possible on both Wayland and Xorg, though the process differs.<br />
<br />
Implementation was mainly discussed and decided in GNOME fractional scaling hackfest 2017, check [https://hackmd.io/WspOFZpRTo2qlWc8fh_zPQ] for more technical details.<br />
<br />
{{Note|{{Accuracy|This note may not be entirely correct, especially for GTK4, see [https://www.reddit.com/r/gnome/comments/11ekj8o/comment/jah8i0b/]}}<br />
<br />
GTK does not and has no plans to support DPI scaling on all elements except fonts. Therefore, fractional scaling on GNOME uses oversampling, which means rendering at a higher resolution, then scaling down with integer scaling, and is true for both Wayland and Xorg sessions. This brings higher GPU and CPU (since GTK is not fully hardware accelerated) usage, more power consumption, and in some cases significantly slower responsiveness, particularly noticeable in Xorg. If it is necessary to avoid these problems, consider switching to a Qt based desktop environment.}}<br />
<br />
===== Wayland =====<br />
<br />
Enable the experimental fractional scaling feature:<br />
<br />
$ gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"<br />
<br />
then open ''Settings > Devices > Displays'' (the new options may only appear after a restart).<br />
<br />
{{Note|Enabling fractional scaling can result in blur for legacy applications using XWayland, ''even if only integer scales are used'', because the rendering method changes.}}<br />
<br />
To enable the option for all users, create the following three files with the corresponding content<br />
<br />
{{hc|/etc/dconf/profile/user|<nowiki><br />
user-db:user<br />
system-db:local<br />
</nowiki>}}<br />
<br />
{{hc|/etc/dconf/db/local.d/00-hidpi|<nowiki><br />
[org/gnome/mutter]<br />
experimental-features=['scale-monitor-framebuffer']<br />
</nowiki>}}<br />
<br />
{{hc|/etc/dconf/db/locks/hidpi|<nowiki><br />
/org/gnome/mutter/experimental-features<br />
</nowiki>}}<br />
<br />
Then run {{ic|dconf update}} and restart the machine. This will permanently lock the option.<br />
<br />
===== Xorg =====<br />
<br />
Ubuntu has provided a patch[https://salsa.debian.org/gnome-team/mutter/-/blob/ubuntu/master/debian/patches/ubuntu/x11-Add-support-for-fractional-scaling-using-Randr.patch] to scale with Randr in GNOME Settings. This patch is already provided by {{AUR|mutter-x11-scaling}}. After installing it, you can set:<br />
<br />
$ gsettings set org.gnome.mutter experimental-features "['x11-randr-fractional-scaling']"<br />
<br />
Then open ''Settings > Devices > Displays'' to set the scale.<br />
<br />
You can also manually achieve any non-integer scale factor by using a combination of GNOME's {{ic|scaling-factor}} and [[xrandr]]. This combination keeps the TTF fonts properly scaled so that they do not become blurry if using {{ic|xrandr}} alone. You specify zoom-in factor with {{ic|gsettings}} and zoom-out factor with [[xrandr]].<br />
<br />
First scale GNOME up to the minimum size which is too big. Usually "2" is already too big, otherwise try "3" etc. Then start scaling down by setting zoom-out factor with [[xrandr]]. First get the relevant output name, the examples below use {{ic|eDP1}}. Start e.g. with zoom-out 1.25 times. If the UI is still too big, increase the scale factor; if it is too small decrease the scale factor.<br />
<br />
$ xrandr --output eDP1 --scale 1.25x1.25<br />
<br />
{{Note|To allow the mouse to reach the whole screen, you may need to use the {{ic|--panning}} option as explained in [[#Side display]].}}<br />
<br />
To ensure that the settings persist across reboots, you may choose to use {{Pkg|autorandr}}. Refer to [https://askubuntu.com/a/1130337 this StackOverflow] for more information.<br />
<br />
{{Accuracy|The following was initially added under [[#X Resources]]. Clarify how it integrates with the info there or that above for GNOME.|section=GNOME ignores X settings}}<br />
<br />
GNOME ignores X settings due to its xsettings Plugin in Gnome Settings Daemon, where DPI setting is hard coded.<br />
There is blog entry for [http://blog.drtebi.com/2012/12/changing-dpi-setting-on-gnome-34.html recompiling Gnome Settings Daemon]{{Dead link|2022|09|18|status=domain name not resolved}}.<br />
In the source documentation there is another way mentioned to set X settings DPI:<br />
<br />
You can use the gsettings, just make sure to read previous setting first and merge it. In just simply set it with this command:<br />
<br />
$ gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Xft/DPI': <153600>}"<br />
<br />
From README.xsettings<br />
<br />
Noting that variants must be specified in the usual way (wrapped in <>).<br />
<br />
Note also that DPI in the above example is expressed in 1024ths of an inch.<br />
<br />
==== Text Scaling ====<br />
<br />
Alternatively, or in addition to changing the display scaling, you can separately scale text. This can be done by navigating to ''Fonts > Scaling Factor'' in Gnome Tweaks, or using gsettings. Note that the text scaling factor need not be limited to whole integers, for example:<br />
<br />
$ gsettings set org.gnome.desktop.interface text-scaling-factor 1.5<br />
<br />
===== GTK+ vs Gnome Shell elements on Xorg =====<br />
<br />
{{Out of date|Needs a partial rewrite regarding the Gnome Shell Toolkit, since it looks unmaintained since [https://gitlab.gnome.org/GNOME/gnome-shell/-/tree/shell-toolkit 2009].}}<br />
<br />
Adjusting the text scaling as per the above only affects GTK+ elements of the GNOME desktop. This should cover everything on Wayland. However, those on an Xorg session may find that they need to make further adjustments on HiDPI environments, since the GNOME Shell UI (including the top bar, dock, application menus, etc.) relies separately on the [https://developer.gnome.org/st/stable/ St]{{Dead link|2021|11|11|status=404}} toolkit. Note that this is a long-standing issue to which a [https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/486 patch] has been merged and available for Gnome Shell 3.35 onward. For older releases, Xorg users can resolve most of the Gnome shell scaling problems by manually editing the shell theme that they are currently using. The relevant CSS files are normally located at {{ic|/usr/share/themes/YOUR-THEME/gnome-shell/gnome-shell.css}}. Users should increase all "font-size" elements in this file in proportion to their display scaling (doubling font sizes for 200% scaling, etc.) For example, the top of an edited CSS file for the [https://github.com/adapta-project/adapta-gtk-theme Adapta] shell theme might look like:<br />
<br />
{{hc|usr/share/themes/Adapta/gnome-shell/gnome-shell.css|2=<br />
stage { font-size: 20pt; font-family: Roboto, Noto Sans, Sans-Serif; color: #263238; }<br />
}}<br />
<br />
Once these changes have been saved, activate them by switching to another theme (for example, using {{pkg|gnome-tweaks}}) and then reverting back again. The top bar, application menus, calendar, and other shell elements should now be correctly scaled.<br />
<br />
In addition to editing the relevant shell theme's CSS file, users on Xorg may also wish to increase the title bar font at the top of open applications. This can be done through the dconf editor ({{ic|org > gnome > desktop > wm > preferences :: titlebar-font}}). Note that the {{ic|title-bar-uses-system-fonts}} option should also be turned off. Alternatively, use gsettings:<br />
<br />
$ gsettings set org.gnome.desktop.wm.preferences titlebar-font 'Cantarell Bold 22' ## Change as needed<br />
$ gsettings set org.gnome.desktop.wm.preferences titlebar-uses-system-font false<br />
<br />
=== KDE Plasma ===<br />
<br />
You can use Plasma's settings to fine tune font, icon, and widget scaling. This solution affects both Qt and GTK applications.<br />
<br />
{{Note|Plasma 5.27 [https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2544 dropped] use of {{ic|GDK_SCALE}}/{{ic|GDK_DPI_SCALE}} variables and [https://invent.kde.org/plasma/kde-gtk-config/-/merge_requests/49 switched] to [[Xsettingsd]]. It should be installed to make scaling work for GTK apps. Or you can set this variables manually as described in [[#GDK 3 (GTK 3)]].}}<br />
<br />
To adjust font, widget, and icon scaling together:<br />
<br />
# ''System Settings > Display and Monitor > Display Configuration > Global Scale''<br />
# Drag the slider to the desired size<br />
# Restart for the settings to take effect<br />
<br />
{{Note|If you are using xorg, and global scaling is set but not applied to Qt applications after reboot, please check if {{ic|xft.dpi}} is set in {{ic|~/.Xresources}} . If so, removing the variable and adjusting global scaling again may take effect.}}<br />
<br />
===== Cursor size =====<br />
<br />
To adjust cursor size:<br />
<br />
# ''System Settings > Appearance > Cursors > Size''<br />
<br />
===== Font scaling =====<br />
<br />
To adjust only font scaling:<br />
<br />
# ''System Settings > Appearance > Fonts''<br />
# Check "Force fonts DPI" and adjust the DPI level to the desired value. This setting should take effect immediately for newly started applications. You will have to logout and login for it to take effect on Plasma desktop.<br />
<br />
===== Icon scaling =====<br />
<br />
To adjust only icon scaling:<br />
<br />
# ''System Settings > Appearance > Icons > Advanced''<br />
# Choose the desired icon size for each category listed. This should take effect immediately.<br />
<br />
==== Tray icons with fixed size ====<br />
<br />
The tray icons are not scaled with the rest of the desktop, since Plasma ignores the Qt scaling settings by default. To make Plasma respect the Qt settings, [[Environment variables|set]] {{ic|1=PLASMA_USE_QT_SCALING=1}}.<br />
<br />
==== XWayland ====<br />
<br />
As of Plasma 5.26, the XWayland scale method can be chosen at the bottom of the System Settings => Display and Monitor => Display Configuration page.<br />
<br />
In "Scaled by the system" mode, the X application will be rendered at 1x and then magnified (scaled) by KDE. This works for all applications, but causes blurriness due to the magnification.<br />
<br />
In "Apply scaling themselves" mode, the X application will have to render itself at the appropriate size. This will avoid blurriness, but applications which aren't HiDPI-aware will render themselves at 1x scale and therefore will appear small.<br />
<br />
See this [https://pointieststick.com/2022/06/17/this-week-in-kde-non-blurry-xwayland-apps/ blog post] for details.<br />
<br />
=== Xfce ===<br />
<br />
Xfce supports HiDPI scaling which can be enabled using the settings manager:<br />
<br />
# Go to ''Settings Manager > Appearance > Settings > Window Scaling'' and select 2 as the scaling factor.<br />
# Go to ''Settings Manager > Window Manager > Style'' and select {{ic|Default-xhdpi}} theme.<br />
<br />
Alternatively, it is possible to do the same from command line using {{ic|xfconf-query}}:<br />
<br />
$ xfconf-query -c xsettings -p /Gdk/WindowScalingFactor -s 2<br />
$ xfconf-query -c xfwm4 -p /general/theme -s Default-xhdpi<br />
<br />
After either of the above changes, fonts in some GTK applications may still not be scaled; you may additionally do the following (see [[#GDK 3 (GTK 3)]]):<br />
<br />
# Go to ''Settings Manager > Appearance > Fonts > Custom DPI setting'' and change from 96 to 192<br />
# Set the [[environment variable]] {{ic|1=GDK_DPI_SCALE=0.5}} to un-scale some fonts that would be scaled twice.<br />
<br />
The steps above would set 2x scaled resolution for Xfce and other GTK 3 applications.<br />
<br />
Scaling for Qt 5 applications should be set manually, see [[#Qt 5]]. Note that if you set a Custom DPI for fonts above, you likely need to set {{ic|1=QT_FONT_DPI=96}} to avoid double-scaling of fonts in Qt applications.<br />
<br />
=== Cinnamon ===<br />
<br />
Has good support out of the box.<br />
<br />
=== Enlightenment ===<br />
<br />
For E18, go to the E Setting panel. In ''Look > Scaling'', you can control the UI scaling ratios. A ratio of 1.2 seems to work well for the native resolution of the MacBook Pro 15" screen.<br />
<br />
== X Resources ==<br />
<br />
If you are not using a desktop environment such as KDE, Xfce, or other that manipulates the X settings for you, you can set the desired DPI setting manually via the {{ic|Xft.dpi}} variable in [[Xresources]]:<br />
<br />
{{hc|~/.Xresources|2=<br />
Xft.dpi: 192<br />
<br />
! These might also be useful depending on your monitor and personal preference:<br />
Xft.autohint: 0<br />
Xft.lcdfilter: lcddefault<br />
Xft.hintstyle: hintfull<br />
Xft.hinting: 1<br />
Xft.antialias: 1<br />
Xft.rgba: rgb<br />
}}<br />
<br />
For {{ic|Xft.dpi}}, using integer multiples of 96 usually works best, e.g. 192 for 200% scaling.<br />
<br />
Make sure the settings are loaded properly when X starts, for instance in your {{ic|~/.xinitrc}} with {{ic|xrdb -merge ~/.Xresources}} (see [[Xresources]] for more information).<br />
<br />
This will make the font render properly in most toolkits and applications, it will however not affect things such as icon size!<br />
Setting {{ic|Xft.dpi}} at the same time as toolkit scale (e.g. {{ic|GDK_SCALE}}) may cause interface elements to be much larger than intended in some programs like firefox.<br />
<br />
== X Server ==<br />
<br />
{{Accuracy|{{Pkg|libxft}} is a ''font rendering interface library'', the {{ic|Xft.dpi}} setting was not intended to be abused by other applications. On the other hand, the {{ic|xorg.conf}} value should affect everything.}}<br />
<br />
Some programs may still interpret the DPI given by the X server (most interpret X Resources, though, directly or indirectly). Older versions of i3 (before 2017) and Chromium (before 2017) used to do this.<br />
<br />
To verify that the X Server has properly detected the physical dimensions of your monitor, use the ''xdpyinfo'' utility from the {{Pkg|xorg-xdpyinfo}} package:<br />
<br />
{{hc|$ xdpyinfo {{!}} grep -B 2 resolution|<br />
screen #0:<br />
dimensions: 3200x1800 pixels (423x238 millimeters)<br />
resolution: 192x192 dots per inch<br />
}}<br />
<br />
This example uses inaccurate dimensions (423mm x 328mm, even though the Dell XPS 9530 has 346mm x 194mm) to have a clean multiple of 96 dpi, in this case 192 dpi. This tends to work better than using the correct DPI — Pango renders fonts crisper in i3 for example.<br />
<br />
If the DPI displayed by xdpyinfo is not correct, see [[Xorg#Display size and DPI]] for how to fix it.<br />
<br />
== GUI toolkits ==<br />
<br />
=== Qt 5 ===<br />
<br />
Since Qt 5.6, Qt 5 applications can be instructed to honor screen DPI by setting the {{ic|QT_AUTO_SCREEN_SCALE_FACTOR}} [[environment variable]]:<br />
<br />
export QT_AUTO_SCREEN_SCALE_FACTOR=1<br />
<br />
If automatic detection of DPI does not produce the desired effect, scaling can be set manually per-screen ({{ic|QT_SCREEN_SCALE_FACTORS}}) or globally ({{ic|QT_SCALE_FACTOR}}). For more details see the [https://blog.qt.io/blog/2016/01/26/high-dpi-support-in-qt-5-6/ Qt blog post] or [https://doc.qt.io/qt-5/highdpi.html Qt developer documentation].<br />
<br />
{{Note|<br />
* If you manually set the screen factor, it is important to set {{ic|1=QT_AUTO_SCREEN_SCALE_FACTOR=0}} otherwise some applications which explicitly force high DPI enabling get scaled twice.<br />
* {{ic|QT_SCALE_FACTOR}} scales fonts, but {{ic|QT_SCREEN_SCALE_FACTORS}} does not scale fonts.<br />
* If you also set the font DPI manually in ''xrdb'' to support other toolkits, {{ic|QT_SCALE_FACTORS}} will give you huge fonts.<br />
* If you have multiple screens of differing DPI ie: [[#Side display]] you may need to do {{ic|1=QT_SCREEN_SCALE_FACTORS="2;2"}}<br />
}}<br />
<br />
An [https://bugreports.qt.io/browse/QTBUG-53022 alternative] is e.g.:<br />
<br />
QT_FONT_DPI=96 clementine<br />
<br />
=== GDK 3 (GTK 3) ===<br />
<br />
{{Note|As stated in the [[#X Resources]] section, if you have xft.dpi set to a larger dpi, it will make other scales larger than usual, including GDK.}} <br />
<br />
Setting the GDK scale (in X11, not wayland) will scale the UI, however it will not scale icons. If you are using a minimal window manager where you are setting the dpi via Xft.dpi, GDK should scale perfectly fine with it. In other cases, [https://docs.gtk.org/gtk3/x11.html do the following]:<br />
<br />
To scale UI elements by an integer only factor:<br />
<br />
$ export GDK_SCALE=2<br />
<br />
GTK3/4 does not support fractional scaling currently, so fractional factors will be ignored. This environment variable is also ignored in mutter wayland sessions.<br />
<br />
{{ic|GDK_DPI_SCALE}} can be used to scale text only. To undo scaling of text, fractional scale can be used:<br />
<br />
$ export GDK_DPI_SCALE=0.5<br />
<br />
Under GTK3/4 it not currently possible to scale icon sizes, unless the application explicitly implements a way to do so. See bug report [https://gitlab.gnome.org/GNOME/gtk/-/issues/4528 #4528]. If you need this feature, use Qt when possible.<br />
<br />
=== GTK 2 ===<br />
<br />
Scaling of UI elements is not supported by the toolkit itself, however it is possible to generate a theme with elements pre-scaled for HiDPI display using {{AUR|themix-full-git}}.<br />
<br />
=== Electron ===<br />
<br />
[https://electronjs.org/ Electron] applications (e.g. {{AUR|slack-desktop}}, {{pkg|signal-desktop}}, etc.) can be configured to use a custom scaling value by adding a {{ic|1=--force-device-scale-factor}} flag to the .desktop file. This is normally located at {{ic|/usr/share/applications/}}, and can normally be overridden on a per-user basis by copying it to {{ic|~/.local/share/applications}}. The flag should be added to the line beginning with "Exec=". For example:<br />
<br />
{{hc|/usr/share/applications/slack.desktop|2=<br />
Exec=env LD_PRELOAD=/usr/lib/libcurl.so.3 /usr/bin/slack --force-device-scale-factor=1.5 %U<br />
}}<br />
<br />
=== Elementary (EFL) ===<br />
<br />
To scale UI elements by a factor of 1.5:<br />
<br />
export ELM_SCALE=1.5<br />
<br />
For more details see https://phab.enlightenment.org/w/elementary/{{Dead link|2023|04|23|status=404}}<br />
<br />
=== GNUstep ===<br />
<br />
GNUstep applications that use its gui (AppKit) library accept a {{ic|GSScaleFactor}} property in their defaults (STEP preferences). To define a scaling factor of 1.5 for all applications:<br />
<br />
defaults write NSGlobalDomain GSScaleFactor 1.5<br />
<br />
Note that you must also disable font hinting by setting the value of {{ic|GSFontHinting}} to 17, else text rendering will look broken when rendering long lines.<br />
<br />
defaults write NSGlobalDomain GSFontHinting 17<br />
<br />
Some automatic detection was possible back in 2011, but the code responsible for the X11 backend was [https://github.com/gnustep/libs-back/commit/337ce46bba304732d9a7c7495a3dd245a3219660 commented out] thereafter.<br />
<br />
== Boot managers ==<br />
<br />
=== GRUB ===<br />
<br />
==== Lower the framebuffer resolution ====<br />
<br />
Set a lower resolution for the framebuffer as explained in [[GRUB/Tips and tricks#Setting the framebuffer resolution]].<br />
<br />
==== Change GRUB font size ====<br />
<br />
Find a ttf font that you like in {{ic|/usr/share/fonts/}}.<br />
<br />
Convert the font to a format that GRUB can utilize:<br />
<br />
# grub-mkfont -s 30 -o /boot/grubfont.pf2 /usr/share/fonts/FontFamily/FontName.ttf<br />
<br />
{{Note|Change the {{ic|-s 30}} parameter to modify the font size}}<br />
<br />
Edit {{ic|/etc/default/grub}} to set the new font as shown in [[GRUB/Tips and tricks#Background image and bitmap fonts]]:<br />
<br />
GRUB_FONT="/boot/grubfont.pf2"<br />
<br />
{{Note|{{ic|GRUB_THEME}} overrides {{ic|GRUB_FONT}} if it is used.}}<br />
<br />
Finally [[GRUB#Generate the main configuration file|regenerate the main configuration file]].<br />
<br />
{{Tip|The font size can also be changed with the GUI tool {{Pkg|grub-customizer}}.}}<br />
<br />
=== systemd-boot ===<br />
<br />
Adding the following line and running {{ic|bootctl update}} increases font-size in the [[systemd-boot#Loader configuration|systemd-boot]] menu:<br />
<br />
{{hc|/boot/loader/loader.conf|2=<br />
console-mode 1<br />
}}<br />
<br />
== Applications ==<br />
<br />
If you are running a Wayland session, but application is running via Xwayland (either because it does not support Wayland natively or because it uses X11 by default), you could still get blurry fonts and interface, even if the application supports HiDPI. See [https://bugs.kde.org/show_bug.cgi?id=389191 this bug report]. See also [[Wayland#Detect Xwayland applications visually]].<br />
<br />
=== Atom ===<br />
<br />
Add {{ic|1=--force-device-scale-factor=2}} as a flag to the atom.desktop file:<br />
<br />
{{hc|/usr/share/applications/atom.desktop|2=<br />
Exec=/usr/bin/atom --force-device-scale-factor=2 %F<br />
}}<br />
<br />
=== Browsers ===<br />
<br />
==== Firefox ====<br />
<br />
Firefox should use the [[#GDK 3 (GTK 3)]] settings. However, the suggested {{ic|GDK_SCALE}} suggestion does not consistently scale the entirety of Firefox, and does not work for fractional values (e.g., a factor of 158DPI/96DPI = 1.65 for a 1080p 14" laptop). You may want to use {{ic|GDK_DPI_SCALE}} instead. Another option, which will avoid Firefox-specific settings in many setups is to use the settings in [[#X Resources]] as Firefox should respect the {{ic|Xft.dpi}} value defined there.<br />
<br />
To override those, open Firefox advanced preferences page ({{ic|about:config}}) and add and set parameter {{ic|ui.textScaleFactor}} to {{ic|150}} (or find the one that suits you better; {{ic|150}} is a good choice for Retina screens). You will likely also need to edit the zoom level in general preferences to e.g. 120%. This does not consistently scale the entirety of Firefox: edit {{ic|layout.css.devPixelsPerPx}} for that, but as of Firefox 103 it may not work as expected.<br />
<br />
If Firefox is not scaling fonts, you may want to create {{ic|userChrome.css}} and add appropriate styles to it. More information about {{ic|userChrome.css}} at [http://kb.mozillazine.org/index.php?title=UserChrome.css mozillaZine]. Starting from Firefox 69 the {{ic|userChrome.css}} and {{ic|userContent.css}} files are not loaded by default unless preference is set by the user. Open Firefox advanced preferences page ({{ic|about:config}}) and set parameter {{ic|toolkit.legacyUserProfileCustomizations.stylesheets}} to {{ic|True}}, then restart Firefox to apply the changes.<br />
<br />
{{hc|~/.mozilla/firefox/<em><profile></em>/chrome/userChrome.css|<br />
@namespace url("https://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");<br />
<br />
/* #tabbrowser-tabs, #navigator-toolbox, menuitem, menu, ... */<br />
* {<br />
font-size: 15px !important;<br />
}<br />
<br />
/* exception for badge on adblocker */<br />
.toolbarbutton-badge {<br />
font-size: 8px !important;<br />
}<br />
}}<br />
<br />
If you use a HiDPI monitor such as Retina display together with another monitor, you can use the [https://addons.mozilla.org/firefox/addon/ffreszoom/ ffreszoom] add-on, which will adjust the page zoom if it detects you are using a large monitor (zoom level and threshold are configurable). Modifying the internal CSS DPI setting from an extension is currently unsupported [https://bugzilla.mozilla.org/show_bug.cgi?id=1373607].<br />
<br />
If you use Wayland, see [[Firefox#Wayland]] for instructions to enable the optional Wayland backend on {{pkg|firefox}}. This is also appicable to {{pkg|thunderbird}}.<br />
<br />
==== Chromium / Google Chrome ====<br />
<br />
Chromium should use the [[#GDK 3 (GTK 3)]] settings.<br />
<br />
To override those, use the {{ic|1=--force-device-scale-factor}} flag with a scaling value. This will scale all content and ui, including tab and font size. For example {{ic|1=chromium --force-device-scale-factor=2}}.<br />
<br />
Using this option, a scaling factor of 1 would be normal scaling. Floating point values can be used. To make the change permanent, for Chromium, you can add it to {{ic|~/.config/chromium-flags.conf}}:<br />
<br />
{{hc|~/.config/chromium-flags.conf|2=<br />
--force-device-scale-factor=2<br />
}}<br />
<br />
To make this work for Chrome, add the same option to {{ic|~/.config/chrome-flags.conf}} instead.<br />
<br />
If you use a HiDPI monitor such as Retina display together with another monitor, you can use the [https://chrome.google.com/webstore/detail/resolution-zoom/enjjhajnmggdgofagbokhmifgnaophmh reszoom] extension in order to automatically adjust the zoom level for the active screen.<br />
<br />
If using Wayland session, you should [[Chromium#Native Wayland support|enable]] native wayland support to avoid blurriness. See also [[Chromium#Incorrect HiDPI rendering]].<br />
<br />
==== Opera ====<br />
<br />
Opera should use the [[#GDK 3 (GTK 3)]] settings.<br />
<br />
To override those, use the {{ic|1=--alt-high-dpi-setting=X}} command line option, where X is the desired DPI. For example, with {{ic|1=--alt-high-dpi-setting=144}} Opera will assume that DPI is 144. Newer versions of opera will auto detect the DPI using the font DPI setting (in KDE: the force font DPI setting.)<br />
<br />
=== Gimp 2.10 ===<br />
<br />
To fix toolbar icon sizes, update ''Preferences > Interface > Icon Theme > Custom icon size'' to {{ic|1=huge}} or other value.<br />
<br />
If menu fonts are still too small you can update an existing theme by copying it from {{ic|/usr/share/gimp/2.0/themes}} into {{ic|~/.config/GIMP/2.10/themes/}} and changing {{ic|gtk-font-name}} and {{ic|font_name}} in {{ic|gtkrc}} into something bigger like {{ic|1=Sans 30}}. Then select the new theme from ''Preferences > Interface > Theme''. When copying make sure to rename the new directory into something different from the original name (example ''Dark > DarkHighDPI'').<br />
<br />
You can also try using [https://github.com/jedireza/gimp-hidpi gimp-hidpi] (installation instructions are outdated and refer to version 2.8, in Gimp 2.10 the theme should be installed into {{ic|~/.config/GIMP/2.10/themes/}})<br />
<br />
On the latest versions of {{AUR|gimp-devel}}, wayland and HiDPI are both fully supported. Icons and text can be scaled from ''Preferences > Interface > Icon Theme''/''Display'' respectively.<br />
<br />
=== Inkscape ===<br />
<br />
To scale the icons to a "usable" size go to ''Preferences > Interface'' and set the icon size to Large or Larger[https://web.archive.org/web/20171118050743/http://www.inkscapeforum.com/viewtopic.php?t=18684][https://wiki.inkscape.org/wiki/index.php/HiDPI].<br />
<br />
=== Java applications ===<br />
<br />
==== AWT/Swing ====<br />
<br />
Java applications using the ''AWT/Swing'' framework can be scaled by defining the {{ic|sun.java2d.uiScale}} VM property when invoking {{ic|java}}. The value can be an integer percentage value, or a float value. For example,<br />
<br />
java -Dsun.java2d.uiScale=2 -jar some_swing_application.jar<br />
java -Dsun.java2d.uiScale=300% -jar some_swing_application.jar<br />
<br />
Since Java 9 the {{ic|GDK_SCALE}} environment variable is used to scale Swing applications accordingly.<br />
<br />
Note that at this point, Java ''AWT/Swing'' (up to including OpenJDK 13) only effectively supports integer values. A setting of {{ic|1=-Dsun.java2d.uiScale=250%}} or {{ic|1=GDK_SCALE=2.5}} will be treated as if it were set to {{ic|1=-Dsun.java2d.uiScale=2}} resp. {{ic|1=GDK_SCALE=2}}.<br />
<br />
==== JavaFX ====<br />
<br />
Java applications using ''JavaFX'' can be scaled by defining the {{ic|glass.gtk.uiScale}} VM property when invoking {{ic|java}}. The value can be an integer percentage value, an integer DPI value (where {{ic|96dpi}} represents a scale factor of {{ic|100%}}, and for example {{ic|192dpi}} represents a scale factor of {{ic|200%}}), or a float value. For example,<br />
<br />
java -Dglass.gtk.uiScale=200% -jar some_jfx_application.jar<br />
java -Dglass.gtk.uiScale=192dpi -jar some_jfx_application.jar<br />
java -Dglass.gtk.uiScale=2.0 -jar some_jfx_application.jar<br />
<br />
''JavaFX'' perfectly well supports fractions. Using values like {{ic|1=-Dglass.gtk.uiScale=250%}} or {{ic|1=-Dglass.gtk.uiScale=2.5}} will deliver the expected result.<br />
<br />
==== Mixed AWT/Swing and JavaFX ====<br />
<br />
Some Java applications mix ''JavaFX'' and ''AWT/Swing'' (via {{ic|javafx.embed.swing.JFXPanel}}). In that case, the settings for ''AWT/Swing'' will also affect ''JavaFX'', and setting {{ic|-Dglass.gtk.uiScale}} will have no effect.<br />
<br />
==== IntelliJ IDEA ====<br />
<br />
IntelliJ IDEA supports two HiDPI modes (JRE-managed and IDE-managed). The sequence for determining system scale factor is well documented at [https://intellij-support.jetbrains.com/hc/en-us/articles/360007994999-HiDPI-configuration]:<br />
<br />
# Java property – {{ic|-Dsun.java2d.uiScale}}<br />
# {{man|1|gsettings}} – {{ic|ubuntu.user-interface/scale-factor}} or {{ic|org.gnome.desktop.interface/scaling-factor}}<br />
# {{ic|GDK_SCALE}} and {{ic|GDK_DPI_SCALE}}<br />
# [[Xresources]] – {{ic|Xft.dpi}}<br />
# 1.0<br />
<br />
For troubleshooting, consult the "Show HiDPI Info" dialog via [https://www.jetbrains.com/help/idea/searching-everywhere.html search everywhere "Shift Shift"].<br />
<br />
When using per-monitor scaling, an issue might occur where IntelliJ fails to recognize the real, original monitor resolution. <br />
To remediate this problem some people have success by adding the {{ic|1=-Dsun.java2d.uiScale.enabled=true}} option to the {{ic|idea64.vmoptions}} file (''Help > Edit custom VM options''). <br />
<br />
If this does not work, the experimental GTK option {{ic|scale-monitor-framebuffer}} might be enabled on Wayland ([[#Wayland|see above]]). Currently JetBrains products run on xwayland and thus [https://youtrack.jetbrains.com/issue/IDEA-228070 have no native wayland support yet]. This makes the rendering in JetBrains products incompatible with the monitor scaling framebuffer. Disabling the framebuffer thus might solve blurry font/rendering issues for JB products, but alas results in disabled fractional scaling.<br />
<br />
=== LibreOffice ===<br />
<br />
[[LibreOffice]] on all VCL backends take setting from there respective toolkits. There is a bug where the {{ic|kf5}} backend on Wayland does not scale [https://bugs.documentfoundation.org/show_bug.cgi?id=138520]. Use the {{ic|gtk3}} VCL backend instead. See [[LibreOffice#Theme]].<br />
<br />
=== MATLAB ===<br />
<br />
Recent versions (R2017b) of [[MATLAB]] allow to set the scale factor[https://www.mathworks.com/matlabcentral/answers/406956-does-matlab-support-high-dpi-screens-on-linux]:<br />
<br />
>> s = settings;s.matlab.desktop.DisplayScaleFactor<br />
>> s.matlab.desktop.DisplayScaleFactor.PersonalValue = 2<br />
<br />
The settings take effect after MATLAB is restarted.<br />
<br />
This can become tedious if you need to change the scaling frequently. To simplify this, consider using the following script:<br />
<br />
{{hc|~/bin/matlab-scale|2=<br />
#!/bin/sh<br />
exec matlab -r "s = settings;s.matlab.desktop.DisplayScaleFactor.PersonalValue=$1;quit" -nodesktop -nosplash<br />
}}<br />
<br />
To change the display scaling to 3:<br />
<br />
$ matlab-scale 3<br />
<br />
=== Mono applications ===<br />
<br />
According to [https://bugzilla.xamarin.com/35/35870/bug.html]{{Dead link|2023|04|23|status=domain name not resolved}}, Mono applications should be scalable like [[#GDK 3 (GTK 3)|GTK 3]] applications. The precise method depends on the GUI library: GtkSharp obviouslys points back to Gtk, while the usual Windows Forms (libgdiplus) simply detects Xft settings.<br />
<br />
=== NetBeans ===<br />
<br />
NetBeans allows the font size of its interface to be controlled using the {{ic|1=--fontsize}} parameter during startup. To make this change permanent edit the {{ic|1=/usr/share/netbeans/etc/netbeans.conf}} file and append the {{ic|1=--fontsize}} parameter to the {{ic|1=netbeans_default_options}} property.[https://web.archive.org/web/20210117211145/http://wiki.netbeans.org/FaqFontSize]<br />
<br />
The editor fontsize can be controlled from ''Tools > Option > Fonts & Colors''.<br />
<br />
The output window fontsize can be controlled from ''Tools > Options > Miscelaneous > Output''<br />
<br />
=== OBS Studio ===<br />
<br />
OBS 29 supports HiDPI setups without any extra configuration.<br />
<br />
For older versions of OBS, the recommendation was to set the environment variable {{ic|1=QT_AUTO_SCREEN_SCALE_FACTOR=0}} to disable [https://doc.qt.io/qt-5/highdpi.html#migrate-existing-applications Qt’s hi-dpi migration mode] and install the Yami theme. Do not use the Yami theme with OBS 29 or newer, as it is not necessary anymore and will cause buggy behavior.<br />
<br />
=== Skype ===<br />
<br />
Skype for Linux ({{AUR|skypeforlinux-stable-bin}} package) uses [[#GDK 3 (GTK 3)]].<br />
<br />
=== Spotify ===<br />
<br />
You can change scale factor by simple {{ic|Ctrl++}} for zoom in, {{ic|Ctrl+-}} for zoom out and {{ic|Ctrl+0}} for default scale. Scaling setting will be saved in {{ic|~/.config/spotify/Users/YOUR-SPOTIFY-USER-NAME/prefs}}, you may have to create this file by yourself:<br />
<br />
{{hc|~/.config/spotify/Users/YOUR-SPOTIFY-USER-NAME/prefs|2=<br />
app.browser.zoom-level=100<br />
}}<br />
<br />
Also Spotify can be launched with a custom scaling factor which will be multiplied with setting specified in {{ic|~/.config/spotify/Users/YOUR-SPOTIFY-USER-NAME/prefs}}, for example<br />
<br />
$ spotify --force-device-scale-factor=1.5<br />
<br />
=== Steam ===<br />
<br />
==== Official HiDPI support ====<br />
<br />
* Starting on 25 of January 2018 in the beta program there is actual support for HiDPI and it should be automatically detected.<br />
* ''Steam > Settings > Interface'', check "Enlarge text and icons based on monitor size" (restart required)<br />
* If it is not automatically detected, use {{ic|1=GDK_SCALE=2}} to set the desired scale factor.<br />
<br />
==== Unofficial ====<br />
<br />
The [https://github.com/MoriTanosuke/HiDPI-Steam-Skin HiDPI-Steam-Skin] can be installed to increase the font size of the interface. While not perfect, it does improve usability. <br />
<br />
{{Note|The README for the HiDPI skin lists several possible locations for where to place the skin. The correct folder out of these can be identified by the presence of a file named {{ic|1=skins_readme.txt}}.}}<br />
<br />
[https://steamcommunity.com/groups/metroskin/discussions/0/517142253861033946/ MetroSkin Unofficial Patch] also helps with HiDPI on Steam with Linux.<br />
<br />
=== Sublime Text 3 ===<br />
<br />
Sublime Text 3 has full support for display scaling. Go to ''Preferences > Settings > User Settings'' and add {{ic|"ui_scale": 2.0}} to your settings.<br />
<br />
=== Thunderbird ===<br />
<br />
See [[#Firefox]]. To access {{ic|about:config}}, go to ''Edit > Preferences > Advanced >Config editor''.<br />
<br />
=== VirtualBox ===<br />
<br />
{{Note|This only applies to KDE with scaling enabled.}}<br />
<br />
VirtualBox also applies the system-wide scaling to the virtual monitor, which reduces the maximum resolution inside VMs by your scaling factor (see [https://www.virtualbox.org/ticket/16604]).<br />
<br />
This can be worked around by calculating the inverse of your scaling factor and manually setting this new scaling factor for the VirtualBox execution, e.g.<br />
<br />
$ QT_SCALE_FACTOR=0.5 VirtualBoxVM --startvm vm-name<br />
<br />
=== VMware ===<br />
<br />
Text in the VMware application is rendered at an appropriate size following the system configuration, but icons are small and UI elements have little padding between them.<br />
<br />
As described in [[#GDK 3 (GTK 3)]], you can use {{ic|GDK_SCALE}} to further scale up the entire UI (including icons & padding) and then use {{ic|GDK_DPI_SCALE}} to scale only the text back down to a reasonable size.<br />
<br />
For example, to get a final 2x scale factor:<br />
<br />
$ GDK_SCALE=2 GDK_DPI_SCALE=0.5 vmware<br />
<br />
=== Wine applications ===<br />
<br />
Run<br />
<br />
$ winecfg<br />
<br />
and change the "dpi" setting found in the "Graphics" tab. This only affects the font size.<br />
<br />
=== Zathura document viewer ===<br />
<br />
No modifications required for document viewing.<br />
<br />
UI text scaling is specified via [https://pwmt.org/projects/zathura/documentation/ configuration file] (note that "font" is a [https://pwmt.org/projects/girara/options/ girara option]):<br />
<br />
set font "monospace normal 20"<br />
<br />
=== Zoom ===<br />
<br />
Set the {{ic|scaleFactor}} variable in {{ic|~/.config/zoomus.conf}}.<br />
<br />
For the Flatpak version, set the environment variable {{ic|QT_SCALE_FACTOR}} (e.g. to 0.5 [https://old.reddit.com/r/Zoom/comments/hat5af/linux_client_ui_elements_too_large_after_update/]). This can be easily done with [https://flathub.org/apps/details/com.github.tchx84.Flatseal Flatseal], if using a GUI tool is preferred.<br />
<br />
=== Gazebo ===<br />
<br />
Gazebo only renders an upper left of a view instead of the whole view. To fix this a Qt enviorment variable must be set.<br />
To run Gazebo:<br />
$ QT_SCREEN_SCALE_FACTORS=[1.0] gazebo<br />
To run a ROS simulation:<br />
$ TURTLEBOT3_MODEL=burger QT_SCREEN_SCALE_FACTORS=[1.0] roslaunch turtlebot3_gazebo turtlebot3_world.launch<br />
Making an alias such as gazebo="QT_SCREEN_SCALE_FACTORS=[1.0] gazebo" works for the first case but not for the second.<br />
<br />
=== Fcitx ===<br />
<br />
Fcitx preedit {{ic|FontSize}} can be changed in {{ic|~/.config/fcitx/conf/fcitx-classic-ui.config}}.<br />
<br />
For Fcitx5, set {{ic|Font}} with a size inside double quotes in {{ic|~/.config/fcitx5/conf/classicui.conf}}.<br />
<br />
=== Unsupported applications, via a network layer ===<br />
<br />
{{AUR|run_scaled-git}} can be used to scale applications (which uses {{Pkg|xpra}} internally).<br />
<br />
Another approach is to run the application full screen and without decoration in its own VNC desktop. Then scale the viewer. With {{AUR|vncdesk-git}} you can set up a desktop per application, then start server and client with a simple command such as {{ic|vncdesk 2}}.<br />
<br />
[[x11vnc]] has an experimental option {{ic|-appshare}}, which opens one viewer per application window. Perhaps something could be hacked up with that.<br />
<br />
=== Unsupported applications, via weston ===<br />
<br />
There is a no-network, potentially GPU-accelerated solution to scale old/unsupported applications via weston. The basic example goes as:<br />
<br />
weston --xwayland --socket=testscale --scale=2<br />
DISPLAY=:1 WAYLAND_DISPLAY=testscale your_app<br />
<br />
Note 1: You can make it look nicer. Create a dedicated {{ic|weston.ini}} and use it with {{ic|weston --config}}:<br />
<br />
[core]<br />
idle-time=0<br />
[shell]<br />
panel-position=none<br />
locking=false<br />
<br />
Note 2: Adjust your {{ic|DISPLAY}} according to your system, {{ic|:1}} is simply the default that comes after the main {{ic|:0}}. Check files created in {{ic|/tmp/.X11-unix}} to do that.<br />
<br />
Note 3: If you want a separate window per each scaled app, adjust the {{ic|--socket}} parameter to weston and {{ic|WAYLAND_DISPLAY}} + {{ic|DISPLAY}} for each started app. Scripting that is not easy because Xorg display has to be a small-ish integer, but you can create a semi-safe script to infer it.<br />
<br />
Note 4: It is not fully tested yet whether weston and xwayland truly off-board the heavy parts to the GPU. At least {{ic|weston}} advertises to do so, but no tests on that were done yet. Please edit if you make the GPU usage tests.<br />
<br />
== Multiple displays ==<br />
<br />
The HiDPI setting applies to the whole desktop, so non-HiDPI external displays show everything too large. However, note that setting different scaling factors for different monitors is already supported in [[Wayland]].<br />
<br />
=== Side display ===<br />
<br />
One workaround is to use [[xrandr]]'s scale option. To have a non-HiDPI monitor (on DP1) right of an internal HiDPI display (eDP1), one could run:<br />
<br />
$ xrandr --output eDP-1 --auto --output DP-1 --auto --scale 2x2 --right-of eDP-1<br />
<br />
When extending above the internal display, you may see part of the internal display on the external monitor. In that case, specify the position manually.<br />
<br />
You may adjust the "sharpness" parameter on your monitor settings to adjust the blur level introduced with scaling.<br />
<br />
{{Note|1=<nowiki/><br />
* Above solution with {{ic|--scale 2x2}} does not work on some Nvidia cards. No solution is currently available. [https://bbs.archlinux.org/viewtopic.php?pid=1670840] A potential workaround exists with configuring {{ic|1=ForceFullCompositionPipeline=On}} on the {{ic|CurrentMetaMode}} via {{ic|nvidia-settings}}. For more info see [https://askubuntu.com/a/979551].<br />
* If you are using the {{ic|modesetting}} driver you will get mouse flickering. This can be solved by scaling your non-scaled screen by 0.9999x0.9999.}}<br />
<br />
=== Multiple external monitors ===<br />
<br />
There might be some problems in scaling more than one external monitors which have lower dpi than the built-in HiDPI display. In that case, you may want to try downscaling the HiDPI display instead, with e.g.<br />
<br />
$ xrandr --output eDP1 --scale 0.5x0.5 --output DP2 --right-of eDP1 --output HDMI1 --right-of DP2<br />
<br />
In addition, when you downscale the HiDPI display, the font on the HiDPI display will be slightly blurry, but it is a different kind of bluriness compared with the one introduced by upscaling the external displays. You may compare and see which kind of bluriness is less problematic for you.<br />
<br />
=== Mirroring ===<br />
<br />
If all you want is to mirror ("unify") displays, this is easy as well:<br />
<br />
With AxB your native HiDPI resolution (for ex 3200x1800) and CxD your external screen resolution (e.g. 1920x1200)<br />
<br />
$ xrandr --output HDMI --scale [A/C]x[B/D]<br />
<br />
In this example which is QHD (3200/1920 = 1.66 and 1800/1200 = 1.5)<br />
<br />
$ xrandr --output HDMI --scale 1.66x1.5<br />
<br />
For UHD to 1080p (3840/1920=2 2160/1080=2)<br />
<br />
$ xrandr --output HDMI --scale 2x2<br />
<br />
You may adjust the "sharpness" parameter on your monitor settings to adjust the blur level introduced with scaling.<br />
<br />
=== Tools ===<br />
<br />
There are several tools which automate the commands described above.<br />
<br />
* [https://gist.github.com/wvengen/178642bbc8236c1bdb67 This script] extend a non-HiDPI external display above a HiDPI internal display.<br />
* [https://github.com/ashwinvis/xrandr-extend xrandr-extend].<br />
* {{AUR|xlayoutdisplay}} is a CLI front end for xrandr which detects and sets correct DPI: [https://github.com/alex-courtis/xlayoutdisplay README]<br />
<br />
== Linux console (tty) ==<br />
<br />
=== In-kernel fonts ===<br />
<br />
The [[Linux console]] changes the font to {{ic|TER16x32}} (based on {{ic|ter-i32b}} from {{Pkg|terminus-font}}[https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac8b6f148fc97e9e10b48bd337ef571b1d1136aa]) based on the vertical and horizontal pixel count of the display[https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dfd19a5004eff03755967086aa04254c3d91b8ec] regardless of its physical size. If your monitor is not recognised as HiDPI, the default font can be changed. In that case, specify {{ic|1=fbcon=font:TER16x32}} in the [[kernel command line]]. 32pixel fonts are the maximum supported by the Linux kernel, in some cases this may not be enough.<br />
<br />
=== Fonts outside the kernel (tty) ===<br />
<br />
The largest fonts present in the {{Pkg|kbd}} package are {{ic|latarcyrheb-sun32}} and {{ic|solar24x32}}. Other packages like {{Pkg|terminus-font}} contain further alternatives, such as {{ic|ter-132n}} (normal) and {{ic|ter-132b}} (bold). See [[Linux console#Fonts]] for configuration details and [[Linux console#Persistent configuration]] in particular for applying the font setting during the early userspace boot sequence.<br />
<br />
After changing the font, it is often garbled and unreadable when changing to other virtual consoles ({{ic|tty2-6}}). To fix this you can [[Kernel mode setting#Forcing modes and EDID|force specific mode]] for KMS, such as {{ic|1=video=2560x1600@60}} (substitute in the native resolution of your HiDPI display), and reboot. Using small resolutions will make the text look bigger, but also pixelated.<br />
<br />
Users booting though [[UEFI]] may experience the console and [[boot loader]] being constrained to a low resolution despite correct [[KMS]] settings being set. This can be caused by legacy/BIOS boot being enabled in UEFI settings. Disabling legacy boot to bypass the compatibility layer should allow the system to boot at the correct resolution.<br />
<br />
=== Modern HiDPI support (kmscon) ===<br />
<br />
For real HiDPI support, see [[KMSCON]] instead of changing the font size in the tty.<br />
<br />
== See also ==<br />
<br />
* [https://www.phoronix.com/scan.php?page=article&item=linux_uhd4k_gpus Ultra HD 4K Linux Graphics Card Testing] (Nov 2013)<br />
* [https://www.eizo.com/library/basics/pixel_density_4k/ Understanding pixel density]<br />
* [http://wok.oblomov.eu/tecnologia/mixed-dpi-x11/ Mixed DPI and the X Window System]</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization/Chinese&diff=775099Localization/Chinese2023-04-09T00:29:13Z<p>Hongy19: add more noto font</p>
<hr />
<div>[[Category:Localization]]<br />
[[es:Localization (Español)/Chinese]]<br />
[[zh-hant:Localization (正體中文)/Chinese]]<br />
{{Related articles start}}<br />
{{Related|Localization/Simplified Chinese}}<br />
{{Related|Localization_(简体中文)/Simplified_Chinese_(简体中文)}}<br />
{{Related|Localization_(正體中文)/Chinese_(正體中文)}}<br />
{{Related articles end}}<br />
<br />
This article describes how to set up a Chinese language environment.<br />
<br />
== Fonts ==<br />
<br />
* adobe source han fonts<br />
** {{Pkg|adobe-source-han-sans-cn-fonts}} - Simplified Chinese OpenType/CFF Sans fonts<br />
** {{Pkg|adobe-source-han-sans-tw-fonts}} - Traditional Chinese OpenType/CFF Sans fonts<br />
** {{Pkg|adobe-source-han-sans-hk-fonts}} - Hong Kong Chinese OpenType/CFF Sans fonts<br />
** {{Pkg|adobe-source-han-serif-cn-fonts}} - Simplified Chinese OpenType/CFF Serif fonts<br />
** {{Pkg|adobe-source-han-serif-tw-fonts}} - Traditional Chinese OpenType/CFF Serif fonts<br />
** {{Pkg|adobe-source-han-serif-hk-fonts}} - Hong Kong Chinese OpenType/CFF Serif fonts<br />
* noto Chinese fonts<br />
** {{Pkg|noto-fonts}} - Google Noto TTF fonts<br />
** {{Pkg|noto-fonts-cjk}} - Google Noto CJK fonts<br />
** {{Pkg|noto-fonts-emoji}} - Google Noto emoji fonts<br />
** {{AUR|noto-fonts-sc}} - Noto CJK-SC fonts for Simplified Chinese<br />
** {{AUR|noto-fonts-tc}} - Noto CJK-TC fonts for Traditional Chinese<br />
* wqy fonts<br />
** {{Pkg|wqy-microhei}} - WenQuanYi Micro Hei font family (also known as Hei, Gothic or Dotum) is a sans-serif style derived from Droid Sans Fallback, it offers high quality CJK outline font and it is extremely compact (~5M).<br />
** {{Pkg|wqy-zenhei}} - Hei Ti Style (sans-serif) Chinese Outline font embedded with bitmapped Song Ti (also supporting Japanese (partial) and Korean characters).<br />
** {{Pkg|wqy-bitmapfont}} - Bitmapped Song Ti (serif) Chinese font.<br />
* arphic fonts<br />
** {{Pkg|ttf-arphic-ukai}} - ''Kaiti'' (brush stroke) Unicode font (enabling anti-aliasing is suggested)<br />
** {{Pkg|ttf-arphic-uming}} - ''Mingti'' (printed) Unicode font<br />
* {{Pkg|opendesktop-fonts}} - ''New Sung'' font, previously is ttf-fireflysung package<br />
* {{Pkg|ttf-hannom}} - Chinese and Vietnamese ttf fonts<br />
* Standard fonts of Traditional Chinese<br />
** {{AUR|ttf-tw}} - Kai and Song traditional Chinese font from the Ministry of Education of Taiwan<br />
** {{AUR|ttf-twcns-fonts}} Chinese TrueType fonts by Ministry of Education of Taiwan government, supporting CNS11643 standard, including Kai and Sung fontface.<br />
* Windows Chinese fonts<br />
** {{AUR|ttf-ms-win8-zh_cn}} - windows8 simple Chinese fonts.<br />
** {{AUR|ttf-ms-win8-zh_tw}} - windows8 traditional Chinese fonts.<br />
** {{AUR|ttf-ms-win10-zh_cn}} - windows10 simple Chinese fonts.<br />
** {{AUR|ttf-ms-win10-zh_tw}} - windows10 traditional Chinese fonts.<br />
* {{AUR|ttf-i.bming}} - CJK serif font that emphasis on an old-style typeface.<br />
<br />
== Input methods ==<br />
<br />
The following [[input method]] (IM) engines are available for Chinese:<br />
<br />
{| class="wikitable" style="text-align:center;"<br />
! Engine !! [[Fcitx5]] !! [[Fcitx]] !! [[IBus]] !! [[Uim]] !! [[Scim]] !! [[Nimf]]<br />
|-<br />
| [[Rime]] || {{Pkg|fcitx5-rime}} || {{Pkg|fcitx-rime}} || {{Pkg|ibus-rime}} || {{-}} || {{-}} || built-in<br />
|-<br />
| [[Wikipedia:Pinyin|Pinyin]] || {{Pkg|fcitx5-chinese-addons}} || built-in || {{Pkg|ibus-pinyin}} || {{-}} || {{AUR|scim-pinyin}} || built-in<br />
|-<br />
| [https://github.com/chewing/libchewing Zhuyin] || {{Pkg|fcitx5-chewing}} || {{Pkg|fcitx-chewing}} || {{Pkg|ibus-chewing}} || {{-}} || {{Pkg|scim-chewing}} || built-in<br />
|-<br />
| [[Wikipedia:Cangjie_input_method|Cangjie]]<br>[[Wikipedia:Simplified_Cangjie|Sucheng]]<br>[[Wikipedia:zh:快速倉頡輸入法|SmartCangjie]] || {{Pkg|fcitx5-table-extra}} || {{Pkg|fcitx-table-extra}} || {{Pkg|ibus-table-chinese}} || {{-}} || {{AUR|scim-tables}} || {{-}}<br />
|-<br />
| [[Wikipedia:Wubi_method|Wubi]] || built-in || built-in || {{Pkg|ibus-table}} || built-in || {{AUR|scim-tables}} || {{-}}<br />
|-<br />
| [https://github.com/libpinyin/libpinyin Libpinyin] || {{-}} || {{Pkg|fcitx-libpinyin}} || {{Pkg|ibus-libpinyin}} || {{-}} || {{-}} || {{-}}<br />
|-<br />
| [https://github.com/sunpinyin/sunpinyin SunPinyin] || {{-}} || {{Pkg|fcitx-sunpinyin}} || {{Pkg|ibus-sunpinyin}} || {{-}} || {{-}} || {{-}}<br />
|}</div>Hongy19https://wiki.archlinux.org/index.php?title=Sshguard&diff=773735Sshguard2023-03-25T01:08:07Z<p>Hongy19: /* UFW */ add ipv6 part for ufw rule</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Secure Shell]]<br />
[[Category:Firewalls]]<br />
[[es:Sshguard]]<br />
[[ja:Sshguard]]<br />
[[zh-hans:Sshguard]]<br />
{{Related articles start}}<br />
{{Related|fail2ban}}<br />
{{Related|ssh}}<br />
{{Related articles end}}<br />
{{warning|Using an IP blacklist will stop trivial attacks but it relies on an additional daemon and successful logging (the partition containing /var can become full, especially if an attacker is pounding on the server). Additionally, with the knowledge of your IP address, the attacker can send packets with a spoofed source header and get you locked out of the server. [[SSH keys]] provide an elegant solution to brute forcing without these problems.}}<br />
[https://www.sshguard.net sshguard] is a daemon that protects [[SSH]] and other services against brute-force attacks, similar to [[fail2ban]].<br />
<br />
sshguard is different from the latter in that it is written in C, is lighter and simpler to use with fewer features while performing its core function equally well.<br />
<br />
sshguard is not vulnerable to most (or maybe any) of the log analysis [https://web.archive.org/web/20120625102244/http://www.ossec.net/main/attacking-log-analysis-tools vulnerabilities] that have caused problems for similar tools.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|sshguard}} package.<br />
<br />
== Configuration ==<br />
<br />
sshguard works by monitoring {{ic|/var/log/auth.log}}, [[syslog-ng]] or the [[systemd journal]] for failed login attempts. For each failed attempt, the offending host is banned from further communication for a limited amount of time. The default amount of time the offender is banned starts at 120 seconds, and is increases by a factor of 1.5 every time it fails another login. sshguard can be configured to permanently ban a host with too many failed attempts.<br />
<br />
Both temporary and permanent bans are done by adding an entry into the "sshguard" chain in iptables that drops all packets from the offender. The ban is then logged to syslog and ends up in {{ic|/var/log/auth.log}}, or the systemd journal if the latter is being used.<br />
<br />
You must configure one of the following firewalls to be used with sshguard in order for blocking to work.<br />
<br />
=== firewalld ===<br />
<br />
{{Out of date|ipset has been deprecated in firewalld and the following steps will break firewalld.}}<br />
<br />
sshguard can work with [[firewalld]]. Make sure you have firewalld enabled, configured and setup first. To make sshguard write to your zone of preference, issue the following commands:<br />
<br />
# firewall-cmd --permanent --zone=public --add-rich-rule="rule source ipset=sshguard4 drop"<br />
<br />
If you use ipv6, you can issue the same command but substitute sshguard4 with sshguard6. Finish with<br />
<br />
# firewall-cmd --reload<br />
<br />
You can verify the above with<br />
<br />
# firewall-cmd --info-ipset=sshguard4<br />
<br />
Finally, in /etc/sshguard.conf, find the line for BACKEND and change it as follows<br />
<br />
{{hc|/etc/sshguard.conf|2=<br />
BACKEND="/usr/lib/sshguard/sshg-fw-firewalld"<br />
}}<br />
<br />
=== UFW ===<br />
<br />
If UFW is installed and enabled, it must be given the ability to pass along DROP control to sshguard. This is accomplished by modifying {{ic|/etc/ufw/before.rules}} to contain the following lines which should be inserted just after the section for loopback devices. {{Note|Users running sshd on a non-standard port should substitute that in the final line above (where 22 is the standard).}}<br />
<br />
{{hc|/etc/ufw/before.rules|<br />
# allow all on loopback<br />
-A ufw-before-input -i lo -j ACCEPT<br />
-A ufw-before-output -o lo -j ACCEPT<br />
<br />
# hand off control for sshd to sshguard<br />
# ipv4<br />
:sshguard - [0:0]<br />
-A ufw-before-input -p tcp --dport 22 -j sshguard<br />
#for ipv6<br />
:sshguard - [0:0]<br />
-A ufw6-before-input -p tcp --dport 22 -j sshguard<br />
}}<br />
<br />
[[Restart]] ufw after making this modification.<br />
<br />
=== iptables ===<br />
<br />
{{Note|See [[iptables]] and [[Simple stateful firewall]] first to set up a firewall.}}<br />
<br />
The main configuration required is creating a chain named {{ic|sshguard}}, where sshguard automatically inserts rules to drop packets coming from bad hosts:<br />
<br />
# iptables -N sshguard<br />
<br />
Then add a rule to jump to the {{ic|sshguard}} chain from the {{ic|INPUT}} chain. This rule must be added '''before''' any other rules processing the ports that sshguard is protecting. Use the following line to protect FTP and SSH or see [https://web.archive.org/web/20180902011955/https://www.sshguard.net/docs/setup/#netfilter-iptables] for more examples.<br />
<br />
# iptables -A INPUT -m multiport -p tcp --destination-ports 21,22 -j sshguard<br />
<br />
To save the rules:<br />
<br />
# iptables-save > /etc/iptables/iptables.rules<br />
<br />
{{Note|For IPv6, repeat the same steps with ''ip6tables'' and save the rules with ''ip6tables-save'' to {{ic|/etc/iptables/ip6tables.rules}}.}}<br />
<br />
=== nftables ===<br />
<br />
Change the value of {{ic|BACKEND}} to the following:<br />
<br />
{{hc|1=/etc/sshguard.conf|2=<br />
BACKEND="/usr/lib/sshguard/sshg-fw-nft-sets"<br />
}}<br />
<br />
When you [[start/enable]] the {{ic|sshguard.service}}, two new tables named {{ic|sshguard}} in the {{ic|ip}} and {{ic|ip6}} address families are added which filter incoming traffic through sshguard's list of IP addresses. The chains in the {{ic|sshguard}} table have a priority of -10 and will be processed before other rules of lower priority. See {{man|7|sshguard-setup}} and [[nftables]] for more information.<br />
<br />
== Usage ==<br />
<br />
=== systemd ===<br />
<br />
[[Enable]] and [[start]] {{ic|sshguard.service}}.<br />
<br />
=== syslog-ng ===<br />
<br />
If you have {{Pkg|syslog-ng}} installed, you may start sshguard directly from the command line instead.<br />
<br />
/usr/sbin/sshguard -l /var/log/auth.log -b /var/db/sshguard/blacklist.db<br />
<br />
== Configuration ==<br />
<br />
Configuration is done in {{ic|/etc/sshguard.conf}} which is required for ''sshguard'' to start. A commented example is located at {{ic|/usr/share/doc/sshguard/sshguard.conf.sample}} or can also be found on [https://bitbucket.org/sshguard/sshguard/src/master/examples/sshguard.conf.sample Bitbucket sshguard.conf.sample].<br />
<br />
{{Note|Piped commands and runtime flags in ''sshguard's'' systemd units [https://sourceforge.net/p/sshguard/mailman/message/35709860/ are not supported]. Such flags can be modified in the configuration file.}}<br />
<br />
=== Blacklisting threshold ===<br />
<br />
By default in the Arch-provided configuration file, offenders become permanently banned once they reach a "danger" level of 120 (or 12 failed logins; see [https://web.archive.org/web/20160908055836/http://www.sshguard.net/docs/terminology/#attack-dangerousness attack dangerousness] for more details). This behavior can be modified by prepending a danger level to the blacklist file.<br />
<br />
{{hc|/etc/sshguard.conf|2=<br />
BLACKLIST_FILE=200:/var/db/sshguard/blacklist.db<br />
}}<br />
<br />
The {{ic|200:}} in this example tells sshguard to permanently ban a host after achieving a danger level of 200.<br />
<br />
Finally, [[restart]] {{ic|sshguard.service}}.<br />
<br />
=== Moderate banning example ===<br />
<br />
A slightly more aggressive banning rule than the default one is proposed here to illustrate various options:<br />
* It monitors [[sshd]] and [[vsftpd]] via logs from the [[systemd/Journal]]<br />
* It blocks attackers after 2 attempts (each having a cost of 10, explaining the {{ic|20}} value of the {{ic|THRESHOLD}} parameter) for 180 seconds with subsequent block time longer by a factor of 1.5. Note that this 1.5 multiplicative delay is internal and not controlled in the settings<br />
* Attackers are permanently blacklisted after 10 attempts (10 attempts having each a cost of 10, explaining the {{ic|100}} value in the {{ic|BLACKLIST_FILE}} parameter)<br />
* It blocks not only the attacker's IP but all the IPv4 subnet 24 ([[wikipedia:Classless_Inter-Domain_Routing|CIDR]] notation)<br />
<br />
{{hc|/etc/sshguard.conf|2=<br />
# Full path to backend executable (required, no default)<br />
BACKEND="/usr/lib/sshguard/sshg-fw-iptables"<br />
<br />
# Log reader command (optional, no default)<br />
LOGREADER="LANG=C.UTF-8 /usr/bin/journalctl -afb -p info -n1 -t sshd -t vsftpd -o cat"<br />
<br />
# How many problematic attempts trigger a block<br />
THRESHOLD=20<br />
# Blocks last at least 180 seconds<br />
BLOCK_TIME=180<br />
# The attackers are remembered for up to 3600 seconds<br />
DETECTION_TIME=3600<br />
<br />
# Blacklist threshold and file name<br />
BLACKLIST_FILE=100:/var/db/sshguard/blacklist.db<br />
<br />
# IPv6 subnet size to block. Defaults to a single address, CIDR notation. (optional, default to 128)<br />
IPV6_SUBNET=64<br />
# IPv4 subnet size to block. Defaults to a single address, CIDR notation. (optional, default to 32)<br />
IPV4_SUBNET=24<br />
}}<br />
<br />
=== Aggressive banning ===<br />
<br />
For some users under constant attack, a more aggressive banning policy can be adopted. If you are confident that accidental failed logins are unlikely, you can instruct SSHGuard to permanently ban hosts after a single failed login. Modify the parameters in the configuration file in the following way:<br />
<br />
{{hc|/etc/sshguard.conf|2=<br />
THRESHOLD=10<br />
BLACKLIST_FILE=10:/var/db/sshguard/blacklist.db<br />
}}<br />
<br />
Finally [[restart]] {{ic|sshguard.service}}.<br />
<br />
Also, to prevent multiple authentication attempts during a single connection, you may want to change {{ic|/etc/ssh/sshd_config}} by defining:<br />
<br />
{{hc|/etc/ssh/sshd_config|<br />
MaxAuthTries 1<br />
}}<br />
<br />
[[Restart]] {{ic|sshd.service}} for this change to take effect.<br />
<br />
== Tips and Tricks ==<br />
<br />
=== Unbanning ===<br />
<br />
If you ban ''yourself'', you can wait to get unbanned automatically or use iptables or nftables to unban yourself.<br />
<br />
You will also need to remove the IP address from {{ic|/var/db/sshguard/blacklist.db}} in order to make unbanning persistent.<br />
<br />
==== iptables ====<br />
<br />
First check if your IP is banned by sshguard:<br />
<br />
# iptables --list sshguard --line-numbers --numeric<br />
<br />
Then use the following command to unban, with the line-number as identified in the former command: <br />
<br />
# iptables --delete sshguard ''line-number''<br />
<br />
==== nftables ====<br />
<br />
Remove your IP address from the {{ic|attackers}} set:<br />
<br />
# nft delete element ''family'' sshguard attackers { ''ip_address'' }<br />
<br />
where {{ic|''family''}} is either {{ic|ip}} or {{ic|ip6}}.<br />
<br />
=== Logging ===<br />
<br />
To see what is being passed to sshguard, examine the script in {{ic|/usr/lib/systemd/scripts/sshguard-journalctl}} and the systemd service {{ic|sshguard.service}}. An equivalent command to view the logs in the terminal:<br />
<br />
# journalctl -afb -p info SYSLOG_FACILITY=4 SYSLOG_FACILITY=10</div>Hongy19https://wiki.archlinux.org/index.php?title=Dictd&diff=773141Dictd2023-03-18T11:07:29Z<p>Hongy19: clairfy offline mode need to update localhost in dict.conf</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Dictionaries]]<br />
[[ja:Dictd]]<br />
The [https://sourceforge.net/projects/dict/ official website] describes dictd as:<br />
:Client/server software, human language dictionary databases, and tools supporting the [[Wikipedia:DICT|DICT]] protocol ([[RFC:2229]]).<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|dictd}} package.<br />
<br />
=== Graphical front ends ===<br />
<br />
There are various graphical applications that can access {{ic|dictd}} through the [[wikipedia:DICT|DICT protocol]]:<br />
<br />
* {{App|[[GoldenDict]]|Feature-rich dictionary lookup program supporting multiple dictionary formats.|http://goldendict.org|{{AUR|goldendict-git}}}}<br />
* {{App|gnome-dictionary|A GNOME application to look up definitions.|https://wiki.gnome.org/Apps/Dictionary|{{Pkg|gnome-dictionary}}}}<br />
* {{App|xfce4-dict|A dictionary plugin for the Xfce panel.|https://docs.xfce.org/apps/xfce4-dict/start|{{Pkg|xfce4-dict}}}}<br />
* {{App|dictionary.el|Emacs interface to dictd dictionary servers.|https://www.myrkr.in-berlin.de/dictionary|{{AUR|dictionary}}}}<br />
<br />
== Usage ==<br />
<br />
Dictionaries can be queried by:<br />
<br />
$ dict ''word''<br />
<br />
To query a specific dictionary database, you can use the {{ic|-d}} flag. To query the English-Spanish database, for example, you can use:<br />
<br />
$ dict -d eng-spa ''word''<br />
<br />
Without further configuration, it is likely that dictd will query online databases. See below to set up offline dictionaries.<br />
<br />
== Configuration ==<br />
<br />
By default, dictd tries to query offline databases first, then online databases. However, offline databases will not be available unless {{ic|dictd.service}} is enabled, with locale properly set up and offline dictionaries installed (see below).<br />
<br />
The online mode can be disabled by commenting {{ic|server dict.org}} out in {{ic|/etc/dict/dict.conf}}. Conversely, the offline mode can be disabled by commenting {{ic|server localhost}} out.<br />
<br />
=== Locale ===<br />
<br />
By default, dictd comes configured to use the {{ic|en_US.UTF-8}} locale. If your system does not have this locale compiled, {{ic|dictd.service}} will fail to start without a helpful error message.<br />
<br />
It is likely that you want to configure it to use another locale:<br />
<br />
{{hc|/etc/conf.d/dictd|2=<br />
DICTD_ARGS="--locale ''your locale''"<br />
}}<br />
<br />
=== Hosting offline dictionaries ===<br />
<br />
Dictd can be configured to host offline dictionaries by enabling {{ic|dictd.service}} and dict need to be configured to using {{ic|localhost}} as the server in /etc/dict/dict.conf or .dictrc.<br />
<br />
First, offline dictionaries need to be installed. Dictionaries are available through the [[Arch User Repository]] with the search term {{ic|dictd}}. Some popular English dictionaries include:<br />
<br />
* {{Aur|dict-gcide}} - [[Wikipedia:GCIDE|GNU version of the Collaborative International Dictionary of English]]<br />
* {{Aur|dict-wn}} - [[Wikipedia:WordNet|WordNet]]<br />
* {{Aur|dict-moby-thesaurus}} - [[Wikipedia:Moby_Project#Thesaurus|Moby Thesaurus]]<br />
<br />
The [https://freedict.org FreeDict] project also provides many bilingual dictionaries compatible with dictd, which are usually available on AUR.<br />
<br />
After installation, [[restart]] {{ic|dictd.service}} if needed to access the newly available dictionary. Afterwards, dictionaries can be queried as described above.<br />
<br />
{{Tip|A list of all the available dictionaries can be queried by executing:<br />
<br />
$ dict -I<br />
}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Parse error ===<br />
<br />
The following error:<br />
<br />
/etc/dict/dictd.conf:25: syntax error, unexpected $end<br />
/etc/dict/dictd.conf:25: #LASTLINE<br />
/etc/dict/dictd.conf:25: ^<br />
dictd (yyerror): parse error<br />
parse error<br />
<br />
Means that {{ic|dictd}} cannot find a dictionary database. These can be added manually to {{ic|/etc/dict/dictd.conf}}. For example:<br />
<br />
database eng-spa {<br />
data /usr/share/dictd/eng-spa.dict.dz<br />
index /usr/share/dictd/eng-spa.index<br />
}<br />
<br />
Adds the English-Spanish dictionary installed by {{Aur|dict-freedict-eng-spa}}. For other dictionaries, copy and paste the above database declaration but make sure to change the database name, i.e. {{ic|eng-spa}}, and also change the {{ic|data}} and {{ic|index}} paths above to specify the right files.</div>Hongy19https://wiki.archlinux.org/index.php?title=Wayland&diff=362458Wayland2015-02-23T13:56:48Z<p>Hongy19: </p>
<hr />
<div>[[Category:X Server]]<br />
[[es:Wayland]]<br />
[[fr:Wayland]]<br />
[[ja:Wayland]]<br />
[[ru:Wayland]]<br />
[[zh-CN:Wayland]]<br />
{{Related articles start}}<br />
{{Related|KMS}}<br />
{{Related|Xorg}}<br />
{{Related|Mir}}<br />
{{Related articles end}}<br />
'''Wayland''' is a new windowing protocol for Linux. Utilization of Wayland requires changes to and re-installation of parts of your system's software. For more information on Wayland see its [http://wayland.freedesktop.org/ homepage].<br />
<br />
{{Warning|Wayland is still under development and some features may be incomplete.}}<br />
<br />
== Requirements ==<br />
<br />
Currently Wayland will only work on systems utilizing [[KMS]].<br />
<br />
== Installation ==<br />
<br />
Wayland is most likely installed on your system already, as it is an indirect dependency of {{Pkg|gtk2}} and {{Pkg|gtk3}}. If it is not installed, you will find the {{Pkg|wayland}} package in the [[official repositories]].<br />
<br />
== Usage ==<br />
<br />
As Wayland is only a library, it is useless on its own. To replace X Server, you need a compositor (like Weston).<br />
<br />
== Weston ==<br />
<br />
=== Installation ===<br />
<br />
You need to install {{Pkg|weston}} from the official repositories.<br />
<br />
=== Usage ===<br />
<br />
{| class="wikitable" style="float: right; width: 200px;"<br />
|+ '''''Keyboard Shortcuts''' (super = windows key - can be changed, see weston.ini)'' {{Ic|Ctrl-b}}<br />
!Cmd<br />
!Action<br />
|-<br />
|Ctrl + Alt + Backspace<br />
|Quit Weston<br />
|-<br />
|Super + Scroll (or PageUp/PageDown)<br />
|Zoom in/out of desktop<br />
|-<br />
|Super + Tab<br />
|Switch windows<br />
|-<br />
|Super + LMB<br />
|Move Window<br />
|-<br />
|Super + MMB<br />
|Resize Window<br />
|-<br />
|Super + RMB<br />
|Rotate Window !<br />
|-<br />
|Super + Alt + Scroll<br />
|Change window opacity<br />
|-<br />
|Super + K<br />
|Force Kill Active Window<br />
|-<br />
|Super + KeyUp/KeyDown<br />
|Switch Prev/Next Workspace<br />
|-<br />
|Super + Shift + KeyUp/KeyDown<br />
|Grab Current Window and Switch Workspace<br />
|-<br />
|Super + F'''''n'''''<br />
|Switch to Workspace '''''n'''''<br />
|-<br />
|Super + S<br />
|Take a screenshot<br />
|-<br />
|Super + R<br />
|Record a screencast.<br />
|}<br />
<br />
Now that Wayland and its requirements are installed you should be ready to test it out. <br />
<br />
It is possible to run Weston inside a running X session:<br />
$ weston<br />
<br />
Alternatively, to launch Weston natively, try switching to a terminal and running:<br />
$ weston-launch<br />
<br />
Then at a TTY within Weston, you can run the demos. To launch a terminal emulator:<br />
$ weston-terminal<br />
<br />
To move flowers around the screen:<br />
$ weston-flower <br />
<br />
To test the frame protocol (runs {{ic|glxgears}}):<br />
$ weston-gears<br />
<br />
To display images:<br />
$ weston-image image1.jpg image2.jpg...<br />
<br />
To display PDF Files:<br />
$ weston-view doc1.pdf doc2.pdf...<br />
<br />
=== Configuration ===<br />
Example configuration file for keyboard layout, module selection and UI modifications. See {{ic|man weston.ini}} for full details:<br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
### uncomment this line for xwayland support ###<br />
#modules=xwayland.so<br />
<br />
[shell]<br />
background-image=/usr/share/backgrounds/gnome/Aqua.jpg<br />
background-color=0xff002244<br />
panel-color=0x90ff0000<br />
locking=true<br />
animation=zoom<br />
#binding-modifier=ctrl<br />
#num-workspaces=6<br />
### for cursor themes install xcursor-themes pkg from Extra. ###<br />
#cursor-theme=whiteglass<br />
#cursor-size=24<br />
<br />
### tablet options ###<br />
#lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png<br />
#lockscreen=/usr/share/backgrounds/gnome/Garden.jpg<br />
#homescreen=/usr/share/backgrounds/gnome/Blinds.jpg<br />
#animation=fade<br />
<br />
[keyboard]<br />
keymap_rules=evdev<br />
#keymap_layout=gb<br />
#keymap_options=caps:ctrl_modifier,shift:both_capslock_cancel<br />
### keymap_options from /usr/share/X11/xkb/rules/base.lst ###<br />
<br />
<br />
[terminal]<br />
#font=DroidSansMono<br />
#font-size=14<br />
<br />
<br />
<br />
[launcher]<br />
icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png<br />
path=/usr/bin/gnome-terminal<br />
<br />
[launcher]<br />
icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png<br />
path=/usr/bin/weston-terminal<br />
<br />
[launcher]<br />
icon=/usr/share/icons/hicolor/24x24/apps/firefox.png<br />
path=/usr/bin/firefox<br />
<br />
[launcher]<br />
icon=/usr/share/icons/gnome/24x24/apps/arts.png<br />
path=./clients/flower<br />
<br />
[screensaver]<br />
# Uncomment path to disable screensaver<br />
path=/usr/libexec/weston-screensaver<br />
duration=600<br />
<br />
[input-method]<br />
path=/usr/libexec/weston-keyboard<br />
<br />
### for Laptop displays ###<br />
#[output]<br />
#name=LVDS1<br />
#mode=1680x1050<br />
#transform=90<br />
<br />
#[output]<br />
#name=VGA1<br />
# The following sets the mode with a modeline, you can get modelines for your preffered resolutions using the cvt utility<br />
#mode=173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync<br />
#transform=flipped<br />
<br />
#[output]<br />
#name=X1<br />
#mode=1024x768<br />
#transform=flipped-270</nowiki><br />
}}<br />
<br />
Minimal {{ic|weston.ini}} :<br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
modules=xwayland.so<br />
<br />
[keyboard]<br />
keymap_layout=gb<br />
<br />
[launcher]<br />
icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png<br />
path=/usr/bin/weston-terminal<br />
<br />
[launcher]<br />
icon=/usr/share/icons/hicolor/24x24/apps/firefox.png<br />
path=/usr/bin/firefox<br />
<br />
<br />
[output]<br />
name=LVDS1<br />
mode=1680x1050<br />
transform=90</nowiki><br />
}}<br />
<br />
==== XWayland ====<br />
You can find an official {{Pkg|xorg-server-xwayland}} package in extra.<br />
<br />
When you want to run an X application from within Weston, it spins up Xwayland to service the request. The following configuration file is required:<br />
<br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
modules=xwayland.so</nowiki><br />
}}<br />
<br />
==== Screencast recording ====<br />
Weston has build-in screencast recording which can be started and stopped by pressing the '''Super''' + '''R''' key combination. Screencasts are saved to the file {{ic|capture.wcap}} in the current working directory of Weston. <br />
<br />
The WCAP format is a lossless video format specific to Weston, which only records the difference in frames. To be able to play the recorded screencast, the WCAP file will need to be converted to a format which a media player can understand. <br />
<br />
To convert the file to webm, execute:<br />
<br />
$ wcap-decode capture.wcap --yuv4mpeg2 | vpxenc --target-bitrate=1024 --best -t 4 -o foo.webm -<br />
<br />
<br />
To convert the file to ogv, execute:<br />
<br />
$ wcap-decode capture.wcap --yuv4mpeg2 | theora_encode - -o cap.ogv<br />
<br />
<br />
==== High DPI displays ====<br />
Use<br />
{{hc|~/.config/weston.ini|<br />
<nowiki><br />
[output]<br />
name=...<br />
scale=2<br />
</nowiki><br />
}}<br />
for "retina" or "HiDPI" displays.<br />
<br />
== GUI libraries ==<br />
<br />
See details on the [http://wayland.freedesktop.org/toolkits.html official website].<br />
<br />
=== GTK+ 3 ===<br />
<br />
The {{Pkg|gtk3}} package from the official repositories now has the Wayland backend enabled.<br />
<br />
GTK+ 3 gained support for multiple backends at runtime and can switch between backends in the same way Qt can with lighthouse.<br />
<br />
When both Wayland and X backends are enabled, GTK+ will default to the X11 backend, but this can be overridden by modifying an environment variable: {{ic|GDK_BACKEND&#61;wayland}}.<br />
<br />
=== Qt 5 ===<br />
You need to install {{Pkg|qt5-wayland}}. <br />
To run a Qt 5 app with the Wayland plugin, set the {{ic|1=QT_QPA_PLATFORM=wayland-egl}} [[environment variable]].<br />
<br />
=== Clutter ===<br />
<br />
The Clutter toolkit has a Wayland backend that allows it to run as a Wayland client. The backend is enabled in the official package in extra.<br />
<br />
To run a Clutter app on Wayland, set {{ic|CLUTTER_BACKEND&#61;wayland}}.<br />
<br />
=== SDL ===<br />
<br />
Experimental wayland support is now in SDL 2.0.2 and enabled by default on Arch Linux.<br />
<br />
To run a SDL application on Wayland, set {{ic|SDL_VIDEODRIVER&#61;wayland}}.<br />
<br />
=== glfw ===<br />
<br />
Version 3.1 will have wayland support through a compile flag that you have to enable. In the mean time you can install the package from the AUR {{AUR|glfw3-git}} and add {{ic|-DGLFW_USE_WAYLAND&#61;ON}} to the CMake flags.<br />
<br />
=== EFL ===<br />
<br />
EFL has complete Wayland support. <br />
To run a EFL application on Wayland, see Wayland [http://wayland.freedesktop.org/efl.html project page].<br />
<br />
== Window managers and desktop shells ==<br />
<br />
=== GNOME ===<br />
<br />
{{Warning| Gnome Wayland session will not launch unless you have {{pkg|xorg-server-xwayland}} installed.}}<br />
With version 3.14, [[GNOME]] supports running the desktop using Wayland. The Gnome compositor can be run without using X, and will act as a Wayland system compositor. It is considered stable for production use, but there are still some features that are not yet supported (refer Gnome documentation). Under this desktop, applications using X will run using XWayland.<br />
<br />
To start up a Gnome Wayland session, GDM login manager needs to be used, and the user must select the "Gnome on Wayland" session before logging in.<br />
<br />
=== Hawaii ===<br />
<br />
See [[Hawaii]].<br />
<br />
=== i3 ===<br />
<br />
Some developers from [[i3]] are thinking of starting [http://www.i3way.org/ a completely new project] for implementing a shell plugin for Weston to implement the same features and style of i3.<br />
<br />
=== KDE ===<br />
<br />
[[KDE]] 4.11 added support for [http://blog.martin-graesslin.com/blog/2013/06/starting-a-full-kde-plasma-session-in-wayland/ KWin under Wayland system compositor]. There is currently no support for using KWin as a session compositor.<br />
<br />
=== Loliwm ===<br />
<br />
[https://github.com/Cloudef/loliwm loliwm] is a tiling WM for Wayland.<br />
<br />
=== Velox ===<br />
<br />
[https://github.com/michaelforney/velox velox] is a simple window manager based on swc. It is inspired by [[dwm]] and [[xmonad]].<br />
<br />
=== Orbital ===<br />
<br />
[https://github.com/giucam/orbital Orbital] is a Wayland compositor and shell, using Qt5 and Weston. The goal of the project is to build a simple yet flexible and good looking Wayland desktop. It is not a full fledged DE but rather the analogue of a WM in the X11 world, such as [[Awesome]] or [[Fluxbox]].<br />
<br />
=== Papyros Shell ===<br />
<br />
[https://github.com/papyros/papyros-shell Papyros Shell] is the desktop shell for [http://papyros.io Papyros], built using QtQuick and QtCompositor as a compositor for Wayland.<br />
<br />
=== Maynard ===<br />
<br />
[https://github.com/raspberrypi/maynard Maynard] is a desktop shell client for Weston based on GTK. It was based on weston-gtk-shell, a project by Tiago Vignatti.<br />
<br />
=== Motorcar ===<br />
<br />
[https://github.com/evil0sheep/motorcar Motorcar] is a wayland compositor to explore 3D windowing.<br />
<br />
==Troubleshooting==<br />
<br />
=== LLVM assertion failure ===<br />
If you get an LLVM assertion failure, you need to rebuild {{Pkg|mesa}} without Gallium LLVM until this problem is fixed. <br />
<br />
This may imply disabling some drivers which require LLVM.<br />
You may also try exporting the following, if having problems with hardware drivers: <br />
<br />
$ export EGL_DRIVER=/usr/lib/egl/egl_gallium.so<br />
<br />
=== Weston fails to launch after update to 1.7 ===<br />
This is possibly caused by the `desktop-shell.so` module being loaded by your weston.ini. This used to be required, but is not anymore.<br />
<br />
To remove it simply look for a line similar to this line.<br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
modules=xwayland.so,desktop-shell.so</nowiki><br />
}}<br />
Remove the `desktop-shell.so` from that line. <br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
modules=xwayland.so</nowiki><br />
}}<br />
<br />
=== mouse click fail for chrome/chromium in weston+xwayland ===<br />
Chrome/chromium could launch from weston, but only keyboard works, no mouse click work.<br />
It is a weston [https://bugs.freedesktop.org/show_bug.cgi?id=89178 bug]. Chrome works well in other wayland compositors, like loliwm<br />
<br />
== See also ==<br />
* [[Cursor Themes]]<br />
* [https://bbs.archlinux.org/viewtopic.php?id=107499 Arch Linux forum discussion]<br />
* [http://wayland.freedesktop.org/docs/html/ Wayland documentation online]<br />
* [http://www.chaosreigns.com/wiki/Wayland_State Wayland usability wiki]</div>Hongy19https://wiki.archlinux.org/index.php?title=Wayland&diff=362457Wayland2015-02-23T13:54:32Z<p>Hongy19: </p>
<hr />
<div>[[Category:X Server]]<br />
[[es:Wayland]]<br />
[[fr:Wayland]]<br />
[[ja:Wayland]]<br />
[[ru:Wayland]]<br />
[[zh-CN:Wayland]]<br />
{{Related articles start}}<br />
{{Related|KMS}}<br />
{{Related|Xorg}}<br />
{{Related|Mir}}<br />
{{Related articles end}}<br />
'''Wayland''' is a new windowing protocol for Linux. Utilization of Wayland requires changes to and re-installation of parts of your system's software. For more information on Wayland see its [http://wayland.freedesktop.org/ homepage].<br />
<br />
{{Warning|Wayland is still under development and some features may be incomplete.}}<br />
<br />
== Requirements ==<br />
<br />
Currently Wayland will only work on systems utilizing [[KMS]].<br />
<br />
== Installation ==<br />
<br />
Wayland is most likely installed on your system already, as it is an indirect dependency of {{Pkg|gtk2}} and {{Pkg|gtk3}}. If it is not installed, you will find the {{Pkg|wayland}} package in the [[official repositories]].<br />
<br />
== Usage ==<br />
<br />
As Wayland is only a library, it is useless on its own. To replace X Server, you need a compositor (like Weston).<br />
<br />
== Weston ==<br />
<br />
=== Installation ===<br />
<br />
You need to install {{Pkg|weston}} from the official repositories.<br />
<br />
=== Usage ===<br />
<br />
{| class="wikitable" style="float: right; width: 200px;"<br />
|+ '''''Keyboard Shortcuts''' (super = windows key - can be changed, see weston.ini)'' {{Ic|Ctrl-b}}<br />
!Cmd<br />
!Action<br />
|-<br />
|Ctrl + Alt + Backspace<br />
|Quit Weston<br />
|-<br />
|Super + Scroll (or PageUp/PageDown)<br />
|Zoom in/out of desktop<br />
|-<br />
|Super + Tab<br />
|Switch windows<br />
|-<br />
|Super + LMB<br />
|Move Window<br />
|-<br />
|Super + MMB<br />
|Resize Window<br />
|-<br />
|Super + RMB<br />
|Rotate Window !<br />
|-<br />
|Super + Alt + Scroll<br />
|Change window opacity<br />
|-<br />
|Super + K<br />
|Force Kill Active Window<br />
|-<br />
|Super + KeyUp/KeyDown<br />
|Switch Prev/Next Workspace<br />
|-<br />
|Super + Shift + KeyUp/KeyDown<br />
|Grab Current Window and Switch Workspace<br />
|-<br />
|Super + F'''''n'''''<br />
|Switch to Workspace '''''n'''''<br />
|-<br />
|Super + S<br />
|Take a screenshot<br />
|-<br />
|Super + R<br />
|Record a screencast.<br />
|}<br />
<br />
Now that Wayland and its requirements are installed you should be ready to test it out. <br />
<br />
It is possible to run Weston inside a running X session:<br />
$ weston<br />
<br />
Alternatively, to launch Weston natively, try switching to a terminal and running:<br />
$ weston-launch<br />
<br />
Then at a TTY within Weston, you can run the demos. To launch a terminal emulator:<br />
$ weston-terminal<br />
<br />
To move flowers around the screen:<br />
$ weston-flower <br />
<br />
To test the frame protocol (runs {{ic|glxgears}}):<br />
$ weston-gears<br />
<br />
To display images:<br />
$ weston-image image1.jpg image2.jpg...<br />
<br />
To display PDF Files:<br />
$ weston-view doc1.pdf doc2.pdf...<br />
<br />
=== Configuration ===<br />
Example configuration file for keyboard layout, module selection and UI modifications. See {{ic|man weston.ini}} for full details:<br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
### uncomment this line for xwayland support ###<br />
#modules=xwayland.so<br />
<br />
[shell]<br />
background-image=/usr/share/backgrounds/gnome/Aqua.jpg<br />
background-color=0xff002244<br />
panel-color=0x90ff0000<br />
locking=true<br />
animation=zoom<br />
#binding-modifier=ctrl<br />
#num-workspaces=6<br />
### for cursor themes install xcursor-themes pkg from Extra. ###<br />
#cursor-theme=whiteglass<br />
#cursor-size=24<br />
<br />
### tablet options ###<br />
#lockscreen-icon=/usr/share/icons/gnome/256x256/actions/lock.png<br />
#lockscreen=/usr/share/backgrounds/gnome/Garden.jpg<br />
#homescreen=/usr/share/backgrounds/gnome/Blinds.jpg<br />
#animation=fade<br />
<br />
[keyboard]<br />
keymap_rules=evdev<br />
#keymap_layout=gb<br />
#keymap_options=caps:ctrl_modifier,shift:both_capslock_cancel<br />
### keymap_options from /usr/share/X11/xkb/rules/base.lst ###<br />
<br />
<br />
[terminal]<br />
#font=DroidSansMono<br />
#font-size=14<br />
<br />
<br />
<br />
[launcher]<br />
icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png<br />
path=/usr/bin/gnome-terminal<br />
<br />
[launcher]<br />
icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png<br />
path=/usr/bin/weston-terminal<br />
<br />
[launcher]<br />
icon=/usr/share/icons/hicolor/24x24/apps/firefox.png<br />
path=/usr/bin/firefox<br />
<br />
[launcher]<br />
icon=/usr/share/icons/gnome/24x24/apps/arts.png<br />
path=./clients/flower<br />
<br />
[screensaver]<br />
# Uncomment path to disable screensaver<br />
path=/usr/libexec/weston-screensaver<br />
duration=600<br />
<br />
[input-method]<br />
path=/usr/libexec/weston-keyboard<br />
<br />
### for Laptop displays ###<br />
#[output]<br />
#name=LVDS1<br />
#mode=1680x1050<br />
#transform=90<br />
<br />
#[output]<br />
#name=VGA1<br />
# The following sets the mode with a modeline, you can get modelines for your preffered resolutions using the cvt utility<br />
#mode=173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync<br />
#transform=flipped<br />
<br />
#[output]<br />
#name=X1<br />
#mode=1024x768<br />
#transform=flipped-270</nowiki><br />
}}<br />
<br />
Minimal {{ic|weston.ini}} :<br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
modules=xwayland.so<br />
<br />
[keyboard]<br />
keymap_layout=gb<br />
<br />
[launcher]<br />
icon=/usr/share/icons/gnome/24x24/apps/utilities-terminal.png<br />
path=/usr/bin/weston-terminal<br />
<br />
[launcher]<br />
icon=/usr/share/icons/hicolor/24x24/apps/firefox.png<br />
path=/usr/bin/firefox<br />
<br />
<br />
[output]<br />
name=LVDS1<br />
mode=1680x1050<br />
transform=90</nowiki><br />
}}<br />
<br />
==== XWayland ====<br />
You can find an official {{Pkg|xorg-server-xwayland}} package in extra.<br />
<br />
When you want to run an X application from within Weston, it spins up Xwayland to service the request. The following configuration file is required:<br />
<br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
modules=xwayland.so</nowiki><br />
}}<br />
<br />
==== Screencast recording ====<br />
Weston has build-in screencast recording which can be started and stopped by pressing the '''Super''' + '''R''' key combination. Screencasts are saved to the file {{ic|capture.wcap}} in the current working directory of Weston. <br />
<br />
The WCAP format is a lossless video format specific to Weston, which only records the difference in frames. To be able to play the recorded screencast, the WCAP file will need to be converted to a format which a media player can understand. <br />
<br />
To convert the file to webm, execute:<br />
<br />
$ wcap-decode capture.wcap --yuv4mpeg2 | vpxenc --target-bitrate=1024 --best -t 4 -o foo.webm -<br />
<br />
<br />
To convert the file to ogv, execute:<br />
<br />
$ wcap-decode capture.wcap --yuv4mpeg2 | theora_encode - -o cap.ogv<br />
<br />
<br />
==== High DPI displays ====<br />
Use<br />
{{hc|~/.config/weston.ini|<br />
<nowiki><br />
[output]<br />
name=...<br />
scale=2<br />
</nowiki><br />
}}<br />
for "retina" or "HiDPI" displays.<br />
<br />
== GUI libraries ==<br />
<br />
See details on the [http://wayland.freedesktop.org/toolkits.html official website].<br />
<br />
=== GTK+ 3 ===<br />
<br />
The {{Pkg|gtk3}} package from the official repositories now has the Wayland backend enabled.<br />
<br />
GTK+ 3 gained support for multiple backends at runtime and can switch between backends in the same way Qt can with lighthouse.<br />
<br />
When both Wayland and X backends are enabled, GTK+ will default to the X11 backend, but this can be overridden by modifying an environment variable: {{ic|GDK_BACKEND&#61;wayland}}.<br />
<br />
=== Qt 5 ===<br />
You need to install {{Pkg|qt5-wayland}}. <br />
To run a Qt 5 app with the Wayland plugin, set the {{ic|1=QT_QPA_PLATFORM=wayland-egl}} [[environment variable]].<br />
<br />
=== Clutter ===<br />
<br />
The Clutter toolkit has a Wayland backend that allows it to run as a Wayland client. The backend is enabled in the official package in extra.<br />
<br />
To run a Clutter app on Wayland, set {{ic|CLUTTER_BACKEND&#61;wayland}}.<br />
<br />
=== SDL ===<br />
<br />
Experimental wayland support is now in SDL 2.0.2 and enabled by default on Arch Linux.<br />
<br />
To run a SDL application on Wayland, set {{ic|SDL_VIDEODRIVER&#61;wayland}}.<br />
<br />
=== glfw ===<br />
<br />
Version 3.1 will have wayland support through a compile flag that you have to enable. In the mean time you can install the package from the AUR {{AUR|glfw3-git}} and add {{ic|-DGLFW_USE_WAYLAND&#61;ON}} to the CMake flags.<br />
<br />
=== EFL ===<br />
<br />
EFL has complete Wayland support. <br />
To run a EFL application on Wayland, see Wayland [http://wayland.freedesktop.org/efl.html project page].<br />
<br />
== Window managers and desktop shells ==<br />
<br />
=== GNOME ===<br />
<br />
{{Warning| Gnome Wayland session will not launch unless you have {{pkg|xorg-server-xwayland}} installed.}}<br />
With version 3.14, [[GNOME]] supports running the desktop using Wayland. The Gnome compositor can be run without using X, and will act as a Wayland system compositor. It is considered stable for production use, but there are still some features that are not yet supported (refer Gnome documentation). Under this desktop, applications using X will run using XWayland.<br />
<br />
To start up a Gnome Wayland session, GDM login manager needs to be used, and the user must select the "Gnome on Wayland" session before logging in.<br />
<br />
=== Hawaii ===<br />
<br />
See [[Hawaii]].<br />
<br />
=== i3 ===<br />
<br />
Some developers from [[i3]] are thinking of starting [http://www.i3way.org/ a completely new project] for implementing a shell plugin for Weston to implement the same features and style of i3.<br />
<br />
=== KDE ===<br />
<br />
[[KDE]] 4.11 added support for [http://blog.martin-graesslin.com/blog/2013/06/starting-a-full-kde-plasma-session-in-wayland/ KWin under Wayland system compositor]. There is currently no support for using KWin as a session compositor.<br />
<br />
=== Loliwm ===<br />
<br />
[https://github.com/Cloudef/loliwm loliwm] is a tiling WM for Wayland.<br />
<br />
=== Velox ===<br />
<br />
[https://github.com/michaelforney/velox velox] is a simple window manager based on swc. It is inspired by [[dwm]] and [[xmonad]].<br />
<br />
=== Orbital ===<br />
<br />
[https://github.com/giucam/orbital Orbital] is a Wayland compositor and shell, using Qt5 and Weston. The goal of the project is to build a simple yet flexible and good looking Wayland desktop. It is not a full fledged DE but rather the analogue of a WM in the X11 world, such as [[Awesome]] or [[Fluxbox]].<br />
<br />
=== Papyros Shell ===<br />
<br />
[https://github.com/papyros/papyros-shell Papyros Shell] is the desktop shell for [http://papyros.io Papyros], built using QtQuick and QtCompositor as a compositor for Wayland.<br />
<br />
=== Maynard ===<br />
<br />
[https://github.com/raspberrypi/maynard Maynard] is a desktop shell client for Weston based on GTK. It was based on weston-gtk-shell, a project by Tiago Vignatti.<br />
<br />
=== Motorcar ===<br />
<br />
[https://github.com/evil0sheep/motorcar Motorcar] is a wayland compositor to explore 3D windowing.<br />
<br />
==Troubleshooting==<br />
<br />
=== LLVM assertion failure ===<br />
If you get an LLVM assertion failure, you need to rebuild {{Pkg|mesa}} without Gallium LLVM until this problem is fixed. <br />
<br />
This may imply disabling some drivers which require LLVM.<br />
You may also try exporting the following, if having problems with hardware drivers: <br />
<br />
$ export EGL_DRIVER=/usr/lib/egl/egl_gallium.so<br />
<br />
=== Weston fails to launch after update to 1.7 ===<br />
This is possibly caused by the `desktop-shell.so` module being loaded by your weston.ini. This used to be required, but is not anymore.<br />
<br />
To remove it simply look for a line similar to this line.<br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
modules=xwayland.so,desktop-shell.so</nowiki><br />
}}<br />
Remove the `desktop-shell.so` from that line. <br />
{{hc|~/.config/weston.ini|<br />
<nowiki>[core]<br />
modules=xwayland.so</nowiki><br />
}}<br />
<br />
=== chrome/chromium doesn't work in weston+xwayland ===<br />
weston has [https://bugs.freedesktop.org/show_bug.cgi?id=89178 bug], try other compositors, like loliwm<br />
<br />
== See also ==<br />
* [[Cursor Themes]]<br />
* [https://bbs.archlinux.org/viewtopic.php?id=107499 Arch Linux forum discussion]<br />
* [http://wayland.freedesktop.org/docs/html/ Wayland documentation online]<br />
* [http://www.chaosreigns.com/wiki/Wayland_State Wayland usability wiki]</div>Hongy19https://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture&diff=295133Advanced Linux Sound Architecture2014-01-31T11:01:50Z<p>Hongy19: /* HDMI output does not work */</p>
<hr />
<div>[[Category:Sound]]<br />
[[Category:Audio/Video]]<br />
[[cs:Advanced Linux Sound Architecture]]<br />
[[de:Alsa]]<br />
[[es:Advanced Linux Sound Architecture]]<br />
[[fa:ALSA]]<br />
[[fr:Alsa]]<br />
[[he:Advanced Linux Sound Architecture]]<br />
[[it:Advanced Linux Sound Architecture]]<br />
[[ja:Advanced Linux Sound Architecture]]<br />
[[nl:Advanced Linux Sound Architecture]]<br />
[[pt:Advanced Linux Sound Architecture]]<br />
[[ru:Advanced Linux Sound Architecture]]<br />
[[sk:Advanced Linux Sound Architecture]]<br />
[[th:Advanced Linux Sound Architecture]]<br />
[[tr:Gelişmiş_ses_mimarisi_(ALSA)]]<br />
[[zh-CN:Advanced Linux Sound Architecture]]<br />
{{Related articles start}}<br />
{{Related|Sound system}}<br />
{{Related|Disable PC Speaker Beep}}<br />
{{Related articles end}}<br />
The [[Wikipedia:Advanced Linux Sound Architecture|Advanced Linux Sound Architecture]] ('''ALSA''') is a Linux kernel component which replaced the original Open Sound System (OSSv3) for providing device drivers for sound cards. Besides the sound device drivers, '''ALSA''' also bundles a user space library for application developers who want to use driver features with a higher level API than direct interaction with the kernel drivers.<br />
<br />
{{Note|For an alternative sound environment, see the [[Open Sound System]] page.}}<br />
<br />
== Installation ==<br />
<br />
ALSA is included in the default Arch kernel as a set of modules, so installing it is not necessary.<br />
<br />
[[udev]] will automatically probe your hardware at boot, loading the corresponding kernel module for your audio card. Therefore, your sound should already be working, but upstream sources mute all channels by default.<br />
<br />
Users with a local login (at a virtual terminal or a display manager) have permission to play audio and change mixer levels. To allow this for a remote login, the user has to be [[Users and Groups#Group management|added]] to the {{ic|audio}} group. Membership in the {{ic|audio}} group also allows direct access to devices, which can lead to applications grabbing exclusive output (breaking software mixing) and breaks fast-user-switching, and multiseat. Therefore, adding a user to the {{ic|audio}} group is '''not''' recommended, unless you specifically need to[https://wiki.ubuntu.com/Audio/TheAudioGroup].<br />
<br />
=== User-space utilities ===<br />
<br />
[[pacman|Install]] the {{Pkg|alsa-utils}} package from the [[Official Repositories|official repositories]] which contains the {{ic|alsamixer}} user-space tool, which allows for configuration of the sound device from the console or terminal. Also install the {{Pkg|alsa-plugins}} package if you want [[#High quality resampling|high quality resampling]], [[#Upmixing/Downmixing|upmixing/downmixing]] and other advanced features.<br />
<br />
If you want OSS applications to work with dmix (software mixing), also install the {{Pkg|alsa-oss}} package. Load the {{ic|snd_seq_oss}}, {{ic|snd_pcm_oss}} and {{ic|snd_mixer_oss}} [[kernel modules]] to enable the OSS emulation modules.<br />
<br />
== Unmuting the channels ==<br />
<br />
The current version of ALSA installs with all channels '''muted by default'''. You will need to unmute the channels manually.<br />
<br />
It is easiest to use {{ic|alsamixer}} ncurses UI to accomplish this:<br />
<br />
$ alsamixer<br />
<br />
Alternatively, use {{ic|amixer}} from the command-line:<br />
<br />
$ amixer sset Master unmute<br />
<br />
In {{ic|alsamixer}}, the {{ic|MM}} label below a channel indicates that the channel is muted, and {{ic|00}} indicates that it is open.<br />
<br />
Scroll to the {{ic|Master}} and {{ic|PCM}} channels with the {{ic|←}} and {{ic|→}} keys and unmute them by pressing the {{ic|m}} key. Use the {{ic|↑}} key to increase the volume and obtain a value of {{ic|0}} dB gain. The gain can be found in the upper left next to the {{ic|Item:}} field. Higher values of gain will produce distorted sound.<br />
<br />
To get full 5.1 or 7.1 surround sound you likely need to unmute other channels such as Front, Surround, Center, LFE (subwoofer) and Side (these are the names of the channels with Intel HD Audio, they may vary with different hardware). Please take note that this will not automatically upmix stereo sources (like most music). In order to accomplish that, see [[#Upmixing/Downmixing]].<br />
<br />
To enable your microphone, switch to the Capture tab with {{ic|F4}} and enable a channel with {{ic|Space}}.<br />
<br />
Leave alsamixer by pressing {{ic|Esc}}.<br />
<br />
{{Note|<br />
* Some cards need to have digital output muted/turned off in order to hear analog sound. For the Soundblaster Audigy LS mute the IEC958 channel.<br />
* Some machines, (like the Thinkpad T61), have a Speaker channel which must be unmuted and adjusted as well.<br />
* Some machines, (like the Dell E6400) may also require the {{ic|Front}} and {{ic|Headphone}} channels to be unmuted and adjusted.<br />
* If your volume adjustments seems to be lost when you reboot, try running alsamixer as root. <br />
}}<br />
<br />
Next, test to see if sound works:<br />
<br />
$ speaker-test -c 2<br />
<br />
Change {{ic|-c}} to fit your speaker setup. Use {{ic|-c 8}} for 7.1, for instance:<br />
<br />
$ speaker-test -c 8<br />
<br />
If it does not work, proceed to [[#Configuration|Configuration]] and then [[#Troubleshooting|Troubleshooting]] to solve your problems.<br />
<br />
The {{Pkg|alsa-utils}} package includes {{ic|alsa-restore.service}} and {{ic|alsa-store.service}}, which are preconfigured to run at boot and shutdown respectively.<br />
For reference, ALSA stores its settings in {{ic|/var/lib/alsa/asound.state}}.<br />
<br />
== Configuration ==<br />
<br />
=== No sound in VirtualBox ===<br />
<br />
If you experience problems with VirtualBox, the following command might be helpful:<br />
<br />
{{hc|$ alsactl init|2=<nowiki><br />
<br />
Found hardware: "ICH" "SigmaTel STAC9700,83,84" "AC97a:83847600" "0x8086" "0x0000"<br />
Hardware is initialized using a generic method<br />
</nowiki>}}<br />
<br />
You might need to activate the ALSA output in your audio software as well.<br />
<br />
=== Set the default sound card ===<br />
<br />
If your sound card order changes on boot, you can specify their order in any file ending with {{ic|.conf}} in {{ic|/etc/modprobe.d}} ({{ic|/etc/modprobe.d/alsa-base.conf}} is suggested).<br />
For example, if you want your mia sound card to be #0:<br />
<br />
{{hc|/etc/modprobe.d/alsa-base.conf|2=<nowiki><br />
options snd slots=snd_mia,snd_hda_intel<br />
options snd_mia index=0<br />
options snd_hda_intel index=1<br />
</nowiki>}}<br />
<br />
Use {{ic|<nowiki>$ cat /proc/asound/modules</nowiki>}} to get the loaded sound modules and their order. This list is usually all that is needed for the loading order. Use {{ic|<nowiki>$ lsmod | grep snd</nowiki>}} to get a devices & modules list. This configuration assumes you have one mia sound card using {{ic|snd_mia}} and one (e.g. onboard) card using {{ic|snd_hda_intel}}.<br />
<br />
You can also provide an index of {{ic|-2}} to instruct ALSA to never use a card as the primary one. Distributions such as Linux Mint and Ubuntu use the following settings to avoid USB and other "abnormal" drivers from getting index {{ic|0}}:<br />
<br />
{{hc|/etc/modprobe.d/alsa-base.conf|2=<br />
options bt87x index=-2<br />
options cx88_alsa index=-2<br />
options saa7134-alsa index=-2<br />
options snd-atiixp-modem index=-2<br />
options snd-intel8x0m index=-2<br />
options snd-via82xx-modem index=-2<br />
options snd-usb-audio index=-2<br />
options snd-usb-caiaq index=-2<br />
options snd-usb-ua101 index=-2<br />
options snd-usb-us122l index=-2<br />
options snd-usb-usx2y index=-2<br />
options snd-pcsp index=-2<br />
options snd-usb-audio index=-2<br />
}}<br />
<br />
These changes require a system reboot.<br />
<br />
==== Select the default PCM via environment variable ====<br />
<br />
In your configuration file, preferably global, add:<br />
pcm.!default {<br />
type plug<br />
slave.pcm {<br />
@func getenv<br />
vars [ ALSAPCM ]<br />
default "hw:Audigy2"<br />
}<br />
}<br />
<br />
You need to replace the default line with the name of your card (in the example is {{ic|Audigy2}}). You can get the names with {{ic|aplay -l}} or you can also use PCMs like '''surround51'''. But if you need to use the microphone it is a good idea to select full-duplex PCM as default.<br />
<br />
Now you can start programs selecting the sound card just changing the environment variable {{ic|ALSAPCM}}. It works fine for all program that do not allow to select the card, for the others ensure you keep the default card.<br />
For example, assuming you wrote a downmix PCM called '''mix51to20''' you can use it with {{ic|mplayer}} using the commandline {{ic|ALSAPCM&#61;mix51to20 mplayer example_6_channel.wav}}<br />
<br />
==== Alternative method ====<br />
<br />
First you will have to find out the card and device id that you want to set as the default by running {{ic|aplay -l}}:<br />
<br />
{{hc|$ aplay -l|2=<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: CONEXANT Analog [CONEXANT Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 1: Conexant Digital [Conexant Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 1: JamLab [JamLab], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 2: Audio [Altec Lansing XT1 - USB Audio], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
}}<br />
<br />
For example, the last entry in this list has the card ID 2 and the device ID 0. To set this card as the default, you can either use the system-wide file {{ic|/etc/asound.conf}} or the user-specific file {{ic|~/.asoundrc}}. You may have to create the file if it does not exist. Then insert the following options with the corresponding card.<br />
{{bc|<br />
pcm.!default {<br />
type hw<br />
card 2<br />
}<br />
<br />
ctl.!default {<br />
type hw <br />
card 2<br />
}<br />
}}<br />
<br />
{{Note|For the Asus U32U serie it seems that card should be set to 1 for both pcm and ctl.}}<br />
<br />
The 'pcm' options affect which card and device will be used for audio playback while the 'ctl' option affects which card is used by control utilities like alsamixer .<br />
<br />
The changes should take effect as soon as you (re-)start an application (MPlayer etc.). You can also test with a command like ''aplay''.<br />
<br />
$ aplay -D default ''your_favourite_sound.wav''<br />
<br />
If you receive an error regarding your asound configuration, check the [http://www.alsa-project.org/main/index.php/Asoundrc#The_default_plugin upstream documentation] for possible changes to the config file format.<br />
<br />
=== Making sure the sound modules are loaded ===<br />
<br />
You can assume that udev will autodetect your sound properly. You can check this with the command<br />
<br />
{{hc|<nowiki>$ lsmod | grep '^snd' | column -t</nowiki>|2=<br />
snd_hda_codec_hdmi 22378 4<br />
snd_hda_codec_realtek 294191 1<br />
snd_hda_intel 21738 1<br />
snd_hda_codec 73739 3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel<br />
snd_hwdep 6134 1 snd_hda_codec<br />
snd_pcm 71032 3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec<br />
snd_timer 18992 1 snd_pcm<br />
snd 55132 9 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer<br />
snd_page_alloc 7017 2 snd_hda_intel,snd_pcm<br />
}}<br />
<br />
If the output looks similar, your sound drivers have been successfully autodetected.<br />
{{Note|Since {{ic|udev>&#61;171}}, the OSS emulation modules ({{ic|snd_seq_oss, snd_pcm_oss, snd_mixer_oss}}) are not loaded by default: [[kernel modules#Loading|Load them manually]] if they are needed.}}<br />
<br />
You might also want to check the directory {{ic|/dev/snd/}} for the right device files:<br />
<br />
{{hc|$ ls -l /dev/snd|2=<nowiki><br />
total 0<br />
crw-rw---- 1 root audio 116, 0 Apr 8 14:17 controlC0<br />
crw-rw---- 1 root audio 116, 32 Apr 8 14:17 controlC1<br />
crw-rw---- 1 root audio 116, 24 Apr 8 14:17 pcmC0D0c<br />
crw-rw---- 1 root audio 116, 16 Apr 8 14:17 pcmC0D0p<br />
crw-rw---- 1 root audio 116, 25 Apr 8 14:17 pcmC0D1c<br />
crw-rw---- 1 root audio 116, 56 Apr 8 14:17 pcmC1D0c<br />
crw-rw---- 1 root audio 116, 48 Apr 8 14:17 pcmC1D0p<br />
crw-rw---- 1 root audio 116, 1 Apr 8 14:17 seq<br />
crw-rw---- 1 root audio 116, 33 Apr 8 14:17 timer<br />
</nowiki>}}<br />
<br />
{{Note|If requesting help on IRC or the forums, please post the output of the above commands.}}<br />
<br />
If you have at least the devices '''controlC0''' and '''pcmC0D0p''' or similar, then your sound modules have been detected and loaded properly.<br />
<br />
If this is not the case, your sound modules have not been detected properly. To solve this, you can try loading the modules manually:<br />
<br />
* Locate the module for your sound card: [http://www.alsa-project.org/main/index.php/Matrix:Main ALSA Soundcard Matrix] The module will be prefixed with 'snd-' (for example: {{ic|snd-via82xx}}).<br />
* [[Kernel modules#Loading|Load the module]].<br />
* Check for the device files in {{ic|/dev/snd}} (see above) and/or try if {{ic|alsamixer}} or {{ic|amixer}} have reasonable output.<br />
* Configure {{ic|snd-NAME-OF-MODULE}} and {{ic|snd-pcm-oss}} to [[Kernel modules#Loading|load at boot]].<br />
<br />
=== Getting SPDIF output ===<br />
<br />
(from gralves from the Gentoo forums)<br />
* In GNOME Volume Control, under the Options tab, change the IEC958 to PCM. This option can be enabled in the preferences.<br />
* If you do not have GNOME Volume Control installed,<br />
** Edit {{ic|/var/lib/alsa/asound.state}}. This file is where alsasound stores your mixer settings.<br />
** Find a line that says: 'IEC958 Playback Switch'. Near it you will find a line saying {{ic|value:false}}. Change it to {{ic|value:true}}.<br />
** Now find this line: 'IEC958 Playback AC97-SPSA'. Change its value to 0.<br />
** Restart ALSA.<br />
<br />
Alternative way to enable SPDIF output automatically on login (tested on SoundBlaster Audigy):<br />
<br />
* add following lines to {{ic|/etc/rc.local}}:<br />
# Use COAX-digital output<br />
amixer set 'IEC958 Optical' 100 unmute<br />
amixer set 'Audigy Analog/Digital Output Jack' on<br />
<br />
You can see the name of your card's digital output with:<br />
$ amixer scontrols<br />
<br />
=== System-wide equalizer ===<br />
<br />
==== Using AlsaEqual (provides UI) ====<br />
<br />
Install {{AUR|alsaequal}} from the [[AUR]].<br />
<br />
{{Note | If you have a x86_64-system and are using a 32bit-flashplugin the sound in flash will not work. Either you have to disable alsaequal or build alsaequal for 32bit.}}<br />
<br />
After installing the package, insert the following into your ALSA configuration file ({{ic|~/.asoundrc}} or {{ic|/etc/asound.conf}}):<br />
<br />
ctl.equal {<br />
type equal;<br />
}<br />
<br />
pcm.plugequal {<br />
type equal;<br />
# Modify the line below if you do not<br />
# want to use sound card 0.<br />
#slave.pcm "plughw:0,0";<br />
#by default we want to play from more sources at time:<br />
slave.pcm "plug:dmix";<br />
}<br />
#pcm.equal {<br />
# If you do not want the equalizer to be your<br />
# default soundcard comment the following<br />
# line and uncomment the above line. (You can<br />
# choose it as the output device by addressing<br />
# it with specific apps,eg mpg123 -a equal 06.Back_In_Black.mp3)<br />
pcm.!default {<br />
type plug;<br />
slave.pcm plugequal;<br />
}<br />
<br />
And you are ready to change your equalizer using command<br />
$ alsamixer -D equal<br />
<br />
Note that configuration file is different for each user (until not specified else) it is saved in {{ic|~/.alsaequal.bin}}.<br />
so if you want to use AlsaEqual with [[mpd]] or another software running under different user, you can configure it using<br />
# su mpd -c 'alsamixer -D equal'<br />
or for example, you can make a symlink to your {{ic|.alsaequal.bin}} in his home...<br />
<br />
===== Managing AlsaEqual states =====<br />
<br />
Install {{AUR|alsaequal-mgr}} from the [[AUR]] (or alternatively from [http://xyne.archlinux.ca/repos/ Xyne's repos]).<br />
<br />
Configure the equalizer as usual with <br />
$ alsamixer -D equal<br />
<br />
When you are satisfied with the state, you may give it a name ("foo" in this example) and save it:<br />
$ alsaequal-mgr save foo<br />
<br />
The state "foo" can then be restored at a later time with<br />
$ alsaequal-mgr load foo<br />
<br />
You can thus create different equalizer states for games, movies, music genres, VoIP apps, etc. and reload them as necessary.<br />
<br />
See the [http://xyne.archlinux.ca/projects/alsaequal-mgr/ project page] and the help message for more options.<br />
<br />
==== Using mbeq ====<br />
<br />
{{Note|This method requires the use of a ladspa plugin which might use quite a bit of CPU when sound plays. In addition, this was made with stereophonic sound (e.g. headphones) in mind.}}<br />
<br />
Install the {{Pkg|alsa-plugins}}, {{Pkg|ladspa}} and {{Pkg|swh-plugins}} packages if you do not already have them.<br />
<br />
* If you have not already created either an {{ic|~/.asoundrc}} or a {{ic|/etc/asound.conf}} file, then create either one and insert the following:<br />
<br />
{{hc|/etc/asound.conf|2=<nowiki>pcm.eq {<br />
type ladspa<br />
<br />
# The output from the EQ can either go direct to a hardware device<br />
# (if you have a hardware mixer, e.g. SBLive/Audigy) or it can go<br />
# to the software mixer shown here.<br />
#slave.pcm "plughw:0,0"<br />
slave.pcm "plug:dmix"<br />
<br />
# Sometimes you may need to specify the path to the plugins,<br />
# especially if you have just installed them. Once you have logged<br />
# out/restarted this should not be necessary, but if you get errors<br />
# about being unable to find plugins, try uncommenting this.<br />
#path "/usr/lib/ladspa"<br />
<br />
plugins [<br />
{<br />
label mbeq<br />
id 1197<br />
input {<br />
#this setting is here by example, edit to your own taste<br />
#bands: 50hz, 100hz, 156hz, 220hz, 311hz, 440hz, 622hz, 880hz, 1250hz, 1750hz, 25000hz,<br />
#50000hz, 10000hz, 20000hz<br />
controls [ -5 -5 -5 -5 -5 -10 -20 -15 -10 -10 -10 -10 -10 -3 -2 ]<br />
}<br />
}<br />
]<br />
}<br />
<br />
# Redirect the default device to go via the EQ - you may want to do<br />
# this last, once you are sure everything is working. Otherwise all<br />
# your audio programs will break/crash if something has gone wrong.<br />
<br />
pcm.!default {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
<br />
# Redirect the OSS emulation through the EQ too (when programs are running through "aoss")<br />
<br />
pcm.dsp0 {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
</nowiki>}}<br />
<br />
* You should be good to go (if not, ask in the forum).<br />
<br />
== High quality resampling ==<br />
<br />
When software mixing is enabled, ALSA is forced to resample everything to the same frequency (48000 by default when supported). dmix uses a poor resampling algorithm which produces noticeable sound quality loss.<br />
<br />
Install {{Pkg|alsa-plugins}} and {{Pkg|libsamplerate}}.<br />
<br />
Change the default rate converter to libsamplerate:<br />
<br />
{{hc|/etc/asound.conf|defaults.pcm.rate_converter "samplerate_best"}}<br />
<br />
or:<br />
<br />
{{hc|~/.asoundrc|defaults.pcm.rate_converter "samplerate_best"}}<br />
<br />
'''samplerate_best''' offers the best sound quality, but you need a decent CPU to be able to use it as it requires a lot of CPU cycles for real-time resampling. You may also need to adjust buffer_size in your dmix settings from the basic 4096 to 8192 or 16384. There are other algorithms available ('''samplerate''', etc.) but they may not provide much of an improvement over the default resampler.<br />
<br />
{{Warning|On some systems, enabling samplerate_best may cause a problem where you get no sound from flashplayer.}}<br />
<br />
== Upmixing/downmixing ==<br />
<br />
=== Upmixing ===<br />
<br />
In order for stereo sources like music to be able to saturate a 5.1 or 7.1 sound system, you need to use upmixing. In darker days this used to be tricky and error prone but nowadays plugins exist to easily take care of this task. We will use the {{ic|upmix}} plugin, included in {{Pkg|alsa-plugins}}.<br />
<br />
Then add the following to your ALSA configuration file of choice (either {{ic|/etc/asound.conf}} or {{ic|~/.asoundrc}}):<br />
pcm.upmix71 {<br />
type upmix<br />
slave.pcm "surround71"<br />
delay 15<br />
channels 8<br />
}<br />
<br />
You can easily change this example for 7.1 upmixing to 5.1 or 4.0.<br />
<br />
This adds a new pcm that you can use for upmixing. If you want all sound sources to go through this pcm, add it as a default below the previous definition like so:<br />
<br />
pcm.!default "plug:upmix71"<br />
<br />
The plugin automatically allows multiple sources to play through it without problems so setting is as a default is actually a safe choice. <br />
If this is not working, you have to setup your own dmixer for the upmixing PCM like this: <br />
pcm.dmix6 {<br />
type asym<br />
playback.pcm {<br />
type dmix<br />
ipc_key 567829<br />
slave {<br />
pcm "hw:0,0"<br />
channels 6<br />
}<br />
}<br />
}<br />
<br />
and use "dmix6" instead of "surround71". <br />
If you experience skipping or distorted sound, consider increasing the buffer_size (to 32768, for example) or use a [[#High quality resampling|high quality resampler]].<br />
<br />
=== Downmixing ===<br />
<br />
If you want to downmix sources to stereo because you, for instance, want to watch a movie with 5.1 sound on a stereo system, use the {{ic|vdownmix}} plugin, included in {{Pkg|alsa-plugins}}..<br />
<br />
Again, in your configuration file, add this:<br />
<br />
pcm.!surround51 {<br />
type vdownmix<br />
slave.pcm "default"<br />
}<br />
pcm.!surround40 {<br />
type vdownmix<br />
slave.pcm "default"<br />
}<br />
<br />
{{Note|1=This might not be enough to make downmixing working, see [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541786]. So, you might also need to add {{ic|pcm.!default "plug:surround51"}} or {{ic|pcm.!default "plug:surround40"}}. Only one {{ic|vdownmix}} plug can be used; if you have 7.1 channels, you will need to use {{ic|surround71}} instead the configuration above. A good example, which includes a configuration that makes both {{ic|vdownmix}} and {{ic|dmix}} working, can be found [https://bbs.archlinux.org/viewtopic.php?id=167275 here].}}<br />
<br />
== Mixing ==<br />
<br />
=== Software mixing (dmix) ===<br />
<br />
{{Note|For ALSA 1.0.9rc2 and higher on analog sound outputs you do not need to setup dmix. Dmix is enabled as default for soundcards which do not support hardware mixing.}}<br />
<br />
If that does not work however, it is a matter of simply creating a .asoundrc file in your home folder with the following contents.<br />
<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
<br />
This should enable software mixing and allows more than one application to make use of the soundcard. If not, try replacing all /etc/asound.conf content with the above.<br />
<br />
For a digital sound output such as S/PDIF, the ALSA package still does not enable dmix by default. Thus, the dmix configuration above can be used to enable dmix for S/PDIF devices.<br />
<br />
See [[#Troubleshooting]] for common problems and solutions.<br />
<br />
=== Hardware mixing ===<br />
<br />
==== Support ====<br />
<br />
If you have an audio chipset that supports mixing in hardware, then no configuration is necessary. Almost every onboard audio chipset does not support hardware mixing, and requires mixing to be done in software (see above). Many sound cards do support hardware mixing, and the ones best supported on Linux are listed below:<br />
<br />
* Creative SoundBlaster Live! (5.1 model)<br />
* Creative SoundBlaster Audigy (some models)<br />
* Creative SoundBlaster Audidy 2 (ZS models)<br />
* Creative SoundBlaster Audigy 4 (Pro models)<br />
<br />
{{Note|<br />
* The low end variants of above cards, (Audigy SE, Audigy 2 NX, SoundBlaster Live! 24bit and SoundBlaster Live! 7.1) '''do not''' support hardware mixing as they use other chips.<br />
* The onboard VIA8237 chip supports 4-stream hardware mixing, however, it does only 3 for some motherboards (the 4th makes no sound) or is just broken. Even if it works, the quality is not good compared to other solutions.<br />
}}<br />
<br />
==== Fixes ====<br />
<br />
If you are using 64-bit Arch and the Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02), you can get sound working for Enemy Territory with the following:<br />
echo "et.x86 0 0 direct" > /proc/asound/card0/pcm0p/oss<br />
echo "et.x86 0 0 disable" > /proc/asound/card0/pcm0c/oss<br />
<br />
== Troubleshooting ==<br />
<br />
=== Sound skipping while using dynamic frequency scaling ===<br />
<br />
Some combinations of ALSA drivers and chipsets may cause audio from all sources to skip when used in combination with a dynamic frequency scaling governor such as {{ic|ondemand}} or {{ic|conservative}}. Currently, the solution is to switch back to the {{ic|performance}} governor.<br />
<br />
Refer to the [[CPU Frequency Scaling]] for more information.<br />
<br />
=== Problems with availability to only one user at a time ===<br />
<br />
You might find that only one user can use the dmixer at a time. This is probably ok for most, but for those who run [[mpd]] as a separate user this poses a problem. When mpd is playing a normal user cannot play sounds though the dmixer. While it's quite possible to just run mpd under a user's login account, another solution has been found. Adding the line {{ic|ipc_key_add_uid 0}} to the {{ic|pcm.dmixer}} block disables this locking. The following is a snippet of the {{ic|asound.conf}}, the rest is the same as above.<br />
...<br />
pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid 0<br />
ipc_perm 0660<br />
slave {<br />
...<br />
<br />
=== Simultaneous playback problems ===<br />
<br />
If you are having problems with simultaneous playback, and if [[PulseAudio]] is installed (i.e. by [[GNOME]]), its default configuration is set to "hijack" the soundcard. Some users of ALSA may not want to use [[PulseAudio]] and are quite content with their current ALSA settings. One fix is to edit {{ic|/etc/asound.conf}} and comment out the following lines:<br />
# Use PulseAudio by default<br />
#pcm.!default {<br />
# type pulse<br />
# fallback "sysdefault"<br />
# hint {<br />
# show on<br />
# description "Default ALSA Output (currently PulseAudio Sound Server)"<br />
# }<br />
#}<br />
<br />
Commenting the following out also may help:<br />
#ctl.!default {<br />
# type pulse<br />
# fallback "sysdefault"<br />
#}<br />
<br />
This may be a much simpler solution than completely uninstalling [[PulseAudio]].<br />
<br />
Effectively, here is an example of a working {{ic|/etc/asound.conf}}:<br />
{{bc|<nowiki>pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid 0<br />
ipc_perm 0660<br />
}<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}</nowiki><br />
}}<br />
<br />
{{Note|This {{ic|/etc/asound.conf}} file was intended for and used successfully with a global [[MPD]] configuration. See [[Alsa#Problems_with_Availability_to_Only_One_User_at_a_Time|this section]] on multiple users}}<br />
<br />
=== Random lack of sound on startup ===<br />
<br />
You can quickly test sound by running {{ic|speaker-test}}. If there is no sound, the error message might look something like<br />
<br />
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave<br />
Playback open error: -16<br />
Device or resource busy<br />
<br />
If you have no sound on startup, this may be because your system has multiple sound cards, and their order may sometimes change on startup. If this is the case, try [[#Set the default sound card|setting the default sound card]].<br />
<br />
If you use mpd and the configuration tips above do not work for you, try [http://mpd.wikia.com/wiki/Configuration#ALSA_MPD_software_volume_control reading this] instead.<br />
<br />
==== Timidity ====<br />
<br />
[[Timidity]] can be the cause of missing audio. Try running:<br />
<br />
$ systemctl status timidity<br />
<br />
If it failed, try {{ic|# killall -9 timidity}}. If this solves the issue, then you should disable the timidity daemon to be started at boot.<br />
<br />
=== Specific program problems ===<br />
<br />
For other programs who insist on their own audio setup, e.g., XMMS or MPlayer, you would need to set their specific options.<br />
<br />
For MPlayer, open up a [[MPlayer#Configuration|configuration file]] and add the following line:<br />
ao=alsa<br />
For ''mpv'' append the same line in one of its [[mpv#Configuration|configuration files]].<br />
<br />
For XMMS/Beep Media Player, go into their options and make sure the sound driver is set to Alsa, not oss.<br />
<br />
To do this in XMMS:<br />
* Open XMMS<br />
** Options > Preferences.<br />
** Choose the ALSA output plugin.<br />
<br />
For applications which do not provide a ALSA output, you can use aoss from the alsa-oss package. To use aoss, when you run the program, prefix it with {{ic|aoss}}, eg:<br />
aoss realplay<br />
<br />
pcm.!default{ ... } doesnt work for me anymore. but this does:<br />
pcm.default pcm.dmixer<br />
<br />
=== Model settings ===<br />
<br />
Although Alsa detects your soundcard through the BIOS at times Alsa may not be able to recognize your [http://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt model type]. The soundcard chip can be found in {{ic|alsamixer}} (e.g. ALC662) and the model can be set in {{ic|/etc/modprobe.d/modprobe.conf}} or {{ic|/etc/modprobe.d/sound.conf}}. For example:<br />
<br />
options snd-hda-intel model=MODEL<br />
<br />
There are other model settings too. For most cases Alsa defaults will do. If you want to look at more specific settings for your soundcard take a look at the [http://bugtrack.alsa-project.org/main/index.php/Matrix:Main Alsa Soundcard List] find your model, then Details, then look at the "Setting up modprobe..." section. Enter these values in {{ic|/etc/modprobe.d/modprobe.conf}}. For example, for an Intel AC97 audio:<br />
<br />
{{bc|<br />
# ALSA portion<br />
alias char-major-116 snd<br />
alias snd-card-0 snd-intel8x0<br />
# module options should go here<br />
<br />
# OSS/Free portion<br />
alias char-major-14 soundcore<br />
alias sound-slot-0 snd-card-0<br />
<br />
# card #1<br />
alias sound-service-0-0 snd-mixer-oss<br />
alias sound-service-0-1 snd-seq-oss<br />
alias sound-service-0-3 snd-pcm-oss<br />
alias sound-service-0-8 snd-seq-oss<br />
alias sound-service-0-12 snd-pcm-oss<br />
}}<br />
<br />
=== Conflicting PC speaker ===<br />
<br />
If you are sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try adding the following line to {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-NAME-OF-MODULE ac97_quirk=0<br />
<br />
The above fix has been observed to work with {{ic|via82xx}}<br />
options snd-NAME-OF-MODULE ac97_quirk=1<br />
The above fix has been reported to work with {{ic|snd_intel8x0}}<br />
<br />
=== No microphone input ===<br />
<br />
In alsamixer, make sure that all the volume levels are up under recording, and that CAPTURE is toggled active on the microphone (e.g. Mic, Internal Mic) and/or on Capture (in alsamixer, select these items and press space). Try making positive Mic Boost and raising Capture and Digital levels higher; this make make static or distortion, but then you can adjust them back down once you are hearing ''something'' when you record<br />
<br />
As the pulseaudio wrapper is shown as "default" in alsamixer, you may have to press F6 to select your actual soundcard first. You may also need to enable and increase the volume of Line-in in the Playback section.<br />
<br />
To test the microphone, run these commands (see arecord's man page for further information):<br />
$ arecord -d 5 test-mic.wav<br />
$ aplay test-mic.wav<br />
<br />
If all fails, you may want to eliminate hardware failure by testing the microphone with a different device.<br />
<br />
For at least some computers, muting a microphone (MM) simply means its input does not go immediately to the speakers. It still receives input.<br />
<br />
Many Dell laptops need "-dmic" to be appended to the model name in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-hda-intel model=dell-m6-dmic<br />
<br />
Some programs use try to use OSS as the main input software. If you have enabled the {{ic|snd_pcm_oss}}, {{ic|snd_mixer_oss}} or {{ic|snd_seq_oss}} [[kernel modules]] previously (they are not loaded by default), try unloading them.<br />
<br />
See also:<br />
* http://www.alsa-project.org/main/index.php/SoundcardTesting<br />
* http://alsa.opensrc.org/Record_from_mic<br />
<br />
=== Crackling in microphone ===<br />
<br />
If you're getting a crackling or popping from your microphone that can't be resolved with ALSA settings or cleaning your microphone jack, try adding the following line to {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-hda-intel model=MODEL position_fix=3<br />
<br />
This option will fix crackling on pure Alsa, but will cause issues to pulseaudio. To let Pulse use these settings effectively, edit {{ic|/etc/pulse/default.pa}} and find this line:<br />
<br />
load-module module-udev-detect<br />
<br />
And change it to this:<br />
<br />
load-module module-udev-detect tsched=0<br />
<br />
See the DMA-Position Problem in the kernel docs.<br />
<br />
* [https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio.txt HD-audio Kernel Docs]<br />
<br />
=== Setting the default microphone/capture device ===<br />
<br />
Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes a problem if your microphone is on a separate device (e.g. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your {{ic|~/.asoundrc}} file to include the following:<br />
<br />
pcm.usb<br />
{<br />
type hw<br />
card U0x46d0x81d<br />
}<br />
<br />
pcm.!default<br />
{<br />
type asym<br />
playback.pcm<br />
{<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
capture.pcm<br />
{<br />
type plug<br />
slave.pcm "usb"<br />
}<br />
}<br />
<br />
Replace "U0x46d0x81d" with your capture device's card name in ALSA. You can use {{ic|arecord -L}} to list all the capture devices detected by ALSA.<br />
<br />
=== Internal microphone not working ===<br />
<br />
First make sure all the volume levels are up under recording in alsamixer. In my case adding the following option to {{ic|/etc/sound.conf}} and reloading the snd-* module produced a new volume setting called Capture which was capturing for the internal mic. For eg, for snd-hda-intel add<br />
<br />
options snd-hda-intel enable_msi=1<br />
<br />
Then reload the module (as below), up the recording volume of Capture and then test.<br />
<br />
# rmmod snd-hda-intel && modprobe snd-hda-intel<br />
<br />
=== No sound with onboard Intel sound card ===<br />
<br />
There may be a problem with two conflicting modules loaded, namely {{ic|snd_intel8x0}} and {{ic|snd_intel8x0m}}. In this case, blacklist snd_intel8x0m:<br />
<br />
{{hc|/etc/modprobe.d/modprobe.conf|blacklist snd_intel8x0m}}<br />
<br />
''Muting'' the "External Amplifier" in {{ic|alsamixer}} or {{ic|amixer}} may also help. See [http://alsa.opensrc.org/Intel8x0#Dell_Inspiron_8600_.28and_probably_others.29 the ALSA wiki].<br />
<br />
Unmuting the "Mix" setting in the mixer might help, also.<br />
<br />
=== No headphone sound with onboard Intel sound card ===<br />
<br />
With '''Intel Corporation 82801 I (ICH9 Family) HD Audio Controller''' on laptop, you may need to add this line to modprobe or sound.conf:<br />
<br />
options snd-hda-intel model=''model''<br />
<br />
Where ''model'' is any one of the following (in order of possibility to work, but not merit):<br />
<br />
* dell-vostro<br />
* olpc-xo-1_5<br />
* laptop<br />
* dell-m6<br />
* laptop-hpsense<br />
<br />
{{Note|It may be necessary to put this "options" line below (after) any "alias" lines about your card.}}<br />
<br />
You can see all the available models in the kernel documentation. For example [http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/sound/alsa/HD-Audio-Models.txt here], but check that it is the correct version of that document for your kernel version.<br />
<br />
A list of available models is also available [http://www.mjmwired.net/kernel/Documentation/sound/alsa/HD-Audio-Models.txt here]. To know your chip name type the following command (with * being corrected to match your files). Note that some chips could have been renamed and do not directly match the available ones in the file.<br />
<br />
$ grep Codec /proc/asound/card*/codec*<br />
<br />
Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it is either your headphones or your mic. Please report to ALSA if you are affected by this bug.<br />
<br />
And also, if you have problems getting beeps to work (pcspkr):<br />
<br />
options snd-hda-intel model=$model enable=1 index=0<br />
<br />
=== No sound when S/PDIF video card is installed ===<br />
<br />
Discover available modules and their order:<br />
{{hc|$ cat /proc/asound/modules|<br />
0 snd_hda_intel<br />
1 snd_ca0106<br />
}}<br />
<br />
Disable the undesired video card audio codec in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
# /etc/modprobe.d/modprobe.conf<br />
#<br />
install snd_hda_intel /bin/false<br />
<br />
If both devices use the same module then we can use the *enable* parameter from snd-hda-intel module, it's an array of booleans that can enable/disable the desired sound card.<br />
<br />
e.g <br />
options snd-hda-intel enable=1,0<br />
the following gives you the list of cards<br />
cat /proc/asound/cards<br />
<br />
=== Poor sound quality or clipping ===<br />
<br />
If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0.<br />
<br />
If snd-usb-audio driver has been loaded, you could try to enable {{ic|softvol}} in {{ic|/etc/asound.conf}} file. Example configuration for the first audio device:<br />
pcm.!default {<br />
type plug<br />
slave.pcm "softvol"<br />
}<br />
pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
slave {<br />
pcm "hw:0"<br />
period_time 0<br />
period_size 4096<br />
buffer_size 131072<br />
rate 50000<br />
}<br />
bindings {<br />
0 0<br />
1 1<br />
}<br />
}<br />
pcm.dsnooper {<br />
type dsnoop<br />
ipc_key 1024<br />
slave {<br />
pcm "hw:0"<br />
channels 2<br />
period_time 0<br />
period_size 4096<br />
buffer_size 131072<br />
rate 50000<br />
}<br />
bindings {<br />
0 0<br />
1 1<br />
}<br />
}<br />
pcm.softvol {<br />
type softvol<br />
slave { pcm "dmixer" }<br />
control {<br />
name "Master"<br />
card 0<br />
}<br />
}<br />
ctl.!default {<br />
type hw<br />
card 0<br />
}<br />
ctl.softvol {<br />
type hw<br />
card 0<br />
}<br />
ctl.dmixer {<br />
type hw<br />
card 0<br />
}<br />
<br />
=== Pops when starting and stopping playback===<br />
<br />
Some modules (e.g. snd-ac97-codec and snd-hda-intel) can power off your sound card when not in use. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when move the slider volume, or open and close windows (KDE4). If you find this annoying try {{ic|modinfo snd-MY-MODULE}}, and look for a module option that adjusts or disables this feature.<br />
<br />
''Example'': disable the power saving mode and solve cracking sound trough speakers problem, using snd-hda-intel add in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-hda-intel power_save=0<br />
or:<br />
options snd-hda-intel power_save=0 power_save_controller=N<br />
<br />
You can also try it with {{ic|1=modprobe snd-hda-intel power_save=0}} before.<br />
<br />
You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high).<br />
<br />
''Example:'' on an onboard VIA VT1708S (using the snd-hda-intel module) these cracks occured even though 'power_save' was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the problem.<br />
<br />
Source: https://www.kernel.org/doc/Documentation/sound/alsa/powersave.txt<br />
<br />
If you use a laptop, pm-utils will change {{ic|power_save}} back to 1 when you go onto battery power even if you disable power saving in {{ic|/etc/modprobe.d}}. Disable this for pm-utils by disabling the script that makes the change (see [[Pm-utils#Disabling_a_hook|Disabling a hook]] for more information):<br />
# touch /etc/pm/power.d/intel-audio-powersave<br />
<br />
=== S/PDIF output does not work ===<br />
<br />
If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running<br />
# iecset audio on<br />
<br />
You can also put this command in an enabled [[systemd]] service as it sometimes it may stop working after a reboot.<br />
<br />
=== HDMI output does not work ===<br />
<br />
The procedure described below can be used to test HDMI audio. Before proceeding, make sure you have enabled and unmuted the output with {{ic|alsamixer}}.<br />
<br />
{{Note|If you are using an ATI card and linux kernel &gt;&#61;3.0, a necessary kernel module is disabled by default. See [[ATI#HDMI_Audio]].}}<br />
<br />
Connect your PC to the Display via HDMI cable and enable the display with a tool such as {{ic|xrandr}} or {{ic|arandr}}. For example:<br />
<br />
$ xrandr # list outputs<br />
$ xrandr --output DVI-D_1 --mode 1024x768 --right-of PANEL # enable output<br />
<br />
Use {{ic|aplay -l}} to get the discover the card and device number. For example:<br />
<br />
$ aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: SB [HDA ATI SB], device 0: ALC892 Analog [ALC892 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: SB [HDA ATI SB], device 1: ALC892 Digital [ALC892 Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
'''card 1''': Generic [HD-Audio Generic], '''device 3''': HDMI 0 [HDMI 0]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
<br />
Send sound to the device. Following the example in the previous step, you would send sound to card 1, device 3:<br />
<br />
$ aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Center.wav<br />
<br />
If aplay does not output any errors, but still no sound is heared, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding. In particular, if you are using a standalone window manager (don’t know about Gnome or KDE), you may need to have some sound playing ''while'' plugging in the HDMI cable.<br />
<br />
mplay and other application could be configured to use special HDMI device as audio output. But flashplugin could only use default device. The following method is used to override default device. But you need to change it back when your TV is disconnected from HDMI port.<br />
<br />
If the test is successful, create or edit your {{ic|~/.asoundrc}} file to set HDMI as the default audio device.<br />
<br />
{{hc|~/.asoundrc|<br />
pcm.!default {<br />
type hw<br />
card 0<br />
device 3<br />
}<br />
}}<br />
<br />
Or you above config does not work try:<br />
{{hc|~/.asoundrc|<br />
defaults.pcm.card 0<br />
defaults.pcm.device 3<br />
defaults.ctl.card 0<br />
}}<br />
<br />
=== HDMI multi-channel PCM output does not work (Intel) ===<br />
<br />
As of Linux 3.1 multi-channel PCM output through HDMI with a Intel card (Intel Eaglelake, IbexPeak/Ironlake,SandyBridge/CougarPoint and IvyBridge/PantherPoint) is not yet supported. Support for it has been recently added and expected to be available in Linux 3.2. To make it work in Linux 3.1 you need to apply the following patches:<br />
<br />
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=76adaa34db407f174dd06370cb60f6029c33b465 drm: support routines for HDMI/DP ELD]<br />
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=e0dac65ed45e72fe34cc7ccc76de0ba220bd38bb drm/i915: pass ELD to HDMI/DP audio driver]<br />
<br />
=== HP TX2500 ===<br />
<br />
Add these 2 lines into {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-cmipci mpu_port=0x330 fm_port=0x388<br />
options snd-hda-intel index=0 model=toshiba position_fix=1<br />
<br />
options snd-hda-intel model=hp (works for tx2000cto)<br />
<br />
=== Skipping sound when playing MP3 ===<br />
<br />
If you have sound skipping when playing MP3 files and you have more then 2 speakers attached to your computer (i.e. more than 2 speaker system), run ''alsamixer'' and disable the channels for the speakers that you '''do not''' have (i.e. do not enable the sound for the center speaker if you do not have a center speaker.<br />
<br />
=== Using a USB headset and external USB sound cards ===<br />
<br />
If you are using a USB headset with ALSA you can try using {{AUR|asoundconf}} (currently only available from the [[AUR]]) to set the headset as the primary sound output. Before running make sure you have usb audio module enabled ({{ic|modprobe snd_usb_audio}}).<br />
<br />
# asoundconf is-active<br />
# asoundconf list<br />
# asoundconf set-default-card ''chosen soundcard''<br />
<br />
==== Crackling sound with USB devices ====<br />
<br />
If you experience crackling sound on USB devices, you can try tuning the {{ic|snd-usb-audio}} for minimal latency.<br />
<br />
Add this to your {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-usb-audio nrpacks=1<br />
<br />
source: http://alsa.opensrc.org/Usb-audio#Tuning_USB_devices_for_minimal_latencies<br />
<br />
==== Hot-plugging a USB sound card ====<br />
<br />
In order to automatically make a USB Sound Card the primary output device, when the card is plugged in, you can use the following udev rules (e.g. add the following two lines to {{ic|/etc/udev/rules.d/00-local.rules}} and reboot).<br />
<br />
{{bc|1=KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"<br />
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"}}<br />
<br />
=== Error 'Unknown hardware' appears after a kernel update===<br />
<br />
The following messages may be displayed during the start-up ALSA after the kernel update:<br />
Unknown hardware "foo" "bar" ...<br />
Hardware is initialized using a guess method<br />
/usr/bin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory)<br />
<br />
or:<br />
Found hardware: "HDA-Intel" "VIA VT1705" "HDA:11064397,18490397,00100000" "0x1849" "0x0397"<br />
Hardware is initialized using a generic method<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #1 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #2 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #25 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #26 (No such file or directory)<br />
<br />
Simply store ALSA mixer settings again:<br />
# alsactl -f /var/lib/alsa/asound.state store<br />
<br />
It may be necessary configure ALSA again with alsamixer<br />
<br />
=== HDA analyzer ===<br />
<br />
If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found [http://www.alsa-project.org/main/index.php/HDA_Analyzer at the ALSA wiki].<br />
Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.<br />
<br />
{{Note|<br />
* The script is done by such way that it is incompatible with Python 3 (which is now shipped with Arch Linux) but tries to use it. The workaround is: open "run.py", find all occurences of "python" (2 occurences - one on the first line, and the second on the last line) and replace them all by "python2".<br />
* The script requires root acces, but running it via su/sudo is bogus. Run it via {{ic|kdesu}} or {{ic|gksu}}.<br />
}}<br />
<br />
=== ALSA with SDL ===<br />
<br />
If you get no sound via SDL and ALSA cannot be chosen from the application. Try setting the environmental variable SDL_AUDIODRIVER to alsa.<br />
# export SDL_AUDIODRIVER=alsa<br />
<br />
=== Low sound workaround ===<br />
<br />
If you are facing low sound even after maxing out your speakers/headphones, you can give the softvol plugin a try. Add the following to {{ic|/etc/asound.conf}}.<br />
{{bc|<nowiki><br />
pcm.!default {<br />
type plug<br />
slave.pcm "softvol"<br />
}<br />
<br />
pcm.softvol {<br />
type softvol<br />
slave {<br />
pcm "dmix"<br />
}<br />
control {<br />
name "Pre-Amp"<br />
card 0<br />
}<br />
min_dB -5.0<br />
max_dB 20.0<br />
resolution 6<br />
}<br />
</nowiki>}}<br />
{{Note|You will probably have to restart the computer, as restarting the alsa daemon did not load the new configuration for me. Also, if the configuration does not work even after restarting, try changing {{ic|plug}} with {{ic|hw}} in the above configuration.}}<br />
<br />
After the changes are loaded successfully, you will see a {{ic|Pre-Amp}} section in alsamixer. You can adjust the levels there.<br />
{{Note|<br />
* Setting a high value for {{ic|Pre-Amp}} can cause sound distortion, so adjust it according to the level that suits you.<br />
* Some audio codecs may need to have settings adjusted in the HDA Analyzer ([[#HDA analyzer|see above]]) in order to achieve proper volume without distortion. Checking the HP option under widget control in the Playback Switch (Node[0x14] PIN in the ALC892 codec, for instance) can sometimes improve audio quality and volume significantly.<br />
}}<br />
<br />
=== Popping sound after resuming from suspension ===<br />
<br />
You might hear a popping sound after resuming the computer from suspension. This can be fixed by editing {{ic|/etc/pm/sleep.d/90alsa}} and removing the line that says {{ic|aplay -d 1 /dev/zero}}<br />
<br />
=== Mute after reboot ===<br />
<br />
After reboot, sound setting by alsamixer can not restore. Maybe you can restore by command : {{ic|sudo alsactl restore}}. Please check the {{ic|Auto-Mute}} toggle status in alsamixer : set {{ic|Enabled}} to {{ic|Disabled}}.<br />
<br />
=== Volume too low ===<br />
<br />
The first thing to try is run {{ic|alsamixer}} and try to increase the value of the sliders, possibly unmuting channels if necessary. Note that if you have many sliders, you may have to scroll to the right to see any missing sliders.<br />
<br />
If all the sliders are maxed out, and the volume is still too low, you can try running the script at http://www.alsa-project.org/hda-analyzer.py to reset your codec settings:<br />
<br />
$ wget http://www.alsa-project.org/hda-analyzer.py<br />
$ sudo python2 hda-analyzer.py<br />
<br />
(Note that the script assumes "python" refers to Python 2, but on a typical ArchLinux installation, "python" refers to Python 3. Therefore, you may need to edit the last line of the script from {{ic|os.system("python %s" % TMPDIR + '/' + FILES[0] + ' ' + ' '.join(sys.argv[1:]))}} to {{ic|os.system("python2 %s" % TMPDIR + '/' + FILES[0] + ' ' + ' '.join(sys.argv[1:]))}}.<br />
<br />
Close the analyzer, and when prompted as to whether you want to reset the codecs, say "yes".<br />
<br />
If the volume is *still* too low, run {{ic|alsamixer}} again: resetting the codecs may have caused new sliders to become enabled, and some of them may be set to a low value.<br />
<br />
===alsamixer F3 and F4 key issue ===<br />
In urxvt, the alsamixer quits when F2/F3/F4 key is pressed. F3/F4 is used to switch to playback/capture view. But in Xterm, F3/F4 could work normally and switch to playback/capture view. This abnormal behavior maybe caused by different escape codes sent by different term, see http://aperiodic.net/phil/archives/Geekery/term-function-keys.html for detail.<br />
<br />
== Example configurations ==<br />
<br />
See [[Advanced Linux Sound Architecture/Example Configurations]].<br />
<br />
== See also ==<br />
<br />
* [http://www.mjmwired.net/kernel/Documentation/sound/alsa/ALSA-Configuration.txt Advanced ALSA module configuration]<br />
* [http://alsa.opensrc.org/Main_Page Unofficial ALSA wiki]<br />
* [https://bbs.archlinux.org/viewtopic.php?id=36815 HOWTO: compile driver from svn]<br />
* [http://www.volkerschatz.com/noise/alsa.html A close look at ALSA: ALSA concept introduction]</div>Hongy19https://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture&diff=295007Advanced Linux Sound Architecture2014-01-30T11:18:26Z<p>Hongy19: /* Troubleshooting */</p>
<hr />
<div>[[Category:Sound]]<br />
[[Category:Audio/Video]]<br />
[[cs:Advanced Linux Sound Architecture]]<br />
[[de:Alsa]]<br />
[[es:Advanced Linux Sound Architecture]]<br />
[[fa:ALSA]]<br />
[[fr:Alsa]]<br />
[[he:Advanced Linux Sound Architecture]]<br />
[[it:Advanced Linux Sound Architecture]]<br />
[[ja:Advanced Linux Sound Architecture]]<br />
[[nl:Advanced Linux Sound Architecture]]<br />
[[pt:Advanced Linux Sound Architecture]]<br />
[[ru:Advanced Linux Sound Architecture]]<br />
[[sk:Advanced Linux Sound Architecture]]<br />
[[th:Advanced Linux Sound Architecture]]<br />
[[tr:Gelişmiş_ses_mimarisi_(ALSA)]]<br />
[[zh-CN:Advanced Linux Sound Architecture]]<br />
{{Related articles start}}<br />
{{Related|Sound system}}<br />
{{Related|Disable PC Speaker Beep}}<br />
{{Related articles end}}<br />
The [[Wikipedia:Advanced Linux Sound Architecture|Advanced Linux Sound Architecture]] ('''ALSA''') is a Linux kernel component which replaced the original Open Sound System (OSSv3) for providing device drivers for sound cards. Besides the sound device drivers, '''ALSA''' also bundles a user space library for application developers who want to use driver features with a higher level API than direct interaction with the kernel drivers.<br />
<br />
{{Note|For an alternative sound environment, see the [[Open Sound System]] page.}}<br />
<br />
== Installation ==<br />
<br />
ALSA is included in the default Arch kernel as a set of modules, so installing it is not necessary.<br />
<br />
[[udev]] will automatically probe your hardware at boot, loading the corresponding kernel module for your audio card. Therefore, your sound should already be working, but upstream sources mute all channels by default.<br />
<br />
Users with a local login (at a virtual terminal or a display manager) have permission to play audio and change mixer levels. To allow this for a remote login, the user has to be [[Users and Groups#Group management|added]] to the {{ic|audio}} group. Membership in the {{ic|audio}} group also allows direct access to devices, which can lead to applications grabbing exclusive output (breaking software mixing) and breaks fast-user-switching, and multiseat. Therefore, adding a user to the {{ic|audio}} group is '''not''' recommended, unless you specifically need to[https://wiki.ubuntu.com/Audio/TheAudioGroup].<br />
<br />
=== User-space utilities ===<br />
<br />
[[pacman|Install]] the {{Pkg|alsa-utils}} package from the [[Official Repositories|official repositories]] which contains the {{ic|alsamixer}} user-space tool, which allows for configuration of the sound device from the console or terminal. Also install the {{Pkg|alsa-plugins}} package if you want [[#High quality resampling|high quality resampling]], [[#Upmixing/Downmixing|upmixing/downmixing]] and other advanced features.<br />
<br />
If you want OSS applications to work with dmix (software mixing), also install the {{Pkg|alsa-oss}} package. Load the {{ic|snd_seq_oss}}, {{ic|snd_pcm_oss}} and {{ic|snd_mixer_oss}} [[kernel modules]] to enable the OSS emulation modules.<br />
<br />
== Unmuting the channels ==<br />
<br />
The current version of ALSA installs with all channels '''muted by default'''. You will need to unmute the channels manually.<br />
<br />
It is easiest to use {{ic|alsamixer}} ncurses UI to accomplish this:<br />
<br />
$ alsamixer<br />
<br />
Alternatively, use {{ic|amixer}} from the command-line:<br />
<br />
$ amixer sset Master unmute<br />
<br />
In {{ic|alsamixer}}, the {{ic|MM}} label below a channel indicates that the channel is muted, and {{ic|00}} indicates that it is open.<br />
<br />
Scroll to the {{ic|Master}} and {{ic|PCM}} channels with the {{ic|←}} and {{ic|→}} keys and unmute them by pressing the {{ic|m}} key. Use the {{ic|↑}} key to increase the volume and obtain a value of {{ic|0}} dB gain. The gain can be found in the upper left next to the {{ic|Item:}} field. Higher values of gain will produce distorted sound.<br />
<br />
To get full 5.1 or 7.1 surround sound you likely need to unmute other channels such as Front, Surround, Center, LFE (subwoofer) and Side (these are the names of the channels with Intel HD Audio, they may vary with different hardware). Please take note that this will not automatically upmix stereo sources (like most music). In order to accomplish that, see [[#Upmixing/Downmixing]].<br />
<br />
To enable your microphone, switch to the Capture tab with {{ic|F4}} and enable a channel with {{ic|Space}}.<br />
<br />
Leave alsamixer by pressing {{ic|Esc}}.<br />
<br />
{{Note|<br />
* Some cards need to have digital output muted/turned off in order to hear analog sound. For the Soundblaster Audigy LS mute the IEC958 channel.<br />
* Some machines, (like the Thinkpad T61), have a Speaker channel which must be unmuted and adjusted as well.<br />
* Some machines, (like the Dell E6400) may also require the {{ic|Front}} and {{ic|Headphone}} channels to be unmuted and adjusted.<br />
* If your volume adjustments seems to be lost when you reboot, try running alsamixer as root. <br />
}}<br />
<br />
Next, test to see if sound works:<br />
<br />
$ speaker-test -c 2<br />
<br />
Change {{ic|-c}} to fit your speaker setup. Use {{ic|-c 8}} for 7.1, for instance:<br />
<br />
$ speaker-test -c 8<br />
<br />
If it does not work, proceed to [[#Configuration|Configuration]] and then [[#Troubleshooting|Troubleshooting]] to solve your problems.<br />
<br />
The {{Pkg|alsa-utils}} package includes {{ic|alsa-restore.service}} and {{ic|alsa-store.service}}, which are preconfigured to run at boot and shutdown respectively.<br />
For reference, ALSA stores its settings in {{ic|/var/lib/alsa/asound.state}}.<br />
<br />
== Configuration ==<br />
<br />
=== No sound in VirtualBox ===<br />
<br />
If you experience problems with VirtualBox, the following command might be helpful:<br />
<br />
{{hc|$ alsactl init|2=<nowiki><br />
<br />
Found hardware: "ICH" "SigmaTel STAC9700,83,84" "AC97a:83847600" "0x8086" "0x0000"<br />
Hardware is initialized using a generic method<br />
</nowiki>}}<br />
<br />
You might need to activate the ALSA output in your audio software as well.<br />
<br />
=== Set the default sound card ===<br />
<br />
If your sound card order changes on boot, you can specify their order in any file ending with {{ic|.conf}} in {{ic|/etc/modprobe.d}} ({{ic|/etc/modprobe.d/alsa-base.conf}} is suggested).<br />
For example, if you want your mia sound card to be #0:<br />
<br />
{{hc|/etc/modprobe.d/alsa-base.conf|2=<nowiki><br />
options snd slots=snd_mia,snd_hda_intel<br />
options snd_mia index=0<br />
options snd_hda_intel index=1<br />
</nowiki>}}<br />
<br />
Use {{ic|<nowiki>$ cat /proc/asound/modules</nowiki>}} to get the loaded sound modules and their order. This list is usually all that is needed for the loading order. Use {{ic|<nowiki>$ lsmod | grep snd</nowiki>}} to get a devices & modules list. This configuration assumes you have one mia sound card using {{ic|snd_mia}} and one (e.g. onboard) card using {{ic|snd_hda_intel}}.<br />
<br />
You can also provide an index of {{ic|-2}} to instruct ALSA to never use a card as the primary one. Distributions such as Linux Mint and Ubuntu use the following settings to avoid USB and other "abnormal" drivers from getting index {{ic|0}}:<br />
<br />
{{hc|/etc/modprobe.d/alsa-base.conf|2=<br />
options bt87x index=-2<br />
options cx88_alsa index=-2<br />
options saa7134-alsa index=-2<br />
options snd-atiixp-modem index=-2<br />
options snd-intel8x0m index=-2<br />
options snd-via82xx-modem index=-2<br />
options snd-usb-audio index=-2<br />
options snd-usb-caiaq index=-2<br />
options snd-usb-ua101 index=-2<br />
options snd-usb-us122l index=-2<br />
options snd-usb-usx2y index=-2<br />
options snd-pcsp index=-2<br />
options snd-usb-audio index=-2<br />
}}<br />
<br />
These changes require a system reboot.<br />
<br />
==== Select the default PCM via environment variable ====<br />
<br />
In your configuration file, preferably global, add:<br />
pcm.!default {<br />
type plug<br />
slave.pcm {<br />
@func getenv<br />
vars [ ALSAPCM ]<br />
default "hw:Audigy2"<br />
}<br />
}<br />
<br />
You need to replace the default line with the name of your card (in the example is {{ic|Audigy2}}). You can get the names with {{ic|aplay -l}} or you can also use PCMs like '''surround51'''. But if you need to use the microphone it is a good idea to select full-duplex PCM as default.<br />
<br />
Now you can start programs selecting the sound card just changing the environment variable {{ic|ALSAPCM}}. It works fine for all program that do not allow to select the card, for the others ensure you keep the default card.<br />
For example, assuming you wrote a downmix PCM called '''mix51to20''' you can use it with {{ic|mplayer}} using the commandline {{ic|ALSAPCM&#61;mix51to20 mplayer example_6_channel.wav}}<br />
<br />
==== Alternative method ====<br />
<br />
First you will have to find out the card and device id that you want to set as the default by running {{ic|aplay -l}}:<br />
<br />
{{hc|$ aplay -l|2=<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: CONEXANT Analog [CONEXANT Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 1: Conexant Digital [Conexant Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 1: JamLab [JamLab], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 2: Audio [Altec Lansing XT1 - USB Audio], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
}}<br />
<br />
For example, the last entry in this list has the card ID 2 and the device ID 0. To set this card as the default, you can either use the system-wide file {{ic|/etc/asound.conf}} or the user-specific file {{ic|~/.asoundrc}}. You may have to create the file if it does not exist. Then insert the following options with the corresponding card.<br />
{{bc|<br />
pcm.!default {<br />
type hw<br />
card 2<br />
}<br />
<br />
ctl.!default {<br />
type hw <br />
card 2<br />
}<br />
}}<br />
<br />
{{Note|For the Asus U32U serie it seems that card should be set to 1 for both pcm and ctl.}}<br />
<br />
The 'pcm' options affect which card and device will be used for audio playback while the 'ctl' option affects which card is used by control utilities like alsamixer .<br />
<br />
The changes should take effect as soon as you (re-)start an application (MPlayer etc.). You can also test with a command like ''aplay''.<br />
<br />
$ aplay -D default ''your_favourite_sound.wav''<br />
<br />
If you receive an error regarding your asound configuration, check the [http://www.alsa-project.org/main/index.php/Asoundrc#The_default_plugin upstream documentation] for possible changes to the config file format.<br />
<br />
=== Making sure the sound modules are loaded ===<br />
<br />
You can assume that udev will autodetect your sound properly. You can check this with the command<br />
<br />
{{hc|<nowiki>$ lsmod | grep '^snd' | column -t</nowiki>|2=<br />
snd_hda_codec_hdmi 22378 4<br />
snd_hda_codec_realtek 294191 1<br />
snd_hda_intel 21738 1<br />
snd_hda_codec 73739 3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel<br />
snd_hwdep 6134 1 snd_hda_codec<br />
snd_pcm 71032 3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec<br />
snd_timer 18992 1 snd_pcm<br />
snd 55132 9 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer<br />
snd_page_alloc 7017 2 snd_hda_intel,snd_pcm<br />
}}<br />
<br />
If the output looks similar, your sound drivers have been successfully autodetected.<br />
{{Note|Since {{ic|udev>&#61;171}}, the OSS emulation modules ({{ic|snd_seq_oss, snd_pcm_oss, snd_mixer_oss}}) are not loaded by default: [[kernel modules#Loading|Load them manually]] if they are needed.}}<br />
<br />
You might also want to check the directory {{ic|/dev/snd/}} for the right device files:<br />
<br />
{{hc|$ ls -l /dev/snd|2=<nowiki><br />
total 0<br />
crw-rw---- 1 root audio 116, 0 Apr 8 14:17 controlC0<br />
crw-rw---- 1 root audio 116, 32 Apr 8 14:17 controlC1<br />
crw-rw---- 1 root audio 116, 24 Apr 8 14:17 pcmC0D0c<br />
crw-rw---- 1 root audio 116, 16 Apr 8 14:17 pcmC0D0p<br />
crw-rw---- 1 root audio 116, 25 Apr 8 14:17 pcmC0D1c<br />
crw-rw---- 1 root audio 116, 56 Apr 8 14:17 pcmC1D0c<br />
crw-rw---- 1 root audio 116, 48 Apr 8 14:17 pcmC1D0p<br />
crw-rw---- 1 root audio 116, 1 Apr 8 14:17 seq<br />
crw-rw---- 1 root audio 116, 33 Apr 8 14:17 timer<br />
</nowiki>}}<br />
<br />
{{Note|If requesting help on IRC or the forums, please post the output of the above commands.}}<br />
<br />
If you have at least the devices '''controlC0''' and '''pcmC0D0p''' or similar, then your sound modules have been detected and loaded properly.<br />
<br />
If this is not the case, your sound modules have not been detected properly. To solve this, you can try loading the modules manually:<br />
<br />
* Locate the module for your sound card: [http://www.alsa-project.org/main/index.php/Matrix:Main ALSA Soundcard Matrix] The module will be prefixed with 'snd-' (for example: {{ic|snd-via82xx}}).<br />
* [[Kernel modules#Loading|Load the module]].<br />
* Check for the device files in {{ic|/dev/snd}} (see above) and/or try if {{ic|alsamixer}} or {{ic|amixer}} have reasonable output.<br />
* Configure {{ic|snd-NAME-OF-MODULE}} and {{ic|snd-pcm-oss}} to [[Kernel modules#Loading|load at boot]].<br />
<br />
=== Getting SPDIF output ===<br />
<br />
(from gralves from the Gentoo forums)<br />
* In GNOME Volume Control, under the Options tab, change the IEC958 to PCM. This option can be enabled in the preferences.<br />
* If you do not have GNOME Volume Control installed,<br />
** Edit {{ic|/var/lib/alsa/asound.state}}. This file is where alsasound stores your mixer settings.<br />
** Find a line that says: 'IEC958 Playback Switch'. Near it you will find a line saying {{ic|value:false}}. Change it to {{ic|value:true}}.<br />
** Now find this line: 'IEC958 Playback AC97-SPSA'. Change its value to 0.<br />
** Restart ALSA.<br />
<br />
Alternative way to enable SPDIF output automatically on login (tested on SoundBlaster Audigy):<br />
<br />
* add following lines to {{ic|/etc/rc.local}}:<br />
# Use COAX-digital output<br />
amixer set 'IEC958 Optical' 100 unmute<br />
amixer set 'Audigy Analog/Digital Output Jack' on<br />
<br />
You can see the name of your card's digital output with:<br />
$ amixer scontrols<br />
<br />
=== System-wide equalizer ===<br />
<br />
==== Using AlsaEqual (provides UI) ====<br />
<br />
Install {{AUR|alsaequal}} from the [[AUR]].<br />
<br />
{{Note | If you have a x86_64-system and are using a 32bit-flashplugin the sound in flash will not work. Either you have to disable alsaequal or build alsaequal for 32bit.}}<br />
<br />
After installing the package, insert the following into your ALSA configuration file ({{ic|~/.asoundrc}} or {{ic|/etc/asound.conf}}):<br />
<br />
ctl.equal {<br />
type equal;<br />
}<br />
<br />
pcm.plugequal {<br />
type equal;<br />
# Modify the line below if you do not<br />
# want to use sound card 0.<br />
#slave.pcm "plughw:0,0";<br />
#by default we want to play from more sources at time:<br />
slave.pcm "plug:dmix";<br />
}<br />
#pcm.equal {<br />
# If you do not want the equalizer to be your<br />
# default soundcard comment the following<br />
# line and uncomment the above line. (You can<br />
# choose it as the output device by addressing<br />
# it with specific apps,eg mpg123 -a equal 06.Back_In_Black.mp3)<br />
pcm.!default {<br />
type plug;<br />
slave.pcm plugequal;<br />
}<br />
<br />
And you are ready to change your equalizer using command<br />
$ alsamixer -D equal<br />
<br />
Note that configuration file is different for each user (until not specified else) it is saved in {{ic|~/.alsaequal.bin}}.<br />
so if you want to use AlsaEqual with [[mpd]] or another software running under different user, you can configure it using<br />
# su mpd -c 'alsamixer -D equal'<br />
or for example, you can make a symlink to your {{ic|.alsaequal.bin}} in his home...<br />
<br />
===== Managing AlsaEqual states =====<br />
<br />
Install {{AUR|alsaequal-mgr}} from the [[AUR]] (or alternatively from [http://xyne.archlinux.ca/repos/ Xyne's repos]).<br />
<br />
Configure the equalizer as usual with <br />
$ alsamixer -D equal<br />
<br />
When you are satisfied with the state, you may give it a name ("foo" in this example) and save it:<br />
$ alsaequal-mgr save foo<br />
<br />
The state "foo" can then be restored at a later time with<br />
$ alsaequal-mgr load foo<br />
<br />
You can thus create different equalizer states for games, movies, music genres, VoIP apps, etc. and reload them as necessary.<br />
<br />
See the [http://xyne.archlinux.ca/projects/alsaequal-mgr/ project page] and the help message for more options.<br />
<br />
==== Using mbeq ====<br />
<br />
{{Note|This method requires the use of a ladspa plugin which might use quite a bit of CPU when sound plays. In addition, this was made with stereophonic sound (e.g. headphones) in mind.}}<br />
<br />
Install the {{Pkg|alsa-plugins}}, {{Pkg|ladspa}} and {{Pkg|swh-plugins}} packages if you do not already have them.<br />
<br />
* If you have not already created either an {{ic|~/.asoundrc}} or a {{ic|/etc/asound.conf}} file, then create either one and insert the following:<br />
<br />
{{hc|/etc/asound.conf|2=<nowiki>pcm.eq {<br />
type ladspa<br />
<br />
# The output from the EQ can either go direct to a hardware device<br />
# (if you have a hardware mixer, e.g. SBLive/Audigy) or it can go<br />
# to the software mixer shown here.<br />
#slave.pcm "plughw:0,0"<br />
slave.pcm "plug:dmix"<br />
<br />
# Sometimes you may need to specify the path to the plugins,<br />
# especially if you have just installed them. Once you have logged<br />
# out/restarted this should not be necessary, but if you get errors<br />
# about being unable to find plugins, try uncommenting this.<br />
#path "/usr/lib/ladspa"<br />
<br />
plugins [<br />
{<br />
label mbeq<br />
id 1197<br />
input {<br />
#this setting is here by example, edit to your own taste<br />
#bands: 50hz, 100hz, 156hz, 220hz, 311hz, 440hz, 622hz, 880hz, 1250hz, 1750hz, 25000hz,<br />
#50000hz, 10000hz, 20000hz<br />
controls [ -5 -5 -5 -5 -5 -10 -20 -15 -10 -10 -10 -10 -10 -3 -2 ]<br />
}<br />
}<br />
]<br />
}<br />
<br />
# Redirect the default device to go via the EQ - you may want to do<br />
# this last, once you are sure everything is working. Otherwise all<br />
# your audio programs will break/crash if something has gone wrong.<br />
<br />
pcm.!default {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
<br />
# Redirect the OSS emulation through the EQ too (when programs are running through "aoss")<br />
<br />
pcm.dsp0 {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
</nowiki>}}<br />
<br />
* You should be good to go (if not, ask in the forum).<br />
<br />
== High quality resampling ==<br />
<br />
When software mixing is enabled, ALSA is forced to resample everything to the same frequency (48000 by default when supported). dmix uses a poor resampling algorithm which produces noticeable sound quality loss.<br />
<br />
Install {{Pkg|alsa-plugins}} and {{Pkg|libsamplerate}}.<br />
<br />
Change the default rate converter to libsamplerate:<br />
<br />
{{hc|/etc/asound.conf|defaults.pcm.rate_converter "samplerate_best"}}<br />
<br />
or:<br />
<br />
{{hc|~/.asoundrc|defaults.pcm.rate_converter "samplerate_best"}}<br />
<br />
'''samplerate_best''' offers the best sound quality, but you need a decent CPU to be able to use it as it requires a lot of CPU cycles for real-time resampling. You may also need to adjust buffer_size in your dmix settings from the basic 4096 to 8192 or 16384. There are other algorithms available ('''samplerate''', etc.) but they may not provide much of an improvement over the default resampler.<br />
<br />
{{Warning|On some systems, enabling samplerate_best may cause a problem where you get no sound from flashplayer.}}<br />
<br />
== Upmixing/downmixing ==<br />
<br />
=== Upmixing ===<br />
<br />
In order for stereo sources like music to be able to saturate a 5.1 or 7.1 sound system, you need to use upmixing. In darker days this used to be tricky and error prone but nowadays plugins exist to easily take care of this task. We will use the {{ic|upmix}} plugin, included in {{Pkg|alsa-plugins}}.<br />
<br />
Then add the following to your ALSA configuration file of choice (either {{ic|/etc/asound.conf}} or {{ic|~/.asoundrc}}):<br />
pcm.upmix71 {<br />
type upmix<br />
slave.pcm "surround71"<br />
delay 15<br />
channels 8<br />
}<br />
<br />
You can easily change this example for 7.1 upmixing to 5.1 or 4.0.<br />
<br />
This adds a new pcm that you can use for upmixing. If you want all sound sources to go through this pcm, add it as a default below the previous definition like so:<br />
<br />
pcm.!default "plug:upmix71"<br />
<br />
The plugin automatically allows multiple sources to play through it without problems so setting is as a default is actually a safe choice. <br />
If this is not working, you have to setup your own dmixer for the upmixing PCM like this: <br />
pcm.dmix6 {<br />
type asym<br />
playback.pcm {<br />
type dmix<br />
ipc_key 567829<br />
slave {<br />
pcm "hw:0,0"<br />
channels 6<br />
}<br />
}<br />
}<br />
<br />
and use "dmix6" instead of "surround71". <br />
If you experience skipping or distorted sound, consider increasing the buffer_size (to 32768, for example) or use a [[#High quality resampling|high quality resampler]].<br />
<br />
=== Downmixing ===<br />
<br />
If you want to downmix sources to stereo because you, for instance, want to watch a movie with 5.1 sound on a stereo system, use the {{ic|vdownmix}} plugin, included in {{Pkg|alsa-plugins}}..<br />
<br />
Again, in your configuration file, add this:<br />
<br />
pcm.!surround51 {<br />
type vdownmix<br />
slave.pcm "default"<br />
}<br />
pcm.!surround40 {<br />
type vdownmix<br />
slave.pcm "default"<br />
}<br />
<br />
{{Note|1=This might not be enough to make downmixing working, see [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541786]. So, you might also need to add {{ic|pcm.!default "plug:surround51"}} or {{ic|pcm.!default "plug:surround40"}}. Only one {{ic|vdownmix}} plug can be used; if you have 7.1 channels, you will need to use {{ic|surround71}} instead the configuration above. A good example, which includes a configuration that makes both {{ic|vdownmix}} and {{ic|dmix}} working, can be found [https://bbs.archlinux.org/viewtopic.php?id=167275 here].}}<br />
<br />
== Mixing ==<br />
<br />
=== Software mixing (dmix) ===<br />
<br />
{{Note|For ALSA 1.0.9rc2 and higher on analog sound outputs you do not need to setup dmix. Dmix is enabled as default for soundcards which do not support hardware mixing.}}<br />
<br />
If that does not work however, it is a matter of simply creating a .asoundrc file in your home folder with the following contents.<br />
<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
<br />
This should enable software mixing and allows more than one application to make use of the soundcard. If not, try replacing all /etc/asound.conf content with the above.<br />
<br />
For a digital sound output such as S/PDIF, the ALSA package still does not enable dmix by default. Thus, the dmix configuration above can be used to enable dmix for S/PDIF devices.<br />
<br />
See [[#Troubleshooting]] for common problems and solutions.<br />
<br />
=== Hardware mixing ===<br />
<br />
==== Support ====<br />
<br />
If you have an audio chipset that supports mixing in hardware, then no configuration is necessary. Almost every onboard audio chipset does not support hardware mixing, and requires mixing to be done in software (see above). Many sound cards do support hardware mixing, and the ones best supported on Linux are listed below:<br />
<br />
* Creative SoundBlaster Live! (5.1 model)<br />
* Creative SoundBlaster Audigy (some models)<br />
* Creative SoundBlaster Audidy 2 (ZS models)<br />
* Creative SoundBlaster Audigy 4 (Pro models)<br />
<br />
{{Note|<br />
* The low end variants of above cards, (Audigy SE, Audigy 2 NX, SoundBlaster Live! 24bit and SoundBlaster Live! 7.1) '''do not''' support hardware mixing as they use other chips.<br />
* The onboard VIA8237 chip supports 4-stream hardware mixing, however, it does only 3 for some motherboards (the 4th makes no sound) or is just broken. Even if it works, the quality is not good compared to other solutions.<br />
}}<br />
<br />
==== Fixes ====<br />
<br />
If you are using 64-bit Arch and the Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02), you can get sound working for Enemy Territory with the following:<br />
echo "et.x86 0 0 direct" > /proc/asound/card0/pcm0p/oss<br />
echo "et.x86 0 0 disable" > /proc/asound/card0/pcm0c/oss<br />
<br />
== Troubleshooting ==<br />
<br />
=== Sound skipping while using dynamic frequency scaling ===<br />
<br />
Some combinations of ALSA drivers and chipsets may cause audio from all sources to skip when used in combination with a dynamic frequency scaling governor such as {{ic|ondemand}} or {{ic|conservative}}. Currently, the solution is to switch back to the {{ic|performance}} governor.<br />
<br />
Refer to the [[CPU Frequency Scaling]] for more information.<br />
<br />
=== Problems with availability to only one user at a time ===<br />
<br />
You might find that only one user can use the dmixer at a time. This is probably ok for most, but for those who run [[mpd]] as a separate user this poses a problem. When mpd is playing a normal user cannot play sounds though the dmixer. While it's quite possible to just run mpd under a user's login account, another solution has been found. Adding the line {{ic|ipc_key_add_uid 0}} to the {{ic|pcm.dmixer}} block disables this locking. The following is a snippet of the {{ic|asound.conf}}, the rest is the same as above.<br />
...<br />
pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid 0<br />
ipc_perm 0660<br />
slave {<br />
...<br />
<br />
=== Simultaneous playback problems ===<br />
<br />
If you are having problems with simultaneous playback, and if [[PulseAudio]] is installed (i.e. by [[GNOME]]), its default configuration is set to "hijack" the soundcard. Some users of ALSA may not want to use [[PulseAudio]] and are quite content with their current ALSA settings. One fix is to edit {{ic|/etc/asound.conf}} and comment out the following lines:<br />
# Use PulseAudio by default<br />
#pcm.!default {<br />
# type pulse<br />
# fallback "sysdefault"<br />
# hint {<br />
# show on<br />
# description "Default ALSA Output (currently PulseAudio Sound Server)"<br />
# }<br />
#}<br />
<br />
Commenting the following out also may help:<br />
#ctl.!default {<br />
# type pulse<br />
# fallback "sysdefault"<br />
#}<br />
<br />
This may be a much simpler solution than completely uninstalling [[PulseAudio]].<br />
<br />
Effectively, here is an example of a working {{ic|/etc/asound.conf}}:<br />
{{bc|<nowiki>pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid 0<br />
ipc_perm 0660<br />
}<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}</nowiki><br />
}}<br />
<br />
{{Note|This {{ic|/etc/asound.conf}} file was intended for and used successfully with a global [[MPD]] configuration. See [[Alsa#Problems_with_Availability_to_Only_One_User_at_a_Time|this section]] on multiple users}}<br />
<br />
=== Random lack of sound on startup ===<br />
<br />
You can quickly test sound by running {{ic|speaker-test}}. If there is no sound, the error message might look something like<br />
<br />
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave<br />
Playback open error: -16<br />
Device or resource busy<br />
<br />
If you have no sound on startup, this may be because your system has multiple sound cards, and their order may sometimes change on startup. If this is the case, try [[#Set the default sound card|setting the default sound card]].<br />
<br />
If you use mpd and the configuration tips above do not work for you, try [http://mpd.wikia.com/wiki/Configuration#ALSA_MPD_software_volume_control reading this] instead.<br />
<br />
==== Timidity ====<br />
<br />
[[Timidity]] can be the cause of missing audio. Try running:<br />
<br />
$ systemctl status timidity<br />
<br />
If it failed, try {{ic|# killall -9 timidity}}. If this solves the issue, then you should disable the timidity daemon to be started at boot.<br />
<br />
=== Specific program problems ===<br />
<br />
For other programs who insist on their own audio setup, e.g., XMMS or MPlayer, you would need to set their specific options.<br />
<br />
For MPlayer, open up a [[MPlayer#Configuration|configuration file]] and add the following line:<br />
ao=alsa<br />
For ''mpv'' append the same line in one of its [[mpv#Configuration|configuration files]].<br />
<br />
For XMMS/Beep Media Player, go into their options and make sure the sound driver is set to Alsa, not oss.<br />
<br />
To do this in XMMS:<br />
* Open XMMS<br />
** Options > Preferences.<br />
** Choose the ALSA output plugin.<br />
<br />
For applications which do not provide a ALSA output, you can use aoss from the alsa-oss package. To use aoss, when you run the program, prefix it with {{ic|aoss}}, eg:<br />
aoss realplay<br />
<br />
pcm.!default{ ... } doesnt work for me anymore. but this does:<br />
pcm.default pcm.dmixer<br />
<br />
=== Model settings ===<br />
<br />
Although Alsa detects your soundcard through the BIOS at times Alsa may not be able to recognize your [http://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt model type]. The soundcard chip can be found in {{ic|alsamixer}} (e.g. ALC662) and the model can be set in {{ic|/etc/modprobe.d/modprobe.conf}} or {{ic|/etc/modprobe.d/sound.conf}}. For example:<br />
<br />
options snd-hda-intel model=MODEL<br />
<br />
There are other model settings too. For most cases Alsa defaults will do. If you want to look at more specific settings for your soundcard take a look at the [http://bugtrack.alsa-project.org/main/index.php/Matrix:Main Alsa Soundcard List] find your model, then Details, then look at the "Setting up modprobe..." section. Enter these values in {{ic|/etc/modprobe.d/modprobe.conf}}. For example, for an Intel AC97 audio:<br />
<br />
{{bc|<br />
# ALSA portion<br />
alias char-major-116 snd<br />
alias snd-card-0 snd-intel8x0<br />
# module options should go here<br />
<br />
# OSS/Free portion<br />
alias char-major-14 soundcore<br />
alias sound-slot-0 snd-card-0<br />
<br />
# card #1<br />
alias sound-service-0-0 snd-mixer-oss<br />
alias sound-service-0-1 snd-seq-oss<br />
alias sound-service-0-3 snd-pcm-oss<br />
alias sound-service-0-8 snd-seq-oss<br />
alias sound-service-0-12 snd-pcm-oss<br />
}}<br />
<br />
=== Conflicting PC speaker ===<br />
<br />
If you are sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try adding the following line to {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-NAME-OF-MODULE ac97_quirk=0<br />
<br />
The above fix has been observed to work with {{ic|via82xx}}<br />
options snd-NAME-OF-MODULE ac97_quirk=1<br />
The above fix has been reported to work with {{ic|snd_intel8x0}}<br />
<br />
=== No microphone input ===<br />
<br />
In alsamixer, make sure that all the volume levels are up under recording, and that CAPTURE is toggled active on the microphone (e.g. Mic, Internal Mic) and/or on Capture (in alsamixer, select these items and press space). Try making positive Mic Boost and raising Capture and Digital levels higher; this make make static or distortion, but then you can adjust them back down once you are hearing ''something'' when you record<br />
<br />
As the pulseaudio wrapper is shown as "default" in alsamixer, you may have to press F6 to select your actual soundcard first. You may also need to enable and increase the volume of Line-in in the Playback section.<br />
<br />
To test the microphone, run these commands (see arecord's man page for further information):<br />
$ arecord -d 5 test-mic.wav<br />
$ aplay test-mic.wav<br />
<br />
If all fails, you may want to eliminate hardware failure by testing the microphone with a different device.<br />
<br />
For at least some computers, muting a microphone (MM) simply means its input does not go immediately to the speakers. It still receives input.<br />
<br />
Many Dell laptops need "-dmic" to be appended to the model name in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-hda-intel model=dell-m6-dmic<br />
<br />
Some programs use try to use OSS as the main input software. If you have enabled the {{ic|snd_pcm_oss}}, {{ic|snd_mixer_oss}} or {{ic|snd_seq_oss}} [[kernel modules]] previously (they are not loaded by default), try unloading them.<br />
<br />
See also:<br />
* http://www.alsa-project.org/main/index.php/SoundcardTesting<br />
* http://alsa.opensrc.org/Record_from_mic<br />
<br />
=== Crackling in microphone ===<br />
<br />
If you're getting a crackling or popping from your microphone that can't be resolved with ALSA settings or cleaning your microphone jack, try adding the following line to {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-hda-intel model=MODEL position_fix=3<br />
<br />
This option will fix crackling on pure Alsa, but will cause issues to pulseaudio. To let Pulse use these settings effectively, edit {{ic|/etc/pulse/default.pa}} and find this line:<br />
<br />
load-module module-udev-detect<br />
<br />
And change it to this:<br />
<br />
load-module module-udev-detect tsched=0<br />
<br />
See the DMA-Position Problem in the kernel docs.<br />
<br />
* [https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio.txt HD-audio Kernel Docs]<br />
<br />
=== Setting the default microphone/capture device ===<br />
<br />
Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes a problem if your microphone is on a separate device (e.g. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your {{ic|~/.asoundrc}} file to include the following:<br />
<br />
pcm.usb<br />
{<br />
type hw<br />
card U0x46d0x81d<br />
}<br />
<br />
pcm.!default<br />
{<br />
type asym<br />
playback.pcm<br />
{<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
capture.pcm<br />
{<br />
type plug<br />
slave.pcm "usb"<br />
}<br />
}<br />
<br />
Replace "U0x46d0x81d" with your capture device's card name in ALSA. You can use {{ic|arecord -L}} to list all the capture devices detected by ALSA.<br />
<br />
=== Internal microphone not working ===<br />
<br />
First make sure all the volume levels are up under recording in alsamixer. In my case adding the following option to {{ic|/etc/sound.conf}} and reloading the snd-* module produced a new volume setting called Capture which was capturing for the internal mic. For eg, for snd-hda-intel add<br />
<br />
options snd-hda-intel enable_msi=1<br />
<br />
Then reload the module (as below), up the recording volume of Capture and then test.<br />
<br />
# rmmod snd-hda-intel && modprobe snd-hda-intel<br />
<br />
=== No sound with onboard Intel sound card ===<br />
<br />
There may be a problem with two conflicting modules loaded, namely {{ic|snd_intel8x0}} and {{ic|snd_intel8x0m}}. In this case, blacklist snd_intel8x0m:<br />
<br />
{{hc|/etc/modprobe.d/modprobe.conf|blacklist snd_intel8x0m}}<br />
<br />
''Muting'' the "External Amplifier" in {{ic|alsamixer}} or {{ic|amixer}} may also help. See [http://alsa.opensrc.org/Intel8x0#Dell_Inspiron_8600_.28and_probably_others.29 the ALSA wiki].<br />
<br />
Unmuting the "Mix" setting in the mixer might help, also.<br />
<br />
=== No headphone sound with onboard Intel sound card ===<br />
<br />
With '''Intel Corporation 82801 I (ICH9 Family) HD Audio Controller''' on laptop, you may need to add this line to modprobe or sound.conf:<br />
<br />
options snd-hda-intel model=''model''<br />
<br />
Where ''model'' is any one of the following (in order of possibility to work, but not merit):<br />
<br />
* dell-vostro<br />
* olpc-xo-1_5<br />
* laptop<br />
* dell-m6<br />
* laptop-hpsense<br />
<br />
{{Note|It may be necessary to put this "options" line below (after) any "alias" lines about your card.}}<br />
<br />
You can see all the available models in the kernel documentation. For example [http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/sound/alsa/HD-Audio-Models.txt here], but check that it is the correct version of that document for your kernel version.<br />
<br />
A list of available models is also available [http://www.mjmwired.net/kernel/Documentation/sound/alsa/HD-Audio-Models.txt here]. To know your chip name type the following command (with * being corrected to match your files). Note that some chips could have been renamed and do not directly match the available ones in the file.<br />
<br />
$ grep Codec /proc/asound/card*/codec*<br />
<br />
Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it is either your headphones or your mic. Please report to ALSA if you are affected by this bug.<br />
<br />
And also, if you have problems getting beeps to work (pcspkr):<br />
<br />
options snd-hda-intel model=$model enable=1 index=0<br />
<br />
=== No sound when S/PDIF video card is installed ===<br />
<br />
Discover available modules and their order:<br />
{{hc|$ cat /proc/asound/modules|<br />
0 snd_hda_intel<br />
1 snd_ca0106<br />
}}<br />
<br />
Disable the undesired video card audio codec in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
# /etc/modprobe.d/modprobe.conf<br />
#<br />
install snd_hda_intel /bin/false<br />
<br />
If both devices use the same module then we can use the *enable* parameter from snd-hda-intel module, it's an array of booleans that can enable/disable the desired sound card.<br />
<br />
e.g <br />
options snd-hda-intel enable=1,0<br />
the following gives you the list of cards<br />
cat /proc/asound/cards<br />
<br />
=== Poor sound quality or clipping ===<br />
<br />
If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0.<br />
<br />
If snd-usb-audio driver has been loaded, you could try to enable {{ic|softvol}} in {{ic|/etc/asound.conf}} file. Example configuration for the first audio device:<br />
pcm.!default {<br />
type plug<br />
slave.pcm "softvol"<br />
}<br />
pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
slave {<br />
pcm "hw:0"<br />
period_time 0<br />
period_size 4096<br />
buffer_size 131072<br />
rate 50000<br />
}<br />
bindings {<br />
0 0<br />
1 1<br />
}<br />
}<br />
pcm.dsnooper {<br />
type dsnoop<br />
ipc_key 1024<br />
slave {<br />
pcm "hw:0"<br />
channels 2<br />
period_time 0<br />
period_size 4096<br />
buffer_size 131072<br />
rate 50000<br />
}<br />
bindings {<br />
0 0<br />
1 1<br />
}<br />
}<br />
pcm.softvol {<br />
type softvol<br />
slave { pcm "dmixer" }<br />
control {<br />
name "Master"<br />
card 0<br />
}<br />
}<br />
ctl.!default {<br />
type hw<br />
card 0<br />
}<br />
ctl.softvol {<br />
type hw<br />
card 0<br />
}<br />
ctl.dmixer {<br />
type hw<br />
card 0<br />
}<br />
<br />
=== Pops when starting and stopping playback===<br />
<br />
Some modules (e.g. snd-ac97-codec and snd-hda-intel) can power off your sound card when not in use. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when move the slider volume, or open and close windows (KDE4). If you find this annoying try {{ic|modinfo snd-MY-MODULE}}, and look for a module option that adjusts or disables this feature.<br />
<br />
''Example'': disable the power saving mode and solve cracking sound trough speakers problem, using snd-hda-intel add in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-hda-intel power_save=0<br />
or:<br />
options snd-hda-intel power_save=0 power_save_controller=N<br />
<br />
You can also try it with {{ic|1=modprobe snd-hda-intel power_save=0}} before.<br />
<br />
You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high).<br />
<br />
''Example:'' on an onboard VIA VT1708S (using the snd-hda-intel module) these cracks occured even though 'power_save' was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the problem.<br />
<br />
Source: https://www.kernel.org/doc/Documentation/sound/alsa/powersave.txt<br />
<br />
If you use a laptop, pm-utils will change {{ic|power_save}} back to 1 when you go onto battery power even if you disable power saving in {{ic|/etc/modprobe.d}}. Disable this for pm-utils by disabling the script that makes the change (see [[Pm-utils#Disabling_a_hook|Disabling a hook]] for more information):<br />
# touch /etc/pm/power.d/intel-audio-powersave<br />
<br />
=== S/PDIF output does not work ===<br />
<br />
If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running<br />
# iecset audio on<br />
<br />
You can also put this command in an enabled [[systemd]] service as it sometimes it may stop working after a reboot.<br />
<br />
=== HDMI output does not work ===<br />
<br />
The procedure described below can be used to test HDMI audio. Before proceeding, make sure you have enabled and unmuted the output with {{ic|alsamixer}}.<br />
<br />
{{Note|If you are using an ATI card and linux kernel &gt;&#61;3.0, a necessary kernel module is disabled by default. See [[ATI#HDMI_Audio]].}}<br />
<br />
Connect your PC to the Display via HDMI cable and enable the display with a tool such as {{ic|xrandr}} or {{ic|arandr}}. For example:<br />
<br />
$ xrandr # list outputs<br />
$ xrandr --output DVI-D_1 --mode 1024x768 --right-of PANEL # enable output<br />
<br />
Use {{ic|aplay -l}} to get the discover the card and device number. For example:<br />
<br />
$ aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: SB [HDA ATI SB], device 0: ALC892 Analog [ALC892 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: SB [HDA ATI SB], device 1: ALC892 Digital [ALC892 Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
'''card 1''': Generic [HD-Audio Generic], '''device 3''': HDMI 0 [HDMI 0]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
<br />
Send sound to the device. Following the example in the previous step, you would send sound to card 1, device 3:<br />
<br />
$ aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Center.wav<br />
<br />
If aplay does not output any errors, but still no sound is heared, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding. In particular, if you are using a standalone window manager (don’t know about Gnome or KDE), you may need to have some sound playing ''while'' plugging in the HDMI cable.<br />
<br />
If the test is successful, create or edit your {{ic|~/.asoundrc}} file to set HDMI as the default audio device.<br />
<br />
{{hc|~/.asoundrc|<br />
pcm.!default {<br />
type hw<br />
card 0<br />
device 3<br />
}<br />
}}<br />
<br />
Or you above config does not work try:<br />
{{hc|~/.asoundrc|<br />
defaults.pcm.card 0<br />
defaults.pcm.device 3<br />
defaults.ctl.card 0<br />
}}<br />
<br />
=== HDMI multi-channel PCM output does not work (Intel) ===<br />
<br />
As of Linux 3.1 multi-channel PCM output through HDMI with a Intel card (Intel Eaglelake, IbexPeak/Ironlake,SandyBridge/CougarPoint and IvyBridge/PantherPoint) is not yet supported. Support for it has been recently added and expected to be available in Linux 3.2. To make it work in Linux 3.1 you need to apply the following patches:<br />
<br />
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=76adaa34db407f174dd06370cb60f6029c33b465 drm: support routines for HDMI/DP ELD]<br />
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=e0dac65ed45e72fe34cc7ccc76de0ba220bd38bb drm/i915: pass ELD to HDMI/DP audio driver]<br />
<br />
=== HP TX2500 ===<br />
<br />
Add these 2 lines into {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-cmipci mpu_port=0x330 fm_port=0x388<br />
options snd-hda-intel index=0 model=toshiba position_fix=1<br />
<br />
options snd-hda-intel model=hp (works for tx2000cto)<br />
<br />
=== Skipping sound when playing MP3 ===<br />
<br />
If you have sound skipping when playing MP3 files and you have more then 2 speakers attached to your computer (i.e. more than 2 speaker system), run ''alsamixer'' and disable the channels for the speakers that you '''do not''' have (i.e. do not enable the sound for the center speaker if you do not have a center speaker.<br />
<br />
=== Using a USB headset and external USB sound cards ===<br />
<br />
If you are using a USB headset with ALSA you can try using {{AUR|asoundconf}} (currently only available from the [[AUR]]) to set the headset as the primary sound output. Before running make sure you have usb audio module enabled ({{ic|modprobe snd_usb_audio}}).<br />
<br />
# asoundconf is-active<br />
# asoundconf list<br />
# asoundconf set-default-card ''chosen soundcard''<br />
<br />
==== Crackling sound with USB devices ====<br />
<br />
If you experience crackling sound on USB devices, you can try tuning the {{ic|snd-usb-audio}} for minimal latency.<br />
<br />
Add this to your {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-usb-audio nrpacks=1<br />
<br />
source: http://alsa.opensrc.org/Usb-audio#Tuning_USB_devices_for_minimal_latencies<br />
<br />
==== Hot-plugging a USB sound card ====<br />
<br />
In order to automatically make a USB Sound Card the primary output device, when the card is plugged in, you can use the following udev rules (e.g. add the following two lines to {{ic|/etc/udev/rules.d/00-local.rules}} and reboot).<br />
<br />
{{bc|1=KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"<br />
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"}}<br />
<br />
=== Error 'Unknown hardware' appears after a kernel update===<br />
<br />
The following messages may be displayed during the start-up ALSA after the kernel update:<br />
Unknown hardware "foo" "bar" ...<br />
Hardware is initialized using a guess method<br />
/usr/bin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory)<br />
<br />
or:<br />
Found hardware: "HDA-Intel" "VIA VT1705" "HDA:11064397,18490397,00100000" "0x1849" "0x0397"<br />
Hardware is initialized using a generic method<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #1 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #2 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #25 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #26 (No such file or directory)<br />
<br />
Simply store ALSA mixer settings again:<br />
# alsactl -f /var/lib/alsa/asound.state store<br />
<br />
It may be necessary configure ALSA again with alsamixer<br />
<br />
=== HDA analyzer ===<br />
<br />
If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found [http://www.alsa-project.org/main/index.php/HDA_Analyzer at the ALSA wiki].<br />
Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.<br />
<br />
{{Note|<br />
* The script is done by such way that it is incompatible with Python 3 (which is now shipped with Arch Linux) but tries to use it. The workaround is: open "run.py", find all occurences of "python" (2 occurences - one on the first line, and the second on the last line) and replace them all by "python2".<br />
* The script requires root acces, but running it via su/sudo is bogus. Run it via {{ic|kdesu}} or {{ic|gksu}}.<br />
}}<br />
<br />
=== ALSA with SDL ===<br />
<br />
If you get no sound via SDL and ALSA cannot be chosen from the application. Try setting the environmental variable SDL_AUDIODRIVER to alsa.<br />
# export SDL_AUDIODRIVER=alsa<br />
<br />
=== Low sound workaround ===<br />
<br />
If you are facing low sound even after maxing out your speakers/headphones, you can give the softvol plugin a try. Add the following to {{ic|/etc/asound.conf}}.<br />
{{bc|<nowiki><br />
pcm.!default {<br />
type plug<br />
slave.pcm "softvol"<br />
}<br />
<br />
pcm.softvol {<br />
type softvol<br />
slave {<br />
pcm "dmix"<br />
}<br />
control {<br />
name "Pre-Amp"<br />
card 0<br />
}<br />
min_dB -5.0<br />
max_dB 20.0<br />
resolution 6<br />
}<br />
</nowiki>}}<br />
{{Note|You will probably have to restart the computer, as restarting the alsa daemon did not load the new configuration for me. Also, if the configuration does not work even after restarting, try changing {{ic|plug}} with {{ic|hw}} in the above configuration.}}<br />
<br />
After the changes are loaded successfully, you will see a {{ic|Pre-Amp}} section in alsamixer. You can adjust the levels there.<br />
{{Note|<br />
* Setting a high value for {{ic|Pre-Amp}} can cause sound distortion, so adjust it according to the level that suits you.<br />
* Some audio codecs may need to have settings adjusted in the HDA Analyzer ([[#HDA analyzer|see above]]) in order to achieve proper volume without distortion. Checking the HP option under widget control in the Playback Switch (Node[0x14] PIN in the ALC892 codec, for instance) can sometimes improve audio quality and volume significantly.<br />
}}<br />
<br />
=== Popping sound after resuming from suspension ===<br />
<br />
You might hear a popping sound after resuming the computer from suspension. This can be fixed by editing {{ic|/etc/pm/sleep.d/90alsa}} and removing the line that says {{ic|aplay -d 1 /dev/zero}}<br />
<br />
=== Mute after reboot ===<br />
<br />
After reboot, sound setting by alsamixer can not restore. Maybe you can restore by command : {{ic|sudo alsactl restore}}. Please check the {{ic|Auto-Mute}} toggle status in alsamixer : set {{ic|Enabled}} to {{ic|Disabled}}.<br />
<br />
=== Volume too low ===<br />
<br />
The first thing to try is run {{ic|alsamixer}} and try to increase the value of the sliders, possibly unmuting channels if necessary. Note that if you have many sliders, you may have to scroll to the right to see any missing sliders.<br />
<br />
If all the sliders are maxed out, and the volume is still too low, you can try running the script at http://www.alsa-project.org/hda-analyzer.py to reset your codec settings:<br />
<br />
$ wget http://www.alsa-project.org/hda-analyzer.py<br />
$ sudo python2 hda-analyzer.py<br />
<br />
(Note that the script assumes "python" refers to Python 2, but on a typical ArchLinux installation, "python" refers to Python 3. Therefore, you may need to edit the last line of the script from {{ic|os.system("python %s" % TMPDIR + '/' + FILES[0] + ' ' + ' '.join(sys.argv[1:]))}} to {{ic|os.system("python2 %s" % TMPDIR + '/' + FILES[0] + ' ' + ' '.join(sys.argv[1:]))}}.<br />
<br />
Close the analyzer, and when prompted as to whether you want to reset the codecs, say "yes".<br />
<br />
If the volume is *still* too low, run {{ic|alsamixer}} again: resetting the codecs may have caused new sliders to become enabled, and some of them may be set to a low value.<br />
<br />
===alsamixer F3 and F4 key issue ===<br />
In urxvt, the alsamixer quits when F2/F3/F4 key is pressed. F3/F4 is used to switch to playback/capture view. But in Xterm, F3/F4 could work normally and switch to playback/capture view. This abnormal behavior maybe caused by different escape codes sent by different term, see http://aperiodic.net/phil/archives/Geekery/term-function-keys.html for detail.<br />
<br />
== Example configurations ==<br />
<br />
See [[Advanced Linux Sound Architecture/Example Configurations]].<br />
<br />
== See also ==<br />
<br />
* [http://www.mjmwired.net/kernel/Documentation/sound/alsa/ALSA-Configuration.txt Advanced ALSA module configuration]<br />
* [http://alsa.opensrc.org/Main_Page Unofficial ALSA wiki]<br />
* [https://bbs.archlinux.org/viewtopic.php?id=36815 HOWTO: compile driver from svn]<br />
* [http://www.volkerschatz.com/noise/alsa.html A close look at ALSA: ALSA concept introduction]</div>Hongy19https://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture&diff=295006Advanced Linux Sound Architecture2014-01-30T11:11:14Z<p>Hongy19: /* See also */</p>
<hr />
<div>[[Category:Sound]]<br />
[[Category:Audio/Video]]<br />
[[cs:Advanced Linux Sound Architecture]]<br />
[[de:Alsa]]<br />
[[es:Advanced Linux Sound Architecture]]<br />
[[fa:ALSA]]<br />
[[fr:Alsa]]<br />
[[he:Advanced Linux Sound Architecture]]<br />
[[it:Advanced Linux Sound Architecture]]<br />
[[ja:Advanced Linux Sound Architecture]]<br />
[[nl:Advanced Linux Sound Architecture]]<br />
[[pt:Advanced Linux Sound Architecture]]<br />
[[ru:Advanced Linux Sound Architecture]]<br />
[[sk:Advanced Linux Sound Architecture]]<br />
[[th:Advanced Linux Sound Architecture]]<br />
[[tr:Gelişmiş_ses_mimarisi_(ALSA)]]<br />
[[zh-CN:Advanced Linux Sound Architecture]]<br />
{{Related articles start}}<br />
{{Related|Sound system}}<br />
{{Related|Disable PC Speaker Beep}}<br />
{{Related articles end}}<br />
The [[Wikipedia:Advanced Linux Sound Architecture|Advanced Linux Sound Architecture]] ('''ALSA''') is a Linux kernel component which replaced the original Open Sound System (OSSv3) for providing device drivers for sound cards. Besides the sound device drivers, '''ALSA''' also bundles a user space library for application developers who want to use driver features with a higher level API than direct interaction with the kernel drivers.<br />
<br />
{{Note|For an alternative sound environment, see the [[Open Sound System]] page.}}<br />
<br />
== Installation ==<br />
<br />
ALSA is included in the default Arch kernel as a set of modules, so installing it is not necessary.<br />
<br />
[[udev]] will automatically probe your hardware at boot, loading the corresponding kernel module for your audio card. Therefore, your sound should already be working, but upstream sources mute all channels by default.<br />
<br />
Users with a local login (at a virtual terminal or a display manager) have permission to play audio and change mixer levels. To allow this for a remote login, the user has to be [[Users and Groups#Group management|added]] to the {{ic|audio}} group. Membership in the {{ic|audio}} group also allows direct access to devices, which can lead to applications grabbing exclusive output (breaking software mixing) and breaks fast-user-switching, and multiseat. Therefore, adding a user to the {{ic|audio}} group is '''not''' recommended, unless you specifically need to[https://wiki.ubuntu.com/Audio/TheAudioGroup].<br />
<br />
=== User-space utilities ===<br />
<br />
[[pacman|Install]] the {{Pkg|alsa-utils}} package from the [[Official Repositories|official repositories]] which contains the {{ic|alsamixer}} user-space tool, which allows for configuration of the sound device from the console or terminal. Also install the {{Pkg|alsa-plugins}} package if you want [[#High quality resampling|high quality resampling]], [[#Upmixing/Downmixing|upmixing/downmixing]] and other advanced features.<br />
<br />
If you want OSS applications to work with dmix (software mixing), also install the {{Pkg|alsa-oss}} package. Load the {{ic|snd_seq_oss}}, {{ic|snd_pcm_oss}} and {{ic|snd_mixer_oss}} [[kernel modules]] to enable the OSS emulation modules.<br />
<br />
== Unmuting the channels ==<br />
<br />
The current version of ALSA installs with all channels '''muted by default'''. You will need to unmute the channels manually.<br />
<br />
It is easiest to use {{ic|alsamixer}} ncurses UI to accomplish this:<br />
<br />
$ alsamixer<br />
<br />
Alternatively, use {{ic|amixer}} from the command-line:<br />
<br />
$ amixer sset Master unmute<br />
<br />
In {{ic|alsamixer}}, the {{ic|MM}} label below a channel indicates that the channel is muted, and {{ic|00}} indicates that it is open.<br />
<br />
Scroll to the {{ic|Master}} and {{ic|PCM}} channels with the {{ic|←}} and {{ic|→}} keys and unmute them by pressing the {{ic|m}} key. Use the {{ic|↑}} key to increase the volume and obtain a value of {{ic|0}} dB gain. The gain can be found in the upper left next to the {{ic|Item:}} field. Higher values of gain will produce distorted sound.<br />
<br />
To get full 5.1 or 7.1 surround sound you likely need to unmute other channels such as Front, Surround, Center, LFE (subwoofer) and Side (these are the names of the channels with Intel HD Audio, they may vary with different hardware). Please take note that this will not automatically upmix stereo sources (like most music). In order to accomplish that, see [[#Upmixing/Downmixing]].<br />
<br />
To enable your microphone, switch to the Capture tab with {{ic|F4}} and enable a channel with {{ic|Space}}.<br />
<br />
Leave alsamixer by pressing {{ic|Esc}}.<br />
<br />
{{Note|<br />
* Some cards need to have digital output muted/turned off in order to hear analog sound. For the Soundblaster Audigy LS mute the IEC958 channel.<br />
* Some machines, (like the Thinkpad T61), have a Speaker channel which must be unmuted and adjusted as well.<br />
* Some machines, (like the Dell E6400) may also require the {{ic|Front}} and {{ic|Headphone}} channels to be unmuted and adjusted.<br />
* If your volume adjustments seems to be lost when you reboot, try running alsamixer as root. <br />
}}<br />
<br />
Next, test to see if sound works:<br />
<br />
$ speaker-test -c 2<br />
<br />
Change {{ic|-c}} to fit your speaker setup. Use {{ic|-c 8}} for 7.1, for instance:<br />
<br />
$ speaker-test -c 8<br />
<br />
If it does not work, proceed to [[#Configuration|Configuration]] and then [[#Troubleshooting|Troubleshooting]] to solve your problems.<br />
<br />
The {{Pkg|alsa-utils}} package includes {{ic|alsa-restore.service}} and {{ic|alsa-store.service}}, which are preconfigured to run at boot and shutdown respectively.<br />
For reference, ALSA stores its settings in {{ic|/var/lib/alsa/asound.state}}.<br />
<br />
== Configuration ==<br />
<br />
=== No sound in VirtualBox ===<br />
<br />
If you experience problems with VirtualBox, the following command might be helpful:<br />
<br />
{{hc|$ alsactl init|2=<nowiki><br />
<br />
Found hardware: "ICH" "SigmaTel STAC9700,83,84" "AC97a:83847600" "0x8086" "0x0000"<br />
Hardware is initialized using a generic method<br />
</nowiki>}}<br />
<br />
You might need to activate the ALSA output in your audio software as well.<br />
<br />
=== Set the default sound card ===<br />
<br />
If your sound card order changes on boot, you can specify their order in any file ending with {{ic|.conf}} in {{ic|/etc/modprobe.d}} ({{ic|/etc/modprobe.d/alsa-base.conf}} is suggested).<br />
For example, if you want your mia sound card to be #0:<br />
<br />
{{hc|/etc/modprobe.d/alsa-base.conf|2=<nowiki><br />
options snd slots=snd_mia,snd_hda_intel<br />
options snd_mia index=0<br />
options snd_hda_intel index=1<br />
</nowiki>}}<br />
<br />
Use {{ic|<nowiki>$ cat /proc/asound/modules</nowiki>}} to get the loaded sound modules and their order. This list is usually all that is needed for the loading order. Use {{ic|<nowiki>$ lsmod | grep snd</nowiki>}} to get a devices & modules list. This configuration assumes you have one mia sound card using {{ic|snd_mia}} and one (e.g. onboard) card using {{ic|snd_hda_intel}}.<br />
<br />
You can also provide an index of {{ic|-2}} to instruct ALSA to never use a card as the primary one. Distributions such as Linux Mint and Ubuntu use the following settings to avoid USB and other "abnormal" drivers from getting index {{ic|0}}:<br />
<br />
{{hc|/etc/modprobe.d/alsa-base.conf|2=<br />
options bt87x index=-2<br />
options cx88_alsa index=-2<br />
options saa7134-alsa index=-2<br />
options snd-atiixp-modem index=-2<br />
options snd-intel8x0m index=-2<br />
options snd-via82xx-modem index=-2<br />
options snd-usb-audio index=-2<br />
options snd-usb-caiaq index=-2<br />
options snd-usb-ua101 index=-2<br />
options snd-usb-us122l index=-2<br />
options snd-usb-usx2y index=-2<br />
options snd-pcsp index=-2<br />
options snd-usb-audio index=-2<br />
}}<br />
<br />
These changes require a system reboot.<br />
<br />
==== Select the default PCM via environment variable ====<br />
<br />
In your configuration file, preferably global, add:<br />
pcm.!default {<br />
type plug<br />
slave.pcm {<br />
@func getenv<br />
vars [ ALSAPCM ]<br />
default "hw:Audigy2"<br />
}<br />
}<br />
<br />
You need to replace the default line with the name of your card (in the example is {{ic|Audigy2}}). You can get the names with {{ic|aplay -l}} or you can also use PCMs like '''surround51'''. But if you need to use the microphone it is a good idea to select full-duplex PCM as default.<br />
<br />
Now you can start programs selecting the sound card just changing the environment variable {{ic|ALSAPCM}}. It works fine for all program that do not allow to select the card, for the others ensure you keep the default card.<br />
For example, assuming you wrote a downmix PCM called '''mix51to20''' you can use it with {{ic|mplayer}} using the commandline {{ic|ALSAPCM&#61;mix51to20 mplayer example_6_channel.wav}}<br />
<br />
==== Alternative method ====<br />
<br />
First you will have to find out the card and device id that you want to set as the default by running {{ic|aplay -l}}:<br />
<br />
{{hc|$ aplay -l|2=<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: CONEXANT Analog [CONEXANT Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 1: Conexant Digital [Conexant Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 1: JamLab [JamLab], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 2: Audio [Altec Lansing XT1 - USB Audio], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
}}<br />
<br />
For example, the last entry in this list has the card ID 2 and the device ID 0. To set this card as the default, you can either use the system-wide file {{ic|/etc/asound.conf}} or the user-specific file {{ic|~/.asoundrc}}. You may have to create the file if it does not exist. Then insert the following options with the corresponding card.<br />
{{bc|<br />
pcm.!default {<br />
type hw<br />
card 2<br />
}<br />
<br />
ctl.!default {<br />
type hw <br />
card 2<br />
}<br />
}}<br />
<br />
{{Note|For the Asus U32U serie it seems that card should be set to 1 for both pcm and ctl.}}<br />
<br />
The 'pcm' options affect which card and device will be used for audio playback while the 'ctl' option affects which card is used by control utilities like alsamixer .<br />
<br />
The changes should take effect as soon as you (re-)start an application (MPlayer etc.). You can also test with a command like ''aplay''.<br />
<br />
$ aplay -D default ''your_favourite_sound.wav''<br />
<br />
If you receive an error regarding your asound configuration, check the [http://www.alsa-project.org/main/index.php/Asoundrc#The_default_plugin upstream documentation] for possible changes to the config file format.<br />
<br />
=== Making sure the sound modules are loaded ===<br />
<br />
You can assume that udev will autodetect your sound properly. You can check this with the command<br />
<br />
{{hc|<nowiki>$ lsmod | grep '^snd' | column -t</nowiki>|2=<br />
snd_hda_codec_hdmi 22378 4<br />
snd_hda_codec_realtek 294191 1<br />
snd_hda_intel 21738 1<br />
snd_hda_codec 73739 3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel<br />
snd_hwdep 6134 1 snd_hda_codec<br />
snd_pcm 71032 3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec<br />
snd_timer 18992 1 snd_pcm<br />
snd 55132 9 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer<br />
snd_page_alloc 7017 2 snd_hda_intel,snd_pcm<br />
}}<br />
<br />
If the output looks similar, your sound drivers have been successfully autodetected.<br />
{{Note|Since {{ic|udev>&#61;171}}, the OSS emulation modules ({{ic|snd_seq_oss, snd_pcm_oss, snd_mixer_oss}}) are not loaded by default: [[kernel modules#Loading|Load them manually]] if they are needed.}}<br />
<br />
You might also want to check the directory {{ic|/dev/snd/}} for the right device files:<br />
<br />
{{hc|$ ls -l /dev/snd|2=<nowiki><br />
total 0<br />
crw-rw---- 1 root audio 116, 0 Apr 8 14:17 controlC0<br />
crw-rw---- 1 root audio 116, 32 Apr 8 14:17 controlC1<br />
crw-rw---- 1 root audio 116, 24 Apr 8 14:17 pcmC0D0c<br />
crw-rw---- 1 root audio 116, 16 Apr 8 14:17 pcmC0D0p<br />
crw-rw---- 1 root audio 116, 25 Apr 8 14:17 pcmC0D1c<br />
crw-rw---- 1 root audio 116, 56 Apr 8 14:17 pcmC1D0c<br />
crw-rw---- 1 root audio 116, 48 Apr 8 14:17 pcmC1D0p<br />
crw-rw---- 1 root audio 116, 1 Apr 8 14:17 seq<br />
crw-rw---- 1 root audio 116, 33 Apr 8 14:17 timer<br />
</nowiki>}}<br />
<br />
{{Note|If requesting help on IRC or the forums, please post the output of the above commands.}}<br />
<br />
If you have at least the devices '''controlC0''' and '''pcmC0D0p''' or similar, then your sound modules have been detected and loaded properly.<br />
<br />
If this is not the case, your sound modules have not been detected properly. To solve this, you can try loading the modules manually:<br />
<br />
* Locate the module for your sound card: [http://www.alsa-project.org/main/index.php/Matrix:Main ALSA Soundcard Matrix] The module will be prefixed with 'snd-' (for example: {{ic|snd-via82xx}}).<br />
* [[Kernel modules#Loading|Load the module]].<br />
* Check for the device files in {{ic|/dev/snd}} (see above) and/or try if {{ic|alsamixer}} or {{ic|amixer}} have reasonable output.<br />
* Configure {{ic|snd-NAME-OF-MODULE}} and {{ic|snd-pcm-oss}} to [[Kernel modules#Loading|load at boot]].<br />
<br />
=== Getting SPDIF output ===<br />
<br />
(from gralves from the Gentoo forums)<br />
* In GNOME Volume Control, under the Options tab, change the IEC958 to PCM. This option can be enabled in the preferences.<br />
* If you do not have GNOME Volume Control installed,<br />
** Edit {{ic|/var/lib/alsa/asound.state}}. This file is where alsasound stores your mixer settings.<br />
** Find a line that says: 'IEC958 Playback Switch'. Near it you will find a line saying {{ic|value:false}}. Change it to {{ic|value:true}}.<br />
** Now find this line: 'IEC958 Playback AC97-SPSA'. Change its value to 0.<br />
** Restart ALSA.<br />
<br />
Alternative way to enable SPDIF output automatically on login (tested on SoundBlaster Audigy):<br />
<br />
* add following lines to {{ic|/etc/rc.local}}:<br />
# Use COAX-digital output<br />
amixer set 'IEC958 Optical' 100 unmute<br />
amixer set 'Audigy Analog/Digital Output Jack' on<br />
<br />
You can see the name of your card's digital output with:<br />
$ amixer scontrols<br />
<br />
=== System-wide equalizer ===<br />
<br />
==== Using AlsaEqual (provides UI) ====<br />
<br />
Install {{AUR|alsaequal}} from the [[AUR]].<br />
<br />
{{Note | If you have a x86_64-system and are using a 32bit-flashplugin the sound in flash will not work. Either you have to disable alsaequal or build alsaequal for 32bit.}}<br />
<br />
After installing the package, insert the following into your ALSA configuration file ({{ic|~/.asoundrc}} or {{ic|/etc/asound.conf}}):<br />
<br />
ctl.equal {<br />
type equal;<br />
}<br />
<br />
pcm.plugequal {<br />
type equal;<br />
# Modify the line below if you do not<br />
# want to use sound card 0.<br />
#slave.pcm "plughw:0,0";<br />
#by default we want to play from more sources at time:<br />
slave.pcm "plug:dmix";<br />
}<br />
#pcm.equal {<br />
# If you do not want the equalizer to be your<br />
# default soundcard comment the following<br />
# line and uncomment the above line. (You can<br />
# choose it as the output device by addressing<br />
# it with specific apps,eg mpg123 -a equal 06.Back_In_Black.mp3)<br />
pcm.!default {<br />
type plug;<br />
slave.pcm plugequal;<br />
}<br />
<br />
And you are ready to change your equalizer using command<br />
$ alsamixer -D equal<br />
<br />
Note that configuration file is different for each user (until not specified else) it is saved in {{ic|~/.alsaequal.bin}}.<br />
so if you want to use AlsaEqual with [[mpd]] or another software running under different user, you can configure it using<br />
# su mpd -c 'alsamixer -D equal'<br />
or for example, you can make a symlink to your {{ic|.alsaequal.bin}} in his home...<br />
<br />
===== Managing AlsaEqual states =====<br />
<br />
Install {{AUR|alsaequal-mgr}} from the [[AUR]] (or alternatively from [http://xyne.archlinux.ca/repos/ Xyne's repos]).<br />
<br />
Configure the equalizer as usual with <br />
$ alsamixer -D equal<br />
<br />
When you are satisfied with the state, you may give it a name ("foo" in this example) and save it:<br />
$ alsaequal-mgr save foo<br />
<br />
The state "foo" can then be restored at a later time with<br />
$ alsaequal-mgr load foo<br />
<br />
You can thus create different equalizer states for games, movies, music genres, VoIP apps, etc. and reload them as necessary.<br />
<br />
See the [http://xyne.archlinux.ca/projects/alsaequal-mgr/ project page] and the help message for more options.<br />
<br />
==== Using mbeq ====<br />
<br />
{{Note|This method requires the use of a ladspa plugin which might use quite a bit of CPU when sound plays. In addition, this was made with stereophonic sound (e.g. headphones) in mind.}}<br />
<br />
Install the {{Pkg|alsa-plugins}}, {{Pkg|ladspa}} and {{Pkg|swh-plugins}} packages if you do not already have them.<br />
<br />
* If you have not already created either an {{ic|~/.asoundrc}} or a {{ic|/etc/asound.conf}} file, then create either one and insert the following:<br />
<br />
{{hc|/etc/asound.conf|2=<nowiki>pcm.eq {<br />
type ladspa<br />
<br />
# The output from the EQ can either go direct to a hardware device<br />
# (if you have a hardware mixer, e.g. SBLive/Audigy) or it can go<br />
# to the software mixer shown here.<br />
#slave.pcm "plughw:0,0"<br />
slave.pcm "plug:dmix"<br />
<br />
# Sometimes you may need to specify the path to the plugins,<br />
# especially if you have just installed them. Once you have logged<br />
# out/restarted this should not be necessary, but if you get errors<br />
# about being unable to find plugins, try uncommenting this.<br />
#path "/usr/lib/ladspa"<br />
<br />
plugins [<br />
{<br />
label mbeq<br />
id 1197<br />
input {<br />
#this setting is here by example, edit to your own taste<br />
#bands: 50hz, 100hz, 156hz, 220hz, 311hz, 440hz, 622hz, 880hz, 1250hz, 1750hz, 25000hz,<br />
#50000hz, 10000hz, 20000hz<br />
controls [ -5 -5 -5 -5 -5 -10 -20 -15 -10 -10 -10 -10 -10 -3 -2 ]<br />
}<br />
}<br />
]<br />
}<br />
<br />
# Redirect the default device to go via the EQ - you may want to do<br />
# this last, once you are sure everything is working. Otherwise all<br />
# your audio programs will break/crash if something has gone wrong.<br />
<br />
pcm.!default {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
<br />
# Redirect the OSS emulation through the EQ too (when programs are running through "aoss")<br />
<br />
pcm.dsp0 {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
</nowiki>}}<br />
<br />
* You should be good to go (if not, ask in the forum).<br />
<br />
== High quality resampling ==<br />
<br />
When software mixing is enabled, ALSA is forced to resample everything to the same frequency (48000 by default when supported). dmix uses a poor resampling algorithm which produces noticeable sound quality loss.<br />
<br />
Install {{Pkg|alsa-plugins}} and {{Pkg|libsamplerate}}.<br />
<br />
Change the default rate converter to libsamplerate:<br />
<br />
{{hc|/etc/asound.conf|defaults.pcm.rate_converter "samplerate_best"}}<br />
<br />
or:<br />
<br />
{{hc|~/.asoundrc|defaults.pcm.rate_converter "samplerate_best"}}<br />
<br />
'''samplerate_best''' offers the best sound quality, but you need a decent CPU to be able to use it as it requires a lot of CPU cycles for real-time resampling. You may also need to adjust buffer_size in your dmix settings from the basic 4096 to 8192 or 16384. There are other algorithms available ('''samplerate''', etc.) but they may not provide much of an improvement over the default resampler.<br />
<br />
{{Warning|On some systems, enabling samplerate_best may cause a problem where you get no sound from flashplayer.}}<br />
<br />
== Upmixing/downmixing ==<br />
<br />
=== Upmixing ===<br />
<br />
In order for stereo sources like music to be able to saturate a 5.1 or 7.1 sound system, you need to use upmixing. In darker days this used to be tricky and error prone but nowadays plugins exist to easily take care of this task. We will use the {{ic|upmix}} plugin, included in {{Pkg|alsa-plugins}}.<br />
<br />
Then add the following to your ALSA configuration file of choice (either {{ic|/etc/asound.conf}} or {{ic|~/.asoundrc}}):<br />
pcm.upmix71 {<br />
type upmix<br />
slave.pcm "surround71"<br />
delay 15<br />
channels 8<br />
}<br />
<br />
You can easily change this example for 7.1 upmixing to 5.1 or 4.0.<br />
<br />
This adds a new pcm that you can use for upmixing. If you want all sound sources to go through this pcm, add it as a default below the previous definition like so:<br />
<br />
pcm.!default "plug:upmix71"<br />
<br />
The plugin automatically allows multiple sources to play through it without problems so setting is as a default is actually a safe choice. <br />
If this is not working, you have to setup your own dmixer for the upmixing PCM like this: <br />
pcm.dmix6 {<br />
type asym<br />
playback.pcm {<br />
type dmix<br />
ipc_key 567829<br />
slave {<br />
pcm "hw:0,0"<br />
channels 6<br />
}<br />
}<br />
}<br />
<br />
and use "dmix6" instead of "surround71". <br />
If you experience skipping or distorted sound, consider increasing the buffer_size (to 32768, for example) or use a [[#High quality resampling|high quality resampler]].<br />
<br />
=== Downmixing ===<br />
<br />
If you want to downmix sources to stereo because you, for instance, want to watch a movie with 5.1 sound on a stereo system, use the {{ic|vdownmix}} plugin, included in {{Pkg|alsa-plugins}}..<br />
<br />
Again, in your configuration file, add this:<br />
<br />
pcm.!surround51 {<br />
type vdownmix<br />
slave.pcm "default"<br />
}<br />
pcm.!surround40 {<br />
type vdownmix<br />
slave.pcm "default"<br />
}<br />
<br />
{{Note|1=This might not be enough to make downmixing working, see [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541786]. So, you might also need to add {{ic|pcm.!default "plug:surround51"}} or {{ic|pcm.!default "plug:surround40"}}. Only one {{ic|vdownmix}} plug can be used; if you have 7.1 channels, you will need to use {{ic|surround71}} instead the configuration above. A good example, which includes a configuration that makes both {{ic|vdownmix}} and {{ic|dmix}} working, can be found [https://bbs.archlinux.org/viewtopic.php?id=167275 here].}}<br />
<br />
== Mixing ==<br />
<br />
=== Software mixing (dmix) ===<br />
<br />
{{Note|For ALSA 1.0.9rc2 and higher on analog sound outputs you do not need to setup dmix. Dmix is enabled as default for soundcards which do not support hardware mixing.}}<br />
<br />
If that does not work however, it is a matter of simply creating a .asoundrc file in your home folder with the following contents.<br />
<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
<br />
This should enable software mixing and allows more than one application to make use of the soundcard. If not, try replacing all /etc/asound.conf content with the above.<br />
<br />
For a digital sound output such as S/PDIF, the ALSA package still does not enable dmix by default. Thus, the dmix configuration above can be used to enable dmix for S/PDIF devices.<br />
<br />
See [[#Troubleshooting]] for common problems and solutions.<br />
<br />
=== Hardware mixing ===<br />
<br />
==== Support ====<br />
<br />
If you have an audio chipset that supports mixing in hardware, then no configuration is necessary. Almost every onboard audio chipset does not support hardware mixing, and requires mixing to be done in software (see above). Many sound cards do support hardware mixing, and the ones best supported on Linux are listed below:<br />
<br />
* Creative SoundBlaster Live! (5.1 model)<br />
* Creative SoundBlaster Audigy (some models)<br />
* Creative SoundBlaster Audidy 2 (ZS models)<br />
* Creative SoundBlaster Audigy 4 (Pro models)<br />
<br />
{{Note|<br />
* The low end variants of above cards, (Audigy SE, Audigy 2 NX, SoundBlaster Live! 24bit and SoundBlaster Live! 7.1) '''do not''' support hardware mixing as they use other chips.<br />
* The onboard VIA8237 chip supports 4-stream hardware mixing, however, it does only 3 for some motherboards (the 4th makes no sound) or is just broken. Even if it works, the quality is not good compared to other solutions.<br />
}}<br />
<br />
==== Fixes ====<br />
<br />
If you are using 64-bit Arch and the Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02), you can get sound working for Enemy Territory with the following:<br />
echo "et.x86 0 0 direct" > /proc/asound/card0/pcm0p/oss<br />
echo "et.x86 0 0 disable" > /proc/asound/card0/pcm0c/oss<br />
<br />
== Troubleshooting ==<br />
<br />
=== Sound skipping while using dynamic frequency scaling ===<br />
<br />
Some combinations of ALSA drivers and chipsets may cause audio from all sources to skip when used in combination with a dynamic frequency scaling governor such as {{ic|ondemand}} or {{ic|conservative}}. Currently, the solution is to switch back to the {{ic|performance}} governor.<br />
<br />
Refer to the [[CPU Frequency Scaling]] for more information.<br />
<br />
=== Problems with availability to only one user at a time ===<br />
<br />
You might find that only one user can use the dmixer at a time. This is probably ok for most, but for those who run [[mpd]] as a separate user this poses a problem. When mpd is playing a normal user cannot play sounds though the dmixer. While it's quite possible to just run mpd under a user's login account, another solution has been found. Adding the line {{ic|ipc_key_add_uid 0}} to the {{ic|pcm.dmixer}} block disables this locking. The following is a snippet of the {{ic|asound.conf}}, the rest is the same as above.<br />
...<br />
pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid 0<br />
ipc_perm 0660<br />
slave {<br />
...<br />
<br />
=== Simultaneous playback problems ===<br />
<br />
If you are having problems with simultaneous playback, and if [[PulseAudio]] is installed (i.e. by [[GNOME]]), its default configuration is set to "hijack" the soundcard. Some users of ALSA may not want to use [[PulseAudio]] and are quite content with their current ALSA settings. One fix is to edit {{ic|/etc/asound.conf}} and comment out the following lines:<br />
# Use PulseAudio by default<br />
#pcm.!default {<br />
# type pulse<br />
# fallback "sysdefault"<br />
# hint {<br />
# show on<br />
# description "Default ALSA Output (currently PulseAudio Sound Server)"<br />
# }<br />
#}<br />
<br />
Commenting the following out also may help:<br />
#ctl.!default {<br />
# type pulse<br />
# fallback "sysdefault"<br />
#}<br />
<br />
This may be a much simpler solution than completely uninstalling [[PulseAudio]].<br />
<br />
Effectively, here is an example of a working {{ic|/etc/asound.conf}}:<br />
{{bc|<nowiki>pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid 0<br />
ipc_perm 0660<br />
}<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}</nowiki><br />
}}<br />
<br />
{{Note|This {{ic|/etc/asound.conf}} file was intended for and used successfully with a global [[MPD]] configuration. See [[Alsa#Problems_with_Availability_to_Only_One_User_at_a_Time|this section]] on multiple users}}<br />
<br />
=== Random lack of sound on startup ===<br />
<br />
You can quickly test sound by running {{ic|speaker-test}}. If there is no sound, the error message might look something like<br />
<br />
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave<br />
Playback open error: -16<br />
Device or resource busy<br />
<br />
If you have no sound on startup, this may be because your system has multiple sound cards, and their order may sometimes change on startup. If this is the case, try [[#Set the default sound card|setting the default sound card]].<br />
<br />
If you use mpd and the configuration tips above do not work for you, try [http://mpd.wikia.com/wiki/Configuration#ALSA_MPD_software_volume_control reading this] instead.<br />
<br />
==== Timidity ====<br />
<br />
[[Timidity]] can be the cause of missing audio. Try running:<br />
<br />
$ systemctl status timidity<br />
<br />
If it failed, try {{ic|# killall -9 timidity}}. If this solves the issue, then you should disable the timidity daemon to be started at boot.<br />
<br />
=== Specific program problems ===<br />
<br />
For other programs who insist on their own audio setup, e.g., XMMS or MPlayer, you would need to set their specific options.<br />
<br />
For MPlayer, open up a [[MPlayer#Configuration|configuration file]] and add the following line:<br />
ao=alsa<br />
For ''mpv'' append the same line in one of its [[mpv#Configuration|configuration files]].<br />
<br />
For XMMS/Beep Media Player, go into their options and make sure the sound driver is set to Alsa, not oss.<br />
<br />
To do this in XMMS:<br />
* Open XMMS<br />
** Options > Preferences.<br />
** Choose the ALSA output plugin.<br />
<br />
For applications which do not provide a ALSA output, you can use aoss from the alsa-oss package. To use aoss, when you run the program, prefix it with {{ic|aoss}}, eg:<br />
aoss realplay<br />
<br />
pcm.!default{ ... } doesnt work for me anymore. but this does:<br />
pcm.default pcm.dmixer<br />
<br />
=== Model settings ===<br />
<br />
Although Alsa detects your soundcard through the BIOS at times Alsa may not be able to recognize your [http://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt model type]. The soundcard chip can be found in {{ic|alsamixer}} (e.g. ALC662) and the model can be set in {{ic|/etc/modprobe.d/modprobe.conf}} or {{ic|/etc/modprobe.d/sound.conf}}. For example:<br />
<br />
options snd-hda-intel model=MODEL<br />
<br />
There are other model settings too. For most cases Alsa defaults will do. If you want to look at more specific settings for your soundcard take a look at the [http://bugtrack.alsa-project.org/main/index.php/Matrix:Main Alsa Soundcard List] find your model, then Details, then look at the "Setting up modprobe..." section. Enter these values in {{ic|/etc/modprobe.d/modprobe.conf}}. For example, for an Intel AC97 audio:<br />
<br />
{{bc|<br />
# ALSA portion<br />
alias char-major-116 snd<br />
alias snd-card-0 snd-intel8x0<br />
# module options should go here<br />
<br />
# OSS/Free portion<br />
alias char-major-14 soundcore<br />
alias sound-slot-0 snd-card-0<br />
<br />
# card #1<br />
alias sound-service-0-0 snd-mixer-oss<br />
alias sound-service-0-1 snd-seq-oss<br />
alias sound-service-0-3 snd-pcm-oss<br />
alias sound-service-0-8 snd-seq-oss<br />
alias sound-service-0-12 snd-pcm-oss<br />
}}<br />
<br />
=== Conflicting PC speaker ===<br />
<br />
If you are sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try adding the following line to {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-NAME-OF-MODULE ac97_quirk=0<br />
<br />
The above fix has been observed to work with {{ic|via82xx}}<br />
options snd-NAME-OF-MODULE ac97_quirk=1<br />
The above fix has been reported to work with {{ic|snd_intel8x0}}<br />
<br />
=== No microphone input ===<br />
<br />
In alsamixer, make sure that all the volume levels are up under recording, and that CAPTURE is toggled active on the microphone (e.g. Mic, Internal Mic) and/or on Capture (in alsamixer, select these items and press space). Try making positive Mic Boost and raising Capture and Digital levels higher; this make make static or distortion, but then you can adjust them back down once you are hearing ''something'' when you record<br />
<br />
As the pulseaudio wrapper is shown as "default" in alsamixer, you may have to press F6 to select your actual soundcard first. You may also need to enable and increase the volume of Line-in in the Playback section.<br />
<br />
To test the microphone, run these commands (see arecord's man page for further information):<br />
$ arecord -d 5 test-mic.wav<br />
$ aplay test-mic.wav<br />
<br />
If all fails, you may want to eliminate hardware failure by testing the microphone with a different device.<br />
<br />
For at least some computers, muting a microphone (MM) simply means its input does not go immediately to the speakers. It still receives input.<br />
<br />
Many Dell laptops need "-dmic" to be appended to the model name in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-hda-intel model=dell-m6-dmic<br />
<br />
Some programs use try to use OSS as the main input software. If you have enabled the {{ic|snd_pcm_oss}}, {{ic|snd_mixer_oss}} or {{ic|snd_seq_oss}} [[kernel modules]] previously (they are not loaded by default), try unloading them.<br />
<br />
See also:<br />
* http://www.alsa-project.org/main/index.php/SoundcardTesting<br />
* http://alsa.opensrc.org/Record_from_mic<br />
<br />
=== Crackling in microphone ===<br />
<br />
If you're getting a crackling or popping from your microphone that can't be resolved with ALSA settings or cleaning your microphone jack, try adding the following line to {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-hda-intel model=MODEL position_fix=3<br />
<br />
This option will fix crackling on pure Alsa, but will cause issues to pulseaudio. To let Pulse use these settings effectively, edit {{ic|/etc/pulse/default.pa}} and find this line:<br />
<br />
load-module module-udev-detect<br />
<br />
And change it to this:<br />
<br />
load-module module-udev-detect tsched=0<br />
<br />
See the DMA-Position Problem in the kernel docs.<br />
<br />
* [https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio.txt HD-audio Kernel Docs]<br />
<br />
=== Setting the default microphone/capture device ===<br />
<br />
Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes a problem if your microphone is on a separate device (e.g. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your {{ic|~/.asoundrc}} file to include the following:<br />
<br />
pcm.usb<br />
{<br />
type hw<br />
card U0x46d0x81d<br />
}<br />
<br />
pcm.!default<br />
{<br />
type asym<br />
playback.pcm<br />
{<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
capture.pcm<br />
{<br />
type plug<br />
slave.pcm "usb"<br />
}<br />
}<br />
<br />
Replace "U0x46d0x81d" with your capture device's card name in ALSA. You can use {{ic|arecord -L}} to list all the capture devices detected by ALSA.<br />
<br />
=== Internal microphone not working ===<br />
<br />
First make sure all the volume levels are up under recording in alsamixer. In my case adding the following option to {{ic|/etc/sound.conf}} and reloading the snd-* module produced a new volume setting called Capture which was capturing for the internal mic. For eg, for snd-hda-intel add<br />
<br />
options snd-hda-intel enable_msi=1<br />
<br />
Then reload the module (as below), up the recording volume of Capture and then test.<br />
<br />
# rmmod snd-hda-intel && modprobe snd-hda-intel<br />
<br />
=== No sound with onboard Intel sound card ===<br />
<br />
There may be a problem with two conflicting modules loaded, namely {{ic|snd_intel8x0}} and {{ic|snd_intel8x0m}}. In this case, blacklist snd_intel8x0m:<br />
<br />
{{hc|/etc/modprobe.d/modprobe.conf|blacklist snd_intel8x0m}}<br />
<br />
''Muting'' the "External Amplifier" in {{ic|alsamixer}} or {{ic|amixer}} may also help. See [http://alsa.opensrc.org/Intel8x0#Dell_Inspiron_8600_.28and_probably_others.29 the ALSA wiki].<br />
<br />
Unmuting the "Mix" setting in the mixer might help, also.<br />
<br />
=== No headphone sound with onboard Intel sound card ===<br />
<br />
With '''Intel Corporation 82801 I (ICH9 Family) HD Audio Controller''' on laptop, you may need to add this line to modprobe or sound.conf:<br />
<br />
options snd-hda-intel model=''model''<br />
<br />
Where ''model'' is any one of the following (in order of possibility to work, but not merit):<br />
<br />
* dell-vostro<br />
* olpc-xo-1_5<br />
* laptop<br />
* dell-m6<br />
* laptop-hpsense<br />
<br />
{{Note|It may be necessary to put this "options" line below (after) any "alias" lines about your card.}}<br />
<br />
You can see all the available models in the kernel documentation. For example [http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/sound/alsa/HD-Audio-Models.txt here], but check that it is the correct version of that document for your kernel version.<br />
<br />
A list of available models is also available [http://www.mjmwired.net/kernel/Documentation/sound/alsa/HD-Audio-Models.txt here]. To know your chip name type the following command (with * being corrected to match your files). Note that some chips could have been renamed and do not directly match the available ones in the file.<br />
<br />
$ grep Codec /proc/asound/card*/codec*<br />
<br />
Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it is either your headphones or your mic. Please report to ALSA if you are affected by this bug.<br />
<br />
And also, if you have problems getting beeps to work (pcspkr):<br />
<br />
options snd-hda-intel model=$model enable=1 index=0<br />
<br />
=== No sound when S/PDIF video card is installed ===<br />
<br />
Discover available modules and their order:<br />
{{hc|$ cat /proc/asound/modules|<br />
0 snd_hda_intel<br />
1 snd_ca0106<br />
}}<br />
<br />
Disable the undesired video card audio codec in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
# /etc/modprobe.d/modprobe.conf<br />
#<br />
install snd_hda_intel /bin/false<br />
<br />
If both devices use the same module then we can use the *enable* parameter from snd-hda-intel module, it's an array of booleans that can enable/disable the desired sound card.<br />
<br />
e.g <br />
options snd-hda-intel enable=1,0<br />
the following gives you the list of cards<br />
cat /proc/asound/cards<br />
<br />
=== Poor sound quality or clipping ===<br />
<br />
If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0.<br />
<br />
If snd-usb-audio driver has been loaded, you could try to enable {{ic|softvol}} in {{ic|/etc/asound.conf}} file. Example configuration for the first audio device:<br />
pcm.!default {<br />
type plug<br />
slave.pcm "softvol"<br />
}<br />
pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
slave {<br />
pcm "hw:0"<br />
period_time 0<br />
period_size 4096<br />
buffer_size 131072<br />
rate 50000<br />
}<br />
bindings {<br />
0 0<br />
1 1<br />
}<br />
}<br />
pcm.dsnooper {<br />
type dsnoop<br />
ipc_key 1024<br />
slave {<br />
pcm "hw:0"<br />
channels 2<br />
period_time 0<br />
period_size 4096<br />
buffer_size 131072<br />
rate 50000<br />
}<br />
bindings {<br />
0 0<br />
1 1<br />
}<br />
}<br />
pcm.softvol {<br />
type softvol<br />
slave { pcm "dmixer" }<br />
control {<br />
name "Master"<br />
card 0<br />
}<br />
}<br />
ctl.!default {<br />
type hw<br />
card 0<br />
}<br />
ctl.softvol {<br />
type hw<br />
card 0<br />
}<br />
ctl.dmixer {<br />
type hw<br />
card 0<br />
}<br />
<br />
=== Pops when starting and stopping playback===<br />
<br />
Some modules (e.g. snd-ac97-codec and snd-hda-intel) can power off your sound card when not in use. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when move the slider volume, or open and close windows (KDE4). If you find this annoying try {{ic|modinfo snd-MY-MODULE}}, and look for a module option that adjusts or disables this feature.<br />
<br />
''Example'': disable the power saving mode and solve cracking sound trough speakers problem, using snd-hda-intel add in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-hda-intel power_save=0<br />
or:<br />
options snd-hda-intel power_save=0 power_save_controller=N<br />
<br />
You can also try it with {{ic|1=modprobe snd-hda-intel power_save=0}} before.<br />
<br />
You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high).<br />
<br />
''Example:'' on an onboard VIA VT1708S (using the snd-hda-intel module) these cracks occured even though 'power_save' was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the problem.<br />
<br />
Source: https://www.kernel.org/doc/Documentation/sound/alsa/powersave.txt<br />
<br />
If you use a laptop, pm-utils will change {{ic|power_save}} back to 1 when you go onto battery power even if you disable power saving in {{ic|/etc/modprobe.d}}. Disable this for pm-utils by disabling the script that makes the change (see [[Pm-utils#Disabling_a_hook|Disabling a hook]] for more information):<br />
# touch /etc/pm/power.d/intel-audio-powersave<br />
<br />
=== S/PDIF output does not work ===<br />
<br />
If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running<br />
# iecset audio on<br />
<br />
You can also put this command in an enabled [[systemd]] service as it sometimes it may stop working after a reboot.<br />
<br />
=== HDMI output does not work ===<br />
<br />
The procedure described below can be used to test HDMI audio. Before proceeding, make sure you have enabled and unmuted the output with {{ic|alsamixer}}.<br />
<br />
{{Note|If you are using an ATI card and linux kernel &gt;&#61;3.0, a necessary kernel module is disabled by default. See [[ATI#HDMI_Audio]].}}<br />
<br />
Connect your PC to the Display via HDMI cable and enable the display with a tool such as {{ic|xrandr}} or {{ic|arandr}}. For example:<br />
<br />
$ xrandr # list outputs<br />
$ xrandr --output DVI-D_1 --mode 1024x768 --right-of PANEL # enable output<br />
<br />
Use {{ic|aplay -l}} to get the discover the card and device number. For example:<br />
<br />
$ aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: SB [HDA ATI SB], device 0: ALC892 Analog [ALC892 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: SB [HDA ATI SB], device 1: ALC892 Digital [ALC892 Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
'''card 1''': Generic [HD-Audio Generic], '''device 3''': HDMI 0 [HDMI 0]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
<br />
Send sound to the device. Following the example in the previous step, you would send sound to card 1, device 3:<br />
<br />
$ aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Center.wav<br />
<br />
If aplay does not output any errors, but still no sound is heared, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding. In particular, if you are using a standalone window manager (don’t know about Gnome or KDE), you may need to have some sound playing ''while'' plugging in the HDMI cable.<br />
<br />
If the test is successful, create or edit your {{ic|~/.asoundrc}} file to set HDMI as the default audio device.<br />
<br />
{{hc|~/.asoundrc|<br />
pcm.!default {<br />
type hw<br />
card 0<br />
device 3<br />
}<br />
}}<br />
<br />
Or you above config does not work try:<br />
{{hc|~/.asoundrc|<br />
defaults.pcm.card 0<br />
defaults.pcm.device 3<br />
defaults.ctl.card 0<br />
}}<br />
<br />
=== HDMI multi-channel PCM output does not work (Intel) ===<br />
<br />
As of Linux 3.1 multi-channel PCM output through HDMI with a Intel card (Intel Eaglelake, IbexPeak/Ironlake,SandyBridge/CougarPoint and IvyBridge/PantherPoint) is not yet supported. Support for it has been recently added and expected to be available in Linux 3.2. To make it work in Linux 3.1 you need to apply the following patches:<br />
<br />
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=76adaa34db407f174dd06370cb60f6029c33b465 drm: support routines for HDMI/DP ELD]<br />
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=e0dac65ed45e72fe34cc7ccc76de0ba220bd38bb drm/i915: pass ELD to HDMI/DP audio driver]<br />
<br />
=== HP TX2500 ===<br />
<br />
Add these 2 lines into {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-cmipci mpu_port=0x330 fm_port=0x388<br />
options snd-hda-intel index=0 model=toshiba position_fix=1<br />
<br />
options snd-hda-intel model=hp (works for tx2000cto)<br />
<br />
=== Skipping sound when playing MP3 ===<br />
<br />
If you have sound skipping when playing MP3 files and you have more then 2 speakers attached to your computer (i.e. more than 2 speaker system), run ''alsamixer'' and disable the channels for the speakers that you '''do not''' have (i.e. do not enable the sound for the center speaker if you do not have a center speaker.<br />
<br />
=== Using a USB headset and external USB sound cards ===<br />
<br />
If you are using a USB headset with ALSA you can try using {{AUR|asoundconf}} (currently only available from the [[AUR]]) to set the headset as the primary sound output. Before running make sure you have usb audio module enabled ({{ic|modprobe snd_usb_audio}}).<br />
<br />
# asoundconf is-active<br />
# asoundconf list<br />
# asoundconf set-default-card ''chosen soundcard''<br />
<br />
==== Crackling sound with USB devices ====<br />
<br />
If you experience crackling sound on USB devices, you can try tuning the {{ic|snd-usb-audio}} for minimal latency.<br />
<br />
Add this to your {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-usb-audio nrpacks=1<br />
<br />
source: http://alsa.opensrc.org/Usb-audio#Tuning_USB_devices_for_minimal_latencies<br />
<br />
==== Hot-plugging a USB sound card ====<br />
<br />
In order to automatically make a USB Sound Card the primary output device, when the card is plugged in, you can use the following udev rules (e.g. add the following two lines to {{ic|/etc/udev/rules.d/00-local.rules}} and reboot).<br />
<br />
{{bc|1=KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"<br />
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"}}<br />
<br />
=== Error 'Unknown hardware' appears after a kernel update===<br />
<br />
The following messages may be displayed during the start-up ALSA after the kernel update:<br />
Unknown hardware "foo" "bar" ...<br />
Hardware is initialized using a guess method<br />
/usr/bin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory)<br />
<br />
or:<br />
Found hardware: "HDA-Intel" "VIA VT1705" "HDA:11064397,18490397,00100000" "0x1849" "0x0397"<br />
Hardware is initialized using a generic method<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #1 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #2 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #25 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #26 (No such file or directory)<br />
<br />
Simply store ALSA mixer settings again:<br />
# alsactl -f /var/lib/alsa/asound.state store<br />
<br />
It may be necessary configure ALSA again with alsamixer<br />
<br />
=== HDA analyzer ===<br />
<br />
If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found [http://www.alsa-project.org/main/index.php/HDA_Analyzer at the ALSA wiki].<br />
Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.<br />
<br />
{{Note|<br />
* The script is done by such way that it is incompatible with Python 3 (which is now shipped with Arch Linux) but tries to use it. The workaround is: open "run.py", find all occurences of "python" (2 occurences - one on the first line, and the second on the last line) and replace them all by "python2".<br />
* The script requires root acces, but running it via su/sudo is bogus. Run it via {{ic|kdesu}} or {{ic|gksu}}.<br />
}}<br />
<br />
=== ALSA with SDL ===<br />
<br />
If you get no sound via SDL and ALSA cannot be chosen from the application. Try setting the environmental variable SDL_AUDIODRIVER to alsa.<br />
# export SDL_AUDIODRIVER=alsa<br />
<br />
=== Low sound workaround ===<br />
<br />
If you are facing low sound even after maxing out your speakers/headphones, you can give the softvol plugin a try. Add the following to {{ic|/etc/asound.conf}}.<br />
{{bc|<nowiki><br />
pcm.!default {<br />
type plug<br />
slave.pcm "softvol"<br />
}<br />
<br />
pcm.softvol {<br />
type softvol<br />
slave {<br />
pcm "dmix"<br />
}<br />
control {<br />
name "Pre-Amp"<br />
card 0<br />
}<br />
min_dB -5.0<br />
max_dB 20.0<br />
resolution 6<br />
}<br />
</nowiki>}}<br />
{{Note|You will probably have to restart the computer, as restarting the alsa daemon did not load the new configuration for me. Also, if the configuration does not work even after restarting, try changing {{ic|plug}} with {{ic|hw}} in the above configuration.}}<br />
<br />
After the changes are loaded successfully, you will see a {{ic|Pre-Amp}} section in alsamixer. You can adjust the levels there.<br />
{{Note|<br />
* Setting a high value for {{ic|Pre-Amp}} can cause sound distortion, so adjust it according to the level that suits you.<br />
* Some audio codecs may need to have settings adjusted in the HDA Analyzer ([[#HDA analyzer|see above]]) in order to achieve proper volume without distortion. Checking the HP option under widget control in the Playback Switch (Node[0x14] PIN in the ALC892 codec, for instance) can sometimes improve audio quality and volume significantly.<br />
}}<br />
<br />
=== Popping sound after resuming from suspension ===<br />
<br />
You might hear a popping sound after resuming the computer from suspension. This can be fixed by editing {{ic|/etc/pm/sleep.d/90alsa}} and removing the line that says {{ic|aplay -d 1 /dev/zero}}<br />
<br />
=== Mute after reboot ===<br />
<br />
After reboot, sound setting by alsamixer can not restore. Maybe you can restore by command : {{ic|sudo alsactl restore}}. Please check the {{ic|Auto-Mute}} toggle status in alsamixer : set {{ic|Enabled}} to {{ic|Disabled}}.<br />
<br />
=== Volume too low ===<br />
<br />
The first thing to try is run {{ic|alsamixer}} and try to increase the value of the sliders, possibly unmuting channels if necessary. Note that if you have many sliders, you may have to scroll to the right to see any missing sliders.<br />
<br />
If all the sliders are maxed out, and the volume is still too low, you can try running the script at http://www.alsa-project.org/hda-analyzer.py to reset your codec settings:<br />
<br />
$ wget http://www.alsa-project.org/hda-analyzer.py<br />
$ sudo python2 hda-analyzer.py<br />
<br />
(Note that the script assumes "python" refers to Python 2, but on a typical ArchLinux installation, "python" refers to Python 3. Therefore, you may need to edit the last line of the script from {{ic|os.system("python %s" % TMPDIR + '/' + FILES[0] + ' ' + ' '.join(sys.argv[1:]))}} to {{ic|os.system("python2 %s" % TMPDIR + '/' + FILES[0] + ' ' + ' '.join(sys.argv[1:]))}}.<br />
<br />
Close the analyzer, and when prompted as to whether you want to reset the codecs, say "yes".<br />
<br />
If the volume is *still* too low, run {{ic|alsamixer}} again: resetting the codecs may have caused new sliders to become enabled, and some of them may be set to a low value.<br />
<br />
== Example configurations ==<br />
<br />
See [[Advanced Linux Sound Architecture/Example Configurations]].<br />
<br />
== See also ==<br />
<br />
* [http://www.mjmwired.net/kernel/Documentation/sound/alsa/ALSA-Configuration.txt Advanced ALSA module configuration]<br />
* [http://alsa.opensrc.org/Main_Page Unofficial ALSA wiki]<br />
* [https://bbs.archlinux.org/viewtopic.php?id=36815 HOWTO: compile driver from svn]<br />
* [http://www.volkerschatz.com/noise/alsa.html A close look at ALSA: ALSA concept introduction]</div>Hongy19https://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture&diff=295005Advanced Linux Sound Architecture2014-01-30T11:09:23Z<p>Hongy19: /* See also */</p>
<hr />
<div>[[Category:Sound]]<br />
[[Category:Audio/Video]]<br />
[[cs:Advanced Linux Sound Architecture]]<br />
[[de:Alsa]]<br />
[[es:Advanced Linux Sound Architecture]]<br />
[[fa:ALSA]]<br />
[[fr:Alsa]]<br />
[[he:Advanced Linux Sound Architecture]]<br />
[[it:Advanced Linux Sound Architecture]]<br />
[[ja:Advanced Linux Sound Architecture]]<br />
[[nl:Advanced Linux Sound Architecture]]<br />
[[pt:Advanced Linux Sound Architecture]]<br />
[[ru:Advanced Linux Sound Architecture]]<br />
[[sk:Advanced Linux Sound Architecture]]<br />
[[th:Advanced Linux Sound Architecture]]<br />
[[tr:Gelişmiş_ses_mimarisi_(ALSA)]]<br />
[[zh-CN:Advanced Linux Sound Architecture]]<br />
{{Related articles start}}<br />
{{Related|Sound system}}<br />
{{Related|Disable PC Speaker Beep}}<br />
{{Related articles end}}<br />
The [[Wikipedia:Advanced Linux Sound Architecture|Advanced Linux Sound Architecture]] ('''ALSA''') is a Linux kernel component which replaced the original Open Sound System (OSSv3) for providing device drivers for sound cards. Besides the sound device drivers, '''ALSA''' also bundles a user space library for application developers who want to use driver features with a higher level API than direct interaction with the kernel drivers.<br />
<br />
{{Note|For an alternative sound environment, see the [[Open Sound System]] page.}}<br />
<br />
== Installation ==<br />
<br />
ALSA is included in the default Arch kernel as a set of modules, so installing it is not necessary.<br />
<br />
[[udev]] will automatically probe your hardware at boot, loading the corresponding kernel module for your audio card. Therefore, your sound should already be working, but upstream sources mute all channels by default.<br />
<br />
Users with a local login (at a virtual terminal or a display manager) have permission to play audio and change mixer levels. To allow this for a remote login, the user has to be [[Users and Groups#Group management|added]] to the {{ic|audio}} group. Membership in the {{ic|audio}} group also allows direct access to devices, which can lead to applications grabbing exclusive output (breaking software mixing) and breaks fast-user-switching, and multiseat. Therefore, adding a user to the {{ic|audio}} group is '''not''' recommended, unless you specifically need to[https://wiki.ubuntu.com/Audio/TheAudioGroup].<br />
<br />
=== User-space utilities ===<br />
<br />
[[pacman|Install]] the {{Pkg|alsa-utils}} package from the [[Official Repositories|official repositories]] which contains the {{ic|alsamixer}} user-space tool, which allows for configuration of the sound device from the console or terminal. Also install the {{Pkg|alsa-plugins}} package if you want [[#High quality resampling|high quality resampling]], [[#Upmixing/Downmixing|upmixing/downmixing]] and other advanced features.<br />
<br />
If you want OSS applications to work with dmix (software mixing), also install the {{Pkg|alsa-oss}} package. Load the {{ic|snd_seq_oss}}, {{ic|snd_pcm_oss}} and {{ic|snd_mixer_oss}} [[kernel modules]] to enable the OSS emulation modules.<br />
<br />
== Unmuting the channels ==<br />
<br />
The current version of ALSA installs with all channels '''muted by default'''. You will need to unmute the channels manually.<br />
<br />
It is easiest to use {{ic|alsamixer}} ncurses UI to accomplish this:<br />
<br />
$ alsamixer<br />
<br />
Alternatively, use {{ic|amixer}} from the command-line:<br />
<br />
$ amixer sset Master unmute<br />
<br />
In {{ic|alsamixer}}, the {{ic|MM}} label below a channel indicates that the channel is muted, and {{ic|00}} indicates that it is open.<br />
<br />
Scroll to the {{ic|Master}} and {{ic|PCM}} channels with the {{ic|←}} and {{ic|→}} keys and unmute them by pressing the {{ic|m}} key. Use the {{ic|↑}} key to increase the volume and obtain a value of {{ic|0}} dB gain. The gain can be found in the upper left next to the {{ic|Item:}} field. Higher values of gain will produce distorted sound.<br />
<br />
To get full 5.1 or 7.1 surround sound you likely need to unmute other channels such as Front, Surround, Center, LFE (subwoofer) and Side (these are the names of the channels with Intel HD Audio, they may vary with different hardware). Please take note that this will not automatically upmix stereo sources (like most music). In order to accomplish that, see [[#Upmixing/Downmixing]].<br />
<br />
To enable your microphone, switch to the Capture tab with {{ic|F4}} and enable a channel with {{ic|Space}}.<br />
<br />
Leave alsamixer by pressing {{ic|Esc}}.<br />
<br />
{{Note|<br />
* Some cards need to have digital output muted/turned off in order to hear analog sound. For the Soundblaster Audigy LS mute the IEC958 channel.<br />
* Some machines, (like the Thinkpad T61), have a Speaker channel which must be unmuted and adjusted as well.<br />
* Some machines, (like the Dell E6400) may also require the {{ic|Front}} and {{ic|Headphone}} channels to be unmuted and adjusted.<br />
* If your volume adjustments seems to be lost when you reboot, try running alsamixer as root. <br />
}}<br />
<br />
Next, test to see if sound works:<br />
<br />
$ speaker-test -c 2<br />
<br />
Change {{ic|-c}} to fit your speaker setup. Use {{ic|-c 8}} for 7.1, for instance:<br />
<br />
$ speaker-test -c 8<br />
<br />
If it does not work, proceed to [[#Configuration|Configuration]] and then [[#Troubleshooting|Troubleshooting]] to solve your problems.<br />
<br />
The {{Pkg|alsa-utils}} package includes {{ic|alsa-restore.service}} and {{ic|alsa-store.service}}, which are preconfigured to run at boot and shutdown respectively.<br />
For reference, ALSA stores its settings in {{ic|/var/lib/alsa/asound.state}}.<br />
<br />
== Configuration ==<br />
<br />
=== No sound in VirtualBox ===<br />
<br />
If you experience problems with VirtualBox, the following command might be helpful:<br />
<br />
{{hc|$ alsactl init|2=<nowiki><br />
<br />
Found hardware: "ICH" "SigmaTel STAC9700,83,84" "AC97a:83847600" "0x8086" "0x0000"<br />
Hardware is initialized using a generic method<br />
</nowiki>}}<br />
<br />
You might need to activate the ALSA output in your audio software as well.<br />
<br />
=== Set the default sound card ===<br />
<br />
If your sound card order changes on boot, you can specify their order in any file ending with {{ic|.conf}} in {{ic|/etc/modprobe.d}} ({{ic|/etc/modprobe.d/alsa-base.conf}} is suggested).<br />
For example, if you want your mia sound card to be #0:<br />
<br />
{{hc|/etc/modprobe.d/alsa-base.conf|2=<nowiki><br />
options snd slots=snd_mia,snd_hda_intel<br />
options snd_mia index=0<br />
options snd_hda_intel index=1<br />
</nowiki>}}<br />
<br />
Use {{ic|<nowiki>$ cat /proc/asound/modules</nowiki>}} to get the loaded sound modules and their order. This list is usually all that is needed for the loading order. Use {{ic|<nowiki>$ lsmod | grep snd</nowiki>}} to get a devices & modules list. This configuration assumes you have one mia sound card using {{ic|snd_mia}} and one (e.g. onboard) card using {{ic|snd_hda_intel}}.<br />
<br />
You can also provide an index of {{ic|-2}} to instruct ALSA to never use a card as the primary one. Distributions such as Linux Mint and Ubuntu use the following settings to avoid USB and other "abnormal" drivers from getting index {{ic|0}}:<br />
<br />
{{hc|/etc/modprobe.d/alsa-base.conf|2=<br />
options bt87x index=-2<br />
options cx88_alsa index=-2<br />
options saa7134-alsa index=-2<br />
options snd-atiixp-modem index=-2<br />
options snd-intel8x0m index=-2<br />
options snd-via82xx-modem index=-2<br />
options snd-usb-audio index=-2<br />
options snd-usb-caiaq index=-2<br />
options snd-usb-ua101 index=-2<br />
options snd-usb-us122l index=-2<br />
options snd-usb-usx2y index=-2<br />
options snd-pcsp index=-2<br />
options snd-usb-audio index=-2<br />
}}<br />
<br />
These changes require a system reboot.<br />
<br />
==== Select the default PCM via environment variable ====<br />
<br />
In your configuration file, preferably global, add:<br />
pcm.!default {<br />
type plug<br />
slave.pcm {<br />
@func getenv<br />
vars [ ALSAPCM ]<br />
default "hw:Audigy2"<br />
}<br />
}<br />
<br />
You need to replace the default line with the name of your card (in the example is {{ic|Audigy2}}). You can get the names with {{ic|aplay -l}} or you can also use PCMs like '''surround51'''. But if you need to use the microphone it is a good idea to select full-duplex PCM as default.<br />
<br />
Now you can start programs selecting the sound card just changing the environment variable {{ic|ALSAPCM}}. It works fine for all program that do not allow to select the card, for the others ensure you keep the default card.<br />
For example, assuming you wrote a downmix PCM called '''mix51to20''' you can use it with {{ic|mplayer}} using the commandline {{ic|ALSAPCM&#61;mix51to20 mplayer example_6_channel.wav}}<br />
<br />
==== Alternative method ====<br />
<br />
First you will have to find out the card and device id that you want to set as the default by running {{ic|aplay -l}}:<br />
<br />
{{hc|$ aplay -l|2=<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: Intel [HDA Intel], device 0: CONEXANT Analog [CONEXANT Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: Intel [HDA Intel], device 1: Conexant Digital [Conexant Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 1: JamLab [JamLab], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 2: Audio [Altec Lansing XT1 - USB Audio], device 0: USB Audio [USB Audio]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
}}<br />
<br />
For example, the last entry in this list has the card ID 2 and the device ID 0. To set this card as the default, you can either use the system-wide file {{ic|/etc/asound.conf}} or the user-specific file {{ic|~/.asoundrc}}. You may have to create the file if it does not exist. Then insert the following options with the corresponding card.<br />
{{bc|<br />
pcm.!default {<br />
type hw<br />
card 2<br />
}<br />
<br />
ctl.!default {<br />
type hw <br />
card 2<br />
}<br />
}}<br />
<br />
{{Note|For the Asus U32U serie it seems that card should be set to 1 for both pcm and ctl.}}<br />
<br />
The 'pcm' options affect which card and device will be used for audio playback while the 'ctl' option affects which card is used by control utilities like alsamixer .<br />
<br />
The changes should take effect as soon as you (re-)start an application (MPlayer etc.). You can also test with a command like ''aplay''.<br />
<br />
$ aplay -D default ''your_favourite_sound.wav''<br />
<br />
If you receive an error regarding your asound configuration, check the [http://www.alsa-project.org/main/index.php/Asoundrc#The_default_plugin upstream documentation] for possible changes to the config file format.<br />
<br />
=== Making sure the sound modules are loaded ===<br />
<br />
You can assume that udev will autodetect your sound properly. You can check this with the command<br />
<br />
{{hc|<nowiki>$ lsmod | grep '^snd' | column -t</nowiki>|2=<br />
snd_hda_codec_hdmi 22378 4<br />
snd_hda_codec_realtek 294191 1<br />
snd_hda_intel 21738 1<br />
snd_hda_codec 73739 3 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel<br />
snd_hwdep 6134 1 snd_hda_codec<br />
snd_pcm 71032 3 snd_hda_codec_hdmi,snd_hda_intel,snd_hda_codec<br />
snd_timer 18992 1 snd_pcm<br />
snd 55132 9 snd_hda_codec_hdmi,snd_hda_codec_realtek,snd_hda_intel,snd_hda_codec,snd_hwdep,snd_pcm,snd_timer<br />
snd_page_alloc 7017 2 snd_hda_intel,snd_pcm<br />
}}<br />
<br />
If the output looks similar, your sound drivers have been successfully autodetected.<br />
{{Note|Since {{ic|udev>&#61;171}}, the OSS emulation modules ({{ic|snd_seq_oss, snd_pcm_oss, snd_mixer_oss}}) are not loaded by default: [[kernel modules#Loading|Load them manually]] if they are needed.}}<br />
<br />
You might also want to check the directory {{ic|/dev/snd/}} for the right device files:<br />
<br />
{{hc|$ ls -l /dev/snd|2=<nowiki><br />
total 0<br />
crw-rw---- 1 root audio 116, 0 Apr 8 14:17 controlC0<br />
crw-rw---- 1 root audio 116, 32 Apr 8 14:17 controlC1<br />
crw-rw---- 1 root audio 116, 24 Apr 8 14:17 pcmC0D0c<br />
crw-rw---- 1 root audio 116, 16 Apr 8 14:17 pcmC0D0p<br />
crw-rw---- 1 root audio 116, 25 Apr 8 14:17 pcmC0D1c<br />
crw-rw---- 1 root audio 116, 56 Apr 8 14:17 pcmC1D0c<br />
crw-rw---- 1 root audio 116, 48 Apr 8 14:17 pcmC1D0p<br />
crw-rw---- 1 root audio 116, 1 Apr 8 14:17 seq<br />
crw-rw---- 1 root audio 116, 33 Apr 8 14:17 timer<br />
</nowiki>}}<br />
<br />
{{Note|If requesting help on IRC or the forums, please post the output of the above commands.}}<br />
<br />
If you have at least the devices '''controlC0''' and '''pcmC0D0p''' or similar, then your sound modules have been detected and loaded properly.<br />
<br />
If this is not the case, your sound modules have not been detected properly. To solve this, you can try loading the modules manually:<br />
<br />
* Locate the module for your sound card: [http://www.alsa-project.org/main/index.php/Matrix:Main ALSA Soundcard Matrix] The module will be prefixed with 'snd-' (for example: {{ic|snd-via82xx}}).<br />
* [[Kernel modules#Loading|Load the module]].<br />
* Check for the device files in {{ic|/dev/snd}} (see above) and/or try if {{ic|alsamixer}} or {{ic|amixer}} have reasonable output.<br />
* Configure {{ic|snd-NAME-OF-MODULE}} and {{ic|snd-pcm-oss}} to [[Kernel modules#Loading|load at boot]].<br />
<br />
=== Getting SPDIF output ===<br />
<br />
(from gralves from the Gentoo forums)<br />
* In GNOME Volume Control, under the Options tab, change the IEC958 to PCM. This option can be enabled in the preferences.<br />
* If you do not have GNOME Volume Control installed,<br />
** Edit {{ic|/var/lib/alsa/asound.state}}. This file is where alsasound stores your mixer settings.<br />
** Find a line that says: 'IEC958 Playback Switch'. Near it you will find a line saying {{ic|value:false}}. Change it to {{ic|value:true}}.<br />
** Now find this line: 'IEC958 Playback AC97-SPSA'. Change its value to 0.<br />
** Restart ALSA.<br />
<br />
Alternative way to enable SPDIF output automatically on login (tested on SoundBlaster Audigy):<br />
<br />
* add following lines to {{ic|/etc/rc.local}}:<br />
# Use COAX-digital output<br />
amixer set 'IEC958 Optical' 100 unmute<br />
amixer set 'Audigy Analog/Digital Output Jack' on<br />
<br />
You can see the name of your card's digital output with:<br />
$ amixer scontrols<br />
<br />
=== System-wide equalizer ===<br />
<br />
==== Using AlsaEqual (provides UI) ====<br />
<br />
Install {{AUR|alsaequal}} from the [[AUR]].<br />
<br />
{{Note | If you have a x86_64-system and are using a 32bit-flashplugin the sound in flash will not work. Either you have to disable alsaequal or build alsaequal for 32bit.}}<br />
<br />
After installing the package, insert the following into your ALSA configuration file ({{ic|~/.asoundrc}} or {{ic|/etc/asound.conf}}):<br />
<br />
ctl.equal {<br />
type equal;<br />
}<br />
<br />
pcm.plugequal {<br />
type equal;<br />
# Modify the line below if you do not<br />
# want to use sound card 0.<br />
#slave.pcm "plughw:0,0";<br />
#by default we want to play from more sources at time:<br />
slave.pcm "plug:dmix";<br />
}<br />
#pcm.equal {<br />
# If you do not want the equalizer to be your<br />
# default soundcard comment the following<br />
# line and uncomment the above line. (You can<br />
# choose it as the output device by addressing<br />
# it with specific apps,eg mpg123 -a equal 06.Back_In_Black.mp3)<br />
pcm.!default {<br />
type plug;<br />
slave.pcm plugequal;<br />
}<br />
<br />
And you are ready to change your equalizer using command<br />
$ alsamixer -D equal<br />
<br />
Note that configuration file is different for each user (until not specified else) it is saved in {{ic|~/.alsaequal.bin}}.<br />
so if you want to use AlsaEqual with [[mpd]] or another software running under different user, you can configure it using<br />
# su mpd -c 'alsamixer -D equal'<br />
or for example, you can make a symlink to your {{ic|.alsaequal.bin}} in his home...<br />
<br />
===== Managing AlsaEqual states =====<br />
<br />
Install {{AUR|alsaequal-mgr}} from the [[AUR]] (or alternatively from [http://xyne.archlinux.ca/repos/ Xyne's repos]).<br />
<br />
Configure the equalizer as usual with <br />
$ alsamixer -D equal<br />
<br />
When you are satisfied with the state, you may give it a name ("foo" in this example) and save it:<br />
$ alsaequal-mgr save foo<br />
<br />
The state "foo" can then be restored at a later time with<br />
$ alsaequal-mgr load foo<br />
<br />
You can thus create different equalizer states for games, movies, music genres, VoIP apps, etc. and reload them as necessary.<br />
<br />
See the [http://xyne.archlinux.ca/projects/alsaequal-mgr/ project page] and the help message for more options.<br />
<br />
==== Using mbeq ====<br />
<br />
{{Note|This method requires the use of a ladspa plugin which might use quite a bit of CPU when sound plays. In addition, this was made with stereophonic sound (e.g. headphones) in mind.}}<br />
<br />
Install the {{Pkg|alsa-plugins}}, {{Pkg|ladspa}} and {{Pkg|swh-plugins}} packages if you do not already have them.<br />
<br />
* If you have not already created either an {{ic|~/.asoundrc}} or a {{ic|/etc/asound.conf}} file, then create either one and insert the following:<br />
<br />
{{hc|/etc/asound.conf|2=<nowiki>pcm.eq {<br />
type ladspa<br />
<br />
# The output from the EQ can either go direct to a hardware device<br />
# (if you have a hardware mixer, e.g. SBLive/Audigy) or it can go<br />
# to the software mixer shown here.<br />
#slave.pcm "plughw:0,0"<br />
slave.pcm "plug:dmix"<br />
<br />
# Sometimes you may need to specify the path to the plugins,<br />
# especially if you have just installed them. Once you have logged<br />
# out/restarted this should not be necessary, but if you get errors<br />
# about being unable to find plugins, try uncommenting this.<br />
#path "/usr/lib/ladspa"<br />
<br />
plugins [<br />
{<br />
label mbeq<br />
id 1197<br />
input {<br />
#this setting is here by example, edit to your own taste<br />
#bands: 50hz, 100hz, 156hz, 220hz, 311hz, 440hz, 622hz, 880hz, 1250hz, 1750hz, 25000hz,<br />
#50000hz, 10000hz, 20000hz<br />
controls [ -5 -5 -5 -5 -5 -10 -20 -15 -10 -10 -10 -10 -10 -3 -2 ]<br />
}<br />
}<br />
]<br />
}<br />
<br />
# Redirect the default device to go via the EQ - you may want to do<br />
# this last, once you are sure everything is working. Otherwise all<br />
# your audio programs will break/crash if something has gone wrong.<br />
<br />
pcm.!default {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
<br />
# Redirect the OSS emulation through the EQ too (when programs are running through "aoss")<br />
<br />
pcm.dsp0 {<br />
type plug<br />
slave.pcm "eq"<br />
}<br />
</nowiki>}}<br />
<br />
* You should be good to go (if not, ask in the forum).<br />
<br />
== High quality resampling ==<br />
<br />
When software mixing is enabled, ALSA is forced to resample everything to the same frequency (48000 by default when supported). dmix uses a poor resampling algorithm which produces noticeable sound quality loss.<br />
<br />
Install {{Pkg|alsa-plugins}} and {{Pkg|libsamplerate}}.<br />
<br />
Change the default rate converter to libsamplerate:<br />
<br />
{{hc|/etc/asound.conf|defaults.pcm.rate_converter "samplerate_best"}}<br />
<br />
or:<br />
<br />
{{hc|~/.asoundrc|defaults.pcm.rate_converter "samplerate_best"}}<br />
<br />
'''samplerate_best''' offers the best sound quality, but you need a decent CPU to be able to use it as it requires a lot of CPU cycles for real-time resampling. You may also need to adjust buffer_size in your dmix settings from the basic 4096 to 8192 or 16384. There are other algorithms available ('''samplerate''', etc.) but they may not provide much of an improvement over the default resampler.<br />
<br />
{{Warning|On some systems, enabling samplerate_best may cause a problem where you get no sound from flashplayer.}}<br />
<br />
== Upmixing/downmixing ==<br />
<br />
=== Upmixing ===<br />
<br />
In order for stereo sources like music to be able to saturate a 5.1 or 7.1 sound system, you need to use upmixing. In darker days this used to be tricky and error prone but nowadays plugins exist to easily take care of this task. We will use the {{ic|upmix}} plugin, included in {{Pkg|alsa-plugins}}.<br />
<br />
Then add the following to your ALSA configuration file of choice (either {{ic|/etc/asound.conf}} or {{ic|~/.asoundrc}}):<br />
pcm.upmix71 {<br />
type upmix<br />
slave.pcm "surround71"<br />
delay 15<br />
channels 8<br />
}<br />
<br />
You can easily change this example for 7.1 upmixing to 5.1 or 4.0.<br />
<br />
This adds a new pcm that you can use for upmixing. If you want all sound sources to go through this pcm, add it as a default below the previous definition like so:<br />
<br />
pcm.!default "plug:upmix71"<br />
<br />
The plugin automatically allows multiple sources to play through it without problems so setting is as a default is actually a safe choice. <br />
If this is not working, you have to setup your own dmixer for the upmixing PCM like this: <br />
pcm.dmix6 {<br />
type asym<br />
playback.pcm {<br />
type dmix<br />
ipc_key 567829<br />
slave {<br />
pcm "hw:0,0"<br />
channels 6<br />
}<br />
}<br />
}<br />
<br />
and use "dmix6" instead of "surround71". <br />
If you experience skipping or distorted sound, consider increasing the buffer_size (to 32768, for example) or use a [[#High quality resampling|high quality resampler]].<br />
<br />
=== Downmixing ===<br />
<br />
If you want to downmix sources to stereo because you, for instance, want to watch a movie with 5.1 sound on a stereo system, use the {{ic|vdownmix}} plugin, included in {{Pkg|alsa-plugins}}..<br />
<br />
Again, in your configuration file, add this:<br />
<br />
pcm.!surround51 {<br />
type vdownmix<br />
slave.pcm "default"<br />
}<br />
pcm.!surround40 {<br />
type vdownmix<br />
slave.pcm "default"<br />
}<br />
<br />
{{Note|1=This might not be enough to make downmixing working, see [http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541786]. So, you might also need to add {{ic|pcm.!default "plug:surround51"}} or {{ic|pcm.!default "plug:surround40"}}. Only one {{ic|vdownmix}} plug can be used; if you have 7.1 channels, you will need to use {{ic|surround71}} instead the configuration above. A good example, which includes a configuration that makes both {{ic|vdownmix}} and {{ic|dmix}} working, can be found [https://bbs.archlinux.org/viewtopic.php?id=167275 here].}}<br />
<br />
== Mixing ==<br />
<br />
=== Software mixing (dmix) ===<br />
<br />
{{Note|For ALSA 1.0.9rc2 and higher on analog sound outputs you do not need to setup dmix. Dmix is enabled as default for soundcards which do not support hardware mixing.}}<br />
<br />
If that does not work however, it is a matter of simply creating a .asoundrc file in your home folder with the following contents.<br />
<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
<br />
This should enable software mixing and allows more than one application to make use of the soundcard. If not, try replacing all /etc/asound.conf content with the above.<br />
<br />
For a digital sound output such as S/PDIF, the ALSA package still does not enable dmix by default. Thus, the dmix configuration above can be used to enable dmix for S/PDIF devices.<br />
<br />
See [[#Troubleshooting]] for common problems and solutions.<br />
<br />
=== Hardware mixing ===<br />
<br />
==== Support ====<br />
<br />
If you have an audio chipset that supports mixing in hardware, then no configuration is necessary. Almost every onboard audio chipset does not support hardware mixing, and requires mixing to be done in software (see above). Many sound cards do support hardware mixing, and the ones best supported on Linux are listed below:<br />
<br />
* Creative SoundBlaster Live! (5.1 model)<br />
* Creative SoundBlaster Audigy (some models)<br />
* Creative SoundBlaster Audidy 2 (ZS models)<br />
* Creative SoundBlaster Audigy 4 (Pro models)<br />
<br />
{{Note|<br />
* The low end variants of above cards, (Audigy SE, Audigy 2 NX, SoundBlaster Live! 24bit and SoundBlaster Live! 7.1) '''do not''' support hardware mixing as they use other chips.<br />
* The onboard VIA8237 chip supports 4-stream hardware mixing, however, it does only 3 for some motherboards (the 4th makes no sound) or is just broken. Even if it works, the quality is not good compared to other solutions.<br />
}}<br />
<br />
==== Fixes ====<br />
<br />
If you are using 64-bit Arch and the Intel Corporation 82801I (ICH9 Family) HD Audio Controller (rev 02), you can get sound working for Enemy Territory with the following:<br />
echo "et.x86 0 0 direct" > /proc/asound/card0/pcm0p/oss<br />
echo "et.x86 0 0 disable" > /proc/asound/card0/pcm0c/oss<br />
<br />
== Troubleshooting ==<br />
<br />
=== Sound skipping while using dynamic frequency scaling ===<br />
<br />
Some combinations of ALSA drivers and chipsets may cause audio from all sources to skip when used in combination with a dynamic frequency scaling governor such as {{ic|ondemand}} or {{ic|conservative}}. Currently, the solution is to switch back to the {{ic|performance}} governor.<br />
<br />
Refer to the [[CPU Frequency Scaling]] for more information.<br />
<br />
=== Problems with availability to only one user at a time ===<br />
<br />
You might find that only one user can use the dmixer at a time. This is probably ok for most, but for those who run [[mpd]] as a separate user this poses a problem. When mpd is playing a normal user cannot play sounds though the dmixer. While it's quite possible to just run mpd under a user's login account, another solution has been found. Adding the line {{ic|ipc_key_add_uid 0}} to the {{ic|pcm.dmixer}} block disables this locking. The following is a snippet of the {{ic|asound.conf}}, the rest is the same as above.<br />
...<br />
pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid 0<br />
ipc_perm 0660<br />
slave {<br />
...<br />
<br />
=== Simultaneous playback problems ===<br />
<br />
If you are having problems with simultaneous playback, and if [[PulseAudio]] is installed (i.e. by [[GNOME]]), its default configuration is set to "hijack" the soundcard. Some users of ALSA may not want to use [[PulseAudio]] and are quite content with their current ALSA settings. One fix is to edit {{ic|/etc/asound.conf}} and comment out the following lines:<br />
# Use PulseAudio by default<br />
#pcm.!default {<br />
# type pulse<br />
# fallback "sysdefault"<br />
# hint {<br />
# show on<br />
# description "Default ALSA Output (currently PulseAudio Sound Server)"<br />
# }<br />
#}<br />
<br />
Commenting the following out also may help:<br />
#ctl.!default {<br />
# type pulse<br />
# fallback "sysdefault"<br />
#}<br />
<br />
This may be a much simpler solution than completely uninstalling [[PulseAudio]].<br />
<br />
Effectively, here is an example of a working {{ic|/etc/asound.conf}}:<br />
{{bc|<nowiki>pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
ipc_key_add_uid 0<br />
ipc_perm 0660<br />
}<br />
pcm.dsp {<br />
type plug<br />
slave.pcm "dmix"<br />
}</nowiki><br />
}}<br />
<br />
{{Note|This {{ic|/etc/asound.conf}} file was intended for and used successfully with a global [[MPD]] configuration. See [[Alsa#Problems_with_Availability_to_Only_One_User_at_a_Time|this section]] on multiple users}}<br />
<br />
=== Random lack of sound on startup ===<br />
<br />
You can quickly test sound by running {{ic|speaker-test}}. If there is no sound, the error message might look something like<br />
<br />
ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave<br />
Playback open error: -16<br />
Device or resource busy<br />
<br />
If you have no sound on startup, this may be because your system has multiple sound cards, and their order may sometimes change on startup. If this is the case, try [[#Set the default sound card|setting the default sound card]].<br />
<br />
If you use mpd and the configuration tips above do not work for you, try [http://mpd.wikia.com/wiki/Configuration#ALSA_MPD_software_volume_control reading this] instead.<br />
<br />
==== Timidity ====<br />
<br />
[[Timidity]] can be the cause of missing audio. Try running:<br />
<br />
$ systemctl status timidity<br />
<br />
If it failed, try {{ic|# killall -9 timidity}}. If this solves the issue, then you should disable the timidity daemon to be started at boot.<br />
<br />
=== Specific program problems ===<br />
<br />
For other programs who insist on their own audio setup, e.g., XMMS or MPlayer, you would need to set their specific options.<br />
<br />
For MPlayer, open up a [[MPlayer#Configuration|configuration file]] and add the following line:<br />
ao=alsa<br />
For ''mpv'' append the same line in one of its [[mpv#Configuration|configuration files]].<br />
<br />
For XMMS/Beep Media Player, go into their options and make sure the sound driver is set to Alsa, not oss.<br />
<br />
To do this in XMMS:<br />
* Open XMMS<br />
** Options > Preferences.<br />
** Choose the ALSA output plugin.<br />
<br />
For applications which do not provide a ALSA output, you can use aoss from the alsa-oss package. To use aoss, when you run the program, prefix it with {{ic|aoss}}, eg:<br />
aoss realplay<br />
<br />
pcm.!default{ ... } doesnt work for me anymore. but this does:<br />
pcm.default pcm.dmixer<br />
<br />
=== Model settings ===<br />
<br />
Although Alsa detects your soundcard through the BIOS at times Alsa may not be able to recognize your [http://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio-Models.txt model type]. The soundcard chip can be found in {{ic|alsamixer}} (e.g. ALC662) and the model can be set in {{ic|/etc/modprobe.d/modprobe.conf}} or {{ic|/etc/modprobe.d/sound.conf}}. For example:<br />
<br />
options snd-hda-intel model=MODEL<br />
<br />
There are other model settings too. For most cases Alsa defaults will do. If you want to look at more specific settings for your soundcard take a look at the [http://bugtrack.alsa-project.org/main/index.php/Matrix:Main Alsa Soundcard List] find your model, then Details, then look at the "Setting up modprobe..." section. Enter these values in {{ic|/etc/modprobe.d/modprobe.conf}}. For example, for an Intel AC97 audio:<br />
<br />
{{bc|<br />
# ALSA portion<br />
alias char-major-116 snd<br />
alias snd-card-0 snd-intel8x0<br />
# module options should go here<br />
<br />
# OSS/Free portion<br />
alias char-major-14 soundcore<br />
alias sound-slot-0 snd-card-0<br />
<br />
# card #1<br />
alias sound-service-0-0 snd-mixer-oss<br />
alias sound-service-0-1 snd-seq-oss<br />
alias sound-service-0-3 snd-pcm-oss<br />
alias sound-service-0-8 snd-seq-oss<br />
alias sound-service-0-12 snd-pcm-oss<br />
}}<br />
<br />
=== Conflicting PC speaker ===<br />
<br />
If you are sure nothing is muted, that your drivers are installed correctly, and that your volume is right, but you still do not hear anything, then try adding the following line to {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-NAME-OF-MODULE ac97_quirk=0<br />
<br />
The above fix has been observed to work with {{ic|via82xx}}<br />
options snd-NAME-OF-MODULE ac97_quirk=1<br />
The above fix has been reported to work with {{ic|snd_intel8x0}}<br />
<br />
=== No microphone input ===<br />
<br />
In alsamixer, make sure that all the volume levels are up under recording, and that CAPTURE is toggled active on the microphone (e.g. Mic, Internal Mic) and/or on Capture (in alsamixer, select these items and press space). Try making positive Mic Boost and raising Capture and Digital levels higher; this make make static or distortion, but then you can adjust them back down once you are hearing ''something'' when you record<br />
<br />
As the pulseaudio wrapper is shown as "default" in alsamixer, you may have to press F6 to select your actual soundcard first. You may also need to enable and increase the volume of Line-in in the Playback section.<br />
<br />
To test the microphone, run these commands (see arecord's man page for further information):<br />
$ arecord -d 5 test-mic.wav<br />
$ aplay test-mic.wav<br />
<br />
If all fails, you may want to eliminate hardware failure by testing the microphone with a different device.<br />
<br />
For at least some computers, muting a microphone (MM) simply means its input does not go immediately to the speakers. It still receives input.<br />
<br />
Many Dell laptops need "-dmic" to be appended to the model name in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-hda-intel model=dell-m6-dmic<br />
<br />
Some programs use try to use OSS as the main input software. If you have enabled the {{ic|snd_pcm_oss}}, {{ic|snd_mixer_oss}} or {{ic|snd_seq_oss}} [[kernel modules]] previously (they are not loaded by default), try unloading them.<br />
<br />
See also:<br />
* http://www.alsa-project.org/main/index.php/SoundcardTesting<br />
* http://alsa.opensrc.org/Record_from_mic<br />
<br />
=== Crackling in microphone ===<br />
<br />
If you're getting a crackling or popping from your microphone that can't be resolved with ALSA settings or cleaning your microphone jack, try adding the following line to {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-hda-intel model=MODEL position_fix=3<br />
<br />
This option will fix crackling on pure Alsa, but will cause issues to pulseaudio. To let Pulse use these settings effectively, edit {{ic|/etc/pulse/default.pa}} and find this line:<br />
<br />
load-module module-udev-detect<br />
<br />
And change it to this:<br />
<br />
load-module module-udev-detect tsched=0<br />
<br />
See the DMA-Position Problem in the kernel docs.<br />
<br />
* [https://www.kernel.org/doc/Documentation/sound/alsa/HD-Audio.txt HD-audio Kernel Docs]<br />
<br />
=== Setting the default microphone/capture device ===<br />
<br />
Some applications (Pidgin, Adobe Flash) do not provide an option to change the capture device. It becomes a problem if your microphone is on a separate device (e.g. USB webcam or microphone) than your internal sound card. To change only the default capture device, leaving the default playback device as is, you can modify your {{ic|~/.asoundrc}} file to include the following:<br />
<br />
pcm.usb<br />
{<br />
type hw<br />
card U0x46d0x81d<br />
}<br />
<br />
pcm.!default<br />
{<br />
type asym<br />
playback.pcm<br />
{<br />
type plug<br />
slave.pcm "dmix"<br />
}<br />
capture.pcm<br />
{<br />
type plug<br />
slave.pcm "usb"<br />
}<br />
}<br />
<br />
Replace "U0x46d0x81d" with your capture device's card name in ALSA. You can use {{ic|arecord -L}} to list all the capture devices detected by ALSA.<br />
<br />
=== Internal microphone not working ===<br />
<br />
First make sure all the volume levels are up under recording in alsamixer. In my case adding the following option to {{ic|/etc/sound.conf}} and reloading the snd-* module produced a new volume setting called Capture which was capturing for the internal mic. For eg, for snd-hda-intel add<br />
<br />
options snd-hda-intel enable_msi=1<br />
<br />
Then reload the module (as below), up the recording volume of Capture and then test.<br />
<br />
# rmmod snd-hda-intel && modprobe snd-hda-intel<br />
<br />
=== No sound with onboard Intel sound card ===<br />
<br />
There may be a problem with two conflicting modules loaded, namely {{ic|snd_intel8x0}} and {{ic|snd_intel8x0m}}. In this case, blacklist snd_intel8x0m:<br />
<br />
{{hc|/etc/modprobe.d/modprobe.conf|blacklist snd_intel8x0m}}<br />
<br />
''Muting'' the "External Amplifier" in {{ic|alsamixer}} or {{ic|amixer}} may also help. See [http://alsa.opensrc.org/Intel8x0#Dell_Inspiron_8600_.28and_probably_others.29 the ALSA wiki].<br />
<br />
Unmuting the "Mix" setting in the mixer might help, also.<br />
<br />
=== No headphone sound with onboard Intel sound card ===<br />
<br />
With '''Intel Corporation 82801 I (ICH9 Family) HD Audio Controller''' on laptop, you may need to add this line to modprobe or sound.conf:<br />
<br />
options snd-hda-intel model=''model''<br />
<br />
Where ''model'' is any one of the following (in order of possibility to work, but not merit):<br />
<br />
* dell-vostro<br />
* olpc-xo-1_5<br />
* laptop<br />
* dell-m6<br />
* laptop-hpsense<br />
<br />
{{Note|It may be necessary to put this "options" line below (after) any "alias" lines about your card.}}<br />
<br />
You can see all the available models in the kernel documentation. For example [http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/sound/alsa/HD-Audio-Models.txt here], but check that it is the correct version of that document for your kernel version.<br />
<br />
A list of available models is also available [http://www.mjmwired.net/kernel/Documentation/sound/alsa/HD-Audio-Models.txt here]. To know your chip name type the following command (with * being corrected to match your files). Note that some chips could have been renamed and do not directly match the available ones in the file.<br />
<br />
$ grep Codec /proc/asound/card*/codec*<br />
<br />
Note that there is a high chance none of the input devices (all internal and external mics) will work if you choose to do this, so it is either your headphones or your mic. Please report to ALSA if you are affected by this bug.<br />
<br />
And also, if you have problems getting beeps to work (pcspkr):<br />
<br />
options snd-hda-intel model=$model enable=1 index=0<br />
<br />
=== No sound when S/PDIF video card is installed ===<br />
<br />
Discover available modules and their order:<br />
{{hc|$ cat /proc/asound/modules|<br />
0 snd_hda_intel<br />
1 snd_ca0106<br />
}}<br />
<br />
Disable the undesired video card audio codec in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
# /etc/modprobe.d/modprobe.conf<br />
#<br />
install snd_hda_intel /bin/false<br />
<br />
If both devices use the same module then we can use the *enable* parameter from snd-hda-intel module, it's an array of booleans that can enable/disable the desired sound card.<br />
<br />
e.g <br />
options snd-hda-intel enable=1,0<br />
the following gives you the list of cards<br />
cat /proc/asound/cards<br />
<br />
=== Poor sound quality or clipping ===<br />
<br />
If you experience poor sound quality, try setting the PCM volume (in alsamixer) to a level such that gain is 0.<br />
<br />
If snd-usb-audio driver has been loaded, you could try to enable {{ic|softvol}} in {{ic|/etc/asound.conf}} file. Example configuration for the first audio device:<br />
pcm.!default {<br />
type plug<br />
slave.pcm "softvol"<br />
}<br />
pcm.dmixer {<br />
type dmix<br />
ipc_key 1024<br />
slave {<br />
pcm "hw:0"<br />
period_time 0<br />
period_size 4096<br />
buffer_size 131072<br />
rate 50000<br />
}<br />
bindings {<br />
0 0<br />
1 1<br />
}<br />
}<br />
pcm.dsnooper {<br />
type dsnoop<br />
ipc_key 1024<br />
slave {<br />
pcm "hw:0"<br />
channels 2<br />
period_time 0<br />
period_size 4096<br />
buffer_size 131072<br />
rate 50000<br />
}<br />
bindings {<br />
0 0<br />
1 1<br />
}<br />
}<br />
pcm.softvol {<br />
type softvol<br />
slave { pcm "dmixer" }<br />
control {<br />
name "Master"<br />
card 0<br />
}<br />
}<br />
ctl.!default {<br />
type hw<br />
card 0<br />
}<br />
ctl.softvol {<br />
type hw<br />
card 0<br />
}<br />
ctl.dmixer {<br />
type hw<br />
card 0<br />
}<br />
<br />
=== Pops when starting and stopping playback===<br />
<br />
Some modules (e.g. snd-ac97-codec and snd-hda-intel) can power off your sound card when not in use. This can make an audible noise (like a crack/pop/scratch) when turning on/off your sound card. Sometimes even when move the slider volume, or open and close windows (KDE4). If you find this annoying try {{ic|modinfo snd-MY-MODULE}}, and look for a module option that adjusts or disables this feature.<br />
<br />
''Example'': disable the power saving mode and solve cracking sound trough speakers problem, using snd-hda-intel add in {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-hda-intel power_save=0<br />
or:<br />
options snd-hda-intel power_save=0 power_save_controller=N<br />
<br />
You can also try it with {{ic|1=modprobe snd-hda-intel power_save=0}} before.<br />
<br />
You may also have to unmute the 'Line' ALSA channel for this to work. Any value will do (other than '0' or something too high).<br />
<br />
''Example:'' on an onboard VIA VT1708S (using the snd-hda-intel module) these cracks occured even though 'power_save' was set to 0. Unmuting the 'Line' channel and setting a value of '1' solved the problem.<br />
<br />
Source: https://www.kernel.org/doc/Documentation/sound/alsa/powersave.txt<br />
<br />
If you use a laptop, pm-utils will change {{ic|power_save}} back to 1 when you go onto battery power even if you disable power saving in {{ic|/etc/modprobe.d}}. Disable this for pm-utils by disabling the script that makes the change (see [[Pm-utils#Disabling_a_hook|Disabling a hook]] for more information):<br />
# touch /etc/pm/power.d/intel-audio-powersave<br />
<br />
=== S/PDIF output does not work ===<br />
<br />
If the optical/coaxial digital output of your motherboard/sound card is not working or stopped working, and have already enabled and unmuted it in alsamixer, try running<br />
# iecset audio on<br />
<br />
You can also put this command in an enabled [[systemd]] service as it sometimes it may stop working after a reboot.<br />
<br />
=== HDMI output does not work ===<br />
<br />
The procedure described below can be used to test HDMI audio. Before proceeding, make sure you have enabled and unmuted the output with {{ic|alsamixer}}.<br />
<br />
{{Note|If you are using an ATI card and linux kernel &gt;&#61;3.0, a necessary kernel module is disabled by default. See [[ATI#HDMI_Audio]].}}<br />
<br />
Connect your PC to the Display via HDMI cable and enable the display with a tool such as {{ic|xrandr}} or {{ic|arandr}}. For example:<br />
<br />
$ xrandr # list outputs<br />
$ xrandr --output DVI-D_1 --mode 1024x768 --right-of PANEL # enable output<br />
<br />
Use {{ic|aplay -l}} to get the discover the card and device number. For example:<br />
<br />
$ aplay -l<br />
**** List of PLAYBACK Hardware Devices ****<br />
card 0: SB [HDA ATI SB], device 0: ALC892 Analog [ALC892 Analog]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
card 0: SB [HDA ATI SB], device 1: ALC892 Digital [ALC892 Digital]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
'''card 1''': Generic [HD-Audio Generic], '''device 3''': HDMI 0 [HDMI 0]<br />
Subdevices: 1/1<br />
Subdevice #0: subdevice #0<br />
<br />
Send sound to the device. Following the example in the previous step, you would send sound to card 1, device 3:<br />
<br />
$ aplay -D plughw:1,3 /usr/share/sounds/alsa/Front_Center.wav<br />
<br />
If aplay does not output any errors, but still no sound is heared, "reboot" the receiver, monitor or tv set. Since the HDMI interface executes a handshake on connection, it might have noticed before that there was no audio stream embedded, and disabled audio decoding. In particular, if you are using a standalone window manager (don’t know about Gnome or KDE), you may need to have some sound playing ''while'' plugging in the HDMI cable.<br />
<br />
If the test is successful, create or edit your {{ic|~/.asoundrc}} file to set HDMI as the default audio device.<br />
<br />
{{hc|~/.asoundrc|<br />
pcm.!default {<br />
type hw<br />
card 0<br />
device 3<br />
}<br />
}}<br />
<br />
Or you above config does not work try:<br />
{{hc|~/.asoundrc|<br />
defaults.pcm.card 0<br />
defaults.pcm.device 3<br />
defaults.ctl.card 0<br />
}}<br />
<br />
=== HDMI multi-channel PCM output does not work (Intel) ===<br />
<br />
As of Linux 3.1 multi-channel PCM output through HDMI with a Intel card (Intel Eaglelake, IbexPeak/Ironlake,SandyBridge/CougarPoint and IvyBridge/PantherPoint) is not yet supported. Support for it has been recently added and expected to be available in Linux 3.2. To make it work in Linux 3.1 you need to apply the following patches:<br />
<br />
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=76adaa34db407f174dd06370cb60f6029c33b465 drm: support routines for HDMI/DP ELD]<br />
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=patch;h=e0dac65ed45e72fe34cc7ccc76de0ba220bd38bb drm/i915: pass ELD to HDMI/DP audio driver]<br />
<br />
=== HP TX2500 ===<br />
<br />
Add these 2 lines into {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
options snd-cmipci mpu_port=0x330 fm_port=0x388<br />
options snd-hda-intel index=0 model=toshiba position_fix=1<br />
<br />
options snd-hda-intel model=hp (works for tx2000cto)<br />
<br />
=== Skipping sound when playing MP3 ===<br />
<br />
If you have sound skipping when playing MP3 files and you have more then 2 speakers attached to your computer (i.e. more than 2 speaker system), run ''alsamixer'' and disable the channels for the speakers that you '''do not''' have (i.e. do not enable the sound for the center speaker if you do not have a center speaker.<br />
<br />
=== Using a USB headset and external USB sound cards ===<br />
<br />
If you are using a USB headset with ALSA you can try using {{AUR|asoundconf}} (currently only available from the [[AUR]]) to set the headset as the primary sound output. Before running make sure you have usb audio module enabled ({{ic|modprobe snd_usb_audio}}).<br />
<br />
# asoundconf is-active<br />
# asoundconf list<br />
# asoundconf set-default-card ''chosen soundcard''<br />
<br />
==== Crackling sound with USB devices ====<br />
<br />
If you experience crackling sound on USB devices, you can try tuning the {{ic|snd-usb-audio}} for minimal latency.<br />
<br />
Add this to your {{ic|/etc/modprobe.d/modprobe.conf}}:<br />
<br />
options snd-usb-audio nrpacks=1<br />
<br />
source: http://alsa.opensrc.org/Usb-audio#Tuning_USB_devices_for_minimal_latencies<br />
<br />
==== Hot-plugging a USB sound card ====<br />
<br />
In order to automatically make a USB Sound Card the primary output device, when the card is plugged in, you can use the following udev rules (e.g. add the following two lines to {{ic|/etc/udev/rules.d/00-local.rules}} and reboot).<br />
<br />
{{bc|1=KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"<br />
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"}}<br />
<br />
=== Error 'Unknown hardware' appears after a kernel update===<br />
<br />
The following messages may be displayed during the start-up ALSA after the kernel update:<br />
Unknown hardware "foo" "bar" ...<br />
Hardware is initialized using a guess method<br />
/usr/bin/alsactl: set_control:nnnn:failed to obtain info for control #mm (No such file or directory)<br />
<br />
or:<br />
Found hardware: "HDA-Intel" "VIA VT1705" "HDA:11064397,18490397,00100000" "0x1849" "0x0397"<br />
Hardware is initialized using a generic method<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #1 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #2 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #25 (No such file or directory)<br />
/usr/bin/alsactl: set_control:1328: failed to obtain info for control #26 (No such file or directory)<br />
<br />
Simply store ALSA mixer settings again:<br />
# alsactl -f /var/lib/alsa/asound.state store<br />
<br />
It may be necessary configure ALSA again with alsamixer<br />
<br />
=== HDA analyzer ===<br />
<br />
If the mappings to your audio pins(plugs) do not correspond but ALSA works fine, you could try HDA Analyzer -- a pyGTK2 GUI for HD-audio control can be found [http://www.alsa-project.org/main/index.php/HDA_Analyzer at the ALSA wiki].<br />
Try tweaking the Widget Control section of the PIN nodes, to make microphones IN and headphone jacks OUT. Referring to the Config Defaults heading is a good idea.<br />
<br />
{{Note|<br />
* The script is done by such way that it is incompatible with Python 3 (which is now shipped with Arch Linux) but tries to use it. The workaround is: open "run.py", find all occurences of "python" (2 occurences - one on the first line, and the second on the last line) and replace them all by "python2".<br />
* The script requires root acces, but running it via su/sudo is bogus. Run it via {{ic|kdesu}} or {{ic|gksu}}.<br />
}}<br />
<br />
=== ALSA with SDL ===<br />
<br />
If you get no sound via SDL and ALSA cannot be chosen from the application. Try setting the environmental variable SDL_AUDIODRIVER to alsa.<br />
# export SDL_AUDIODRIVER=alsa<br />
<br />
=== Low sound workaround ===<br />
<br />
If you are facing low sound even after maxing out your speakers/headphones, you can give the softvol plugin a try. Add the following to {{ic|/etc/asound.conf}}.<br />
{{bc|<nowiki><br />
pcm.!default {<br />
type plug<br />
slave.pcm "softvol"<br />
}<br />
<br />
pcm.softvol {<br />
type softvol<br />
slave {<br />
pcm "dmix"<br />
}<br />
control {<br />
name "Pre-Amp"<br />
card 0<br />
}<br />
min_dB -5.0<br />
max_dB 20.0<br />
resolution 6<br />
}<br />
</nowiki>}}<br />
{{Note|You will probably have to restart the computer, as restarting the alsa daemon did not load the new configuration for me. Also, if the configuration does not work even after restarting, try changing {{ic|plug}} with {{ic|hw}} in the above configuration.}}<br />
<br />
After the changes are loaded successfully, you will see a {{ic|Pre-Amp}} section in alsamixer. You can adjust the levels there.<br />
{{Note|<br />
* Setting a high value for {{ic|Pre-Amp}} can cause sound distortion, so adjust it according to the level that suits you.<br />
* Some audio codecs may need to have settings adjusted in the HDA Analyzer ([[#HDA analyzer|see above]]) in order to achieve proper volume without distortion. Checking the HP option under widget control in the Playback Switch (Node[0x14] PIN in the ALC892 codec, for instance) can sometimes improve audio quality and volume significantly.<br />
}}<br />
<br />
=== Popping sound after resuming from suspension ===<br />
<br />
You might hear a popping sound after resuming the computer from suspension. This can be fixed by editing {{ic|/etc/pm/sleep.d/90alsa}} and removing the line that says {{ic|aplay -d 1 /dev/zero}}<br />
<br />
=== Mute after reboot ===<br />
<br />
After reboot, sound setting by alsamixer can not restore. Maybe you can restore by command : {{ic|sudo alsactl restore}}. Please check the {{ic|Auto-Mute}} toggle status in alsamixer : set {{ic|Enabled}} to {{ic|Disabled}}.<br />
<br />
=== Volume too low ===<br />
<br />
The first thing to try is run {{ic|alsamixer}} and try to increase the value of the sliders, possibly unmuting channels if necessary. Note that if you have many sliders, you may have to scroll to the right to see any missing sliders.<br />
<br />
If all the sliders are maxed out, and the volume is still too low, you can try running the script at http://www.alsa-project.org/hda-analyzer.py to reset your codec settings:<br />
<br />
$ wget http://www.alsa-project.org/hda-analyzer.py<br />
$ sudo python2 hda-analyzer.py<br />
<br />
(Note that the script assumes "python" refers to Python 2, but on a typical ArchLinux installation, "python" refers to Python 3. Therefore, you may need to edit the last line of the script from {{ic|os.system("python %s" % TMPDIR + '/' + FILES[0] + ' ' + ' '.join(sys.argv[1:]))}} to {{ic|os.system("python2 %s" % TMPDIR + '/' + FILES[0] + ' ' + ' '.join(sys.argv[1:]))}}.<br />
<br />
Close the analyzer, and when prompted as to whether you want to reset the codecs, say "yes".<br />
<br />
If the volume is *still* too low, run {{ic|alsamixer}} again: resetting the codecs may have caused new sliders to become enabled, and some of them may be set to a low value.<br />
<br />
== Example configurations ==<br />
<br />
See [[Advanced Linux Sound Architecture/Example Configurations]].<br />
<br />
== See also ==<br />
<br />
* [http://www.mjmwired.net/kernel/Documentation/sound/alsa/ALSA-Configuration.txt Advanced ALSA module configuration]<br />
* [http://alsa.opensrc.org/Main_Page Unofficial ALSA wiki]<br />
* [https://bbs.archlinux.org/viewtopic.php?id=36815 HOWTO: compile driver from svn]<br />
* [http://www.volkerschatz.com/noise/alsa.html A close look at ALSA]</div>Hongy19https://wiki.archlinux.org/index.php?title=GRUB&diff=291591GRUB2014-01-04T12:23:10Z<p>Hongy19: </p>
<hr />
<div>[[Category:Boot loaders]]<br />
[[ar:GRUB]]<br />
[[cs:GRUB2]]<br />
[[de:GRUB]]<br />
[[el:GRUB]]<br />
[[es:GRUB]]<br />
[[fr:GRUB2]]<br />
[[id:GRUB2]]<br />
[[it:GRUB2]]<br />
[[ja:GRUB]]<br />
[[ru:GRUB2]]<br />
[[tr:GRUB2]]<br />
[[zh-CN:GRUB2]]<br />
[[zh-TW:GRUB2]]<br />
{{Related articles start}}<br />
{{Related|Arch Boot Process}}<br />
{{Related|Boot Loaders}}<br />
{{Related|Master Boot Record}}<br />
{{Related|GUID Partition Table}}<br />
{{Related|Unified Extensible Firmware Interface}}<br />
{{Related|GRUB EFI Examples}}<br />
{{Related articles end}}<br />
<br />
[https://www.gnu.org/software/grub/ GRUB] - not to be confused with [[GRUB Legacy]] - is the next generation of the GRand Unified Bootloader. GRUB is derived from [http://www.nongnu.org/pupa/ PUPA] which was a research project to develop the next generation of what is now GRUB Legacy. GRUB has been rewritten from scratch to clean up everything and provide modularity and portability [https://www.gnu.org/software/grub/grub-faq.html#q1].<br />
<br />
In brief, the ''bootloader'' is the first software program that runs when a computer starts. It is responsible for loading and transferring control to the Linux kernel. The kernel, in turn, initializes the rest of the operating system.<br />
<br />
== Preface ==<br />
<br />
* The name ''GRUB'' officially refers to version ''2'' of the software, see [https://www.gnu.org/software/grub/]. If you are looking for the article on the legacy version, see [[GRUB Legacy]].<br />
* GRUB supports [[Btrfs]] as root (without a separate {{ic|/boot}} filesystem) compressed with either zlib or LZO<br />
* GRUB does not support [[F2fs]] as root so you will need a separate {{ic|/boot}} with a supported filesystem.<br />
<br />
=== Notes for GRUB Legacy users ===<br />
<br />
* Upgrading from [[GRUB Legacy]] to GRUB is much the same as freshly installing GRUB. This topic is covered [[#Installation|here]].<br />
* There are differences in the commands of GRUB Legacy and GRUB. Familiarize yourself with [https://www.gnu.org/software/grub/manual/grub.html#Commands GRUB commands] before proceeding (e.g. "find" has been replaced with "search").<br />
* GRUB is now ''modular'' and no longer requires "stage 1.5". As a result, the bootloader itself is limited -- modules are loaded from the hard drive as needed to expand functionality (e.g. for [[LVM]] or RAID support).<br />
* Device naming has changed between GRUB Legacy and GRUB. Partitions are numbered from 1 instead of 0 while drives are still numbered from 0, and prefixed with partition-table type. For example, {{ic|/dev/sda1}} would be referred to as {{ic|(hd0,msdos1)}} (for MBR) or {{ic|(hd0,gpt1)}} (for GPT).<br />
* GRUB is noticeably bigger than GRUB legacy (occupies ~13 MB in {{ic|/boot}}). If you are booting from a separate {{ic|/boot}} partition, and this partition is smaller than 32 MB, you will run into disk space issues, and pacman will refuse to install new kernels.<br />
<br />
==== Backup important data ====<br />
<br />
Although a GRUB installation should run smoothly, it is strongly recommended to keep the GRUB Legacy files before upgrading to GRUB v2.<br />
<br />
# mv /boot/grub /boot/grub-legacy<br />
<br />
Backup the MBR which contains the boot code and partition table (replace {{ic|/dev/sd''X''}} with your actual disk path):<br />
<br />
# dd if=/dev/sd''X'' of=/path/to/backup/mbr_backup bs=512 count=1<br />
<br />
Only 446 bytes of the MBR contain boot code, the next 64 contain the partition table. If you do not want to overwrite your partition table when restoring, it is strongly advised to backup only the MBR boot code:<br />
<br />
# dd if=/dev/sd''X'' of=/path/to/backup/bootcode_backup bs=446 count=1<br />
<br />
If unable to install GRUB2 correctly, see [[#Restore GRUB Legacy|Restore GRUB Legacy]].<br />
<br />
=== Preliminary requirements ===<br />
<br />
==== BIOS systems ====<br />
<br />
===== GUID Partition Table (GPT) specific instructions =====<br />
<br />
GRUB in [[GPT|BIOS-GPT]] configuration requires a [http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html BIOS boot partition] to embed its {{ic|core.img}} in the absence of post-MBR gap in GPT partitioned systems (which is taken over by the GPT Primary Header and Primary Partition table). This partition is used by GRUB only in BIOS-GPT setups. No such partition type exists in case of MBR partitioning (at least not for GRUB). This partition is also not required if the system is UEFI based, as no embedding of bootsectors takes place in that case.<br />
<br />
For a BIOS-GPT configuration, create a 1007 KiB partition at the beginning of the disk using gdisk, cgdisk or GNU Parted with no filesystem. The size of 1007 KiB, plus the size of the preceding GPT of 17 KiB, will allow for the following partition to be correctly aligned at 1024 KiB. If needed, the partition can also be located somewhere else on the disk, but it should be within the first 2 TiB region. Set the partition type to {{ic|ef02}} in (c)gdisk or {{ic|set ''BOOT_PART_NUM'' bios_grub on}} in GNU Parted.<br />
<br />
The GPT partition also creates a protective MBR partition to stop unsupported tools from modifying it. You may need to set a bootable flag on this protective MBR e.g., using cfdisk, or some BIOSes/EFIs will refuse to boot. <br />
<br />
{{Note|<br />
* This partition should be created before {{ic|grub-install}} or {{ic|grub-setup}} is run<br />
* gdisk will only allow you to create this partition on the position which will waste the least amount of space (sector 34-2047) if you create it last, after all the other partitions. This is because gdisk will auto-align partitions to 2048-sector boundaries if possible<br />
}}<br />
<br />
===== Master Boot Record (MBR) specific instructions =====<br />
<br />
Usually the post-[[MBR]] gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 31 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding GRUB's {{ic|core.img}} ({{bug|24103}}). It is advisable to use a partitioner which supports 1 MiB partition alignment to obtain this space as well as satisfy other non-512 byte sector issues (which are unrelated to embedding of {{ic|core.img}}).<br />
<br />
==== UEFI systems ====<br />
<br />
{{Note|It is recommended to read and understand the [[UEFI]], [[GPT]] and [[UEFI Bootloaders]] pages.}}<br />
<br />
===== Check if you have GPT and an ESP =====<br />
<br />
An EFI System Partition (ESP) is needed on every disc you wan to boot using EFI. GPT is not strictly necessary, but it is highly recommended and is the only method currently supported in this article. If you are installing Archlinux on an EFI-capable computer with an already-working operating system, like Windows 8 for example, it is very likely that you already have an ESP. To check for GPT and for an ESP, use {{ic|parted}} as root to print the partition table of the disk you want to boot from. (We are calling it /dev/sda.)<br />
<br />
# parted /dev/sda print<br />
<br />
For GPT, you are looking for "Partition Table: GPT". For EFI, you are looking for a small (512 MiB or less) partition with a vfat filesystem and the 'boot' flag enabled. On it, there should be a folder called "EFI". If these criteria are met, this is your ESP. Make note of the partition number. You will need to know which one it is so you can mount it later on while installing GRUB to it.<br />
<br />
===== Create an ESP =====<br />
<br />
If you do not have an ESP, you will need to create it. Follow [[UEFI#EFI System Partition]] for instructions on creating an ESP.<br />
<br />
== Installation ==<br />
<br />
{{Note|If you are performing an [[Installation Guide|initial installation]] from the Arch live CD, make sure you have chrooted into the installed system before installing grub. Using the CD's own grub installation scripts may result in an invalid {{ic|grub.cfg}}, or other problems that will prevent the system from booting.}}<br />
<br />
=== BIOS systems ===<br />
<br />
GRUB can be [[pacman|installed]] with the {{Pkg|grub}} package from the [[official repositories]]. It will replace {{AUR|grub-legacy}} , if it is installed.<br />
<br />
{{Note|Simply installing the package will not update the {{ic|/boot/grub/i386-pc/core.img}} file and the GRUB modules in {{ic|/boot/grub/i386-pc}}. You need to update them manually using {{ic|grub-install}} as explained below.}}<br />
<br />
Before installing, make sure the correct UUIDs of your disks are inserted into {{ic| grub.cfg}}:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
==== Install boot files ====<br />
<br />
There are 3 ways to install GRUB boot files in BIOS booting:<br />
<br />
* [[#Install to disk|Install to disk]] (recommended)<br />
* [[#Install to partition or partitionless disk|Install to partition or partitionless disk]] (not recommended)<br />
* [[#Generate core.img alone|Generate core.img alone]] (safest method, but requires another BIOS bootloader like [[Syslinux]] to be installed to chainload {{ic|/boot/grub/i386-pc/core.img}})<br />
<br />
{{Note|See http://www.gnu.org/software/grub/manual/html_node/BIOS-installation.html for additional documentation.}}<br />
<br />
===== Install to disk =====<br />
<br />
{{Note|The method is specific to installing GRUB to a partitioned (MBR or GPT) disk, with GRUB files installed to {{ic|/boot/grub}} and its first stage code installed to the 440-byte MBR boot code region (not to be confused with MBR partition table). For partitionless disk (super-floppy) please refer to [[#Install to partition or partitionless disk]]}}<br />
<br />
To setup {{ic|grub}} in the 440-byte Master Boot Record boot code region, populate the {{ic|/boot/grub}} directory, generate the {{ic|/boot/grub/i386-pc/core.img}} file, and embed it in the 31 KiB (minimum size - varies depending on partition alignment) post-MBR gap in case of MBR partitioned disk (or BIOS Boot Partition in case of GPT partitioned disk, denoted by {{ic|bios_grub}} flag in parted and EF02 type code in gdisk), run:<br />
<br />
# grub-install --target=i386-pc --recheck --debug /dev/sda<br />
<br />
{{Note|<br />
* {{ic|/dev/sda}} used for example only.<br />
* {{ic|1=--target=i386-pc}} instructs {{ic|grub-install}} to install for BIOS systems only. It is recommended to always use this option to remove ambiguity in grub-install.<br />
}}<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, you can install GRUB on multiple physical disks.<br />
<br />
===== Install to partition or partitionless disk =====<br />
<br />
{{Note|GRUB does not encourage installation to a partition boot sector or a partitionless disk like GRUB Legacy or Syslinux does. This kind of setup is prone to breakage, especially during updates, and is not supported by Arch devs.}}<br />
<br />
To set up grub to a partition boot sector, to a partitionless disk (also called superfloppy) or to a floppy disk, run (using for example {{ic|/dev/sdaX}} as the {{ic|/boot}} partition):<br />
<br />
# chattr -i /boot/grub/i386-pc/core.img<br />
# grub-install --target=i386-pc --recheck --debug --force /dev/sdaX<br />
# chattr +i /boot/grub/i386-pc/core.img<br />
<br />
{{Note|<br />
* {{ic|/dev/sdaX}} used for example only.<br />
* {{ic|1=--target=i386-pc}} instructs {{ic|grub-install}} to install for BIOS systems only. It is recommended to always use this option to remove ambiguity in ''grub-install''.<br />
}}<br />
<br />
You need to use the {{ic|--force}} option to allow usage of blocklists and should not use {{ic|1=--grub-setup=/bin/true}} (which is similar to simply generating {{ic|core.img}}).<br />
<br />
{{ic|grub-install}} will give out warnings like which should give you the idea of what might go wrong with this approach:<br />
<br />
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.<br />
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists. <br />
However, blocklists are UNRELIABLE and their use is discouraged.<br />
<br />
Without {{ic|--force}} you may get the below error and {{ic|grub-setup}} will not setup its boot code in the partition boot sector:<br />
<br />
/sbin/grub-setup: error: will not proceed with blocklists<br />
<br />
With {{ic|--force}} you should get:<br />
<br />
Installation finished. No error reported.<br />
<br />
The reason why {{ic|grub-setup}} does not by default allow this is because in case of partition or a partitionless disk is that {{ic|grub}} relies on embedded blocklists in the partition bootsector to locate the {{ic|/boot/grub/i386-pc/core.img}} file and the prefix dir {{ic|/boot/grub}}. The sector locations of {{ic|core.img}} may change whenever the filesystem in the partition is being altered (files copied, deleted etc.). For more info see https://bugzilla.redhat.com/show_bug.cgi?id=728742 and https://bugzilla.redhat.com/show_bug.cgi?id=730915.<br />
<br />
The workaround for this is to set the immutable flag on {{ic|/boot/grub/i386-pc/core.img}} (using chattr command as mentioned above) so that the sector locations of the {{ic|core.img}} file in the disk is not altered. The immutable flag on {{ic|/boot/grub/i386-pc/core.img}} needs to be set only if {{ic|grub}} is installed to a partition boot sector or a partitionless disk, not in case of installation to MBR or simple generation of {{ic|core.img}} without embedding any bootsector (mentioned above).<br />
<br />
===== Generate core.img alone =====<br />
<br />
To populate the {{ic|/boot/grub}} directory and generate a {{ic|/boot/grub/i386-pc/core.img}} file '''without''' embedding any {{ic|grub}} bootsector code in the MBR, post-MBR region, or the partition bootsector, add {{ic|1=--grub-setup=/bin/true}} to {{ic|grub-install}}:<br />
<br />
# grub-install --target=i386-pc --grub-setup=/bin/true --recheck --debug /dev/sda<br />
<br />
{{Note|<br />
* {{ic|/dev/sda}} used for example only.<br />
* {{ic|1=--target=i386-pc}} instructs {{ic|grub-install}} to install for BIOS systems only. It is recommended to always use this option to remove ambiguity in grub-install.<br />
}}<br />
<br />
You can then chainload GRUB's {{ic|core.img}} from GRUB Legacy or syslinux as a Linux kernel or as a multiboot kernel.<br />
<br />
=== UEFI systems ===<br />
<br />
{{Note|It is well known that different motherboard manufactures implement UEFI differently. Users experiencing problems getting GRUB or EFI to work properly are encouraged to share detailed steps for hardware-specific cases where UEFI booting does not work as described below. In an effort to keep the parent [[GRUB]] article neat and tidy, see the [[GRUB EFI Examples]] page for these special cases.}}<br />
<br />
First install the {{Pkg|grub}}, {{Pkg|dosfstools}}, and {{Pkg|efibootmgr}} packages, then follow the instructions below. (The last two packages are required for EFI support in grub.)<br />
<br />
{{Note|Simply installing the package will not update the {{ic|core.efi}} file and the GRUB modules in the ESP. You need to do this manually using {{ic|grub-install}} as explained below.}}<br />
<br />
==== Install boot files ====<br />
<br />
===== Recommended method =====<br />
<br />
{{Note|<br />
* The below commands assume you are using installing GRUB for {{ic|x86_64-efi}} (for {{ic|IA32-efi}} replace {{ic|x86_64-efi}} with {{ic|i386-efi}} in the below commands)<br />
* To do this, you need to be booted using UEFI and not BIOS, or grub-install will show errors.<br />
}}<br />
<br />
First, mount the ESP at your preferred mountpoint (usually {{ic|/boot/efi}}, hereafter referred to as $esp). On a first install, you will need to mkdir /boot/efi, if that's where you want to mount it.<br />
<br />
Now, install the GRUB UEFI application to {{ic|$esp/EFI/grub}} and its modules to {{ic|/boot/grub/x86_64-efi}}:<br />
<br />
# grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub --recheck --debug<br />
<br />
{{Note|<br />
* If you have a problem when running grub-install with sysfs or procfs and it says you have to "modprobe efivars", try [[Unified_Extensible_Firmware_Interface#Switch_to_efivarfs]].<br />
* Without {{ic|--target}} or {{ic|--directory}} option, grub-install cannot determine for which firmware to install. In such cases {{ic|grub-install}} will print {{ic|source_dir does not exist. Please specify --target or --directory}}.<br />
* {{ic|--efi-directory}} and {{ic|--bootloader-id}} are specific to GRUB UEFI. {{ic|--efi-directory}} specifies the mountpoint of the ESP. It replaces {{ic|--root-directory}}, which is deprecated. {{ic|--bootloader-id}} specifies the name of the directory used to store the {{ic|grubx64.efi}} file.<br />
* If you notice carefully, there is no <device_path> option (Eg: {{ic|/dev/sda}}) at the end of the {{ic|grub-install}} command unlike the case of setting up GRUB for BIOS systems. Any <device_path> provided will be ignored by the install script, as UEFI bootloaders do not use MBR or Partition boot sectors at all.<br />
}}<br />
<br />
GRUB is now installed.<br />
<br />
===== Alternative method =====<br />
<br />
If you want to keep all of the GRUB boot files inside the EFI System Partition itself, add {{ic|--boot-directory&#61;$esp/EFI}} to the grub-install command:<br />
<br />
# grub-install --target=x86_64-efi --efi-directory=$esp --bootloader-id=grub --boot-directory=$esp/EFI --recheck --debug<br />
<br />
This puts the GRUB modules in {{ic|$esp/EFI/grub}}. ('/grub' is hard coded onto the end of this path.) Using this method, grub.cfg is kept on the EFI System Partition as well, so make sure you point grub-mkconfig to the right place in the configuration phase:<br />
<br />
# grub-mkconfig -o $esp/EFI/grub/grub.cfg<br />
<br />
Configuration is otherwise the same.<br />
<br />
==== Create a GRUB entry in the firmware boot manager ====<br />
<br />
{{ic|grub-install}} automatically tries to create a menu entry in the boot manager. If it does not, then see [[Beginners' Guide#GRUB]] for instructions to use {{ic|efibootmgr}} to create a menu entry. However, the problem is likely to be that you have not booted your CD/USB in UEFI mode, as in [[UEFI#Create UEFI bootable USB from ISO]].<br />
<br />
==== GRUB Standalone ====<br />
<br />
{{Note|Use {{Aur|grub-git}} pkg for standalone GRUB EFI image as the {{Pkg|grub}} pkg does not contain various grub-mkstandalone specific fixes (specifically {{ic|${cmdpath} }} support, which is necessary).}}<br />
<br />
It is possible to create a {{ic|grubx64_standalone.efi}} application which has all the modules embedded in a tar archive within the UEFI application, thus removing the need for having a separate directory populated with all the GRUB UEFI modules and other related files. This is done using the {{ic|grub-mkstandalone}} command (included in {{Pkg|grub}}) as follows"<br />
<br />
# echo 'configfile ${cmdpath}/grub.cfg' > /tmp/grub.cfg ## use single quotes, ${cmdpath} should be present as it is<br />
# grub-mkstandalone -d /usr/lib/grub/x86_64-efi/ -O x86_64-efi --modules="part_gpt part_msdos" --fonts="unicode" --locales="en@quot" --themes="" -o "$esp/EFI/grub/grubx64_standalone.efi" "/boot/grub/grub.cfg=/tmp/grub.cfg" -v<br />
<br />
{{Note|The option {{ic|1=--modules="part_gpt part_msdos"}} (with the quotes) is necessary for {{ic|${cmdpath} }} feature to work properly.}}<br />
<br />
Then copy the GRUB config file to {{ic|$esp/EFI/grub/grub.cfg}} and create a UEFI Boot Manager entry for {{ic|$esp/EFI/grub/grubx64_standalone.efi}} using [[UEFI#efibootmgr|efibootmgr]].<br />
<br />
===== GRUB Standalone - Technical Info =====<br />
<br />
The GRUB EFI file always expects its config file to be at {{ic|${prefix}/grub.cfg}}. However in the standalone GRUB EFI file, the {{ic|${prefix} }} is located inside a tar archive and embedded inside the standalone GRUB EFI file itself (inside grub env it is denoted by {{ic|"(memdisk)"}}, without quotes). This tar archive contains all the files that would be stored normally at {{ic|/boot/grub}} in case of a normal GRUB EFI install. <br />
<br />
Due to this embedding of {{ic|/boot/grub}} contents inside the standalone image itself, it does not rely on actual (external) {{ic|/boot/grub}} for anything. Thus in case of standalone GRUB EFI file {{ic|1=${prefix}==(memdisk)/boot/grub}} and the standalone GRUB EFI file reads expects the config file to be at {{ic|1=${prefix}/grub.cfg==(memdisk)/boot/grub/grub.cfg}}. <br />
<br />
Hence to make sure the standalone GRUB EFI file reads the external {{ic|grub.cfg}} located in the same dir as the EFI file (inside grub env it is denoted by {{ic|${cmdpath} }}), we create a simple {{ic|/tmp/grub.cfg}} which instructs GRUB to use {{ic|${cmdpath}/grub.cfg}} as its config ({{ic|configfile ${cmdpath}/grub.cfg}} command in {{ic|(memdisk)/boot/grub/grub.cfg}}). We then instruct grub-mkstandalone to copy this {{ic|/tmp/grub.cfg}} file to {{ic|${prefix}/grub.cfg}} (which is actually {{ic|(memdisk)/boot/grub/grub.cfg}}) using the option {{ic|1="/boot/grub/grub.cfg=/tmp/grub.cfg"}}.<br />
<br />
This way the standalone GRUB EFI file and actual {{ic|grub.cfg}} can be stored in any dir inside the EFI System Partition (as long as they are in the same dir), thus making them portable.<br />
<br />
== Generating main configuration file ==<br />
<br />
After the installation, the main configuration file {{ic|grub.cfg}} needs to be generated. The generation process can be influenced by a variety of options in {{ic|/etc/default/grub}} and scripts in {{ic|/etc/grub.d/}}, this is covered in the [[#Basic configuration]] and [[#Advanced configuration]] sections.<br />
<br />
{{Note|Remember that {{ic|grub.cfg}} has to be re-generated after any change to {{ic|/etc/default/grub}} or {{ic|/etc/grub.d/*}}.}}<br />
<br />
Use the ''grub-mkconfig'' tool to generate {{ic|grub.cfg}}:<br />
<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
{{Note|<br />
* The file path for BIOS systems is {{ic|/boot/grub/grub.cfg}}, NOT {{ic|/boot/grub/i386-pc/grub.cfg}}.<br />
* For EFI systems, if GRUB was installed with the {{ic|1=--boot-directory=$esp/EFI}} option set, the {{ic|grub.cfg}} file must be placed in the same directory as {{ic|grubx64.efi}}. Otherwise, the {{ic|grub.cfg}} file goes in {{ic|/boot/grub/}}, just like in BIOS systems.<br />
* If you are trying to run ''grub-mkconfig'' in a chroot or ''systemd-nspawn'' container, you might notice that it does not work, complaining that ''grub-probe'' cannot get the "canonical path of /dev/sdaX". In this case, try using ''arch-chroot'' as described [https://bbs.archlinux.org/viewtopic.php?pid&#61;1225067#p1225067 here].<br />
}}<br />
<br />
By default the generation scripts automatically add menu entries for Arch Linux to any generated configuration. However, entries for other operating systems do not work out of the box. On BIOS systems, you may want to install {{Pkg|os-prober}}, which detects other operating systems installed on your machine and adds entries for them into {{ic|grub.cfg}}. If installed, it will be executed when running ''grub-mkconfig''. See [[#Dual-booting]] for advanced configuration.<br />
<br />
=== Converting GRUB Legacy's config file to the new format ===<br />
<br />
If {{ic|grub-mkconfig}} fails, convert your {{ic|/boot/grub/menu.lst}} file to {{ic|/boot/grub/grub.cfg}} using:<br />
<br />
# grub-menulst2cfg /boot/grub/menu.lst /boot/grub/grub.cfg<br />
<br />
{{Note|This option works only in BIOS systems, not in UEFI systems.}}<br />
<br />
For example:<br />
<br />
{{hc|/boot/grub/menu.lst|<nowiki><br />
default=0<br />
timeout=5<br />
<br />
title Arch Linux Stock Kernel<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux.img<br />
<br />
title Arch Linux Stock Kernel Fallback<br />
root (hd0,0)<br />
kernel /vmlinuz-linux root=/dev/sda2 ro<br />
initrd /initramfs-linux-fallback.img<br />
</nowiki>}}<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
set default='0'; if [ x"$default" = xsaved ]; then load_env; set default="$saved_entry"; fi<br />
set timeout=5<br />
<br />
menuentry 'Arch Linux Stock Kernel' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux.img' '/initramfs-linux.img'<br />
}<br />
<br />
menuentry 'Arch Linux Stock Kernel Fallback' {<br />
set root='(hd0,1)'; set legacy_hdbias='0'<br />
legacy_kernel '/vmlinuz-linux' '/vmlinuz-linux' 'root=/dev/sda2' 'ro'<br />
legacy_initrd '/initramfs-linux-fallback.img' '/initramfs-linux-fallback.img'<br />
}<br />
</nowiki>}}<br />
<br />
If you forgot to create a GRUB {{ic|/boot/grub/grub.cfg}} config file and simply rebooted into GRUB Command Shell, type:<br />
<br />
sh:grub> insmod legacycfg<br />
sh:grub> legacy_configfile ${prefix}/menu.lst<br />
<br />
Boot into Arch and re-create the proper GRUB {{ic|/boot/grub/grub.cfg}} config file.<br />
<br />
== Basic configuration ==<br />
<br />
This section covers only editing the {{ic|/etc/default/grub}} configuration file. See [[#Advanced configuration]] if you need more.<br />
<br />
{{Note|Remember to always [[#Generating main configuration file|re-generate the main configuration file]] after you make changes to {{ic|/etc/default/grub}}.}}<br />
<br />
==== Additional arguments ====<br />
<br />
To pass custom additional arguments to the Linux image, you can set the {{ic|GRUB_CMDLINE_LINUX}} + {{ic|GRUB_CMDLINE_LINUX_DEFAULT}} variables in {{ic|/etc/default/grub}}. The two are appended to each other and passed to kernel when generating regular boot entries. For the ''recovery'' boot entry, only {{ic|GRUB_CMDLINE_LINUX}} is used in the generation. <br />
<br />
It is not necessary to use both, but can be useful. For example, you could use {{ic|<nowiki>GRUB_CMDLINE_LINUX_DEFAULT="resume=/dev/sdaX</nowiki> quiet"}} where {{ic|sda'''X'''}} is your swap partition to enable resume after hibernation. This would generate a recovery boot entry without the resume and without ''quiet'' suppressing kernel messages during a boot from that menu entry. Though, the other (regular) menu entries would have them as options. <br />
<br />
For generating the GRUB recovery entry you also have to comment out {{ic|<nowiki>#GRUB_DISABLE_RECOVERY=true</nowiki>}} in {{ic|/etc/default/grub}}. <br />
<br />
You can also use {{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/disk/by-uuid/${swap_uuid}"</nowiki>}}, where {{ic|${swap_uuid} }} is the [[Persistent_block_device_naming|UUID]] of your swap partition.<br />
<br />
Multiple entries are separated by spaces within the double quotes. So, for users who want both resume and systemd it would look like this:<br />
{{ic|<nowiki>GRUB_CMDLINE_LINUX="resume=/dev/sdaX init=/usr/lib/systemd/systemd"</nowiki>}}<br />
<br />
See [[Kernel parameters]] for more info.<br />
<br />
=== Visual configuration ===<br />
<br />
In GRUB it is possible, by default, to change the look of the menu. Make sure to initialize, if not done already, GRUB graphical terminal, gfxterm, with proper video mode, gfxmode, in GRUB. This can be seen in the section [[#"No suitable mode found" error]]. This video mode is passed by GRUB to the linux kernel via 'gfxpayload' so any visual configurations need this mode in order to be in effect.<br />
<br />
==== Setting the framebuffer resolution ====<br />
<br />
GRUB can set the framebuffer for both GRUB itself and the kernel. The old {{ic|1=vga=}} way is deprecated. The preferred method is editing {{ic|/etc/default/grub}} as the following sample:<br />
<br />
GRUB_GFXMODE=1024x768x32<br />
GRUB_GFXPAYLOAD_LINUX=keep<br />
<br />
To generate the changes, run: <br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
<br />
The {{ic|gfxpayload}} property will make sure the kernel keeps the resolution.<br />
<br />
{{Note|<br />
* If this example does not work for you try to replace {{ic|1=gfxmode="1024x768x32"}} by {{ic|1=vbemode="0x105"}}. Remember to replace the specified resolution with one suitable for your screen<br />
* To show all the modes you can use {{ic|1=# hwinfo --framebuffer}} (hwinfo is available in [community]), while at GRUB prompt you can use the {{ic|1=vbeinfo}} command<br />
}}<br />
<br />
If this method does not work for you, the deprecated {{ic|1=vga=}} method will still work. Just<br />
add it next to the {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="}} line in {{ic|/etc/default/grub}}<br />
for eg: {{ic|1="GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792"}} will give you a {{ic|1024x768}} resolution.<br />
<br />
You can choose one of these resolutions: {{ic|640×480}}, {{ic|800×600}}, {{ic|1024×768}}, {{ic|1280×1024}}, {{ic|1600×1200}}, {{ic|1920×1200}}<br />
<br />
==== 915resolution hack ====<br />
<br />
Some times for Intel graphic adapters neither {{ic|1=# hwinfo --framebuffer}} nor {{ic|1=vbeinfo}} will show you the desired resolution. In this case you can use {{ic|915resolution}} hack. This hack will temporarily modify video BIOS and add needed resolution. See [http://915resolution.mango-lang.org/ 915resolution's home page]<br />
<br />
First you need to find a video mode which will be modified later. For that we need the GRUB command shell:<br />
{{hc|sh:grub> 915resolution -l|<br />
Intel 800/900 Series VBIOS Hack : version 0.5.3<br />
[...]<br />
'''Mode 30''' : 640x480, 8 bits/pixel<br />
[...]<br />
}}<br />
Next, we overwrite the {{ic|Mode 30}} with {{ic|1440x900}} resolution:<br />
{{hc|/etc/grub.d/00_header|<br />
[...]<br />
'''915resolution 30 1440 900 # Inserted line'''<br />
set gfxmode&#61;${GRUB_GFXMODE}<br />
[...]<br />
}}<br />
Lastly we need to set {{ic|GRUB_GFXMODE}} as described earlier, regenerate {{ic|grub.cfg}} and reboot to test changes.<br />
<br />
==== Background image and bitmap fonts ====<br />
<br />
GRUB comes with support for background images and bitmap fonts in {{ic|pf2}} format. The unifont font is included in the {{Pkg|grub}} package under the filename {{ic|unicode.pf2}}, or, as only ASCII characters under the name {{ic|ascii.pf2}}.<br />
<br />
Image formats supported include tga, png and jpeg, providing the correct modules are loaded. The maximum supported resolution depends on your hardware.<br />
<br />
Make sure you have set up the proper [[#Setting the framebuffer resolution|framebuffer resolution]].<br />
<br />
Edit {{ic|/etc/default/grub}} like this:<br />
GRUB_BACKGROUND="/boot/grub/myimage"<br />
#GRUB_THEME="/path/to/gfxtheme"<br />
GRUB_FONT="/path/to/font.pf2"<br />
<br />
{{Note|If you have installed GRUB on a separate partition, {{ic|/boot/grub/myimage}} becomes {{ic|/grub/myimage}}.}}<br />
<br />
[[#Generating main configuration file|Re-generate]] {{ic|grub.cfg}} to apply the changes. If adding the splash image was successful, the user will see {{ic|"Found background image..."}} in the terminal as the command is executed. If this phrase is not seen, the image information was probably not incorporated into the {{ic|grub.cfg}} file.<br />
<br />
If the image is not displayed, check:<br />
* The path and the filename in {{ic|/etc/default/grub}} are correct<br />
* The image is of the proper size and format (tga, png, 8-bit jpg)<br />
* The image was saved in the RGB mode, and is not indexed<br />
* The console mode is not enabled in {{ic|/etc/default/grub}}<br />
* The command {{ic|grub-mkconfig}} must be executed to place the background image information into the {{ic|/boot/grub/grub.cfg}} file<br />
<br />
==== Theme ====<br />
<br />
Here is an example for configuring Starfield theme which was included in GRUB package.<br />
<br />
Edit {{ic|/etc/default/grub}}<br />
GRUB_THEME="/usr/share/grub/themes/starfield/theme.txt"<br />
<br />
[[#Generating main configuration file|Re-generate]] {{ic|grub.cfg}} to apply the changes. If configuring the theme was successful, you will see {{ic|Found theme: /usr/share/grub/themes/starfield/theme.txt}} in the terminal.<br />
<br />
Your splash image will usually not be displayed when using a theme.<br />
<br />
==== Menu colors ====<br />
<br />
You can set the menu colors in GRUB. The available colors for GRUB can be found in [https://www.gnu.org/software/grub/manual/html_node/Theme-file-format.html the GRUB Manual].<br />
Here is an example:<br />
<br />
Edit {{ic|/etc/default/grub}}:<br />
GRUB_COLOR_NORMAL="light-blue/black"<br />
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"<br />
<br />
==== Hidden menu ====<br />
<br />
One of the unique features of GRUB is hiding/skipping the menu and showing it by holding {{ic|Esc}} when needed. You can also adjust whether you want to see the timeout counter.<br />
<br />
Edit {{ic|/etc/default/grub}} as you wish. Here is an example where the comments from the beginning of the two lines have been removed to enable the feature, the timeout has been set to five seconds and to be shown to the user:<br />
GRUB_TIMEOUT=0<br />
GRUB_HIDDEN_TIMEOUT=5<br />
GRUB_HIDDEN_TIMEOUT_QUIET=false<br />
GRUB_HIDDEN_TIMEOUT is how many seconds before displaying menu. You also need to set GRUB_TIMEOUT=0 if you want to hide menu.<br />
<br />
==== Disable framebuffer ====<br />
<br />
Users who use NVIDIA proprietary driver might wish to disable GRUB's framebuffer as it can cause problems with the binary driver.<br />
<br />
To disable framebuffer, edit {{ic|/etc/default/grub}} and uncomment the following line:<br />
GRUB_TERMINAL_OUTPUT=console<br />
<br />
Another option if you want to keep the framebuffer in GRUB is to revert to text mode just before starting the kernel. To do that modify the variable in {{ic|/etc/default/grub}}:<br />
GRUB_GFXPAYLOAD_LINUX=text<br />
<br />
=== Persistent block device naming ===<br />
<br />
One naming scheme for [[Persistent block device naming]] is the use of globally unique UUIDs to detect partitions instead of the "old" {{ic|/dev/sd*}}. Advantages are covered up in the above linked article. <br />
<br />
Persistent naming via filesystem UUIDs are used by default in GRUB. <br />
<br />
{{Note|The {{ic|/boot/grub.cfg}} file needs regeneration with the new UUID in {{ic|/etc/default/grub}} every time a relevant filesystem is resized or recreated. Remember this when modifying partitions & filesystems with a Live-CD.}}<br />
<br />
Whether to use UUIDs is controlled by an option in {{ic|/etc/default/grub}}:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
=== Recall previous entry ===<br />
<br />
GRUB can remember the last entry you booted from and use this as the default entry to boot from next time. This is useful if you have multiple kernels (i.e., the current Arch one and the LTS kernel as a fallback option) or operating systems. To do this, edit {{ic|/etc/default/grub}} and change the value of {{ic|GRUB_DEFAULT}}:<br />
<br />
GRUB_DEFAULT=saved<br />
<br />
This ensures that GRUB will default to the saved entry. To enable saving the selected entry, add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_SAVEDEFAULT=true<br />
<br />
{{Note|Manually added menu items, e.g. Windows in {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}}, will need {{ic|savedefault}} added.}}<br />
<br />
=== Changing the default menu entry ===<br />
<br />
To change the default selected entry, edit {{ic|/etc/default/grub}} and change the value of {{ic|GRUB_DEFAULT}}:<br />
<br />
Using numbers :<br />
GRUB_DEFAULT=0<br />
Grub identifies entries in generated menu counted from zero. That means 0 for the first entry which is the default value, 1 for the second and so on.<br />
<br />
Or using menu titles :<br />
GRUB_DEFAULT='Arch Linux, with Linux core repo kernel'<br />
<br />
=== Root encryption ===<br />
<br />
To let GRUB automatically add the kernel parameters for root encryption,<br />
add {{ic|1=cryptdevice=/dev/yourdevice:label}} to {{ic|GRUB_CMDLINE_LINUX}} in {{ic|/etc/default/grub}}.<br />
<br />
{{Tip|If you are upgrading from a working GRUB Legacy configuration, check {{ic|/boot/grub/menu.lst.pacsave}} for the correct device/label to add. Look for them after the text {{ic|kernel /vmlinuz-linux}}.}}<br />
<br />
Example with root mapped to {{ic|/dev/mapper/root}}:<br />
<br />
GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:root"<br />
<br />
Also, disable the usage of UUIDs for the rootfs:<br />
<br />
GRUB_DISABLE_LINUX_UUID=true<br />
<br />
=== Boot non-default entry only once ===<br />
<br />
The command {{ic|grub-reboot}} is very helpful to boot another entry than the default only once. GRUB loads the entry passed in the first command line argument, when the system is rebooted the next time. Most importantly GRUB returns to loading the default entry for all future booting. Changing the configuration file or selecting an entry in the GRUB menu is not necessary.<br />
{{Note|This requires {{ic|1=GRUB_DEFAULT=saved}} in {{ic|/etc/default/grub}} (and then regenerating {{ic|grub.cfg}}) or, in case of hand-made {{ic|grub.cfg}}, the line {{ic|1=set default="${saved_entry}"}}.}}<br />
<br />
== Advanced configuration ==<br />
<br />
This section covers manual editing of {{ic|grub.cfg}}, writing custom scripts in {{ic|/etc/grub.d/}} and other advanced settings.<br />
<br />
=== Manually creating grub.cfg ===<br />
<br />
{{Warning|Editing this file is strongly discouraged. The file is generated by the {{ic|grub-mkconfig}} command, and it is best to edit your {{ic|/etc/default/grub}} or one of the scripts in the {{ic|/etc/grub.d}} folder.}}<br />
<br />
A basic GRUB config file uses the following options:<br />
* {{ic|(hd''X'',''Y'')}} is the partition ''Y'' on disk ''X'', partition numbers starting at 1, disk numbers starting at 0<br />
* {{ic|1=set default=''N''}} is the default boot entry that is chosen after timeout for user action<br />
* {{ic|1=set timeout=''M''}} is the time ''M'' to wait in seconds for a user selection before default is booted<br />
* {{ic|<nowiki>menuentry "title" {entry options}</nowiki>}} is a boot entry titled {{ic|title}}<br />
* {{ic|1=set root=(hd''X'',''Y'')}} sets the boot partition, where the kernel and GRUB modules are stored (boot need not be a separate partition, and may simply be a directory under the "root" partition ({{ic|/}})<br />
<br />
An example configuration:<br />
<br />
{{hc|/boot/grub/grub.cfg|<nowiki><br />
# Config file for GRUB - The GNU GRand Unified Bootloader<br />
# /boot/grub/grub.cfg<br />
<br />
# DEVICE NAME CONVERSIONS<br />
#<br />
# Linux Grub<br />
# -------------------------<br />
# /dev/fd0 (fd0)<br />
# /dev/sda (hd0)<br />
# /dev/sdb2 (hd1,2)<br />
# /dev/sda3 (hd0,3)<br />
#<br />
<br />
# Timeout for menu<br />
set timeout=5<br />
<br />
# Set default boot entry as Entry 0<br />
set default=0<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
set root=(hd0,1)<br />
linux /vmlinuz-linux root=/dev/sda3 ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
## (1) Windows<br />
#menuentry "Windows" {<br />
# set root=(hd0,3)<br />
# chainloader +1<br />
#}<br />
</nowiki>}}<br />
<br />
=== Dual-booting ===<br />
<br />
{{Note|If you want GRUB to automatically search for other systems, you may wish to install {{Pkg|os-prober}}.}}<br />
<br />
==== Automatically generating using /etc/grub.d/40_custom and grub-mkconfig ====<br />
<br />
The best way to add other entries is editing the {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}}. The entries in this file will be automatically added when running {{ic|grub-mkconfig}}.<br />
After adding the new lines, run:<br />
{{bc|<nowiki># grub-mkconfig -o /boot/grub/grub.cfg</nowiki>}}<br />
or, for UEFI-GPT Mode:<br />
{{bc|<nowiki># grub-mkconfig -o /boot/efi/EFI/GRUB/grub.cfg</nowiki>}}<br />
to generate an updated {{ic|grub.cfg}}.<br />
<br />
For example, a typical {{ic|/etc/grub.d/40_custom}} file, could appear similar to the following one, created for [http://h10025.www1.hp.com/ewfrf/wc/product?cc=us&destPage=product&lc=en&product=5402703&tmp_docname= HP Pavilion 15-e056sl Notebook PC], originally with Microsoft Windows 8 preinstalled. Each {{ic|menuentry}} should mantain a structure similar to the following ones. Note that the UEFI partition {{ic|/dev/sda2}} within GRUB is called {{ic|hd0,gpt2}} and {{ic|ahci0,gpt2}} (see [[#Windows Installed in UEFI-GPT Mode menu entry|here]] for more info).<br />
<br />
'''/etc/grub.d/40_custom''':<br />
<br />
{{bc|<nowiki>#!/bin/sh<br />
exec tail -n +3 $0<br />
# This file provides an easy way to add custom menu entries.&nbsp; Simply type the<br />
# menu entries you want to add after this comment.&nbsp; Be careful not to change<br />
# the 'exec tail' line above.<br />
<br />
menuentry "HP / Microsoft Windows 8.1" {<br />
echo "Loading HP / Microsoft Windows 8.1..."<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 763A-9CB6<br />
chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi<br />
}<br />
<br />
menuentry "HP / Microsoft Control Center" {<br />
echo "Loading HP / Microsoft Control Center..."<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --set=root --hint-bios=hd0,gpt2 --hint-efi=hd0,gpt2 --hint-baremetal=ahci0,gpt2 763A-9CB6<br />
chainloader (${root})/EFI/HP/boot/bootmgfw.efi<br />
}<br />
<br />
menuentry "System shutdown" {<br />
echo "System shutting down..."<br />
halt<br />
}<br />
<br />
menuentry "System restart" {<br />
echo "System rebooting..."<br />
reboot<br />
}</nowiki>}}<br />
<br />
===== GNU/Linux menu entry =====<br />
<br />
Assuming that the other distro is on partition {{ic|sda2}}:<br />
<br />
{{bc|<nowiki>menuentry "Other Linux" {<br />
set root=(hd0,2)<br />
linux /boot/vmlinuz (add other options here as required)<br />
initrd /boot/initrd.img (if the other kernel uses/needs one)<br />
}</nowiki>}}<br />
<br />
===== FreeBSD menu entry =====<br />
<br />
Requires that FreeBSD is installed on a single partition with UFS. Assuming it is installed on {{ic|sda4}}:<br />
<br />
{{bc|<nowiki>menuentry "FreeBSD" {<br />
set root=(hd0,4)<br />
chainloader +1<br />
}</nowiki>}}<br />
<br />
===== Windows XP menu entry=====<br />
<br />
This assumes that your Windows partition is {{ic|sda3}}. Remember you need to point set root and chainloader to the system reserve partition that windows made when it installed, not the actual partition windows is on. This example works if your system reserve partition is {{ic|sda3}}.<br />
<br />
{{bc|<nowiki># (2) Windows XP<br />
menuentry "Windows XP" {<br />
set root="(hd0,3)"<br />
chainloader +1<br />
}</nowiki>}}<br />
<br />
If the Windows bootloader is on an entirely different hard drive than GRUB, it may be necessary to trick Windows into believing that it is the first hard drive. This was possible with {{ic|drivemap}}. Assuming GRUB is on {{ic|hd0}} and Windows is on {{ic|hd2}}, you need to add the following after {{ic|set root}}:<br />
<br />
{{bc|<nowiki>drivemap -s hd0 hd2</nowiki>}}<br />
<br />
===== Windows Installed in UEFI-GPT Mode menu entry =====<br />
<br />
{{bc|<nowiki>if [ "${grub_platform}" == "efi" ]; then<br />
menuentry "Microsoft Windows Vista/7/8 x86_64 UEFI-GPT" {<br />
insmod part_gpt<br />
insmod fat<br />
insmod search_fs_uuid<br />
insmod chain<br />
search --fs-uuid --set=root $hints_string $uuid<br />
chainloader /EFI/Microsoft/Boot/bootmgfw.efi<br />
}<br />
fi</nowiki>}}<br />
<br />
where {{ic|$hints_string}} and {{ic|$uuid}} are obtained with the following two commands. {{ic|$uuid}}'s command:<br />
<br />
{{bc|<nowiki># grub-probe --target=fs_uuid $esp/EFI/Microsoft/Boot/bootmgfw.efi<br />
1ce5-7f28</nowiki>}}<br />
<br />
{{ic|$hints_string}}'s command:<br />
<br />
{{bc|<nowiki># grub-probe --target=hints_string $esp/EFI/Microsoft/Boot/bootmgfw.efi<br />
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1</nowiki>}}<br />
<br />
These two commands assume the ESP Windows uses is mounted at {{ic|$esp}}. There might be case differences in the path to Windows's EFI file, what with being Windows, and all.<br />
<br />
===== "Shutdown" menu entry =====<br />
<br />
{{bc|<nowiki>menuentry "System shutdown" {<br />
echo "System shutting down..."<br />
halt<br />
}</nowiki>}}<br />
<br />
===== "Restart" menu entry =====<br />
<br />
{{bc|<nowiki>menuentry "System restart" {<br />
echo "System rebooting..."<br />
reboot<br />
}</nowiki>}}<br />
<br />
===== Windows installed in BIOS-MBR mode =====<br />
<br />
{{Poor writing|This section does not fit into the others, should be slimmed down a bit.}}<br />
<br />
{{Note|GRUB supports booting {{ic|bootmgr}} directly and chainload of partition boot sector is no longer required to boot Windows in a BIOS-MBR setup.}}<br />
<br />
{{Warning|It is the '''system partition''' that has {{ic|bootmgr}}, not your "real" Windows partition (usually C:). When showing all UUIDs with blkid, the system partition is the one with {{ic|LABEL&#61;"SYSTEM RESERVED"}} or {{ic|LABEL&#61;"SYSTEM"}} and is only about 100 to 200 MB in size (much like the boot partition for Arch). See [[Wikipedia:System partition and boot partition]] for more info.}}<br />
<br />
Throughout this section, it is assumed your Windows partition is {{ic|/dev/sda1}}. A different partition will change every instance of hd0,msdos1. First, find the UUID of the NTFS filesystem of the Windows's SYSTEM PARTITION where the {{ic|bootmgr}} and its files reside. For example, if Windows {{ic|bootmgr}} exists at {{ic|/media/SYSTEM_RESERVED/bootmgr}}:<br />
<br />
For Windows Vista/7/8:<br />
<br />
# grub-probe --target=fs_uuid /media/SYSTEM_RESERVED/bootmgr<br />
69B235F6749E84CE<br />
<br />
# grub-probe --target=hints_string /media/SYSTEM_RESERVED/bootmgr<br />
--hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1<br />
<br />
{{Note|For Windows XP, replace {{ic|bootmgr}} with {{ic|NTLDR}} in the above commands. And note that there may not be a separate SYSTEM_RESERVED partition; just probe the file NTLDR on your Windows partition.}}<br />
<br />
Then, add the below code to {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} and regenerate {{ic|grub.cfg}} with {{ic|grub-mkconfig}} as explained above to boot Windows (XP, Vista, 7 or 8) installed in BIOS-MBR mode:<br />
<br />
For Windows Vista/7/8:<br />
<br />
if [ "${grub_platform}" == "pc" ]; then<br />
menuentry "Microsoft Windows Vista/7/8 BIOS-MBR" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE<br />
ntldr /bootmgr<br />
}<br />
fi<br />
<br />
For Windows XP:<br />
<br />
if [ "${grub_platform}" == "pc" ]; then<br />
menuentry "Microsoft Windows XP" {<br />
insmod part_msdos<br />
insmod ntfs<br />
insmod search_fs_uuid<br />
insmod ntldr <br />
search --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 69B235F6749E84CE<br />
ntldr /bootmgr<br />
}<br />
fi<br />
<br />
{{Note|In some cases, mine I have installed GRUB before a clean Windows 8, you cannot boot Windows having an error with {{ic|\boot\bcd}} (error code {{ic|0xc000000f}}). You can fix it going to Windows Recovery Console (cmd from install disk) and executing:<br />
x:\> "bootrec.exe /fixboot" <br />
x:\> "bootrec.exe /RebuildBcd".<br />
Do '''not''' use {{ic|bootrec.exe /Fixmbr}} because it will wipe GRUB out.}}<br />
<br />
{{ic|/etc/grub.d/40_custom}} can be used as a template to create {{ic|/etc/grub.d/nn_custom}}. Where {{ic|nn}} defines the precendence, indicating the order the script is executed. The order scripts are executed determine the placement in the grub boot menu.<br />
<br />
{{Note|{{ic|nn}} should be greater than 06 to ensure necessary scripts are executed first.}}<br />
<br />
==== With Windows via EasyBCD and NeoGRUB ====<br />
<br />
{{Merge|NeoGRUB|New page has been created, so this section should be merged there.}}<br />
<br />
Since EasyBCD's NeoGRUB currently does not understand the GRUB menu format, chainload to it by replacing the contents of your {{ic|C:\NST\menu.lst}} file with lines similar to the following:<br />
<br />
default 0<br />
timeout 1<br />
<br />
title Chainload into GRUB v2<br />
root (hd0,7)<br />
kernel /boot/grub/i386-pc/core.img<br />
<br />
Finally, recreate your {{ic|grub.cfg}} using {{ic|grub-mkconfig}}.<br />
<br />
=== Booting an ISO directly from GRUB ===<br />
<br />
Edit {{ic|/etc/grub.d/40_custom}} or {{ic|/boot/grub/custom.cfg}} to add an entry for the target ISO. When finished, update the GRUB menu as with the usual {{ic|grub-mkconfig -o /boot/grub/grub.cfg}} (as root).<br />
<br />
==== Arch ISO ====<br />
<br />
{{Note|The following examples assume the ISO is in {{ic|/archives}} on {{ic|hd0,6}}.}}<br />
{{Tip|For thumbdrives, use something like {{ic|(hd1,$partition)}} and either {{ic|/dev/sdb'''Y'''}} for the {{ic|img_dev}} parameter or [[Persistent block device naming|a persistent name]], e.g. {{ic|img_dev&#61;/dev/disk/by-label/CORSAIR}}.}}<br />
<br />
===== x86_64 =====<br />
<br />
menuentry "Archlinux-2013.05.01-dual.iso" --class iso {<br />
set isofile="/archives/archlinux-2013.05.01-dual.iso"<br />
set partition="6"<br />
loopback loop (hd0,$partition)/$isofile<br />
linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/x86_64/archiso.img<br />
}<br />
<br />
===== i686 =====<br />
<br />
menuentry "Archlinux-2013.05.01-dual.iso" --class iso {<br />
set isofile="/archives/archlinux-2013.05.01-dual.iso"<br />
set partition="6"<br />
loopback loop (hd0,$partition)/$isofile<br />
linux (loop)/arch/boot/i686/vmlinuz archisolabel=ARCH_201305 img_dev=/dev/sda$partition img_loop=$isofile earlymodules=loop<br />
initrd (loop)/arch/boot/i686/archiso.img<br />
}<br />
<br />
==== Ubuntu ISO ====<br />
<br />
{{Note|The example assumes that the iso is in {{ic|/archives}} on {{ic|hd0,6}}. Users must adjust the location and hdd/partition in the lines below to match their systems.}}<br />
<br />
menuentry "ubuntu-13.04-desktop-amd64.iso" {<br />
set isofile="/archives/ubuntu-13.04-desktop-amd64.iso"<br />
loopback loop (hd0,6)/$isofile<br />
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
menuentry "ubuntu-12.04-desktop-amd64.iso" {<br />
set isofile="/archives/ubuntu-12.04-desktop-amd64.iso"<br />
loopback loop (hd0,6)/$isofile<br />
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash --<br />
initrd (loop)/casper/initrd.lz<br />
}<br />
<br />
==== Other ISOs ====<br />
<br />
Other working configurations from [http://askubuntu.com/questions/141940/how-to-boot-live-iso-images link Source].<br />
<br />
=== LVM ===<br />
<br />
If you use [[LVM]] for your {{ic|/boot}}, add the following before menuentry lines:<br />
<br />
insmod lvm<br />
<br />
and specify your root in the menuentry as:<br />
<br />
set root=lvm/''lvm_group_name''-''lvm_logical_boot_partition_name''<br />
<br />
Example:<br />
<br />
# (0) Arch Linux<br />
menuentry "Arch Linux" {<br />
insmod lvm<br />
set root=lvm/VolumeGroup-lv_boot<br />
# you can only set following two lines<br />
linux /vmlinuz-linux root=/dev/mapper/VolumeGroup-root ro<br />
initrd /initramfs-linux.img<br />
}<br />
<br />
=== RAID ===<br />
<br />
GRUB provides convenient handling of RAID volumes. You need to add {{ic|insmod mdraid}} which allows you to address the volume natively. For example, {{ic|/dev/md0}} becomes:<br />
set root=(md0)<br />
<br />
whereas a partitioned RAID volume (e.g. {{ic|/dev/md0p1}}) becomes:<br />
set root=(md0,1)<br />
<br />
To install grub when using RAID1 as the {{ic|/boot}} partition (or using {{ic|/boot}} housed on a RAID1 root partition), on devices with GPT ef02/'BIOS boot partition', simply run ''grub-install'' on both of the drives, such as:<br />
# grub-install --target=i386-pc --recheck --debug /dev/sda<br />
# grub-install --target=i386-pc --recheck --debug /dev/sdb<br />
<br />
Where the RAID1 array housing {{ic|/boot}} is housed on {{ic|/dev/sda}} and {{ic|/dev/sdb}}.<br />
<br />
=== Using labels ===<br />
<br />
It is possible to use labels, human-readable strings attached to filesystems, by using the {{ic|--label}} option to {{ic|search}}. First of all, label your existing partition:<br />
# tune2fs -L ''LABEL'' ''PARTITION''<br />
<br />
Then, add an entry using labels. An example of this:<br />
<br />
menuentry "Arch Linux, session texte" {<br />
search --label --set=root archroot<br />
linux /boot/vmlinuz-linux root=/dev/disk/by-label/archroot ro<br />
initrd /boot/initramfs-linux.img<br />
}<br />
<br />
=== Password protection of GRUB menu ===<br />
<br />
If you want to secure GRUB so it is not possible for anyone to change boot parameters or use the command line, you can add a user/password combination to GRUB's configuration files. To do this, run the command {{ic|grub-mkpasswd-pbkdf2}}. Enter a password and confirm it:<br />
<br />
{{hc|grub-mkpasswd-pbkdf2|<br />
[...]<br />
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A<br />
}}<br />
<br />
Then, add the following to {{ic|/etc/grub.d/00_header}}:<br />
<br />
{{hc|/etc/grub.d/00_header|<br />
cat << EOF<br />
<br />
set superusers<nowiki>=</nowiki>"'''username'''"<br />
password_pbkdf2 '''username''' '''<password>'''<br />
<br />
EOF<br />
}}<br />
<br />
where {{ic|<password>}} is the string generated by {{ic|grub-mkpasswd_pbkdf2}}.<br />
<br />
Regenerate your configuration file. Your GRUB command line, boot parameters and all boot entries are now protected.<br />
<br />
This can be relaxed and further customized with more users as described in the "Security" part of [https://www.gnu.org/software/grub/manual/grub.html#Security the GRUB manual].<br />
<br />
=== Hide GRUB unless the Shift key is held down ===<br />
<br />
In order to achieve the fastest possible boot, instead of having GRUB wait for a timeout, it is possible for GRUB to hide the menu, unless the {{ic|Shift}} key is held down during GRUB's start-up.<br />
<br />
In order to achieve this, you should add the following line to {{ic|/etc/default/grub}}:<br />
<br />
GRUB_FORCE_HIDDEN_MENU="true"<br />
<br />
And the following file should be created:<br />
<br />
{{hc|/etc/grub.d/31_hold_shift|<nowiki><br />
#! /bin/sh<br />
set -e<br />
<br />
# grub-mkconfig helper script.<br />
# Copyright (C) 2006,2007,2008,2009 Free Software Foundation, Inc.<br />
#<br />
# GRUB is free software: you can redistribute it and/or modify<br />
# it under the terms of the GNU General Public License as published by<br />
# the Free Software Foundation, either version 3 of the License, or<br />
# (at your option) any later version.<br />
#<br />
# GRUB is distributed in the hope that it will be useful,<br />
# but WITHOUT ANY WARRANTY; without even the implied warranty of<br />
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the<br />
# GNU General Public License for more details.<br />
#<br />
# You should have received a copy of the GNU General Public License<br />
# along with GRUB. If not, see <http://www.gnu.org/licenses/>.<br />
<br />
prefix="/usr"<br />
exec_prefix="${prefix}"<br />
datarootdir="${prefix}/share"<br />
<br />
export TEXTDOMAIN=grub<br />
export TEXTDOMAINDIR="${datarootdir}/locale"<br />
source "${datarootdir}/grub/grub-mkconfig_lib"<br />
<br />
found_other_os=<br />
<br />
make_timeout () {<br />
<br />
if [ "x${GRUB_FORCE_HIDDEN_MENU}" = "xtrue" ] ; then <br />
if [ "x${1}" != "x" ] ; then<br />
if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then<br />
verbose=<br />
else<br />
verbose=" --verbose"<br />
fi<br />
<br />
if [ "x${1}" = "x0" ] ; then<br />
cat <<EOF<br />
if [ "x\${timeout}" != "x-1" ]; then<br />
if keystatus; then<br />
if keystatus --shift; then<br />
set timeout=-1<br />
else<br />
set timeout=0<br />
fi<br />
else<br />
if sleep$verbose --interruptible 3 ; then<br />
set timeout=0<br />
fi<br />
fi<br />
fi<br />
EOF<br />
else<br />
cat << EOF<br />
if [ "x\${timeout}" != "x-1" ]; then<br />
if sleep$verbose --interruptible ${GRUB_HIDDEN_TIMEOUT} ; then<br />
set timeout=0<br />
fi<br />
fi<br />
EOF<br />
fi<br />
fi<br />
fi<br />
}<br />
<br />
adjust_timeout () {<br />
if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then<br />
cat <<EOF<br />
if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then<br />
EOF<br />
make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}"<br />
echo else<br />
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"<br />
echo fi<br />
else<br />
make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"<br />
fi<br />
}<br />
<br />
adjust_timeout<br />
<br />
cat <<EOF<br />
if [ "x\${timeout}" != "x-1" ]; then<br />
if keystatus; then<br />
if keystatus --shift; then<br />
set timeout=-1<br />
else<br />
set timeout=0<br />
fi<br />
else<br />
if sleep$verbose --interruptible 3 ; then<br />
set timeout=0<br />
fi<br />
fi<br />
fi<br />
EOF<br />
</nowiki>}}<br />
<br />
=== Combining the use of UUIDs and basic scripting ===<br />
<br />
If you like the idea of using UUIDs to avoid unreliable BIOS mappings or are struggling with GRUB's syntax, here is an example boot menu item that uses UUIDs and a small script to direct GRUB to the proper disk partitions for your system. All you need to do is replace the UUIDs in the sample with the correct UUIDs for your system. The example applies to a system with a boot and root partition. You will obviously need to modify the GRUB configuration if you have additional partitions:<br />
<br />
{{bc|<nowiki><br />
menuentry "Arch Linux 64" {<br />
# Set the UUIDs for your boot and root partition respectively<br />
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07<br />
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a<br />
<br />
# (Note: This may be the same as your boot partition)<br />
<br />
# Get the boot/root devices and set them in the root and grub_boot variables<br />
search --fs-uuid $the_root_uuid --set=root<br />
search --fs-uuid $the_boot_uuid --set=grub_boot<br />
<br />
# Check to see if boot and root are equal.<br />
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)<br />
if [ $the_boot_uuid == $the_root_uuid ] ; then<br />
set grub_boot=($grub_boot)/boot<br />
else<br />
set grub_boot=($grub_boot)<br />
fi<br />
<br />
# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd<br />
linux $grub_boot/vmlinuz-linux root=/dev/disk/by-uuid/$the_root_uuid ro<br />
initrd $grub_boot/initramfs-linux.img<br />
}<br />
</nowiki>}}<br />
<br />
== Using the command shell ==<br />
<br />
Since the MBR is too small to store all GRUB modules, only the menu and a few basic commands reside there. The majority of GRUB functionality remains in modules in {{ic|/boot/grub}}, which are inserted as needed. In error conditions (e.g. if the partition layout changes) GRUB may fail to boot. When this happens, a command shell may appear.<br />
<br />
GRUB offers multiple shells/prompts. If there is a problem reading the menu but the bootloader is able to find the disk, you will likely be dropped to the "normal" shell:<br />
sh:grub><br />
<br />
If there is a more serious problem (e.g. GRUB cannot find required files), you may instead be dropped to the "rescue" shell:<br />
grub rescue><br />
<br />
The rescue shell is a restricted subset of the normal shell, offering much less functionality. If dumped to the rescue shell, first try inserting the "normal" module, then starting the "normal" shell:<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
grub rescue> insmod (hdX,Y)/boot/grub/i386-pc/normal.mod<br />
rescue:grub> normal<br />
<br />
=== Pager support ===<br />
<br />
GRUB supports pager for reading commands that provide long output (like the {{ic|help}} command). This works only in normal shell mode and not in rescue mode. To enable pager, in GRUB command shell type:<br />
sh:grub> set pager=1<br />
<br />
=== Using the command shell environment to boot operating systems ===<br />
<br />
grub> <br />
<br />
The GRUB's command shell environment can be used to boot operating systems.<br />
A common scenario may be to boot Windows / Linux stored on a drive/partition via '''chainloading'''.<br />
<br />
''Chainloading'' means to load another boot-loader from the current one, ie, chain-loading.<br />
<br />
The other bootloader may be embedded at the starting of the disk(MBR) or at the starting of a partition.<br />
<br />
==== Chainloading a partition ====<br />
<br />
set root=(hdX,Y)<br />
chainloader +1<br />
boot<br />
<br />
X=0,1,2...<br />
Y=1,2,3...<br />
<br />
For example to chainload Windows stored in the first partiton of the first hard disk, <br />
<br />
set root=(hd0,1)<br />
chainloader +1<br />
boot<br />
<br />
Similarly GRUB installed to a partition can be chainloaded.<br />
<br />
==== Chainloading a disk/drive ====<br />
<br />
set root=hdX<br />
chainloader +1<br />
boot<br />
<br />
==== Normal loading ====<br />
<br />
See the examples in [[Grub#Using_the_rescue_console|#Using_the_rescue_console]]<br />
<br />
== GUI configuration tools ==<br />
<br />
Following package may be installed:<br />
* {{App|grub-customizer|Customize the bootloader (GRUB or BURG)|https://launchpad.net/grub-customizer|{{AUR|grub-customizer}}}}<br />
* {{App|grub2-editor|KDE4 control module for configuring the GRUB bootloader|http://kde-apps.org/content/show.php?content&#61;139643|{{AUR|grub2-editor}}}}<br />
* {{App|kcm-grub2|This Kcm module manages the most common settings of GRUB|http://kde-apps.org/content/show.php?content&#61;137886|{{AUR|kcm-grub2}}}}<br />
* {{App|startupmanager|GUI app for changing the settings of GRUB Legacy, GRUB, Usplash and Splashy ([https://launchpad.net/startup-manager/+announcement/8300 abandonned])|http://sourceforge.net/projects/startup-manager/|{{AUR|startupmanager}}}}<br />
<br />
== parttool for hide/unhide ==<br />
<br />
If you have a Windows 9x paradigm with hidden {{ic|C:\}} disks GRUB can hide/unhide it using {{ic|parttool}}. For example, to boot the third {{ic|C:\}} disk of three Windows 9x installations on the CLI enter the CLI and:<br />
parttool hd0,1 hidden+ boot-<br />
parttool hd0,2 hidden+ boot-<br />
parttool hd0,3 hidden- boot+<br />
set root=hd0,3<br />
chainloader +1<br />
boot<br />
<br />
== Using the rescue console ==<br />
<br />
See [[#Using the command shell]] first. If unable to activate the standard shell, one possible solution is to boot using a live CD or some other rescue disk to correct configuration errors and reinstall GRUB. However, such a boot disk is not always available (nor necessary); the rescue console is surprisingly robust.<br />
<br />
The available commands in GRUB rescue include {{ic|insmod}}, {{ic|ls}}, {{ic|set}}, and {{ic|unset}}. This example uses {{ic|set}} and {{ic|insmod}}. {{ic|set}} modifies variables and {{ic|insmod}} inserts new modules to add functionality.<br />
<br />
Before starting, the user must know the location of their {{ic|/boot}} partition (be it a separate partition, or a subdirectory under their root):<br />
grub rescue> set prefix=(hdX,Y)/boot/grub<br />
<br />
where X is the physical drive number and Y is the partition number.<br />
<br />
To expand console capabilities, insert the {{ic|linux}} module:<br />
grub rescue> insmod (hdX,Y)/boot/grub/linux.mod<br />
<br />
{{Note|With a separate boot partition, omit {{ic|/boot}} from the path, (i.e. type {{ic|1=set prefix=(hdX,Y)/grub}} and {{ic|insmod (hdX,Y)/grub/linux.mod}}).}}<br />
<br />
This introduces the {{ic|linux}} and {{ic|initrd}} commands, which should be familiar (see [[#Advanced configuration]]).<br />
<br />
An example, booting Arch Linux:<br />
set root=(hd0,5)<br />
linux /boot/vmlinuz-linux root=/dev/sda5<br />
initrd /boot/initramfs-linux.img<br />
boot<br />
<br />
With a separate boot partition, again change the lines accordingly:<br />
set root=(hd0,5)<br />
linux /vmlinuz-linux root=/dev/sda6<br />
initrd /initramfs-linux.img<br />
boot<br />
<br />
After successfully booting the Arch Linux installation, users can correct {{ic|grub.cfg}} as needed and then reinstall GRUB.<br />
<br />
To reinstall GRUB and fix the problem completely, changing {{ic|/dev/sda}} if needed. See [[#Installation]] for details.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Intel BIOS not booting GPT ===<br />
<br />
Some Intel BIOS's require at least one bootable MBR partition to be present at boot, causing GPT-partitioned boot setups to be unbootable.<br />
<br />
This can be circumvented by using (for instance) fdisk to mark one of the GPT partitions (preferably the 1007 KiB partition you have created for GRUB already) bootable in the MBR. This can be achieved, using fdisk, by the following commands: Start fdisk against the disk you are installing, for instance {{ic|fdisk /dev/sda}}, then press {{ic|a}} and select the partition you wish to mark as bootable (probably #1) by pressing the corresponding number, finally press {{ic|w}} to write the changes to the MBR.<br />
<br />
{{Note|The bootable-marking must be done in {{ic|fdisk}} or similar, not in GParted or others, as they will not set the bootable flag in the MBR.}}<br />
<br />
More information is available [http://www.rodsbooks.com/gdisk/bios.html here]<br />
<br />
=== Enable debug messages ===<br />
<br />
Add:<br />
<br />
set pager=1<br />
set debug=all<br />
<br />
to {{ic|grub.cfg}}.<br />
<br />
=== "No suitable mode found" error ===<br />
<br />
If you get this error when booting any menuentry:<br />
<br />
error: no suitable mode found<br />
Booting however<br />
<br />
Then you need to initialize GRUB graphical terminal ({{ic|gfxterm}}) with proper video mode ({{ic|gfxmode}}) in GRUB. This video mode is passed by GRUB to the linux kernel via 'gfxpayload'. In case of UEFI systems, if the GRUB video mode is not initialized, no kernel boot messages will be shown in the terminal (atleast until KMS kicks in).<br />
<br />
Copy {{ic|/usr/share/grub/unicode.pf2}} to ${GRUB_PREFIX_DIR} ({{ic|/boot/grub/}} in case of BIOS and UEFI systems). If GRUB UEFI was installed with {{ic|1=--boot-directory=$esp/EFI}} set, then the directory is {{ic|$esp/EFI/grub/}}:<br />
<br />
# cp /usr/share/grub/unicode.pf2 ${GRUB_PREFIX_DIR}<br />
<br />
If {{ic|/usr/share/grub/unicode.pf2}} does not exist, install {{Pkg|bdf-unifont}}, create the {{ic|unifont.pf2}} file and then copy it to {{ic|${GRUB_PREFIX_DIR<nowiki>}</nowiki>}}:<br />
<br />
# grub-mkfont -o unicode.pf2 /usr/share/fonts/misc/unifont.bdf<br />
<br />
Then, in the {{ic|grub.cfg}} file, add the following lines to enable GRUB to pass the video mode correctly to the kernel, without of which you will only get a black screen (no output) but booting (actually) proceeds successfully without any system hang.<br />
<br />
BIOS systems:<br />
<br />
insmod vbe<br />
<br />
UEFI systems:<br />
<br />
insmod efi_gop<br />
insmod efi_uga<br />
<br />
After that add the following code (common to both BIOS and UEFI):<br />
<br />
insmod font<br />
<br />
if loadfont ${prefix}/fonts/unicode.pf2<br />
then<br />
insmod gfxterm<br />
set gfxmode=auto<br />
set gfxpayload=keep<br />
terminal_output gfxterm<br />
fi<br />
<br />
As you can see for gfxterm (graphical terminal) to function properly, {{ic|unicode.pf2}} font file should exist in {{ic|${GRUB_PREFIX_DIR<nowiki>}</nowiki>}}.<br />
<br />
=== msdos-style error message ===<br />
<br />
grub-setup: warn: This msdos-style partition label has no post-MBR gap; embedding will not be possible!<br />
grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.<br />
However, blocklists are UNRELIABLE and its use is discouraged.<br />
grub-setup: error: If you really want blocklists, use --force.<br />
<br />
This error may occur when you try installing GRUB in a VMware container. Read more about it [https://bbs.archlinux.org/viewtopic.php?pid=581760#p581760 here]. It happens when the first partition starts just after the MBR (block 63), without the usual space of 1 MiB (2048 blocks) before the first partition. Read [[#Master Boot Record (MBR) specific instructions]]<br />
<br />
=== GRUB UEFI drops to shell ===<br />
<br />
If GRUB loads but drops you into the rescue shell with no errors, it may be because of a missing or misplaced {{ic|grub.cfg}}. This will happen if GRUB UEFI was installed with {{ic|--boot-directory}} and {{ic|grub.cfg}} is missing OR if the partition number of the boot partition changed (which is hard-coded into the {{ic|grubx64.efi}} file).<br />
<br />
=== GRUB UEFI not loaded ===<br />
<br />
An example of a working EFI:<br />
{{hc|# efibootmgr -v|<br />
BootCurrent: 0000<br />
Timeout: 3 seconds<br />
BootOrder: 0000,0001,0002<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\efi\grub\grub.efi)<br />
Boot0001* Shell HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\EfiShell.efi)<br />
Boot0002* Festplatte BIOS(2,0,00)P0: SAMSUNG HD204UI<br />
}}<br />
<br />
If the screen only goes black for a second and the next boot option is tried afterwards, according to [https://bbs.archlinux.org/viewtopic.php?pid=981560#p981560 this post], moving GRUB to the partition root can help. The boot option has to be deleted and recreated afterwards. The entry for GRUB should look like this then:<br />
Boot0000* Grub HD(1,800,32000,23532fbb-1bfa-4e46-851a-b494bfe9478c)File(\grub.efi)<br />
<br />
=== Invalid signature ===<br />
<br />
If trying to boot Windows results in an "invalid signature" error, e.g. after reconfiguring partitions or adding additional hard drives, (re)move GRUB's device configuration and let it reconfigure:<br />
# mv /boot/grub/device.map /boot/grub/device.map-old<br />
# grub-mkconfig -o /boot/grub/grub.cfg<br />
{{ic|grub-mkconfig}} should now mention all found boot options, including Windows. If it works, remove {{ic|/boot/grub/device.map-old}}.<br />
<br />
=== Boot freezes ===<br />
<br />
If booting gets stuck without any error message after GRUB loading the kernel and the initial ramdisk, try removing the {{ic|add_efi_memmap}} kernel parameter.<br />
<br />
=== Restore GRUB Legacy ===<br />
<br />
* Move GRUB v2 files out of the way:<br />
<br />
# mv /boot/grub /boot/grub.nonfunctional<br />
<br />
* Copy GRUB Legacy back to {{ic|/boot}}:<br />
<br />
# cp -af /boot/grub-legacy /boot/grub<br />
<br />
* Replace MBR and next 62 sectors of sda with backed up copy<br />
<br />
{{Warning|This command also restores the partition table, so be careful of overwriting a modified partition table with the old one. It '''will''' mess up your system.}}<br />
<br />
# dd if=/path/to/backup/first-sectors of=/dev/sdX bs=512 count=1<br />
<br />
A safer way is to restore only the MBR boot code use:<br />
<br />
# dd if=/path/to/backup/mbr-boot-code of=/dev/sdX bs=446 count=1<br />
<br />
=== Arch not found from other OS ===<br />
<br />
Some have reported that other distributions have trouble finding Arch Linux automatically with {{ic|os-prober}}. If this problem arises, it has been reported that detection can be improved with the presence of {{ic|/etc/lsb-release}}. This file and updating tool is available with the package {{Pkg|lsb-release}} in the [[official repositories]].<br />
<br />
=== Out of memory/Syntax error running grub-mkconfig ===<br />
<br />
{{Note|This is workaround for {{Bug|37904}}.}}<br />
<br />
Add {{ic|1=GRUB_DISABLE_SUBMENU=y}} in {{ic|/etc/default/grub}} and regenerate {{ic|grub.cfg}}.<br />
<br />
== See also ==<br />
<br />
# Official GRUB Manual - https://www.gnu.org/software/grub/manual/grub.html<br />
# Ubuntu wiki page for GRUB - https://help.ubuntu.com/community/Grub2<br />
# GRUB wiki page describing steps to compile for UEFI systems - https://help.ubuntu.com/community/UEFIBooting<br />
# Wikipedia's page on [[Wikipedia:BIOS Boot partition|BIOS Boot partition]]<br />
# http://members.iinet.net/~herman546/p20/GRUB2%20Configuration%20File%20Commands.html - quite complete description of how to configure GRUB</div>Hongy19https://wiki.archlinux.org/index.php?title=Nginx&diff=244227Nginx2013-01-17T04:46:36Z<p>Hongy19: /* Error: No input file specified */</p>
<hr />
<div>[[Category:Web Server]]<br />
[[de:Nginx]]<br />
[[ja:Nginx]]<br />
[[ru:Nginx]]<br />
[[zh-CN:Nginx]]<br />
'''Nginx''' (pronounced "engine X") written by Igor Sysoev (Russia) in 2005, is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. According to Netcraft's [http://news.netcraft.com/archives/2012/04/04/april-2012-web-server-survey.html April 2012 Web Server Survey], Nginx now hosts 10.32% of all domains worldwide, while [[Apache]] hosts about 65.46%. Nginx is now well known for its stability, rich feature set, simple configuration, and low resource consumption.<br />
<br />
== Installation ==<br />
<br />
[[Pacman|Install]] package {{Pkg|nginx}} in the [[Official Repositories|official repositories]].<br />
<br />
For a '''Ruby on Rails''' oriented installation, see [[RubyOnRails#Option_C:_The_Perfect_Rails_Setup|The Perfect Rails Setup]].<br />
<br />
<br />
== Installation in a chroot ==<br />
<br />
Installing Nginx in a chroot adds an additional layer of secure. For<br />
maximum security the chroot should include only the files needed to run<br />
the Nginx server and all files should have the most restrictive<br />
permissions possible, e.g., as much as possible should be owned by root,<br />
directories such as {{ic|/usr/bin}} should be unreadable and unwriteable,<br />
etc. <br />
<br />
Arch comes with an {{ic|http}} user and group by default which will run the<br />
server. The chroot will be in {{ic|/srv/http}}.<br />
<br />
A perl script to create this jail is available at<br />
[https://gist.github.com/4365696 jail.pl gist]. It expects to be run<br />
as root. You'll need to uncomment a line before it makes any changes.<br />
<br />
=== Create Necessary Devices === <br />
<br />
Nginx needs {{ic|/dev/null}}, {{ic|/dev/random}}, and<br />
{{ic|/dev/urandom}}. To install these in the chroot we create the<br />
{{ic|/dev/}} folder and add the devices with mknod. We avoid mounting<br />
all of {{ic|/dev/}} to ensure that, even if the chroot is compromised, an<br />
attacker must break out of the chroot to access important devices like<br />
{{ic|/dev/sda1}}.<br />
<br />
{{Tip|See {{ic|man mknod}} and {{ic|<nowiki>ls -l<br />
/dev/{null,random,urandom}</nowiki>}} to better<br />
understand the argument to mknod.}}<br />
<br />
# export JAIL=/srv/http<br />
# mkdir $JAIL/dev<br />
# mknod -m 0666 $JAIL/dev/null c 1 3<br />
# mknod -m 0666 $JAIL/dev/random c 1 8<br />
# mknod -m 0444 $JAIL/dev/urandom c 1 9<br />
<br />
=== Create Necessary Folders ===<br />
<br />
Nginx requires a bunch of files to run properly. Before copying them<br />
over, create the folders to store them. This assumes your Nginx document<br />
root will be {{ic|/srv/http/www}}.<br />
<br />
# mkdir -p $JAIL/etc/nginx/logs<br />
# mkdir -p $JAIL/usr/{lib,sbin}<br />
# mkdir -p $JAIL/usr/share/nginx<br />
# mkdir -p $JAIL/var/{log,lib}/nginx<br />
# mkdir -p $JAIL/www/cgi-bin<br />
# mkdir -p $JAIL/{run,tmp}<br />
# cd $JAIL; ln -s usr/lib lib <br />
<br />
Then mount {{ic|$JAIL/tmp}} and {{ic|$JAIL/run}} as tmpfs's. The size<br />
should be limited to ensure an attacker cannot eat all the RAM.<br />
<br />
# mount -t tmpfs none /srv/http/run -o 'noexec,size=1M'<br />
# mount -t tmpfs none /srv/http/tmp -o 'noexec,size=100M'<br />
<br />
=== Populate the chroot ===<br />
<br />
First copy over the easy files.<br />
<br />
# cp -r /usr/share/nginx/* $JAIL/usr/share/nginx<br />
# cp -r /usr/share/nginx/html/* $JAIL/www<br />
# cp /usr/sbin/nginx $JAIL/usr/sbin/<br />
# cp -r /var/lib/nginx $JAIL/var/lib/nginx<br />
<br />
Now copy over required libraries. Use ldd to list them and then copy<br />
them all to the correct location. Copying is preferred over hardlinks to<br />
ensure that even if an attacker gains write access to the files they<br />
cannot destroy or alter the true system files.<br />
<br />
{{hc|$ ldd /usr/sbin/nginx|<nowiki><br />
linux-vdso.so.1 (0x00007fff5adff000)<br />
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fdb1a8d3000)<br />
libcrypt.so.1 => /usr/lib/libcrypt.so.1 (0x00007fdb1a69c000)<br />
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fdb1a399000)<br />
libm.so.6 => /usr/lib/libm.so.6 (0x00007fdb1a09f000)<br />
libpcre.so.1 => /usr/lib/libpcre.so.1 (0x00007fdb19e3c000)<br />
libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0x00007fdb19bd2000)<br />
libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0x00007fdb197c9000)<br />
libdl.so.2 => /usr/lib/libdl.so.2 (0x00007fdb195c5000)<br />
libz.so.1 => /usr/lib/libz.so.1 (0x00007fdb193af000)<br />
libGeoIP.so.1 => /usr/lib/libGeoIP.so.1 (0x00007fdb1917c000)<br />
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fdb18f67000)<br />
libc.so.6 => /usr/lib/libc.so.6 (0x00007fdb18bc0000)<br />
/lib/ld-linux-x86-64.so.2 (0x00007fdb1aaef000)</nowiki>}}<br />
<br />
# cp /usr/lib/libpthread.so.0 $JAIL/usr/lib/<br />
# cp /usr/lib/libcrypt.so.1 $JAIL/usr/lib<br />
...<br />
# cp /lib/ld-linux-x86-64.so.2 $JAIL/lib<br />
<br />
Copy over some misc. but necessary libraries and system files.<br />
<br />
{{bc|# cp /usr/lib/libnss_* $JAIL/usr/lib<br />
# cp -rfvL /etc/{services,localtime,nsswitch.conf,nscd.conf,protocols,hosts,ld.so.cache,ld.so.conf,resolv.conf,host.conf,nginx} $JAIL/etc}}<br />
<br />
Create restricted user/group files for the chroot. This way only the<br />
users needed for the chroot to function exist as far as the chroot<br />
knows, and none of the system users/groups are leaked to attackers<br />
should they gain access to the chroot.<br />
<br />
{{hc|$JAIL/etc/group|<br />
http:x:33:<br />
nobody:x:99:<br />
}}<br />
<br />
{{hc|$JAIL/etc/passwd|<br />
http:x:33:33:http:/:/bin/false<br />
nobody:x:99:99:nobody:/:/bin/false<br />
}}<br />
<br />
{{hc|$JAIL/etc/shadow|<br />
http:x:14871::::::<br />
nobody:x:14871::::::<br />
}}<br />
<br />
{{hc|$JAIL/etc/gshadow|<br />
http:::<br />
nobody:::<br />
}}<br />
<br />
# touch $JAIL/etc/shells<br />
# touch $JAIL/run/nginx.pid<br />
<br />
Finally make set very restrictive permissions. As much as possible<br />
should be owned by root and set unwritable.<br />
<br />
# chown -R root:root $JAIL/<br />
<br />
# chown -R #USER:$GROUP $JAIL/www<br />
# chown -R #USER:$GROUP $JAIL/etc/nginx<br />
# chown -R #USER:$GROUP $JAIL/var/{log,lib}/nginx<br />
# chown #USER:$GROUP $JAIL/run/nginx.pid<br />
<br />
# find $JAIL/ -gid 0 -uid 0 -type d -print | xargs chmod -rw<br />
# find $JAIL/ -gid 0 -uid 0 -type d -print | xargs chmod +x<br />
# find $JAIL/etc -gid 0 -uid 0 -type f -print | xargs chmod -x<br />
# find $JAIL/usr/sbin -type f -print | xargs chmod ug+rx<br />
# find $JAIL/ -group http -user http -print | xargs chmod o-rwx<br />
# chmod +rw $JAIL/tmp<br />
# chmod +rw $JAIL/run<br />
<br />
If your server will bind port 80 (or any port 0-1024), give the<br />
chrooted executable permission to bind these ports without root.<br />
<br />
# setcap 'cap_net_bind_service=+ep' $JAIL/usr/sbin/nginx<br />
<br />
=== Modify nginx.service to start chroot ===<br />
<br />
The systemd unit must be changed to start up Nginx in the chroot, as<br />
the http user, and store the pid file in the chroot <br />
{{Note|I'm not sure if the pid file needs to be stored in the root.}}<br />
<br />
{{hc|/usr/lib/systemd/system/nginx.service|<nowiki><br />
[Unit]<br />
Description=A high performance web server and a reverse proxy server<br />
After=syslog.target network.target<br />
<br />
[Service]<br />
Type=forking<br />
PIDFile=/srv/http/run/nginx.pid<br />
ExecStartPre=/usr/bin/chroot --userspec=http:http /srv/http /usr/sbin/nginx -t -q -g 'pid /run/nginx.pid; daemon on; master_process on;'<br />
ExecStart=/usr/bin/chroot --userspec=http:http /srv/http /usr/sbin/nginx -g 'pid /run/nginx.pid; daemon on; master_process on;'<br />
ExecReload=/usr/bin/chroot --userspec=http:http /srv/http /usr/sbin/nginx -g 'pid /run/nginx.pid; daemon on; master_process on;' -s reload<br />
ExecStop=/usr/bin/chroot --userspec=http:http /srv/http /usr/sbin/nginx -g 'pid /run/nginx.pid;' -s quit<br />
<br />
[Install]<br />
WantedBy=multi-user.target</nowiki>}}<br />
<br />
== Starting Service ==<br />
<br />
To start the Nginx service, run:<br />
# rc.d start nginx<br />
<br />
The default served page at http://127.0.0.1 is: <br />
/usr/share/nginx/html/index.html<br />
<br />
To enable the Nginx service by default at start-up just add {{Ic|nginx}} to the {{Ic|DAEMONS}} array in {{ic|/etc/rc.conf}}:<br />
DAEMONS=(ntpd syslog-ng ... nginx)<br />
<br />
==== Using Systemd ====<br />
<br />
To start the Nginx service, run:<br />
# systemctl start nginx<br />
<br />
To enable the Nginx service by default at start-up, run:<br />
# systemctl enable nginx<br />
<br />
== Configuring ==<br />
<br />
You can modify the configuration by editing the files in {{ic|/etc/nginx/}}. The main configuration file is located at {{ic|/etc/nginx/nginx.conf}}. <br />
<br />
More details can be found here: [http://wiki.nginx.org/NginxConfiguration Nginx Configuration Examples].<br />
<br />
=== FastCGI ===<br />
<br />
FastCGI, also FCGI, is a protocol for interfacing interactive programs with a web server. FastCGI is a variation on the earlier Common Gateway Interface (CGI); FastCGI's main aim is to reduce the overhead associated with interfacing the web server and CGI programs, allowing a server to handle more web page requests at once.<br />
<br />
FastCGI technology is introduced into Nginx to work with many external tools, i.e.: [[Perl]], [[PHP]] and [[Python]]. So, you cannot use these unless a FastCGI server has been started. <br />
<br />
==== PHP implementation ====<br />
<br />
There are different ways to run a FastCGI server for PHP.<br />
<br />
===== Step 1: PHP configuration =====<br />
<br />
The {{Ic|open_basedir}} in {{ic|/etc/php/php.ini}} has to list base directories which contain PHP files, like {{ic|/srv/http/}} and {{ic|/usr/share/webapps/}}:<br />
open_basedir = /usr/share/webapps/:/srv/http/:/home/:/tmp/:/usr/share/pear/<br />
<br />
===== Step 2, option A: php-fpm =====<br />
<br />
* http://php-fpm.org<br />
<br />
Install {{Pkg|php-fpm}}:<br />
# pacman -S php-fpm<br />
<br />
The configuration file is {{ic|/etc/php/php-fpm.conf}}.<br />
<br />
To start the service:<br />
# systemctl start php-fpm<br />
<br />
Enable {{Ic|php-fpm}} at startup<br />
# systemctl enable php-fpm.service<br />
<br />
===== Step 2, option B: spawn-fcgi-php =====<br />
<br />
Install {{Aur|spawn-fcgi-php}}, available at [[AUR]]:<br />
$ yaourt -Sy spawn-fcgi-php<br />
<br />
The configuration file is {{ic|/etc/conf.d/spawn-fcgi-php.conf}}.<br />
<br />
To start the service:<br />
# rc.d start spawn-fcgi-php<br />
<br />
Add {{Ic|spawn-fcgi-php}} to the {{Ic|DAEMONS}} array in {{ic|/etc/rc.conf}}.<br />
<br />
===== Step 3: Nginx configuration =====<br />
<br />
Inside each {{Ic|server}} block serving a PHP web application should appear a {{Ic|location}} block similar to:<br />
<br />
{{Ic|/etc/nginx/nginx.conf}}<br />
location ~ \.php$ {<br />
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;<br />
fastcgi_index index.php;<br />
root /usr/share/nginx/html;<br />
include fastcgi.conf;<br />
}<br />
<br />
If you are going to process .html and .htm files with php, you should have something like this:<br />
<br />
location ~ \.(php|html|htm)$ {<br />
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;<br />
fastcgi_index index.php;<br />
root /usr/share/nginx/html;<br />
include fastcgi.conf;<br />
}<br />
location / {<br />
root /usr/share/nginx/html;<br />
index index.html index.htm index.php;<br />
}<br />
<br />
Non .php files processing in php-fpm should be explicitly enabled in configuration<br />
{{Ic|/etc/php/php-fpm.conf}} <br />
<br />
security.limit_extensions = .php .html .htm<br />
<br />
You need to restart a php-fpm daemon if you changed configuration<br />
<br />
'''Pay attention''' to the {{Ic|fastcgi_pass}} argument, as it must be the TCP or Unix socket defined by the chosen FastCGI server in its config file. The '''default''' Unix for {{Ic|php-fpm}} is<br />
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;<br />
and for {{Ic|spawn-fcgi-php}},<br />
fastcgi_pass unix:/var/run/spawn-fcgi-php.sock;<br />
. Or you may use the common TCP socket, '''not default''',<br />
fastcgi_pass 127.0.0.1:9000;<br />
. Unix domain sockets are however much better.<br />
<br />
{{Ic|fastcgi.conf}} or {{Ic|fastcgi_params}} are usually included because they hold FastCGI settings for Nginx; the use of the latter is deprecated, though. They come within the Nginx installation.<br />
<br />
Finally, if Nginx has been working, run:<br />
# systemctl restart nginx<br />
<br />
<br />
If you would like to test the FastCGI implementation, create {{ic|/usr/share/nginx/html/index.php}} with content<br />
<?php<br />
phpinfo();<br />
?> <br />
and visit the URL http://127.0.0.1/index.php with your browser.<br />
<br />
==== CGI implementation ====<br />
<br />
This implementation is needed for CGI applications.<br />
<br />
Install {{Pkg|fcgiwrap}}:<br />
# pacman -Sy fcgiwrap<br />
<br />
===== Systemd =====<br />
<br />
The systemd unit file is currently being discussed on [https://bugs.archlinux.org/task/31696 this ArchLinux task page]. You may want to examine the unit file yourself to ensure it will work the way you want. Copy the unit file from {{ic|/usr/lib/systemd/system/fcgiwrap.service}} to {{ic|/etc/systemd/system/fcgiwrap.service}} (and the {{ic|fcgiwrap.socket}} unit, if present), and modify the {{ic|ExecStart}} line to suit your needs.<br />
<br />
If you want to spawn multiple worker threads, it's recommended that you use {{aur|multiwatch}}, which will take care of restarting crashed children. You'll need to use {{ic|spawn-fcgi}} to create the unix socket, as multiwatch seems unable to handle the systemd-created socket, even though fcgiwrap itself doesn't have any trouble if invoked directly in the unit file. Here is a unit file that uses {{aur|multiwatch}}. Make sure {{ic|fcgiwrap.socket}} is not started or enabled, because it will conflict with this unit:<br />
<br />
{{hc|/etc/systemd/system/fcgiwrap.service|2=<br />
[Unit]<br />
Description=Simple CGI Server<br />
After=nss-user-lookup.target<br />
<br />
[Service]<br />
ExecStart=/usr/bin/spawn-fcgi -u http -g http -s /run/fcgiwrap.sock -n -- /usr/bin/multiwatch -f 10 -- /usr/sbin/fcgiwrap<br />
ExecStartPost=/usr/bin/chmod 660 /run/fcgiwrap.sock<br />
PrivateTmp=true<br />
Restart=on-failure<br />
<br />
[Install]<br />
WantedBy=multi-user.target<br />
}}<br />
<br />
Tweak {{ic|-f 10}} to change the number of children that are spawned.<br />
<br />
{{Warning|The ExecStartPost line is required because of strange behaviour I'm seeing when I use the {{ic|-M 660}} option for {{ic|spawn-fcgi}}. The wrong mode is set. This may be a bug?}}<br />
<br />
===== Initscripts =====<br />
<br />
====== Using a Unix Domain Socket ======<br />
<br />
The default configuration sets TCP socket 127.0.0.1:9001 for listening. It is possible to alter the configuration to use a Unix domain socket, which will be more efficient.<br />
<br />
If you desire to use a Unix domain socket, edit {{ic|/etc/conf.d/fcgiwrap}} like this:<br />
SPAWNER='/usr/bin/spawn-fcgi'<br />
<br />
FCGI_SOCKET='/run/fcgiwrap.sock'<br />
FCGI_USER='http'<br />
FCGI_GROUP='http'<br />
FCGI_EXTRA_OPTIONS='-M 660'<br />
<br />
SPAWNER_ARGS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET $FCGI_EXTRA_OPTIONS -- /usr/sbin/fcgiwrap"<br />
Start the service:<br />
# rc.d start fcgiwrap<br />
and add {{Ic|fcgiwrap}} to the {{Ic|DAEMONS}} array in {{ic|/etc/rc.conf}}.<br />
<br />
====== Multiple Workers ======<br />
<br />
You can increase the number of worker threads by adding the {{ic|-F <num>}} option to the {{ic|SPAWNER_ARGS}} variable in '''/etc/conf.d/fcgiwrap'''. Although this option will work, you may find it difficult to monitor the workers, because they have no parent process.<br />
<br />
A better way to handle multiple worker threads is to use the [https://aur.archlinux.org/packages.php?ID=60080 multiwatch] package from the [[AUR]]. After installing the package, perform the following configuration to achieve this:<br />
<br />
Add the following line near the top of the '''/etc/conf.d/fcgiwrap''' file:<br />
<br />
DAEMON='multiwatch'<br />
<br />
and modify the {{ic|SPAWNER_ARGS}} line:<br />
<br />
FCGI_CHILDREN=5<br />
SPAWNER_ARGS="-u $FCGI_USER -g $FCGI_GROUP -s $FCGI_SOCKET $FCGI_EXTRA_OPTIONS -- /usr/bin/multiwatch -f $FCGI_CHILDREN -- /usr/sbin/fcgiwrap"<br />
<br />
You'll find that the '''/etc/rc.d/fcgiwrap''' script now creates a '''/run/multiwatch.pid''' file instead of the old '''/run/fcgiwrap.pid''' file. The multiwatch daemon will take care of respawning children that die.<br />
<br />
===== Nginx Configuration =====<br />
<br />
Inside each {{Ic|server}} block serving a PHP web application should appear a {{Ic|location}} block similar to:<br />
<br />
location ~ \.cgi$ {<br />
fastcgi_pass unix:/run/fcgiwrap.sock;<br />
include fastcgi.conf;<br />
}<br />
<br />
location ~ \.pl$ {<br />
fastcgi_pass unix:/run/fcgiwrap.sock;<br />
include fastcgi.conf;<br />
}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Accessing local IP redirects to localhost ===<br />
<br />
Solution from the Arch Linux [https://bbs.archlinux.org/viewtopic.php?pid=780561#p780561 forum].<br />
<br />
Edit {{ic|/etc/nginx/nginx.conf}} and locate the "server_name localhost" line without a # infront of it, and add below:<br />
server_name_in_redirect off;<br />
<br />
Default behavior is that nginx redirects any requests to the value given as server_name in the config.<br />
<br />
=== Error: 403 (Permission error) ===<br />
<br />
This is most likely a permission error. Are you sure whatever user configured in the Nginx configuration is able to read the correct files?<br />
<br />
If the files are located within a home directory, (e.g. {{ic|/home/arch/public/webapp}}) and you are sure the user running Nginx has the right permissions (you can temporarily chmod all the files to 777 in order to determine this), {{ic|/home/arch}} might be '''chmod 750''', simply {{Ic|chmod}} it to ''751'', and it should work.<br />
<br />
'''If you have changed your document root'''<br />
<br />
If you are sure that permissions are as they should be, make sure that your document root directory is not empty. Try creating index.html in there.<br />
<br />
=== Error: 404 (Pathinfo error) ===<br />
<br />
In some framework (like thinkphp, cakephp) or CMS, they need the pathinfo function. <br />
<br />
1. Edit the file {{ic|/etc/php/php.ini}}, make sure<br />
cgi.fix_pathinfo=1<br />
2. Edit {{ic|/etc/nginx/conf/nginx.conf}}, comment<br />
<br />
location ~ \.php$ {<br />
...<br />
}<br />
<br />
to <br />
<br />
#location ~ \.php$ {<br />
#...<br />
#}<br />
<br />
Then add the follows,<br />
location ~ ^(.+\.php)(.*)$ {<br />
root /srv/http/nginx;<br />
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; <br />
#fastcgi_pass 127.0.0.1:9000; #Un-comment this and comment "fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;" if you are not using php-fpm.<br />
fastcgi_index index.php;<br />
set $document_root2 $document_root;<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
if ($document_root2 ~ "^(.*\\\\).*?[\\\\|\/]\.\.\/(.*)$") { set $document_root2 $1$2; }<br />
fastcgi_split_path_info ^(.+\.php)(.*)$;<br />
fastcgi_param SCRIPT_FILENAME $document_root2$fastcgi_script_name;<br />
fastcgi_param PATH_INFO $fastcgi_path_info;<br />
fastcgi_param PATH_TRANSLATED $document_root2$fastcgi_path_info;<br />
include fastcgi_params;<br />
fastcgi_param DOCUMENT_ROOT $document_root2;<br />
}<br />
<br />
=== Error: The page you are looking for is temporarily unavailable. Please try again later. ===<br />
<br />
This is because the FastCGI server has not been started, or the socket used has wrong permissions.<br />
<br />
=== Error: No input file specified ===<br />
<br />
Most Likely you do not have the SCRIPT_FILENAME containing the full path to you scripts.<br />
If the configuration of nginx (fastcgi_param SCRIPT_FILENAME) is all right, this kind of error means php fail to load the requestd script. Usually it is simply a permissions issue, you can just run php-cgi as root<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi<br />
or you should create some group and user to start the php-cgi. For example:<br />
# groupadd www<br />
# useradd -g www www<br />
# chmod +w /srv/www/nginx/html<br />
# chown -R www:www /srv/www/nginx/html<br />
# spawn-fcgi -a 127.0.0.1 -p 9000 -u www -g www -f /usr/bin/php-cgi<br />
<br />
Another occasion is that, wrong "root" argument in the "location ~ \.php$" section in {{ic|nginx.conf}}, make sure the "root" points to the same directory as it in "location /" in the same server. Or you may just set root as global, do not define it in any location section.<br />
<br />
Also keep in mind that your php script path was defined as {{ic|/srv/www/nginx/html}} by default using the variable "open_basedir" in {{ic|/etc/php/php.ini}}; you can change them if you need.<br />
<br />
Also notice that not only php script should have read permission, but also the entire directory structure should have execute permission so that PHP user can traverse the path.<br />
<br />
== See Also ==<br />
* [[Nginx/Init_script|Init script for Nginx]]<br />
* [http://nginx.org/ Nginx Official Site]<br />
* [http://calomel.org/nginx.html Nginx HowTo]<br />
* [http://wiki.gotux.net/config:nginx Easy Config Files]</div>Hongy19https://wiki.archlinux.org/index.php?title=Systemd&diff=243255Systemd2013-01-08T15:12:34Z<p>Hongy19: </p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Daemons and system services]]<br />
[[Category:Boot process]]<br />
[[es:Systemd]]<br />
[[fr:Systemd]]<br />
[[it:Systemd]]<br />
[[ja:Systemd]]<br />
[[ru:Systemd]]<br />
[[zh-CN:Systemd]]<br />
[[zh-TW:Systemd]]<br />
{{Article summary start}}<br />
{{Article summary text|Covers how to install and configure systemd.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|systemd/User}}<br />
{{Article summary wiki|systemd/Services}}<br />
{{Article summary wiki|systemd FAQ}}<br />
{{Article summary wiki|init Rosetta}}<br />
{{Article summary wiki|udev}}<br />
{{Article summary end}}<br />
From the [http://freedesktop.org/wiki/Software/systemd project web page]:<br />
<br />
'''''systemd''' is a system and service manager for Linux, compatible with SysV and LSB init scripts. '''systemd''' provides aggressive parallelization capabilities, uses socket and [[D-Bus]] activation for starting services, offers on-demand starting of daemons, keeps track of processes using Linux [[cgroups|control groups]], supports snapshotting and restoring of the system state, maintains mount and automount points and implements an elaborate transactional dependency-based service control logic. It can work as a drop-in replacement for [[SysVinit|sysvinit]].''<br />
<br />
{{Note|1=For a detailed explanation as to why Arch has moved to systemd, see [https://bbs.archlinux.org/viewtopic.php?pid=1149530#p1149530 this forum post].}}<br />
<br />
See also the [[Wikipedia:Systemd|Wikipedia article]].<br />
<br />
== Considerations before switching ==<br />
<br />
* Do [http://freedesktop.org/wiki/Software/systemd/ some reading] about systemd.<br />
* Note the fact that systemd has a '''journal''' system that replaces '''syslog''', although the two can co-exist. See the [[#Journal|section on the journal]] below.<br />
* While systemd can replace some of the functionality of '''cron''', '''acpid''', or '''xinetd''', there is no need to switch away from using the traditional daemons unless you want to.<br />
* Interactive initscripts are not working with systemd. In particular, '''netcfg-menu''' [https://bugs.archlinux.org/task/31377 cannot] be used at system start-up.<br />
<br />
== Installation ==<br />
{{Note|{{pkg|systemd}} and {{pkg|systemd-sysvcompat}} are both installed by default on installation media newer than [https://www.archlinux.org/news/systemd-is-now-the-default-on-new-installations/ 2012-10-13].}}<br />
<br />
{{Note|If you are running Arch Linux inside a VPS, please see [[Virtual_Private_Server#Moving_your_VPS_from_initscripts_to_systemd|the appropriate page]].}}<br />
<br />
The following section is aimed at Arch Linux installations that still rely on {{pkg|sysvinit}} and {{pkg|initscripts}} which have not migrated to {{pkg|systemd}}.<br />
<br />
# Install {{pkg|systemd}} and append the following to your [[kernel line]]: {{ic|1=init=/usr/lib/systemd/systemd}}<br />
# Once completed you may enable any desired services via the use of {{ic|systemctl enable <service_name>}} (this roughly equates to what you included in the {{ic|DAEMONS}} array, with [[Daemons_List|different names]].).<br />
# Reboot your system and verify that {{ic|systemd}} is currently active by using the following command: {{ic|cat /proc/1/comm}}. This should return the string {{ic|systemd}}.<br />
# Make sure your hostname is set correctly under systemd: {{ic|hostnamectl set-hostname myhostname}}.<br />
# Proceed to remove {{pkg|initscripts}} and {{pkg|sysvinit}} from your system and install {{pkg|systemd-sysvcompat}}.<br />
# Optionally, remove the {{ic|1=init=/usr/lib/systemd/systemd}} parameter as it is no longer needed. {{pkg|systemd-sysvcompat}} provides the default init.<br />
<br />
=== Supplementary information ===<br />
<br />
* If you have {{ic|quiet}} in your kernel parameters, you might want to remove it for your first couple of systemd boots, to assist with identifying any issues during boot.<br />
<br />
* Adding your user to [[Users and Groups|groups]] ({{ic|optical}}, {{ic|audio}}, {{ic|scanner}}, etc.) is '''not''' necessary for most use cases with systemd. The groups can even cause some functionality to break. For example, the audio group will break fast user switching and allows applications to block software mixing. Every PAM login provides a logind session, which for a local session will give you permissions via [[Wikipedia:Access control list|POSIX ACLs]] on audio/video devices, and allow certain operations like mounting removable storage via [[udisks]].<br />
<br />
* Removing {{Pkg|initscripts}} package will break compatibility with {{ic|rc.conf}}. Be careful if you have static network set up there or use some daemons, which are not migrated to systemd yet. See the [[#Initscripts emulation|Initscripts emulation section]] for more details on how the two systems can coexist.<br />
<br />
* If you mount LVM devices in fstab your system will wait for them and time out. Wait for the time out to happen and enter your root password in the emergency console. Then type {{ic|systemctl enable lvm}} to enable lvm in systemd. After another reboot the lvm devices should be mountable.<br />
<br />
== Native configuration ==<br />
<br />
{{Note|You may need to create these files. All files should have '''644''' permissions and '''root:root''' ownership.}}<br />
<br />
=== Hostname ===<br />
<br />
The hostname is configured in {{ic|/etc/hostname}}. The file should not contain the system's domain, if any. To set the hostname, do:<br />
<br />
# hostnamectl set-hostname '''myhostname'''<br />
<br />
See {{ic|man 5 hostname}} and {{ic|man 1 hostnamectl}} for details.<br />
<br />
Here is an example file:<br />
{{hc|/etc/hostname|<br />
myhostname<br />
}}<br />
<br />
=== Locale ===<br />
<br />
The default system locale is configured in {{ic|/etc/locale.conf}}. To set the default locale, do:<br />
<br />
# localectl set-locale LANG="de_DE.utf8"<br />
<br />
{{Note|Before you set the default locale, you first need to enable locales available to the system by uncommenting them in {{ic|/etc/locale.gen}} and then executing {{ic|locale-gen}} as root. The locale set via {{ic|localectl}} must be one of the '''uncommented''' locales in {{ic|/etc/locale.gen}}.}}<br />
<br />
See {{ic|man 1 localectl}} and {{ic|man 5 locale.conf}} for details.<br />
<br />
* For more information, see [[Locale]].<br />
<br />
Here is an example file:<br />
{{hc|/etc/locale.conf|<nowiki><br />
LANG=en_US.utf8<br />
</nowiki>}}<br />
<br />
=== Virtual console ===<br />
<br />
The virtual console (keyboard mapping, console font and console map) is configured in {{ic|/etc/vconsole.conf}}:<br />
<br />
{{hc|/etc/vconsole.conf|2=<br />
KEYMAP=us<br />
FONT=lat9w-16<br />
FONT_MAP=8859-1_to_uni}}<br />
<br />
{{Note|As of {{pkg|systemd}}-194, the built-in ''kernel'' font and the ''us'' keymap are used if {{ic|1=KEYMAP=}} and {{ic|1=FONT=}} are empty or not set.}}<br />
<br />
Another way to set the keyboard mapping (keymap) is doing:<br />
<br />
# localectl set-keymap de<br />
<br />
<code>localectl</code> can also be used to set the X11 keymap:<br />
<br />
# localectl set-x11-keymap de<br />
<br />
See {{ic|man 1 localectl}} and {{ic|man 5 vconsole.conf}} for details.<br />
<br />
* For more information, see [[Fonts#Console fonts|console fonts]] and [[KEYMAP|keymaps]].<br />
<br />
=== Time zone ===<br />
<br />
The time zone is configured by creating an appropriate {{ic|/etc/localtime}} symlink, pointing to a zoneinfo file under {{ic|/usr/share/zoneinfo/}}. To do this automatically:<br />
<br />
# timedatectl set-timezone America/Toronto<br />
<br />
See {{ic|man 1 timedatectl}}, {{ic|man 5 localtime}}, and {{ic|man 7 archlinux}} for more details.<br />
<br />
Alternatively, create the symlink yourself:<br />
<!-- DO NOT MAKE THIS AN ABSOLUTE SYMLINK, archlinux(7) clearly shows this should be a relative symlink --><br />
# ln -sf ../usr/share/zoneinfo/America/Toronto /etc/localtime<br />
<br />
If the old configuration file {{ic|/etc/timezone}} exists you can now remove it safely, because it is not used by systemd.<br />
<br />
=== Hardware clock ===<br />
<br />
Systemd will use '''UTC''' for the hardware clock by default.<br />
<br />
{{Tip|It is advised to have a [[NTP|Network Time Protocol daemon]] running to keep the system time synchronized with Internet time and the hardware clock.}}<br />
<br />
==== Hardware clock in localtime ====<br />
<br />
If you want to change the hardware clock to use local time ('''STRONGLY DISCOURAGED''') do:<br />
<br />
# timedatectl set-local-rtc true<br />
<br />
If you want to revert to the hardware clock being in UTC, do:<br />
<br />
# timedatectl set-local-rtc false<br />
<br />
Be warned that, if the hardware clock is set to localtime, dealing with daylight saving time is messy. If the DST changes when your computer is off, your clock will be wrong on next boot ([http://www.cl.cam.ac.uk/~mgk25/mswish/ut-rtc.html there is a lot more to it]). Recent kernels set the system time from the RTC directly on boot, assuming that the RTC is in UTC. This means that if the RTC is in local time, then the system time will first be set up wrongly and then corrected shortly afterwards on every boot. This is the root of certain weird bugs (time going backwards is rarely a good thing).<br />
<br />
One reason for allowing the RTC to be in local time is to allow dual boot with Windows ([http://blogs.msdn.com/b/oldnewthing/archive/2004/09/02/224672.aspx which uses localtime]). However, Windows is able to deal with the RTC being in UTC with a simple [[Time#UTC in Windows|registry fix]]. There, it is recommended that Windows are changed to use UTC, rather than Linux to use localtime. If you make Windows use UTC, also remember to disable the "Internet Time Update" Windows feature, so that Windows don't mess with the hardware clock, trying to sync it with internet time. You should instead leave touching the RTC and syncing it to internet time to Linux, by enabling an [[NTP]] daemon, as suggested previously.<br />
<br />
* For more information, see [[Time]].<br />
<br />
=== Kernel modules ===<br />
<br />
Today, all necessary module loading is handled automatically by [[udev]], so that, if you don't want/need to use any out-of-tree kernel modules, there is no need to put modules that should be loaded at boot in any config file. However, there are cases where you might want to load an extra module during the boot process, or blacklist another one for your computer to function properly.<br />
<br />
==== Extra modules to load at boot ====<br />
<br />
Extra kernel modules to be loaded during boot are configured as a static list in files under {{ic|/etc/modules-load.d/}}. Each configuration file is named in the style of {{ic|/etc/modules-load.d/<program>.conf}}. Configuration files simply contain a list of kernel module names to load, separated by newlines. Empty lines and lines whose first non-whitespace character is {{ic|#}} or {{ic|;}} are ignored.<br />
<br />
{{hc|/etc/modules-load.d/virtio-net.conf|<br />
# Load virtio-net.ko at boot<br />
virtio-net}}<br />
<br />
See {{ic|man 5 modules-load.d}} for more details.<br />
<br />
==== Blacklisting ====<br />
<br />
Module blacklisting works the same way as with {{Pkg|initscripts}} since it is actually handled by {{Pkg|kmod}}. See [[Kernel modules#Blacklisting|Module Blacklisting]] for details.<br />
<br />
=== Filesystem mounts ===<br />
<br />
The default setup will automatically fsck and mount filesystems before starting services that need them to be mounted. For example, systemd automatically makes sure that remote filesystem mounts like [[NFS]] or [[Samba]] are only started after the network has been set up. Therefore, local and remote filesystem mounts specified in {{ic|/etc/fstab}} should work out of the box.<br />
<br />
See {{ic|man 5 systemd.mount}} for details.<br />
<br />
==== Automount ====<br />
<br />
* If you have a large {{ic|/home}} partition, it might be better to allow services that do not depend on {{ic|/home}} to start while {{ic|/home}} is checked by fsck. This can be achieved by adding the following options to the {{ic|/etc/fstab}} entry of your {{ic|/home}} partition:<br />
<br />
noauto,x-systemd.automount<br />
<br />
This will fsck and mount {{ic|/home}} when it is first accessed, and the kernel will buffer all file access to {{ic|/home}} until it is ready.<br />
<br />
Note: this will make your {{ic|/home}} filesystem type {{ic|autofs}}, which is ignored by [[mlocate]] by default. The speedup of automounting {{ic|/home}} may not be more than a second or two, depending on your system, so this trick may not be worth it. <br />
<br />
* The same applies to remote filesystem mounts. If you want them to be mounted only upon access, you will need to use the {{ic|noauto,x-systemd.automount}} parameters. In addition, you can use the {{ic|1=x-systemd.device-timeout=#}} option to specify a timeout in case the network resource is not available.<br />
<br />
* If you have encrypted filesystems with keyfiles, you can also add the {{ic|noauto}} parameter to the corresponding entries in {{ic|/etc/crypttab}}. Systemd will then not open the encrypted device on boot, but instead wait until it is actually accessed and then automatically open it with the specified keyfile before mounting it. This might save a few seconds on boot if you are using an encrypted RAID device for example, because systemd doesn't have to wait for the device to become available. For example:<br />
<br />
{{hc|/etc/crypttab|<br />
data /dev/md0 /root/key noauto}}<br />
<br />
==== LVM ====<br />
<br />
If you have [[LVM]] volumes not activated via the [[Mkinitcpio|initramfs]], enable the {{ic|lvm-monitoring}} service, which is provided by the {{pkg|lvm2}} package:<br />
<br />
# systemctl enable lvm-monitoring<br />
<br />
Similarly, if you have LVM on encrypted devices mounted later during boot (e.g. from {{ic|/etc/crypttab}}), enable the {{ic|lvm-on-crypt}} service, which is also provided by the {{pkg|lvm2}} package:<br />
<br />
# systemctl enable lvm-on-crypt<br />
<br />
=== ACPI power management ===<br />
<br />
Systemd handles some power-related [[Wikipedia:Advanced_Configuration_and_Power_Interface|ACPI]] events. They can be configured via the following options from {{ic|/etc/systemd/logind.conf}}:<br />
<br />
* {{ic|HandlePowerKey}}: specifies which action is invoked when the power key is pressed.<br />
* {{ic|HandleSuspendKey}}: specifies which action is invoked when the suspend key is pressed.<br />
* {{ic|HandleHibernateKey}}: specifies which action is invoked when the hibernate key is pressed.<br />
* {{ic|HandleLidSwitch}}: specifies which action is invoked when the lid is closed.<br />
<br />
The specified action can be one of {{ic|ignore}}, {{ic|poweroff}}, {{ic|reboot}}, {{ic|halt}}, {{ic|suspend}}, {{ic|hibernate}} or {{ic|kexec}}.<br />
<br />
If these options are not configured, systemd will use its defaults: {{ic|1=HandlePowerKey=poweroff}}, {{ic|1=HandleSuspendKey=suspend}}, {{ic|1=HandleHibernateKey=hibernate}}, and {{ic|1=HandleLidSwitch=suspend}}.<br />
<br />
On systems which run no graphical setup or only a simple window manager like [[i3]] or [[awesome]], this may replace the [[acpid]] daemon which is usually used to react to these ACPI events.<br />
<br />
{{Note|Systemd cannot handle AC and Battery ACPI events, so if you use [[Laptop Mode Tools]] or other similar tools [[acpid]] is still required.}}<br />
<br />
In the current version of systemd, the {{ic|Handle}} options will apply throughout the system unless they are "inhibited" (temporarily turned off) by a program, such as a power manager inside a desktop environment. If these inhibits are not taken, you can end up with a situation where systemd suspends your system, then when it wakes up the other power manager suspends it again.<br />
<br />
{{Warning|Currently, the power managers in the newest versions of [[KDE]] and [[GNOME]] are the only ones that issue the necessary "inhibited" commands. Until the others do, you will need to set the {{ic|Handle}} options to {{ic|ignore}} if you want your ACPI events to be handled by [[Xfce]], [[acpid]] or other programs. New versions are on the way that will include this functionality.}}<br />
<br />
{{Note|Systemd can also use other suspend backends (such as [[Uswsusp]] or [[TuxOnIce]]), in addition to the default ''kernel'' backend, in order to put the computer to sleep or hibernate.}}<br />
<br />
==== Sleep hooks ====<br />
<br />
Systemd does not use [[pm-utils]] to put the machine to sleep when using {{ic|systemctl suspend}}, {{ic|systemctl hibernate}} or {{ic|systemctl hybrid-sleep}}; [[pm-utils]] hooks, including any [[Pm-utils#Creating_your_own_hooks|custom hooks]], will not be run. However, systemd provides two similar mechanisms to run custom scripts on these events.<br />
<br />
===== Suspend/resume service files =====<br />
<br />
Service files can be hooked into suspend.target, hibernate.target and sleep.target to execute actions before or after suspend/hibernate. Separate files should be created for user actions and root/system actions. To activate the user service files, {{ic|# systemctl enable suspend@<user> && systemctl enable resume@<user>}}. Examples:<br />
<br />
{{hc|/etc/systemd/system/suspend@.service|2=<nowiki><br />
[Unit]<br />
Description=User suspend actions<br />
Before=sleep.target<br />
<br />
[Service]<br />
User=%I<br />
Type=forking<br />
Environment=DISPLAY=:0<br />
ExecStartPre= -/usr/bin/pkill -u %u unison ; /usr/local/bin/music.sh stop ; /usr/bin/mysql -e 'slave stop'<br />
ExecStart=/usr/bin/sflock<br />
<br />
[Install]<br />
WantedBy=sleep.target</nowiki>}}<br />
<br />
{{hc|/etc/systemd/system/resume@.service|2=<nowiki><br />
[Unit]<br />
Description=User resume actions<br />
After=suspend.target<br />
<br />
[Service]<br />
User=%I<br />
Type=simple<br />
ExecStartPre=/usr/local/bin/ssh-connect.sh<br />
ExecStart=/usr/bin/mysql -e 'slave start'<br />
<br />
[Install]<br />
WantedBy=suspend.target</nowiki>}}<br />
<br />
For root/system actions (activate with {{ic|# systemctl enable root-suspend}}):<br />
<br />
{{hc|/etc/systemd/system/root-resume.service|2=<nowiki><br />
[Unit]<br />
Description=Local system resume actions<br />
After=suspend.target<br />
<br />
[Service]<br />
Type=simple<br />
ExecStart=/usr/bin/systemctl restart mnt-media.automount<br />
<br />
[Install]<br />
WantedBy=suspend.target</nowiki>}}<br />
<br />
{{hc|/etc/systemd/system/root-suspend.service|2=<nowiki><br />
[Unit]<br />
Description=Local system suspend actions<br />
Before=sleep.target<br />
<br />
[Service]<br />
Type=simple<br />
ExecStart=-/usr/bin/pkill sshfs<br />
<br />
[Install]<br />
WantedBy=sleep.target</nowiki>}}<br />
<br />
A couple of handy hints about these service files (more in {{ic|man systemd.service}}):<br />
* If {{ic|1=<nowiki>Type=OneShot</nowiki>}} then you can use multiple {{ic|1=<nowiki>ExecStart=</nowiki>}} lines. Otherwise only one ExecStart line is allowed. You can add more commands with either {{ic|ExecStartPre}} or by separating commands with a semicolon (see the first example above -- note the spaces before and after the semicolon...these are required!).<br />
* A command prefixed with '-' will cause a non-zero exit status to be ignored and treated as a successful command. <br />
* The best place to find errors when troubleshooting these service files is of course with {{ic|journalctl}}.<br />
<br />
===== Hooks in /usr/lib/systemd/system-sleep =====<br />
<br />
Systemd runs all executables in {{ic|/usr/lib/systemd/system-sleep/}}, passing two arguments to each of them:<br />
<br />
* Argument 1: either {{ic|pre}} or {{ic|post}}, depending on whether the machine is going to sleep or waking up<br />
* Argument 2: {{ic|suspend}}, {{ic|hibernate}} or {{ic|hybrid-sleep}}, depending on which is being invoked<br />
<br />
In contrast to [[pm-utils]], systemd will run these scripts concurrently and not one after another.<br />
<br />
The output of any custom script will be logged by {{ic|systemd-suspend.service}}, {{ic|systemd-hibernate.service}} or {{ic|systemd-hybrid-sleep.service}}. You can see its output in systemd's [[Systemd#Journal|journal]]:<br />
# journalctl -b -u systemd-suspend<br />
<br />
Note that you can also use {{ic|sleep.target}}, {{ic|suspend.target}}, {{ic|hibernate.target}} or {{ic|hybrid-sleep.target}} to hook units into the sleep state logic instead of using custom scripts.<br />
<br />
An example of a custom sleep script:<br />
<br />
{{hc|/usr/lib/systemd/system-sleep/example.sh|<br />
#!/bin/sh<br />
case $1/$2 in<br />
pre/*)<br />
echo "Going to $2..."<br />
;;<br />
post/*)<br />
echo "Waking up from $2..."<br />
;;<br />
esac}}<br />
<br />
See {{ic|man 7 systemd.special}} and {{ic|man 8 systemd-sleep}} for more details.<br />
<br />
=== Temporary files ===<br />
<br />
Systemd-tmpfiles uses configuration files in {{ic|/usr/lib/tmpfiles.d/}} and {{ic|/etc/tmpfiles.d/}} to describe the creation, cleaning and removal of volatile and temporary files and directories which usually reside in directories such as {{ic|/run}} or {{ic|/tmp}}. Each configuration file is named in the style of {{ic|/etc/tmpfiles.d/<program>.conf}}. This will also override any files in {{ic|/usr/lib/tmpfiles.d/}} with the same name.<br />
<br />
tmpfiles are usually provided together with service files to create directories which are expected to exist by certain daemons. For example the [[Samba]] daemon expects the directory {{ic|/var/run/samba}} to exist and to have the correct permissions. The corresponding tmpfile looks like this:<br />
<br />
{{hc|/usr/lib/tmpfiles.d/samba.conf|<br />
D /var/run/samba 0755 root root}}<br />
<br />
However, tmpfiles may also be used to write values into certain files on boot. For example, if you use {{ic|/etc/rc.local}} to disable wakeup from USB devices with {{ic|echo USBE > /proc/acpi/wakeup}}, you may use the following tmpfile instead:<br />
<br />
{{hc|/etc/tmpfiles.d/disable-usb-wake.conf|<br />
w /proc/acpi/wakeup - - - - USBE}}<br />
<br />
The tmpfiles method is recommended in this case since systemd doesn't actually support {{ic|/etc/rc.local}}.<br />
<br />
See {{ic|man 5 tmpfiles.d}} for details.<br />
<br />
=== Units ===<br />
<br />
A unit configuration file encodes information about a service, a socket, a device, a mount point, an automount point, a swap file or partition, a start-up target, a file system path or a timer controlled and supervised by systemd. The syntax is inspired by XDG Desktop Entry Specification .desktop files, which are in turn inspired by Microsoft Windows .ini files.<br />
<br />
See {{ic|man 5 systemd.unit}} for details.<br />
<br />
== Transitioning from initscripts to systemd ==<br />
<br />
=== Initscripts emulation ===<br />
<br />
Integration with Arch's classic configuration is provided by the {{Pkg|initscripts}} package. When {{Pkg|initscripts}} are installed in parallel with systemd, with the system running on systemd, systemd will do the following:<br />
<br />
# Parse the {{ic|DAEMONS}} array of {{ic|/etc/rc.conf}} and start all listed daemons at boot<br />
# Execute {{ic|/etc/rc.local}} during boot<br />
# Execute {{ic|/etc/rc.local.shutdown}} during shutdown<br />
<br />
Initscripts emulation is simply meant as a transitional measure to ease users' move to systemd, and '''will eventually go away'''. Native systemd does not rely on {{ic|rc.conf}} centralised configuration, so it is recommended to use [[#Native configuration|native systemd configuration files]], which will take precedence over {{ic|/etc/rc.conf}}.<br />
<br />
{{Note|The recommended way to replace {{ic|/etc/rc.local}} is to write the custom service files for any things you want to run on the system startup. See the corresponding [[#Writing_custom_.service_files|section]].}}<br />
<br />
{{Note|If you disabled {{keypress|Ctrl+Alt+Del}} to reboot in {{ic|/etc/inittab}}, you will have to reconfigure this setting for systemd by running {{ic|systemctl mask ctrl-alt-del.target}} as root.}}<br />
<br />
=== Moving away from the DAEMONS array ===<br />
<br />
For a pure systemd setup, you should remove the {{ic|/etc/rc.conf}} file entirely and enable services only via {{ic|systemctl}}. For each {{ic|<service_name>}} in the {{ic|DAEMONS}} array in {{ic|/etc/rc.conf}}, run:<br />
<br />
# systemctl enable <service_name><br />
<br />
{{Tip|For a list of commonly used daemons with their initscripts and systemd equivalents, see [[Daemons List|this table]].}}<br />
<br />
If {{ic|<service_name>.service}} does not exist:<br />
<br />
* Most probably, systemd uses a different name. For example, {{ic|cronie.service}} replaces the {{ic|crond}} init daemon; {{ic|alsa-store.service}} and {{ic|alsa-restore.service}} replace the {{ic|alsa}} init daemon. Another important instance is the {{ic|network}} daemon, which is replaced with another set of service files (see [[Configuring Network]] for more details.)<br />
* Otherwise, a service file may not be available for systemd. In that case, you'll need to keep {{ic|rc.conf}} to start the service during boot up.<br />
<br />
{{Tip|You may look inside a package that contains daemon start scripts for service names. For instance:<br />
$ pacman -Ql cronie<br />
[...]<br />
cronie /etc/rc.d/crond #Daemon initscript listed in the DAEMONS array (unused in a "pure" systemd configuration)<br />
[...]<br />
cronie /usr/lib/systemd/system/cronie.service #Corresponding systemd daemon service<br />
[...]<br />
}}<br />
<br />
* Finally, some services do not need to be explicitly enabled by the user. For instance, {{ic|dbus.service}} will automatically be enabled when {{ic|dbus-core}} is installed. {{ic|alsa-store.service}} and {{ic|alsa-restore.service}} are also enabled automatically by systemd. Check the list of available services and their state using the {{ic|systemctl}} command like this: {{ic|systemctl status <service_name>}}.<br />
<br />
== Basic systemctl usage ==<br />
<br />
The main command used to introspect and control systemd is {{ic|systemctl}}. Some of its uses are examining the system state and managing the system and services. See {{ic|man 1 systemctl}} for more details.<br />
<br />
{{Tip|You can use all of the following {{ic|systemctl}} commands with the {{ic|-H <user>@<host>}} switch to control a systemd instance on a remote machine. This will use [[SSH]] to connect to the remote systemd instance.}}<br />
<br />
{{Note|{{ic|systemadm}} is the official graphical frontend for {{ic|systemctl}}. It is provided by the {{AUR|systemd-ui-git}} package from the [[AUR]].}}<br />
<br />
=== Analyzing the system state ===<br />
<br />
List running units:<br />
<br />
$ systemctl<br />
<br />
or:<br />
<br />
$ systemctl list-units<br />
<br />
List failed units:<br />
<br />
$ systemctl --failed<br />
<br />
The available unit files can be seen in {{ic|/usr/lib/systemd/system/}} and {{ic|/etc/systemd/system/}} (the latter takes precedence). You can see list installed unit files by:<br />
<br />
$ systemctl list-unit-files<br />
<br />
=== Using units ===<br />
<br />
Units can be, for example, services ({{ic|.service}}), mount points ({{ic|.mount}}), devices ({{ic|.device}}) or sockets ({{ic|.socket}}).<br />
<br />
When using {{ic|systemctl}}, you generally have to specify the complete name of the unit file, including its suffix, for example {{ic|sshd.socket}}. There are however a few shortforms when specifying the unit in the following {{ic|systemctl}} commands:<br />
<br />
* If you don't specify the suffix, systemctl will assume {{ic|.service}}. For example, {{ic|netcfg}} and {{ic|netcfg.service}} are treated equivalent.<br />
* Mount points will automatically be translated into the appropriate {{ic|.mount}} unit. For example, specifying {{ic|/home}} is equivalent to {{ic|home.mount}}.<br />
* Similiar to mount points, devices are automatically translated into the appropriate {{ic|.device}} unit, therefore specifying {{ic|/dev/sda2}} is equivalent to {{ic|dev-sda2.device}}.<br />
<br />
See {{ic|man systemd.unit}} for details.<br />
<br />
Activate a unit immediately:<br />
<br />
# systemctl start <unit><br />
<br />
Deactivate a unit immediately:<br />
<br />
# systemctl stop <unit><br />
<br />
Restart a unit:<br />
<br />
# systemctl restart <unit><br />
<br />
Ask a unit to reload its configuration:<br />
<br />
# systemctl reload <unit><br />
<br />
Show the status of a unit, including whether it is running or not:<br />
<br />
$ systemctl status <unit><br />
<br />
Check whether a unit is already enabled or not:<br />
<br />
$ systemctl is-enabled <unit><br />
<br />
Enable a unit to be started on bootup:<br />
<br />
# systemctl enable <unit><br />
<br />
{{Note|If services do not have an {{ic|Install}} section, it usually means they are called automatically by other services. But if you need to install them manually, use the following command, replacing {{ic|foo}} with the name of the service.<br />
# ln -s /usr/lib/systemd/system/''foo''.service /etc/systemd/system/graphical.target.wants/<br />
}}<br />
<br />
Disable a unit to not start during bootup:<br />
<br />
# systemctl disable <unit><br />
<br />
Show the manual page associated with a unit (this has to be supported by the unit file):<br />
<br />
$ systemctl help <unit><br />
<br />
Reload systemd, scanning for new or changed units:<br />
<br />
# systemctl daemon-reload<br />
<br />
=== Power management ===<br />
{{ic|polkit}} is necessary for power managment.<br />
If you are in a local {{ic|systemd-logind}} user session and no other session is active, the following commands will work without root privileges. If not (for example, because another user is logged into a tty), systemd will automatically ask you for the root password.<br />
<br />
Shut down and reboot the system:<br />
<br />
$ systemctl reboot<br />
<br />
Shut down and power-off the system:<br />
<br />
$ systemctl poweroff<br />
<br />
Suspend the system:<br />
<br />
$ systemctl suspend<br />
<br />
Put the system into hibernation:<br />
<br />
$ systemctl hibernate<br />
<br />
Put the system into hybrid-sleep state (or suspend-to-both):<br />
<br />
$ systemctl hybrid-sleep<br />
<br />
== Running DEs under systemd ==<br />
<br />
To enable graphical login, run your preferred [[Display Manager]] daemon (e.g. [[KDM]]). At the moment, service files exist for [[GDM]], [[KDM]], [[SLiM]], [[XDM]], [[LXDM]] and [[LightDM]].<br />
<br />
# systemctl enable kdm<br />
<br />
This should work out of the box. If not, you might have a {{ic|default.target}} set manually or from a older install:<br />
<br />
{{hc|# ls -l /etc/systemd/system/default.target|<br />
/etc/systemd/system/default.target -> /usr/lib/systemd/system/graphical.target}}<br />
<br />
Simply delete the symlink and systemd will use its stock {{ic|default.target}} (i.e. {{ic|graphical.target}}).<br />
<br />
# rm /etc/systemd/system/default.target<br />
<br />
=== Using systemd-logind ===<br />
<br />
{{Note|As of 2012-10-30, [[ConsoleKit]] has been [https://www.archlinux.org/news/consolekit-replaced-by-logind/ replaced by systemd-logind] as the default mechanism to login to the DE.}}<br />
<br />
In order to check the status of your user session, you can use {{ic|loginctl}}. All [[PolicyKit]] actions like suspending the system or mounting external drives will work out of the box.<br />
<br />
$ loginctl show-session $XDG_SESSION_ID<br />
<br />
== Writing custom .service files ==<br />
''See: [[Systemd/Services]]''<br />
<br />
=== Handling dependencies ===<br />
<br />
With systemd, dependencies can be resolved by designing the unit files correctly. The most typical case is that the unit {{ic|A}} requires the unit {{ic|B}} to be running before {{ic|A}} is started. In that case add {{ic|1=Requires=B}} and {{ic|1=After=B}} to the {{ic|[Unit]}} section of {{ic|A}}. If the dependency is optional, add {{ic|1=Wants=B}} and {{ic|1=After=B}} instead. Note that {{ic|1=Wants=}} and {{ic|1=Requires=}} do not imply {{ic|1=After=}}, meaning that if {{ic|1=After=}} is not specified, the two units will be started in parallel.<br />
<br />
Dependencies are typically placed on services and not on targets. For example, {{ic|network.target}} is pulled in by whatever service configures your network interfaces, therefore ordering your custom unit after it is sufficient since {{ic|network.target}} is started anyway.<br />
<br />
=== Type ===<br />
<br />
There are several different start-up types to consider when writing a custom service file. This is set with the {{ic|1=Type=}} parameter in the {{ic|[Service]}} section. See {{ic|man systemd.service}} for a more detailed explanation.<br />
<br />
* {{ic|1=Type=simple}}: systemd considers the service to be started up immediately. The process must not fork. Do not use this type if other services need to be ordered on this service, unless it is socket activated.<br />
* {{ic|1=Type=forking}}: systemd considers the service started up once the process forks and the parent has exited. For classic daemons use this type unless you know that it is not necessary. You should specify {{ic|1=PIDFile=}} as well so systemd can keep track of the main process.<br />
* {{ic|1=Type=oneshot}}: This is useful for scripts that do a single job and then exit. You may want to set {{ic|1=RemainAfterExit=yes}} as well so that systemd still considers the service as active after the process has exited.<br />
* {{ic|1=Type=notify}}: Identical to {{ic|1=Type=simple}}, but with the stipulation that the daemon will send a signal to systemd when it is ready. The reference implementation for this notification is provided by {{ic|libsystemd-daemon.so}}.<br />
* {{ic|1=Type=dbus}}: The service is considered ready when the specified {{ic|BusName}} appears on DBus's system bus.<br />
<br />
=== Replacing provided unit files ===<br />
<br />
The unit files in {{ic|/etc/systemd/system/}} take precedence over the ones in {{ic|/usr/lib/systemd/system/}}.<br />
To make your own version of a unit (which will not be destroyed by an upgrade), copy the old unit file from {{ic|/usr/lib/}} to {{ic|/etc/}} and make your changes there. Alternatively you can use {{ic|.include}} to parse an existing service file and then override or add new options. For example, if you simply want to add an additional dependency to a service file, you may use:<br />
<br />
{{hc|/etc/systemd/system/<service-name>.service|2=<br />
.include /usr/lib/systemd/system/<service-name>.service<br />
<br />
[Unit]<br />
Requires=<new dependency><br />
After=<new dependency>}}<br />
<br />
Then run the following for your changes to take effect:<br />
<br />
# systemctl reenable <unit><br />
# systemctl restart <unit><br />
<br />
{{Tip|You can use {{ic|systemd-delta}} to see which unit files have been overridden and what exactly has been changed.}} As the provided unit files will be updated from time to time, use systemd-delta for system maintenance.<br />
<br />
=== Syntax highlighting for units within Vim ===<br />
<br />
Syntax highlighting for systemd unit files within [[Vim]] can be enabled by installing {{Pkg|vim-systemd}} from the [[Official Repositories|official repositories]].<br />
<br />
== Targets ==<br />
<br />
Systemd uses ''targets'' which serve a similar purpose as runlevels but act a little different. Each ''target'' is named instead of numbered and is intended to serve a specific purpose with the possibility of having multiple ones active at the same time. Some ''targets'' are implemented by inheriting all of the services of another ''target'' and adding additional services to it. There are systemd ''target''s that mimic the common SystemVinit runlevels so you can still switch ''target''s using the familiar {{ic|telinit RUNLEVEL}} command.<br />
<br />
=== Get current targets ===<br />
<br />
The following should be used under systemd instead of {{ic|runlevel}}:<br />
<br />
$ systemctl list-units --type=target<br />
<br />
=== Create custom target ===<br />
<br />
The runlevels that are assigned a specific purpose on vanilla Fedora installs; 0, 1, 3, 5, and 6; have a 1:1 mapping with a specific systemd ''target''. Unfortunately, there is no good way to do the same for the user-defined runlevels like 2 and 4. If you make use of those it is suggested that you make a new named systemd ''target'' as {{ic|/etc/systemd/system/<your target>}} that takes one of the existing runlevels as a base (you can look at {{ic|/usr/lib/systemd/system/graphical.target}} as an example), make a directory {{ic|/etc/systemd/system/<your target>.wants}}, and then symlink the additional services from {{ic|/usr/lib/systemd/system/}} that you wish to enable.<br />
<br />
=== Targets table ===<br />
<br />
{| border="1"<br />
! SysV Runlevel !! systemd Target !! Notes<br />
|-<br />
| 0 || runlevel0.target, poweroff.target || Halt the system.<br />
|-<br />
| 1, s, single || runlevel1.target, rescue.target || Single user mode.<br />
|-<br />
| 2, 4 || runlevel2.target, runlevel4.target, multi-user.target || User-defined/Site-specific runlevels. By default, identical to 3.<br />
|-<br />
| 3 || runlevel3.target, multi-user.target || Multi-user, non-graphical. Users can usually login via multiple consoles or via the network.<br />
|-<br />
| 5 || runlevel5.target, graphical.target || Multi-user, graphical. Usually has all the services of runlevel 3 plus a graphical login.<br />
|-<br />
| 6 || runlevel6.target, reboot.target || Reboot<br />
|-<br />
| emergency || emergency.target || Emergency shell<br />
|-<br />
|}<br />
<br />
=== Change current target ===<br />
<br />
In systemd targets are exposed via "target units". You can change them like this:<br />
<br />
# systemctl isolate graphical.target<br />
<br />
This will only change the current target, and has no effect on the next boot. This is equivalent to commands such as {{ic|telinit 3}} or {{ic|telinit 5}} in Sysvinit.<br />
<br />
=== Change default target to boot into ===<br />
<br />
The standard target is {{ic|default.target}}, which is aliased by default to {{ic|graphical.target}} (which roughly corresponds to the old runlevel 5). To change the default target at boot-time, append one of the following [[kernel parameters]] to your bootloader:<br />
<br />
{{Tip|The {{ic|.target}} extension can be left out.}}<br />
<br />
* {{ic|1=systemd.unit=multi-user.target}} (which roughly corresponds to the old runlevel 3),<br />
* {{ic|1=systemd.unit=rescue.target}} (which roughly corresponds to the old runlevel 1).<br />
<br />
Alternatively, you may leave the bootloader alone and change {{ic|default.target}}. This can be done using {{ic|systemctl}}:<br />
<br />
# systemctl enable multi-user.target<br />
<br />
The effect of this command is outputted by {{ic|systemctl}}; a symlink to the new default target is made at {{ic|/etc/systemd/system/default.target}}. This works if, and only if:<br />
<br />
[Install]<br />
Alias=default.target<br />
<br />
is in the target's configuration file. Currently, {{ic|multi-user.target}} and {{ic|graphical.target}} both have it.<br />
<br />
== Journal ==<br />
<br />
Since version 38, systemd has its own logging system, the journal. Therefore, running a syslog daemon is no longer required. To read the log, use:<br />
<br />
# journalctl<br />
<br />
By default (when {{ic|Storage&#61;}} is set to {{ic|auto}} in {{ic|/etc/systemd/journald.conf}}), the journal writes to {{ic|/var/log/journal/}}. If the directory {{ic|/var/log/journal/}} does not exist (e.g. if you or some program delete it), systemd will '''not''' create it automatically, but instead write its logs to {{ic|/run/systemd/journal}}. This means that logs will be lost on reboot.<br />
<br />
=== Filtering output ===<br />
<br />
{{ic|journalctl}} allows you to filter the output by specific fields.<br />
<br />
Examples:<br />
<br />
Show all messages from this boot:<br />
<br />
# journalctl -b<br />
<br />
However, often one is interested in messages not from the current, but from the previous boot (e.g. if an unrecoverable system crash happened). Currently, this feature is not implemented, though there was a diskussion at [http://comments.gmane.org/gmane.comp.sysutils.systemd.devel/6608 systemd-devel@lists.freedesktop.org] (September/October 2012).<br />
<br />
As a workaround you can use at the moment:<br />
<br />
# journalctl --since=today | tac | sed -n '/-- Reboot --/{n;:r;/-- Reboot --/q;p;n;b r}' | tac<br />
<br />
, provided, that the previous boot happened today. Be aware that, if there are many messages for the current day, the output of this command can be delayed for quite some time.<br />
<br />
Follow new messages:<br />
<br />
# journalctl -f<br />
<br />
Show all messages by a specific executable:<br />
<br />
# journalctl /usr/lib/systemd/systemd<br />
<br />
Show all messages by a specific process:<br />
<br />
# journalctl _PID=1<br />
<br />
Show all messages by a specific unit:<br />
<br />
# journalctl -u netcfg<br />
<br />
See {{ic|man journalctl}}, {{ic|systemd.journal-fields}} or Lennert's [http://0pointer.de/blog/projects/journalctl.html blog post] for details.<br />
<br />
=== Journal size limit ===<br />
<br />
If the journal is persistent (non-volatile), its size limit is set to a default value of 10% of the size of the respective file system. E.g. with {{ic|/var/log/journal}} located on a 50 GiB root partition this would lead to 5 GiB of journal data. The maximum size of the persistent journal can be controlled by {{ic|SystemMaxUse}} in {{ic|/etc/systemd/journald.conf}}, so to limit it for example to 50 MiB uncomment and edit the corresponding line to:<br />
<br />
SystemMaxUse=50M<br />
<br />
Refer to {{ic|man journald.conf}} for more info.<br />
<br />
=== Journald in conjunction with syslog ===<br />
<br />
Compatibility with classic syslog implementations is provided via a socket {{ic|/run/systemd/journal/syslog}}, to which all messages are forwarded. To make the syslog daemon work with the journal, it has to bind to this socket instead of {{ic|/dev/log}} ([http://lwn.net/Articles/474968/ official announcement]). The {{pkg|syslog-ng}} package in the repositories automatically provides the necessary configuration.<br />
<br />
# systemctl enable syslog-ng<br />
<br />
== Optimization ==<br />
<br />
{{merge|Improve Boot Performance|reason=Should be moved to the article covering this topic.}}<br />
<br />
See [[Improve Boot Performance]].<br />
<br />
=== Analyzing the boot process ===<br />
<br />
==== Using systemd-analyze ====<br />
<br />
Systemd provides a tool called {{ic|systemd-analyze}} that allows you to analyze your boot process so you can see which unit files are causing your boot process to slow down. You can then optimize your system accordingly. You have to install {{Pkg|python2-cairo}} and {{Pkg|python2-gobject}} to use it.<br />
<br />
To see how much time was spent in kernelspace and userspace on boot, simply use:<br />
<br />
$ systemd-analyze<br />
<br />
{{Tip|To see how much time was spent in the initramfs, append the {{ic|timestamp}} hook to your {{ic|HOOKS}} array in {{ic|/etc/[[mkinitcpio]].conf}} and as root, rebuild your initramfs with {{ic|mkinitcpio -p linux}} }}<br />
<br />
To list the started unit files, sorted by the time each of them took to start up:<br />
<br />
$ systemd-analyze blame<br />
<br />
You can also create a SVG file which describes your boot process graphically, similiar to [[Bootchart]]:<br />
<br />
$ systemd-analyze plot > plot.svg<br />
<br />
==== Using bootchart ====<br />
<br />
You could also use a version of bootchart to visualize the boot sequence. Since you are not able to put a second init into the kernel command line you won't be able to use any of the standard bootchart setups. However the {{AUR|bootchart2}} package from [[AUR]] comes with an undocumented systemd service. After you've installed bootchart2 do:<br />
<br />
# systemctl enable bootchart<br />
<br />
Read the [https://github.com/mmeeks/bootchart bootchart documentation] for further details on using this version of bootchart.<br />
<br />
=== Readahead ===<br />
<br />
Systemd comes with its own readahead implementation, this should in principle improve boot time. However, depending on your kernel version and the type of your hard drive, your mileage may vary (i.e. it might be slower). To enable, do:<br />
<br />
# systemctl enable systemd-readahead-collect systemd-readahead-replay<br />
<br />
Remember that in order for the readahead to work its magic, you should reboot a couple of times.<br />
<br />
== Troubleshooting ==<br />
<br />
=== "Error: No space left on device" when trying to start/restart a service ===<br />
Note: I don't know if this is a proper solution, but it seems to have worked for me (I didn't use the same value as they said to, however).<br />
<br />
See this link: [http://support.crashplanpro.com/doku.php/recipe/increase_inotify_watches CrashPlan Support]<br />
<br />
Thanks to [http://forums.fedoraforum.org/showthread.php?t=283422 Fedora Forum] for pointing me to this site.<br />
<br />
=== Shutdown/reboot takes terribly long ===<br />
<br />
If the shutdown process takes a very long time (or seems to freeze) most likely a service not exiting is to blame. Systemd waits some time for each service to exit before trying to kill it. To find out if you are affected, see [http://freedesktop.org/wiki/Software/systemd/Debugging#Shutdown_Completes_Eventually this article].<br />
<br />
=== Short lived processes don't seem to log any output ===<br />
<br />
If {{ic|systemctl -u foounit.service}} doesn't show any output for a short lived service, look at the PID instead. For example, if systemd-modules-load.service fails, and {{ic|systemctl status systemd-modules-load}} shows that it ran as PID 123, then you might be able to see output in the journal for that PID, i.e. {{ic|journalctl -b _PID&#61;123}}. Metadata fields for the journal such as _SYSTEMD_UNIT and _COMM are collected asynchronously and rely on the {{ic|/proc}} directory for the process existing. Fixing this requires fixing the kernel to provide this data via a socket connection, similar to SCM_CREDENTIALS.<br />
<br />
== See also ==<br />
<br />
*[http://www.freedesktop.org/wiki/Software/systemd Official Web Site]<br />
*[http://0pointer.de/public/systemd-man/ Manual Pages]<br />
*[http://freedesktop.org/wiki/Software/systemd/Optimizations systemd Optimizations]<br />
*[http://www.freedesktop.org/wiki/Software/systemd/FrequentlyAskedQuestions FAQ]<br />
*[http://www.freedesktop.org/wiki/Software/systemd/TipsAndTricks Tips And Tricks]<br />
*[http://0pointer.de/public/systemd-ebook-psankar.pdf systemd for Administrators (PDF)]<br />
*[http://fedoraproject.org/wiki/Systemd About systemd on Fedora Project]<br />
*[http://fedoraproject.org/wiki/How_to_debug_Systemd_problems How to debug systemd problems]<br />
*[http://www.h-online.com/open/features/Control-Centre-The-systemd-Linux-init-system-1565543.html Two] [http://www.h-online.com/open/features/Booting-up-Tools-and-tips-for-systemd-1570630.html part] introductory article in ''The H Open'' magazine.<br />
*[http://0pointer.de/blog/projects/systemd.html Lennart's blog story]<br />
*[http://0pointer.de/blog/projects/systemd-update.html status update]<br />
*[http://0pointer.de/blog/projects/systemd-update-2.html status update2]<br />
*[http://0pointer.de/blog/projects/systemd-update-3.html status update3]<br />
*[http://0pointer.de/blog/projects/why.html most recent summary]<br />
*[http://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet Fedora's SysVinit to systemd cheatsheet]</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=175626Backlight2011-12-23T06:36:11Z<p>Hongy19: </p>
<hr />
<div>[[Category:Laptops (English)]]<br />
[[Category:Power management (English)]]<br />
Screen brightness can often be tricky to control. On many machines, physical hardware switches are missing and software solutions may or may not work well. Make sure to find a working method for your hardware! Too bright screens can cause eye strain.<br />
<br />
There are many ways to adjust the screen backlight of a monitor, laptop or integrated panel (such as the iMac) using software, but depending on hardware and model, sometimes only some options are available. This article aims to summarize all possible ways to adjust the backlight.<br />
<br />
==Overview==<br />
There are many ways to control brightness. According to this discussion[https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/397617] and this wiki page [https://wiki.ubuntu.com/Kernel/Debugging/Backlight], the control method could be divided into these category:<br />
* brightness is controlled by vendor specified hotkey. And there is no interface for OS to adjust brightness. <br />
* brightness is controlled by OS:<br />
** brightness could be controlled by ACPI<br />
** brightness could be controlled by graphic driver.<br />
all methods expose themselves to user by /sys/class/brightness. And xrandr/xbacklight could use this folder and choose one method to control brightness. But it is still not very clear which one is preferred by xbacklight as default.<br />
''See FS#27677 for xbacklight, if you get "No outputs have backlight property"''<br />
* brightness is controlled by HW register throught setpci<br />
<br />
==ACPI==<br />
It is often possible to adjust the backlight by ACPI. This controls the actual LEDs or cathodes of the screen. When this ACPI option is available, the illumination is controllable using a GUI slider in the Display/Screen system settings or by simple commands on the CLI. The ACPI kernel interface for interacting with the backlight is typically be located here:<br />
<br />
/sys/class/backlight/acpi_video0/<br />
<br />
It contains the following files and folders:<br />
<br />
actual_brightness brightness max_brightness subsystem/ uevent <br />
bl_power device/ power/ type<br />
<br />
The maximum brightness (often 15) can be found by running {{Codeline|cat}}:<br />
<br />
# cat /sys/class/backlight/acpi_video0/max_brightness<br />
15<br />
<br />
Brightness can then be set (as root) with {{Codeline|echo}}:<br />
<br />
# echo 5 > /sys/class/backlight/acpi_video0/brightness<br />
<br />
Sometimes ACPI does not work well due to different motherboard implementations and ACPI quirks. You can try adding the following kernel parameters in grub to adjust ACPI model:<br />
<br />
acpi_osi=Linux acpi_backlight=vendor<br />
<br />
or<br />
<br />
acpi_osi=Linux acpi_backlight=legacy<br />
''acpi_backlight=vendor will prefer vendor specific driver (e.g. thinkpad_acpi, sony_acpi, etc.) instead of the ACPI video.ko driver.''<br />
<br />
==xbacklight==<br />
You can adjust the backlight through the xorg-server command {{Codeline|xbacklight}}. The utility is provided by the {{Package Official|xorg-xbacklight}} package in [extra].<br />
<br />
A useful demonstration was posted by [http://www.youtube.com/watch?v=_pi3iKMAJcY gotbletu on YouTube]. He suggests the following commands to adjust the backlight:<br />
<br />
* brighten up:<br />
xbacklight -inc 40<br />
<br />
* dim down:<br />
xbacklight -dec 40<br />
<br />
==xcalib==<br />
The program [http://xcalib.sourceforge.net/ xcalib] can be downloaded from [https://aur.archlinux.org/packages.php?ID=10969 AUR] and used to dim the screen. Again, the user gotbletu posted a demonstration on [http://www.youtube.com/watch?v=_pi3iKMAJcY Youtube]. This program can correct gamma, invert colors and reduce contrast, the latter of which we use in this case:<br />
<br />
* dim down:<br />
xcalib -co 40 -a<br />
<br />
This program uses ICC technology to interact with X11 and while the screen is dimmed, you may find that the mouse cursor is just as bright as before.<br />
<br />
==redshift==<br />
The program [http://jonls.dk/redshift/ redshift] in the community repository uses {{Codeline|randr}} to adjust the screen brightness depending on the time of day and your geographic position. It can also do RGB gamma corrections and set color temperatures. As with {{Codeline|xcalib}}, this is very much a software solution and the look of the mouse cursor is unaffected. To execute a single quick adjustment of the brightness, try something like this:<br />
<br />
redshift -o -l 0:0 -b 0.8 -t 6500:6500<br />
<br />
==setpci (use with great care)==<br />
It is possible to set the register of the graphic card to adjust the backlight. It means you adjust the backlight by manipulating the hardware directly, which can be risky and generally is not a good idea. Not all of the graphic cards support this method.<br />
<br />
When using this method, you need to use {{Codeline|lspci}} first to find out where your graphic card is.<br />
# setpci -s 00:02.0 F4.B=0<br />
<br />
== KDE ==<br />
[[KDE]] users can adjust the backlight via System Settings -> Power Management -> Power Profiles.<br />
<br />
== NVIDIA Settings ==<br />
Users of [[NVIDIA|NVIDIA's proprietary drivers]] users can change display brightness via the nvidia-settings utility under "X Server Color Correction."</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=175623Backlight2011-12-23T06:15:13Z<p>Hongy19: /* Overview */</p>
<hr />
<div>[[Category:Laptops (English)]]<br />
[[Category:Power management (English)]]<br />
Screen brightness can often be tricky to control. On many machines, physical hardware switches are missing and software solutions may or may not work well. Make sure to find a working method for your hardware! Too bright screens can cause eye strain.<br />
<br />
There are many ways to adjust the screen backlight of a monitor, laptop or integrated panel (such as the iMac) using software, but depending on hardware and model, sometimes only some options are available. This article aims to summarize all possible ways to adjust the backlight.<br />
<br />
==Overview==<br />
There are many ways to control brightness. According to this discussion[https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/397617] and this wiki page [https://wiki.ubuntu.com/Kernel/Debugging/Backlight], the control method could be divided into these category:<br />
* brightness is controlled by vendor specified hotkey. And there is no interface for OS to adjust brightness. <br />
* brightness is controlled by OS:<br />
** brightness could be controlled by ACPI<br />
** brightness could be controlled by graphic driver.<br />
all methods expose themselves to user by /sys/class/brightness. And xrandr/xbacklight could use this folder and choose one method to control brightness. But it is still not very clear which one is preferred by xbacklight as default.<br />
''See FS#27677 for xbacklight, if you get "No outputs have backlight property"''<br />
* brightness is controlled by HW register throught setpci<br />
<br />
==ACPI==<br />
It is often possible to adjust the backlight by ACPI. This controls the actual LEDs or cathodes of the screen. When this ACPI option is available, the illumination is controllable using a GUI slider in the Display/Screen system settings or by simple commands on the CLI. The ACPI kernel interface for interacting with the backlight is typically be located here:<br />
<br />
/sys/class/backlight/acpi_video0/<br />
<br />
It contains the following files and folders:<br />
<br />
actual_brightness brightness max_brightness subsystem/ uevent <br />
bl_power device/ power/ type<br />
<br />
The maximum brightness (often 15) can be found by running {{Codeline|cat}}:<br />
<br />
# cat /sys/class/backlight/acpi_video0/max_brightness<br />
15<br />
<br />
Brightness can then be set (as root) with {{Codeline|echo}}:<br />
<br />
# echo 5 > /sys/class/backlight/acpi_video0/brightness<br />
<br />
Sometimes ACPI does not work well due to different motherboard implementations and ACPI quirks. You can try adding the following kernel parameters in grub to adjust ACPI model:<br />
<br />
acpi_osi=Linux acpi_backlight=vendor<br />
<br />
or<br />
<br />
acpi_osi=Linux acpi_backlight=legacy<br />
''acpi_backlight=vendor means using vendor specific ACPI module to control brightess instead of normal acpi module''<br />
<br />
==xbacklight==<br />
You can adjust the backlight through the xorg-server command {{Codeline|xbacklight}}. The utility is provided by the {{Package Official|xorg-xbacklight}} package in [extra].<br />
<br />
A useful demonstration was posted by [http://www.youtube.com/watch?v=_pi3iKMAJcY gotbletu on YouTube]. He suggests the following commands to adjust the backlight:<br />
<br />
* brighten up:<br />
xbacklight -inc 40<br />
<br />
* dim down:<br />
xbacklight -dec 40<br />
<br />
==xcalib==<br />
The program [http://xcalib.sourceforge.net/ xcalib] can be downloaded from [https://aur.archlinux.org/packages.php?ID=10969 AUR] and used to dim the screen. Again, the user gotbletu posted a demonstration on [http://www.youtube.com/watch?v=_pi3iKMAJcY Youtube]. This program can correct gamma, invert colors and reduce contrast, the latter of which we use in this case:<br />
<br />
* dim down:<br />
xcalib -co 40 -a<br />
<br />
This program uses ICC technology to interact with X11 and while the screen is dimmed, you may find that the mouse cursor is just as bright as before.<br />
<br />
==redshift==<br />
The program [http://jonls.dk/redshift/ redshift] in the community repository uses {{Codeline|randr}} to adjust the screen brightness depending on the time of day and your geographic position. It can also do RGB gamma corrections and set color temperatures. As with {{Codeline|xcalib}}, this is very much a software solution and the look of the mouse cursor is unaffected. To execute a single quick adjustment of the brightness, try something like this:<br />
<br />
redshift -o -l 0:0 -b 0.8 -t 6500:6500<br />
<br />
==setpci (use with great care)==<br />
It is possible to set the register of the graphic card to adjust the backlight. It means you adjust the backlight by manipulating the hardware directly, which can be risky and generally is not a good idea. Not all of the graphic cards support this method.<br />
<br />
When using this method, you need to use {{Codeline|lspci}} first to find out where your graphic card is.<br />
# setpci -s 00:02.0 F4.B=0<br />
<br />
== KDE ==<br />
[[KDE]] users can adjust the backlight via System Settings -> Power Management -> Power Profiles.<br />
<br />
== NVIDIA Settings ==<br />
Users of [[NVIDIA|NVIDIA's proprietary drivers]] users can change display brightness via the nvidia-settings utility under "X Server Color Correction."</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=175622Backlight2011-12-23T06:13:49Z<p>Hongy19: /* Overview */</p>
<hr />
<div>[[Category:Laptops (English)]]<br />
[[Category:Power management (English)]]<br />
Screen brightness can often be tricky to control. On many machines, physical hardware switches are missing and software solutions may or may not work well. Make sure to find a working method for your hardware! Too bright screens can cause eye strain.<br />
<br />
There are many ways to adjust the screen backlight of a monitor, laptop or integrated panel (such as the iMac) using software, but depending on hardware and model, sometimes only some options are available. This article aims to summarize all possible ways to adjust the backlight.<br />
<br />
==Overview==<br />
There are many ways to control brightness. According to this discussion[https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/397617] and this wiki page [https://wiki.ubuntu.com/Kernel/Debugging/Backlight], the control method could be divided into these category:<br />
* brightness is controlled by vendor specified hotkey. And there is no interface for OS to adjust brightness. <br />
* brightness is controlled by OS:<br />
** brightness could be controlled by ACPI<br />
** brightness could be controlled by graphic driver.<br />
<br />
In this condition, all methods expose themselves to user by /sys/class/brightness. And xrandr/xbacklight could use this folder and choose one method to control brightness. But it is still not very clear which one is preferred by xbacklight as default.<br />
''See FS#27677 for xbacklight, if you get "No outputs have backlight property"''<br />
<br />
==ACPI==<br />
It is often possible to adjust the backlight by ACPI. This controls the actual LEDs or cathodes of the screen. When this ACPI option is available, the illumination is controllable using a GUI slider in the Display/Screen system settings or by simple commands on the CLI. The ACPI kernel interface for interacting with the backlight is typically be located here:<br />
<br />
/sys/class/backlight/acpi_video0/<br />
<br />
It contains the following files and folders:<br />
<br />
actual_brightness brightness max_brightness subsystem/ uevent <br />
bl_power device/ power/ type<br />
<br />
The maximum brightness (often 15) can be found by running {{Codeline|cat}}:<br />
<br />
# cat /sys/class/backlight/acpi_video0/max_brightness<br />
15<br />
<br />
Brightness can then be set (as root) with {{Codeline|echo}}:<br />
<br />
# echo 5 > /sys/class/backlight/acpi_video0/brightness<br />
<br />
Sometimes ACPI does not work well due to different motherboard implementations and ACPI quirks. You can try adding the following kernel parameters in grub to adjust ACPI model:<br />
<br />
acpi_osi=Linux acpi_backlight=vendor<br />
<br />
or<br />
<br />
acpi_osi=Linux acpi_backlight=legacy<br />
''acpi_backlight=vendor means using vendor specific ACPI module to control brightess instead of normal acpi module''<br />
<br />
==xbacklight==<br />
You can adjust the backlight through the xorg-server command {{Codeline|xbacklight}}. The utility is provided by the {{Package Official|xorg-xbacklight}} package in [extra].<br />
<br />
A useful demonstration was posted by [http://www.youtube.com/watch?v=_pi3iKMAJcY gotbletu on YouTube]. He suggests the following commands to adjust the backlight:<br />
<br />
* brighten up:<br />
xbacklight -inc 40<br />
<br />
* dim down:<br />
xbacklight -dec 40<br />
<br />
==xcalib==<br />
The program [http://xcalib.sourceforge.net/ xcalib] can be downloaded from [https://aur.archlinux.org/packages.php?ID=10969 AUR] and used to dim the screen. Again, the user gotbletu posted a demonstration on [http://www.youtube.com/watch?v=_pi3iKMAJcY Youtube]. This program can correct gamma, invert colors and reduce contrast, the latter of which we use in this case:<br />
<br />
* dim down:<br />
xcalib -co 40 -a<br />
<br />
This program uses ICC technology to interact with X11 and while the screen is dimmed, you may find that the mouse cursor is just as bright as before.<br />
<br />
==redshift==<br />
The program [http://jonls.dk/redshift/ redshift] in the community repository uses {{Codeline|randr}} to adjust the screen brightness depending on the time of day and your geographic position. It can also do RGB gamma corrections and set color temperatures. As with {{Codeline|xcalib}}, this is very much a software solution and the look of the mouse cursor is unaffected. To execute a single quick adjustment of the brightness, try something like this:<br />
<br />
redshift -o -l 0:0 -b 0.8 -t 6500:6500<br />
<br />
==setpci (use with great care)==<br />
It is possible to set the register of the graphic card to adjust the backlight. It means you adjust the backlight by manipulating the hardware directly, which can be risky and generally is not a good idea. Not all of the graphic cards support this method.<br />
<br />
When using this method, you need to use {{Codeline|lspci}} first to find out where your graphic card is.<br />
# setpci -s 00:02.0 F4.B=0<br />
<br />
== KDE ==<br />
[[KDE]] users can adjust the backlight via System Settings -> Power Management -> Power Profiles.<br />
<br />
== NVIDIA Settings ==<br />
Users of [[NVIDIA|NVIDIA's proprietary drivers]] users can change display brightness via the nvidia-settings utility under "X Server Color Correction."</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=175621Backlight2011-12-23T06:09:38Z<p>Hongy19: /* Overview */</p>
<hr />
<div>[[Category:Laptops (English)]]<br />
[[Category:Power management (English)]]<br />
Screen brightness can often be tricky to control. On many machines, physical hardware switches are missing and software solutions may or may not work well. Make sure to find a working method for your hardware! Too bright screens can cause eye strain.<br />
<br />
There are many ways to adjust the screen backlight of a monitor, laptop or integrated panel (such as the iMac) using software, but depending on hardware and model, sometimes only some options are available. This article aims to summarize all possible ways to adjust the backlight.<br />
<br />
==Overview==<br />
There are many ways to control brightness. According to this discussion[https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/397617] and this wiki page [https://wiki.ubuntu.com/Kernel/Debugging/Backlight], the control method could be divided into these category:<br />
* brightness is controlled by vendor specified hotkey. And there is no interface for OS to adjust brightness. <br />
* brightness is controlled by OS:<br />
** brightness could be controlled by ACPI<br />
** brightness could be controlled by graphic driver.<br />
In this condition, all method expose themselves to user by /sys/class/brightness. And xrandr/xbacklight will search this folder and choose one method to control brightness. But it is still not very clear which one is preferred by xbacklight as default.<br />
<br />
''See TR FS#27677 for xbacklight, if you get "No outputs have backlight property"''<br />
<br />
==ACPI==<br />
It is often possible to adjust the backlight by ACPI. This controls the actual LEDs or cathodes of the screen. When this ACPI option is available, the illumination is controllable using a GUI slider in the Display/Screen system settings or by simple commands on the CLI. The ACPI kernel interface for interacting with the backlight is typically be located here:<br />
<br />
/sys/class/backlight/acpi_video0/<br />
<br />
It contains the following files and folders:<br />
<br />
actual_brightness brightness max_brightness subsystem/ uevent <br />
bl_power device/ power/ type<br />
<br />
The maximum brightness (often 15) can be found by running {{Codeline|cat}}:<br />
<br />
# cat /sys/class/backlight/acpi_video0/max_brightness<br />
15<br />
<br />
Brightness can then be set (as root) with {{Codeline|echo}}:<br />
<br />
# echo 5 > /sys/class/backlight/acpi_video0/brightness<br />
<br />
Sometimes ACPI does not work well due to different motherboard implementations and ACPI quirks. You can try adding the following kernel parameters in grub to adjust ACPI model:<br />
<br />
acpi_osi=Linux acpi_backlight=vendor<br />
<br />
or<br />
<br />
acpi_osi=Linux acpi_backlight=legacy<br />
''acpi_backlight=vendor means using vendor specific ACPI module to control brightess instead of normal acpi module''<br />
<br />
==xbacklight==<br />
You can adjust the backlight through the xorg-server command {{Codeline|xbacklight}}. The utility is provided by the {{Package Official|xorg-xbacklight}} package in [extra].<br />
<br />
A useful demonstration was posted by [http://www.youtube.com/watch?v=_pi3iKMAJcY gotbletu on YouTube]. He suggests the following commands to adjust the backlight:<br />
<br />
* brighten up:<br />
xbacklight -inc 40<br />
<br />
* dim down:<br />
xbacklight -dec 40<br />
<br />
==xcalib==<br />
The program [http://xcalib.sourceforge.net/ xcalib] can be downloaded from [https://aur.archlinux.org/packages.php?ID=10969 AUR] and used to dim the screen. Again, the user gotbletu posted a demonstration on [http://www.youtube.com/watch?v=_pi3iKMAJcY Youtube]. This program can correct gamma, invert colors and reduce contrast, the latter of which we use in this case:<br />
<br />
* dim down:<br />
xcalib -co 40 -a<br />
<br />
This program uses ICC technology to interact with X11 and while the screen is dimmed, you may find that the mouse cursor is just as bright as before.<br />
<br />
==redshift==<br />
The program [http://jonls.dk/redshift/ redshift] in the community repository uses {{Codeline|randr}} to adjust the screen brightness depending on the time of day and your geographic position. It can also do RGB gamma corrections and set color temperatures. As with {{Codeline|xcalib}}, this is very much a software solution and the look of the mouse cursor is unaffected. To execute a single quick adjustment of the brightness, try something like this:<br />
<br />
redshift -o -l 0:0 -b 0.8 -t 6500:6500<br />
<br />
==setpci (use with great care)==<br />
It is possible to set the register of the graphic card to adjust the backlight. It means you adjust the backlight by manipulating the hardware directly, which can be risky and generally is not a good idea. Not all of the graphic cards support this method.<br />
<br />
When using this method, you need to use {{Codeline|lspci}} first to find out where your graphic card is.<br />
# setpci -s 00:02.0 F4.B=0<br />
<br />
== KDE ==<br />
[[KDE]] users can adjust the backlight via System Settings -> Power Management -> Power Profiles.<br />
<br />
== NVIDIA Settings ==<br />
Users of [[NVIDIA|NVIDIA's proprietary drivers]] users can change display brightness via the nvidia-settings utility under "X Server Color Correction."</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=175620Backlight2011-12-23T06:07:39Z<p>Hongy19: </p>
<hr />
<div>[[Category:Laptops (English)]]<br />
[[Category:Power management (English)]]<br />
Screen brightness can often be tricky to control. On many machines, physical hardware switches are missing and software solutions may or may not work well. Make sure to find a working method for your hardware! Too bright screens can cause eye strain.<br />
<br />
There are many ways to adjust the screen backlight of a monitor, laptop or integrated panel (such as the iMac) using software, but depending on hardware and model, sometimes only some options are available. This article aims to summarize all possible ways to adjust the backlight.<br />
<br />
==Overview==<br />
There are many ways to control brightness. According to this discussion[https://bugs.launchpad.net/ubuntu/+source/xserver-xorg-video-intel/+bug/397617] and this wiki page [https://wiki.ubuntu.com/Kernel/Debugging/Backlight#Into_the_abyss:_looking_at_the_ACPI_BIOS], the control method could be divided into these category:<br />
* brightness is controlled by vendor specified hotkey. And there is no interface for OS to adjust brightness. <br />
* brightness is controlled by OS:<br />
** brightness could be controlled by ACPI<br />
** brightness could be controlled by graphic driver.<br />
In this condition, all method expose themselves to user by /sys/class/brightness. And xrandr/xbacklight will search this folder and choose one method to control brightness. But it is still not very clear which one is preferred by xbacklight as default.<br />
<br />
''See TR FS#27677 for xbacklight, if you get "No outputs have backlight property"''<br />
==ACPI==<br />
It is often possible to adjust the backlight by ACPI. This controls the actual LEDs or cathodes of the screen. When this ACPI option is available, the illumination is controllable using a GUI slider in the Display/Screen system settings or by simple commands on the CLI. The ACPI kernel interface for interacting with the backlight is typically be located here:<br />
<br />
/sys/class/backlight/acpi_video0/<br />
<br />
It contains the following files and folders:<br />
<br />
actual_brightness brightness max_brightness subsystem/ uevent <br />
bl_power device/ power/ type<br />
<br />
The maximum brightness (often 15) can be found by running {{Codeline|cat}}:<br />
<br />
# cat /sys/class/backlight/acpi_video0/max_brightness<br />
15<br />
<br />
Brightness can then be set (as root) with {{Codeline|echo}}:<br />
<br />
# echo 5 > /sys/class/backlight/acpi_video0/brightness<br />
<br />
Sometimes ACPI does not work well due to different motherboard implementations and ACPI quirks. You can try adding the following kernel parameters in grub to adjust ACPI model:<br />
<br />
acpi_osi=Linux acpi_backlight=vendor<br />
<br />
or<br />
<br />
acpi_osi=Linux acpi_backlight=legacy<br />
''acpi_backlight=vendor means using vendor specific ACPI module to control brightess instead of normal acpi module''<br />
<br />
==xbacklight==<br />
You can adjust the backlight through the xorg-server command {{Codeline|xbacklight}}. The utility is provided by the {{Package Official|xorg-xbacklight}} package in [extra].<br />
<br />
A useful demonstration was posted by [http://www.youtube.com/watch?v=_pi3iKMAJcY gotbletu on YouTube]. He suggests the following commands to adjust the backlight:<br />
<br />
* brighten up:<br />
xbacklight -inc 40<br />
<br />
* dim down:<br />
xbacklight -dec 40<br />
<br />
==xcalib==<br />
The program [http://xcalib.sourceforge.net/ xcalib] can be downloaded from [https://aur.archlinux.org/packages.php?ID=10969 AUR] and used to dim the screen. Again, the user gotbletu posted a demonstration on [http://www.youtube.com/watch?v=_pi3iKMAJcY Youtube]. This program can correct gamma, invert colors and reduce contrast, the latter of which we use in this case:<br />
<br />
* dim down:<br />
xcalib -co 40 -a<br />
<br />
This program uses ICC technology to interact with X11 and while the screen is dimmed, you may find that the mouse cursor is just as bright as before.<br />
<br />
==redshift==<br />
The program [http://jonls.dk/redshift/ redshift] in the community repository uses {{Codeline|randr}} to adjust the screen brightness depending on the time of day and your geographic position. It can also do RGB gamma corrections and set color temperatures. As with {{Codeline|xcalib}}, this is very much a software solution and the look of the mouse cursor is unaffected. To execute a single quick adjustment of the brightness, try something like this:<br />
<br />
redshift -o -l 0:0 -b 0.8 -t 6500:6500<br />
<br />
==setpci (use with great care)==<br />
It is possible to set the register of the graphic card to adjust the backlight. It means you adjust the backlight by manipulating the hardware directly, which can be risky and generally is not a good idea. Not all of the graphic cards support this method.<br />
<br />
When using this method, you need to use {{Codeline|lspci}} first to find out where your graphic card is.<br />
# setpci -s 00:02.0 F4.B=0<br />
<br />
== KDE ==<br />
[[KDE]] users can adjust the backlight via System Settings -> Power Management -> Power Profiles.<br />
<br />
== NVIDIA Settings ==<br />
Users of [[NVIDIA|NVIDIA's proprietary drivers]] users can change display brightness via the nvidia-settings utility under "X Server Color Correction."</div>Hongy19https://wiki.archlinux.org/index.php?title=Cron&diff=168443Cron2011-11-02T15:18:32Z<p>Hongy19: </p>
<hr />
<div>[[Category:Daemons and system services (English)]]<br />
<!-- i18n, flags --><br />
{{i18n|cron}}<br />
[[fr:Cron]]<br />
<!-- Overview --><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 />
<br />
Cron is a powerful job scheduler for GNU/Linux and many other operating systems. It automates recurring tasks by executing commands at a given time. It has a wide range of potential applications; most simple recurring tasks, from backups to e-mail retrieval, can be automated using cron, saving users time and headaches.<br />
<br />
==Installation==<br />
<br />
There are multiple cron implementations available from which users may choose. {{Package Official|cronie}} is available in [core] and is installed as part of the '''base''' group, you can check it is correctly installed with:<br />
<br />
# pacman -S --needed cronie<br />
<br />
Until May 2011, the default cron implementation for Arch Linux was {{Package Official|dcron}} (Dillon's Cron), which anyway is still supported and available in [extra]:<br />
<br />
# pacman -S dcron<br />
<br />
Alternatively, users may wish to install {{Package Official|fcron}} from [community] or {{Package AUR|bcron}} or {{Package AUR|vixie-cron}} from the [[AUR]]; all offer a wider range of features and configuration options.<br />
<br />
The [http://www.gentoo.org/doc/en/cron-guide.xml Gentoo Linux Cron Guide] offers a comparison between these implementations.<br />
<br />
==Initial configuration==<br />
{{Out of date}}<br />
{{Warning|The following sections of this article are still based on {{Package Official|dcron}}: you are invited to check the validity of the contents below and fix what is out of date.}}<br />
<br />
====Users & autostart====<br />
Cron should work "out-of-the-box" for most Arch Linux users. In order to use crontab, users must be members of a designated group, but in Arch Linux, that group is ''users'', of which all users should already be members. If for whatever reason some users are not members of this group, they can be added to it with the command:<br />
<br />
# gpasswd -a ''username'' users<br />
<br />
and they should then be able to edit their own crontabs.<br />
<br />
To ensure cron starts on boot, add the ''crond'' daemon to the daemons array of [[rc.conf]]. See [[Daemon#Starting_on_Boot]] for details.<br />
<br />
====Handling errors of jobs====<br />
Errors can occur during execution of jobs. When this happens cron register '''stderr''' output of job as e-mail and try to send it by default via '''sendmail''' command.<br />
To log this message you can use '''-M''' option of crontd and write you own script or install rudimentary SMTP subsystem ('''esmtp''' in this example):<br />
<br />
# pacman -S esmtp procmail<br />
<br />
After installation create file {{Filename|/etc/esmtprc}} with this content:<br />
<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 />
Procmail needs root privileges to work in delivery mode but it is not an issue if you are running the cronjobs as root.<br />
<br />
To test that everything works correctly, create a file {{filename|message.txt}} with ''"test message"'' in it. <br />
<br />
From the directory containing {{filename|message.txt}} run: <br />
<br />
$ sendmail user_name < message.txt <br />
<br />
then: <br />
<br />
$ cat /var/spool/mail/user_name <br />
<br />
You should see in the terminal, the ''"test message"'', the time and date it was sent.<br />
<br />
Thats all, all error output of jobs now will be redirected to {{Filename|/var/spool/mail/$user_name}}.<br />
<br />
Due to the privileged issue, it is hard to create and send the email to root. So you could ask esmtp to forward all root's email to some ordinary users. Add the following lines in esmtprc<br />
force_mda="user-name"<br />
<br />
'''If the above test didn't work''', try creating a file {{filename|~/.esmtprc}} with the same content as {{filename|/etc/esmtprc}}, (you can just create a copy as normal user).<br />
<br />
Run the following command to make sure it has the correct 710 permission: <br />
<br />
$ chmod 710 ~/.esmtprc<br />
<br />
Now just repeat the test with {{filename|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 /home/user/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Codeline|i_love_cron.sh}} at five minute intervals from 9 AM to 4:55 PM every weekday of the month 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 ''crontab'' program to work with their crontabs. To be granted access to this command, user must be a member of the users group (see 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 -d<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 "-u ''username''" to a command) works for listing and deleting crontabs as well.<br />
<br />
<br />
To use nano rather than vi as crontab editor, add the following lines to /etc/bash.bashrc:<br />
<br />
export EDITOR="/usr/bin/nano"<br />
<br />
And restart terminal/s<br />
<br />
==Examples==<br />
<br />
The entry:<br />
<br />
01 * * * * /bin/echo Hello, world!<br />
<br />
runs the command {{Codeline|/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 {{Codeline|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 ''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 {{Filename|/etc/crontab}} or the {{Filename|/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 />
{{File<br />
|name=/var/spool/cron/root<br />
|content=<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 {{Filename|/var/spool/cron/username}}. For example, root's crontab is found at {{Filename|/var/spool/cron/root}}<br />
<br />
See the crontab [[man page]] for further information and configuration examples, dcron's manpages are available [http://www.jimpryor.net/linux/dcron here]{{Linkrot|2011|09|04}} and [http://bbs.archlinux.org/viewtopic.php?id=78654&p=1 this] (note: yacron removed from repos?) forum post has lots of info. <br />
<br />
==run-parts issue==<br />
cronie use run-parts to carry out script in cron.daily/cron.week.y/cron.montly. Be carefull that the script name in these folders shouldn't have any '.', like backup.sh. Since run-parts without options will ignore them. Detail information see man run-parts.<br />
<br />
==Running X apps==<br />
<br />
If you find that you can't run X apps from cron jobs then put this before the<br />
command:<br />
<br />
export DISPLAY=:0.0 ;<br />
<br />
That sets the DISPLAY variable to the first display; which is usually right<br />
unless you like to run multiple xservers on your machine.<br />
<br />
If it still doesn't work then you need to use xhost to give your user control<br />
over X11:<br />
<br />
# xhost +si:localuser:$(whoami)<br />
<br />
I put it in my gnome `Startup Applications' like this:<br />
<br />
bash -c "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 : Vanilla dcron (the default cron daemon in Arch) now supports asynchronous job processing. Just put it with @hourly, @daily, @weekly or @monthy with a jobname, like this:<br />
<br />
@hourly ID=greatest_ever_job echo This job is very useful.<br />
<br />
; Cronwhip ([http://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 />
; Anacron ([http://aur.archlinux.org/packages.php?ID=5196 AUR]): Full replacement for dcron, processes jobs asynchronously.</div>Hongy19https://wiki.archlinux.org/index.php?title=Cron&diff=141879Cron2011-05-18T05:04:29Z<p>Hongy19: /* Handling errors of jobs */</p>
<hr />
<div><!-- Categories by topic --><br />
[[Category:Daemons and system services (English)]]<br />
[[Category:Utilities (English)]]<br />
<!-- Categories by type --><br />
[[Category:HOWTOs (English)]]<br />
<!-- i18n, flags --><br />
{{i18n|cron}}<br />
[[fr:Cron]]<br />
<!-- Overview --><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 />
<br />
Cron is a powerful job scheduler for GNU/Linux and many other operating systems. It automates recurring tasks by executing commands at a given time. It has a wide range of potential applications; most simple recurring tasks, from backups to e-mail retrieval, can be automated using cron, saving users time and headaches.<br />
<br />
==Installation==<br />
<br />
There are multiple cron implementations available for users to choose from. {{Package Official|cronie}} is available in [core] and is installed as part of the '''base''' group, you can check it is correctly installed with:<br />
<br />
# pacman -S --needed cronie<br />
<br />
Until May 2011, the default cron implementation for Arch Linux was {{Package Official|dcron}} (Dillon's Cron), which anyway is still supported and available in [extra]:<br />
<br />
# pacman -S dcron<br />
<br />
Alternatively, users may wish to install {{Package Official|fcron}} from [community] or {{Package AUR|bcron}} or {{Package AUR|vixie-cron}} from the [[AUR]]; all offer a wider range of features and configuration options.<br />
<br />
The [http://www.gentoo.org/doc/en/cron-guide.xml Gentoo Linux Cron Guide] offers a comparison between these implementations.<br />
<br />
==Initial configuration==<br />
{{Out of date}}<br />
{{Warning|The following sections of this article are still based on {{Package Official|dcron}}: you are invited to check the validity of the contents below and fix what is out of date.}}<br />
<br />
====Users & autostart====<br />
Cron should work "out-of-the-box" for most Arch Linux users. In order to use crontab, users must be members of a designated group, but in Arch Linux, that group is ''users'', of which all users should already be members. If for whatever reason some users are not members of this group, they can be added to it with the command:<br />
<br />
# gpasswd -a ''username'' users<br />
<br />
and they should then be able to edit their own crontabs.<br />
<br />
To ensure cron starts on boot, add the ''crond'' daemon to the daemons array of [[rc.conf]]. See [[Daemon#Starting_on_Boot]] for details.<br />
<br />
====Handling errors of jobs====<br />
Errors can occur during execution of jobs. When this happens cron register '''stderr''' output of job as e-mail and try to send it by default via '''sendmail''' command.<br />
To log this message you can use '''-M''' option of crontd and write you own script or install rudimentary SMTP subsystem ('''esmtp''' in this example):<br />
<br />
# pacman -S esmtp procmail<br />
<br />
After installation create file {{Filename|/etc/esmtprc}} with this content:<br />
<br />
mda "/usr/bin/procmail -d %T"<br />
Procmail need root privilegs to work under deliver mode. But due to anacron working as root, so it is not a issue.<br />
<br />
To test that everything works correctly, create a file {{filename|message.txt}} with ''"test message"'' in it. <br />
<br />
From the directory containing {{filename|message.txt}} run: <br />
<br />
$ sendmail user_name < message.txt <br />
<br />
then: <br />
<br />
$ cat /var/spool/mail/user_name <br />
<br />
You should see in the terminal, the ''"test message"'', the time and date it was sent.<br />
<br />
Thats all, all error output of jobs now will be redirected to {{Filename|/var/spool/mail/$user_name}}.<br />
<br />
Due to the privileged issue, it is hard to create and send the email to root. So you could ask esmtp to forward all root's email to some ordinary users. Add the following lines in esmtprc<br />
force_mda="user-name"<br />
<br />
'''If the above test didn't work''', try creating a file {{filename|~/.esmtprc}} with the same content as {{filename|/etc/esmtprc}}, (you can just create a copy as normal user).<br />
<br />
Run the following command to make sure it has the correct 710 permission: <br />
<br />
$ chmod 710 ~/.esmtprc<br />
<br />
Now just repeat the test with {{filename|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 /home/user/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Codeline|i_love_cron.sh}} at five minute intervals from 9 AM to 4:55 PM every weekday of the month 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 ''crontab'' program to work with their crontabs. To be granted access to this command, user must be a member of the users group (see 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 -d<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 "-u ''username''" to a command) works for listing and deleting crontabs as well.<br />
<br />
<br />
To use nano rather than vi as crontab editor, add the following lines to /etc/bashrc:<br />
<br />
export EDITOR="/usr/bin/nano"<br />
<br />
And restart terminal/s<br />
<br />
==Examples==<br />
<br />
The entry:<br />
<br />
01 * * * * /bin/echo Hello, world!<br />
<br />
runs the command {{Codeline|/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 {{Codeline|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 ''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 {{Filename|/etc/crontab}} or the {{Filename|/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 />
{{File<br />
|name=/var/spool/cron/root<br />
|content=<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 {{Filename|/var/spool/cron/username}}. For example, root's crontab is found at {{Filename|/var/spool/cron/root}}<br />
<br />
See the crontab [[man page]] for further information and configuration examples, dcron's manpages are available [http://www.jimpryor.net/linux/dcron here] and [http://bbs.archlinux.org/viewtopic.php?id=78654&p=1 this] (note: yacron removed from repos?) forum post has lots of info. <br />
<br />
==Running X apps==<br />
<br />
If you find that you can't run X apps from cron jobs then put this before the<br />
command:<br />
<br />
export DISPLAY=:0.0 ;<br />
<br />
That sets the DISPLAY variable to the first display; which is usually right<br />
unless you like to run multiple xservers on your machine.<br />
<br />
If it still doesn't work then you need to use xhost to give your user control<br />
over X11:<br />
<br />
# xhost +si:localuser:$(whoami)<br />
<br />
I put it in my gnome `Startup Applications' like this:<br />
<br />
bash -c "xhost +si:localuser:$(whoami)"<br />
<br />
==Asynchronous job processing==<br />
<br />
If you regularly turn off your computer but don't want to miss jobs, there are some solutions available (easiest to hardest):<br />
<br />
; Dcron : Vanilla dcron (the default cron daemon in Arch) now supports asynchronous job processing. Just put it with @hourly, @daily, @weekly or @monthy with a jobname, like this:<br />
<br />
@hourly ID=greatest_ever_job echo This job is very useful.<br />
<br />
; Cronwhip ([http://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 />
; Anacron ([http://aur.archlinux.org/packages.php?ID=5196 AUR]): Full replacement for dcron, processes jobs asynchronously.</div>Hongy19https://wiki.archlinux.org/index.php?title=Cron&diff=141821Cron2011-05-17T15:56:39Z<p>Hongy19: /* Handling errors of jobs */</p>
<hr />
<div><!-- Categories by topic --><br />
[[Category:Daemons and system services (English)]]<br />
[[Category:Utilities (English)]]<br />
<!-- Categories by type --><br />
[[Category:HOWTOs (English)]]<br />
<!-- i18n, flags --><br />
{{i18n|cron}}<br />
[[fr:Cron]]<br />
<!-- Overview --><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 />
<br />
Cron is a powerful job scheduler for GNU/Linux and many other operating systems. It automates recurring tasks by executing commands at a given time. It has a wide range of potential applications; most simple recurring tasks, from backups to e-mail retrieval, can be automated using cron, saving users time and headaches.<br />
<br />
==Installation==<br />
<br />
There are multiple cron implementations available for users to choose from. {{Package Official|cronie}} is available in [core] and is installed as part of the '''base''' group, you can check it is correctly installed with:<br />
<br />
# pacman -S --needed cronie<br />
<br />
Until May 2011, the default cron implementation for Arch Linux was {{Package Official|dcron}} (Dillon's Cron), which anyway is still supported and available in [extra]:<br />
<br />
# pacman -S dcron<br />
<br />
Alternatively, users may wish to install {{Package Official|fcron}} from [community] or {{Package AUR|bcron}} or {{Package AUR|vixie-cron}} from the [[AUR]]; all offer a wider range of features and configuration options.<br />
<br />
The [http://www.gentoo.org/doc/en/cron-guide.xml Gentoo Linux Cron Guide] offers a comparison between these implementations.<br />
<br />
==Initial configuration==<br />
{{Out of date}}<br />
{{Warning|The following sections of this article are still based on {{Package Official|dcron}}: you are invited to check the validity of the contents below and fix what is out of date.}}<br />
<br />
====Users & autostart====<br />
Cron should work "out-of-the-box" for most Arch Linux users. In order to use crontab, users must be members of a designated group, but in Arch Linux, that group is ''users'', of which all users should already be members. If for whatever reason some users are not members of this group, they can be added to it with the command:<br />
<br />
# gpasswd -a ''username'' users<br />
<br />
and they should then be able to edit their own crontabs.<br />
<br />
To ensure cron starts on boot, add the ''crond'' daemon to the daemons array of [[rc.conf]]. See [[Daemon#Starting_on_Boot]] for details.<br />
<br />
====Handling errors of jobs====<br />
Errors can occur during execution of jobs. When this happens cron register '''stderr''' output of job as e-mail and try to send it by default via '''sendmail''' command.<br />
To log this message you can use '''-M''' option of crontd and write you own script or install rudimentary SMTP subsystem ('''esmtp''' in this example):<br />
<br />
# pacman -S esmtp procmail<br />
<br />
After installation create file {{Filename|/etc/esmtprc}} with this content:<br />
<br />
mda "/usr/bin/procmail -d %T"<br />
And please setuid to procmail, otherwise procmail could not work under deliver mode and don't have enough privilege to update user mail with other account privilege.<br />
<br />
To test that everything works correctly, create a file {{filename|message.txt}} with ''"test message"'' in it. <br />
<br />
From the directory containing {{filename|message.txt}} run: <br />
<br />
$ sendmail user_name < message.txt <br />
<br />
then: <br />
<br />
$ cat /var/spool/mail/user_name <br />
<br />
You should see in the terminal, the ''"test message"'', the time and date it was sent.<br />
<br />
Thats all, all error output of jobs now will be redirected to {{Filename|/var/spool/mail/$user_name}}.<br />
<br />
Due to the privileged issue, it is hard to create and send the email to root. So you could ask esmtp to forward all root's email to some ordinary users. Add the following lines in esmtprc<br />
force_mda="user-name"<br />
<br />
'''If the above test didn't work''', try creating a file {{filename|~/.esmtprc}} with the same content as {{filename|/etc/esmtprc}}, (you can just create a copy as normal user).<br />
<br />
Run the following command to make sure it has the correct 710 permission: <br />
<br />
$ chmod 710 ~/.esmtprc<br />
<br />
Now just repeat the test with {{filename|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 /home/user/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Codeline|i_love_cron.sh}} at five minute intervals from 9 AM to 4:55 PM every weekday of the month 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 ''crontab'' program to work with their crontabs. To be granted access to this command, user must be a member of the users group (see 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 -d<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 "-u ''username''" to a command) works for listing and deleting crontabs as well.<br />
<br />
<br />
To use nano rather than vi as crontab editor, add the following lines to /etc/bashrc:<br />
<br />
export EDITOR="/usr/bin/nano"<br />
<br />
And restart terminal/s<br />
<br />
==Examples==<br />
<br />
The entry:<br />
<br />
01 * * * * /bin/echo Hello, world!<br />
<br />
runs the command {{Codeline|/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 {{Codeline|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 ''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 {{Filename|/etc/crontab}} or the {{Filename|/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 />
{{File<br />
|name=/var/spool/cron/root<br />
|content=<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 {{Filename|/var/spool/cron/username}}. For example, root's crontab is found at {{Filename|/var/spool/cron/root}}<br />
<br />
See the crontab [[man page]] for further information and configuration examples, dcron's manpages are available [http://www.jimpryor.net/linux/dcron here] and [http://bbs.archlinux.org/viewtopic.php?id=78654&p=1 this] (note: yacron removed from repos?) forum post has lots of info. <br />
<br />
==Running X apps==<br />
<br />
If you find that you can't run X apps from cron jobs then put this before the<br />
command:<br />
<br />
export DISPLAY=:0.0 ;<br />
<br />
That sets the DISPLAY variable to the first display; which is usually right<br />
unless you like to run multiple xservers on your machine.<br />
<br />
If it still doesn't work then you need to use xhost to give your user control<br />
over X11:<br />
<br />
# xhost +si:localuser:$(whoami)<br />
<br />
I put it in my gnome `Startup Applications' like this:<br />
<br />
bash -c "xhost +si:localuser:$(whoami)"<br />
<br />
==Asynchronous job processing==<br />
<br />
If you regularly turn off your computer but don't want to miss jobs, there are some solutions available (easiest to hardest):<br />
<br />
; Dcron : Vanilla dcron (the default cron daemon in Arch) now supports asynchronous job processing. Just put it with @hourly, @daily, @weekly or @monthy with a jobname, like this:<br />
<br />
@hourly ID=greatest_ever_job echo This job is very useful.<br />
<br />
; Cronwhip ([http://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 />
; Anacron ([http://aur.archlinux.org/packages.php?ID=5196 AUR]): Full replacement for dcron, processes jobs asynchronously.</div>Hongy19https://wiki.archlinux.org/index.php?title=Talk:Backlight&diff=141819Talk:Backlight2011-05-17T15:53:22Z<p>Hongy19: Created page with "the initial purpose is to write a detail instruction on backlight seeting. Because backlight setting is messy and confused. But this wiki is not finished yet. I try to expand it ..."</p>
<hr />
<div>the initial purpose is to write a detail instruction on backlight seeting. Because backlight setting is messy and confused. But this wiki is not finished yet. I try to expand it into a more detail one.<br />
<br />
Maybe we could add a short one in laptop page and keep a more detail one here.</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=141797Localization (简体中文)/Simplified Chinese (简体中文)2011-05-17T11:06:17Z<p>Hongy19: /* 中文字体显示的调整 */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch 之道 (简体中文)|Arch 之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用Arch Linux时,用户通常会遇上这些(典型)的问题:<br />
<br />
==中文界面的显示==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有(最直观的分别是可显示字的数量):<br />
zh_CN.GB2312<br />
zh_CN.GB18030<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce、zhcon或fbterm。<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S wqy-zenhei<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
wqy-bitmapfont<br />
wqy-zenhei<br />
wqy-microhei (AUR中)<br />
wqy-microhei-lite(AUR中)<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到~/.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
== 中文输入法设置 ==<br />
安装相应的输入法 [[scim]] 、 [[fcitx]] 或 [[ibus]]。<br />
<br />
scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔等基于码表的输入法<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在~/.xinitrc, ~/.bashrc或~/.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE="scim" #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE="scim" #设置scim为qt程序默认的输入法<br />
scim -d #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, 直接从mozilla.org下载的firefox, thunderbird,以及realplay。<br />
<br />
fcitx:<br />
与scim类似:<br />
pacman -S fcitx<br />
并将上述配置中的SCIM/scim 改成 FCITX/fcitx。<br />
<br />
==中文字体显示的调整==<br />
安装好字体以后,你可能对中文字体的显示不太满意。这时需要做两种调整:fontconfig调整和单个程序的调整。<br />
fontconfig是字体选择的接口,你可以用它去控制单个字体或者font family的属性,比如hint或者autohit。<br />
另外每个程序中可以设置不同的默认字体,比如Arial或者Tohamo。这些字体的属性由fontconfig控制。<br />
所以当字体显示不满意时,首先需要判断是调整字体的种类还是字体的属性。<br />
===单个程序的字型选择===<br />
浏览器中正文的字体可以设为serif。Serif和San serif的区别可以参考 (http://www.shocr.com/serif-vs-sans-serif/)<br />
===fontconfig设置===<br />
fontconfig的设置文件是~/.fonts.conf或者/etc/fonts/conf.d。<br />
====重排字型的显示顺序====<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
====关闭小号字体的AA(反锯齿)====<br />
对于比较小的字体,关闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
====中文显示模糊或没有中文粗体====<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
KDE环境及其他环境同上<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
没有中文粗体解决方法:<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
==中文字幕的显示==<br />
===mplayer===<br />
要使mplayer正确显示字幕,关键是要使字幕文件的编码和mplayer config里使用的编码相一致。字幕文件编码为gbk,则subcp=cp936;字幕文件编码为utf-8,则subcp=utf8。如果字幕文件编码为utf-8,而设置成subcp=cp936,则会出现部分乱码的情况。另一种更为简单的方法是设置成subcp=enca:zh:ucs-2,由enca负责字幕的编码显示问题。<br />
<br />
修改~/.mplayer/config<br />
font='文泉驿正黑'<br />
subcp=enca:zh:ucs-2<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===SMPlayer===<br />
SMPlayer 是一个基于QT的MPlayer前端。显示中文字幕很方便。只要在设置对话框里设定缺省字幕编码和字体即可。而且立即生效,无需重新启动程序。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以参考<br />
http://forum.ubuntu.org.cn/about2760.html<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
==中文乱码==<br />
<br />
===vim乱码===<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.virc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==='''MP3文件在播放器中乱码'''===<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
=== '''windows分区下的中文文件名乱码''' ===<br />
<br />
一般是因为挂载的字符集与locale不同,可以修改/etc/fstab(如果不了解请仔细阅读相关文档)。如果locale是utf8,例如:<br />
/dev/hdc5 /media/win ntfs-3g defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936<br />
<br />
==='''samba乱码'''===<br />
用Arch作为samba服务器时,在 /etc/samba/smb.conf 中加入下面一行就可以解决Windows客户端等乱码问题:<br />
unix charset=gb2312<br />
<br />
==='''ftp乱码'''===<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
===JAVA界面乱码===<br />
对于java 1.5来说(同样适用于java 1.6),只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文。例如,在已经安装 jre 和ttf-fireflysung 的情况下,执行下面的命令即可:<br />
ln -s /usr/share/fonts/TTF/odosung.ttc /opt/java/jre/lib/fonts/fallback/<br />
cd /opt/java/jre/lib/fonts/fallback/<br />
#以下两个命令要使用root权限<br />
mkfontdir<br />
mkfontscale<br />
<br />
<br />
如果是openjdk6 则需要复制这个文件:/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties.src 到/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties,并修改这个文件中的字体位置,因为文泉绎地址指错了。<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
#pacman -Syu openoffice-base openoffice-zh-CN<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
*目前,由于go-openoffice扩充了OpenOffice.org的功能(比如,完善了许多微软私有文档格式的兼容性),因此,我们推荐您使用go-openoffice。<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
'''Tips:''' 要正常显示所有的中文pdf(除了自定义字库外,比如文渊阁版四库全书),都需要安装poppler-data<br />
因为,linux下pdf大都以Poppler为解析PDF后端的,而Poppler已经提供了包含中文字体在内的包poppler-data,所以只要安装poppler-data,中文显示问题就可解决。 <br />
<br />
===okular===<br />
pacman -S kdegraphics-okular<br />
<br />
===arcobat===<br />
安装AUR里的acroread,并且安装相应中文包即可。<br />
<br />
=== Evince===<br />
<br />
pacman -S evince<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===其他可用的pdf阅读器===<br />
比如foxit<br />
<br />
===另外的问题===<br />
在中国知网、万方数据库上下载的一些论文没有明确指定字体,系统选用英文字体显示它们,于是导致中文无法显示。要解决这一问题,需要修改系统的字体配置,<br />
下面的方法更加建议使用:修改/etc/fonts/conf.d/65-nonlatin.conf<br />
把里面自己想使用的字体位置提到前面就可以了。<br />
<br />
'''Tips:''' 下面的建议是以前对字体配置文件不熟悉的时候经常使用的方法,现在建议不要采纳(虽然网上绝大部分流行的教程都是这么做的)<br />
<br />
====================================================================<br />
一种比较简便的方法是直接删除/etc/fonts/conf.d/49-sansserif.conf:<br />
<br />
# rm /etc/fonts/conf.d/49-sansserif.conf<br />
<br />
建议不要这么做,也可以将/etc/fonts/conf.d/49-sansserif.conf的<br />
<br />
<edit name="family" mode="append_last"><br />
<string>sans-serif</string><br />
</edit><br />
<br />
改成<br />
<br />
<edit name="family" mode="append_last"><br />
<string>文泉驿正黑</string><br />
</edit><br />
<br />
其中“文泉驿正黑”也可被其它所安装的中文字体代替。<br />
<br />
=======================================================================<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merriam Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=141546Localization (简体中文)/Simplified Chinese (简体中文)2011-05-15T16:18:24Z<p>Hongy19: /* 中文字体显示的调整 */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch 之道 (简体中文)|Arch 之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用Arch Linux时,用户通常会遇上这些(典型)的问题:<br />
<br />
==中文界面的显示==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有(最直观的分别是可显示字的数量):<br />
zh_CN.GB2312<br />
zh_CN.GB18030<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce、zhcon或fbterm。<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S wqy-zenhei<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
wqy-bitmapfont<br />
wqy-zenhei<br />
wqy-microhei (AUR中)<br />
wqy-microhei-lite(AUR中)<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到~/.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
== 中文输入法设置 ==<br />
安装相应的输入法 [[scim]] 、 [[fcitx]] 或 [[ibus]]。<br />
<br />
scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔等基于码表的输入法<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在~/.xinitrc, ~/.bashrc或~/.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE="scim" #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE="scim" #设置scim为qt程序默认的输入法<br />
scim -d #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, 直接从mozilla.org下载的firefox, thunderbird,以及realplay。<br />
<br />
fcitx:<br />
与scim类似:<br />
pacman -S fcitx<br />
并将上述配置中的SCIM/scim 改成 FCITX/fcitx。<br />
<br />
==中文字体显示的调整==<br />
安装好字体以后,你可能对中文字体的显示不太满意。这时一般需要做两种调整:fontconfig调整和单个程序的调整。<br />
fontconfig是一种字体选择接口,可以用它去控制font family或者hint, autohit之类的属性。简而言之,你可以用它去控制单个字体的属性。<br />
另外每个程序中一般都有默认字体,这个字体就是经过fontconfig而来。<br />
===单个程序的字型选择===<br />
浏览器中一般正文可以设为serif。关于serif和san serif的区别可以参考下文<br />
*http://www.shocr.com/serif-vs-sans-serif/<br />
===fontconfig设置===<br />
这时需要对fontconfig做某些设置。你可以在~/.fonts.conf中设定,也可以在/etc/fonts/conf.d中设定。<br />
====重排字型的显示顺序====<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
====关闭小号字体的AA(反锯齿)====<br />
对于比较小的字体,关闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
====中文显示模糊或没有中文粗体====<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
KDE环境及其他环境同上<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
没有中文粗体解决方法:<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
==中文字幕的显示==<br />
===mplayer===<br />
要使mplayer正确显示字幕,关键是要使字幕文件的编码和mplayer config里使用的编码相一致。字幕文件编码为gbk,则subcp=cp936;字幕文件编码为utf-8,则subcp=utf8。如果字幕文件编码为utf-8,而设置成subcp=cp936,则会出现部分乱码的情况。另一种更为简单的方法是设置成subcp=enca:zh:ucs-2,由enca负责字幕的编码显示问题。<br />
<br />
修改~/.mplayer/config<br />
font='文泉驿正黑'<br />
subcp=enca:zh:ucs-2<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===SMPlayer===<br />
SMPlayer 是一个基于QT的MPlayer前端。显示中文字幕很方便。只要在设置对话框里设定缺省字幕编码和字体即可。而且立即生效,无需重新启动程序。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以参考<br />
http://forum.ubuntu.org.cn/about2760.html<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
==中文乱码==<br />
<br />
===vim乱码===<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.virc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==='''MP3文件在播放器中乱码'''===<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
=== '''windows分区下的中文文件名乱码''' ===<br />
<br />
一般是因为挂载的字符集与locale不同,可以修改/etc/fstab(如果不了解请仔细阅读相关文档)。如果locale是utf8,例如:<br />
/dev/hdc5 /media/win ntfs-3g defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936<br />
<br />
==='''samba乱码'''===<br />
用Arch作为samba服务器时,在 /etc/samba/smb.conf 中加入下面一行就可以解决Windows客户端等乱码问题:<br />
unix charset=gb2312<br />
<br />
==='''ftp乱码'''===<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
===JAVA界面乱码===<br />
对于java 1.5来说(同样适用于java 1.6),只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文。例如,在已经安装 jre 和ttf-fireflysung 的情况下,执行下面的命令即可:<br />
ln -s /usr/share/fonts/TTF/odosung.ttc /opt/java/jre/lib/fonts/fallback/<br />
cd /opt/java/jre/lib/fonts/fallback/<br />
#以下两个命令要使用root权限<br />
mkfontdir<br />
mkfontscale<br />
<br />
<br />
如果是openjdk6 则需要复制这个文件:/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties.src 到/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties,并修改这个文件中的字体位置,因为文泉绎地址指错了。<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
#pacman -Syu openoffice-base openoffice-zh-CN<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
*目前,由于go-openoffice扩充了OpenOffice.org的功能(比如,完善了许多微软私有文档格式的兼容性),因此,我们推荐您使用go-openoffice。<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
'''Tips:''' 要正常显示所有的中文pdf(除了自定义字库外,比如文渊阁版四库全书),都需要安装poppler-data<br />
因为,linux下pdf大都以Poppler为解析PDF后端的,而Poppler已经提供了包含中文字体在内的包poppler-data,所以只要安装poppler-data,中文显示问题就可解决。 <br />
<br />
===okular===<br />
pacman -S kdegraphics-okular<br />
<br />
===arcobat===<br />
安装AUR里的acroread,并且安装相应中文包即可。<br />
<br />
=== Evince===<br />
<br />
pacman -S evince<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===其他可用的pdf阅读器===<br />
比如foxit<br />
<br />
===另外的问题===<br />
在中国知网、万方数据库上下载的一些论文没有明确指定字体,系统选用英文字体显示它们,于是导致中文无法显示。要解决这一问题,需要修改系统的字体配置,<br />
下面的方法更加建议使用:修改/etc/fonts/conf.d/65-nonlatin.conf<br />
把里面自己想使用的字体位置提到前面就可以了。<br />
<br />
'''Tips:''' 下面的建议是以前对字体配置文件不熟悉的时候经常使用的方法,现在建议不要采纳(虽然网上绝大部分流行的教程都是这么做的)<br />
<br />
====================================================================<br />
一种比较简便的方法是直接删除/etc/fonts/conf.d/49-sansserif.conf:<br />
<br />
# rm /etc/fonts/conf.d/49-sansserif.conf<br />
<br />
建议不要这么做,也可以将/etc/fonts/conf.d/49-sansserif.conf的<br />
<br />
<edit name="family" mode="append_last"><br />
<string>sans-serif</string><br />
</edit><br />
<br />
改成<br />
<br />
<edit name="family" mode="append_last"><br />
<string>文泉驿正黑</string><br />
</edit><br />
<br />
其中“文泉驿正黑”也可被其它所安装的中文字体代替。<br />
<br />
=======================================================================<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merriam Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=141545Localization (简体中文)/Simplified Chinese (简体中文)2011-05-15T16:17:30Z<p>Hongy19: /* fontconfig设置 */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch 之道 (简体中文)|Arch 之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用Arch Linux时,用户通常会遇上这些(典型)的问题:<br />
<br />
==中文界面的显示==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有(最直观的分别是可显示字的数量):<br />
zh_CN.GB2312<br />
zh_CN.GB18030<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce、zhcon或fbterm。<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S wqy-zenhei<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
wqy-bitmapfont<br />
wqy-zenhei<br />
wqy-microhei (AUR中)<br />
wqy-microhei-lite(AUR中)<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到~/.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
== 中文输入法设置 ==<br />
安装相应的输入法 [[scim]] 、 [[fcitx]] 或 [[ibus]]。<br />
<br />
scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔等基于码表的输入法<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在~/.xinitrc, ~/.bashrc或~/.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE="scim" #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE="scim" #设置scim为qt程序默认的输入法<br />
scim -d #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, 直接从mozilla.org下载的firefox, thunderbird,以及realplay。<br />
<br />
fcitx:<br />
与scim类似:<br />
pacman -S fcitx<br />
并将上述配置中的SCIM/scim 改成 FCITX/fcitx。<br />
<br />
==中文字体显示的调整==<br />
安装好字体以后,你可能对中文字体的显示不太满意。这种一般需要做两种调整:fontconfig调整和单个程序的调整。<br />
fontconfig是一种字体选择接口,可以用它去控制font family或者hint, autohit之类的属性。简而言之,你可以用它去控制单个字体的属性。<br />
另外每个程序中一般都有默认字体,这个字体就是经过fontconfig而来。<br />
===单个程序的字型选择===<br />
浏览器中一般正文可以设为serif。关于serif和san serif的区别可以参考下文<br />
*http://www.shocr.com/serif-vs-sans-serif/<br />
===fontconfig设置===<br />
这时需要对fontconfig做某些设置。你可以在~/.fonts.conf中设定,也可以在/etc/fonts/conf.d中设定。<br />
====重排字型的显示顺序====<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
====关闭小号字体的AA(反锯齿)====<br />
对于比较小的字体,关闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
====中文显示模糊或没有中文粗体====<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
KDE环境及其他环境同上<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
没有中文粗体解决方法:<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
==中文字幕的显示==<br />
===mplayer===<br />
要使mplayer正确显示字幕,关键是要使字幕文件的编码和mplayer config里使用的编码相一致。字幕文件编码为gbk,则subcp=cp936;字幕文件编码为utf-8,则subcp=utf8。如果字幕文件编码为utf-8,而设置成subcp=cp936,则会出现部分乱码的情况。另一种更为简单的方法是设置成subcp=enca:zh:ucs-2,由enca负责字幕的编码显示问题。<br />
<br />
修改~/.mplayer/config<br />
font='文泉驿正黑'<br />
subcp=enca:zh:ucs-2<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===SMPlayer===<br />
SMPlayer 是一个基于QT的MPlayer前端。显示中文字幕很方便。只要在设置对话框里设定缺省字幕编码和字体即可。而且立即生效,无需重新启动程序。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以参考<br />
http://forum.ubuntu.org.cn/about2760.html<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
==中文乱码==<br />
<br />
===vim乱码===<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.virc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==='''MP3文件在播放器中乱码'''===<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
=== '''windows分区下的中文文件名乱码''' ===<br />
<br />
一般是因为挂载的字符集与locale不同,可以修改/etc/fstab(如果不了解请仔细阅读相关文档)。如果locale是utf8,例如:<br />
/dev/hdc5 /media/win ntfs-3g defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936<br />
<br />
==='''samba乱码'''===<br />
用Arch作为samba服务器时,在 /etc/samba/smb.conf 中加入下面一行就可以解决Windows客户端等乱码问题:<br />
unix charset=gb2312<br />
<br />
==='''ftp乱码'''===<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
===JAVA界面乱码===<br />
对于java 1.5来说(同样适用于java 1.6),只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文。例如,在已经安装 jre 和ttf-fireflysung 的情况下,执行下面的命令即可:<br />
ln -s /usr/share/fonts/TTF/odosung.ttc /opt/java/jre/lib/fonts/fallback/<br />
cd /opt/java/jre/lib/fonts/fallback/<br />
#以下两个命令要使用root权限<br />
mkfontdir<br />
mkfontscale<br />
<br />
<br />
如果是openjdk6 则需要复制这个文件:/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties.src 到/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties,并修改这个文件中的字体位置,因为文泉绎地址指错了。<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
#pacman -Syu openoffice-base openoffice-zh-CN<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
*目前,由于go-openoffice扩充了OpenOffice.org的功能(比如,完善了许多微软私有文档格式的兼容性),因此,我们推荐您使用go-openoffice。<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
'''Tips:''' 要正常显示所有的中文pdf(除了自定义字库外,比如文渊阁版四库全书),都需要安装poppler-data<br />
因为,linux下pdf大都以Poppler为解析PDF后端的,而Poppler已经提供了包含中文字体在内的包poppler-data,所以只要安装poppler-data,中文显示问题就可解决。 <br />
<br />
===okular===<br />
pacman -S kdegraphics-okular<br />
<br />
===arcobat===<br />
安装AUR里的acroread,并且安装相应中文包即可。<br />
<br />
=== Evince===<br />
<br />
pacman -S evince<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===其他可用的pdf阅读器===<br />
比如foxit<br />
<br />
===另外的问题===<br />
在中国知网、万方数据库上下载的一些论文没有明确指定字体,系统选用英文字体显示它们,于是导致中文无法显示。要解决这一问题,需要修改系统的字体配置,<br />
下面的方法更加建议使用:修改/etc/fonts/conf.d/65-nonlatin.conf<br />
把里面自己想使用的字体位置提到前面就可以了。<br />
<br />
'''Tips:''' 下面的建议是以前对字体配置文件不熟悉的时候经常使用的方法,现在建议不要采纳(虽然网上绝大部分流行的教程都是这么做的)<br />
<br />
====================================================================<br />
一种比较简便的方法是直接删除/etc/fonts/conf.d/49-sansserif.conf:<br />
<br />
# rm /etc/fonts/conf.d/49-sansserif.conf<br />
<br />
建议不要这么做,也可以将/etc/fonts/conf.d/49-sansserif.conf的<br />
<br />
<edit name="family" mode="append_last"><br />
<string>sans-serif</string><br />
</edit><br />
<br />
改成<br />
<br />
<edit name="family" mode="append_last"><br />
<string>文泉驿正黑</string><br />
</edit><br />
<br />
其中“文泉驿正黑”也可被其它所安装的中文字体代替。<br />
<br />
=======================================================================<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merriam Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=141544Localization (简体中文)/Simplified Chinese (简体中文)2011-05-15T16:12:05Z<p>Hongy19: </p>
<hr />
<div>[[Category:General (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch 之道 (简体中文)|Arch 之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用Arch Linux时,用户通常会遇上这些(典型)的问题:<br />
<br />
==中文界面的显示==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有(最直观的分别是可显示字的数量):<br />
zh_CN.GB2312<br />
zh_CN.GB18030<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce、zhcon或fbterm。<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S wqy-zenhei<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
wqy-bitmapfont<br />
wqy-zenhei<br />
wqy-microhei (AUR中)<br />
wqy-microhei-lite(AUR中)<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到~/.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
== 中文输入法设置 ==<br />
安装相应的输入法 [[scim]] 、 [[fcitx]] 或 [[ibus]]。<br />
<br />
scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔等基于码表的输入法<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在~/.xinitrc, ~/.bashrc或~/.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE="scim" #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE="scim" #设置scim为qt程序默认的输入法<br />
scim -d #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, 直接从mozilla.org下载的firefox, thunderbird,以及realplay。<br />
<br />
fcitx:<br />
与scim类似:<br />
pacman -S fcitx<br />
并将上述配置中的SCIM/scim 改成 FCITX/fcitx。<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文字体的显示不太满意。<br />
===单个程序的字型选择===<br />
===fontconfig设置===<br />
这时需要对fontconfig做某些设置。你可以在~/.fonts.conf中设定,也可以在/etc/fonts/conf.d中设定。<br />
====重排字型的显示顺序====<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
====关闭小号字体的AA(反锯齿)====<br />
对于比较小的字体,关闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
====中文显示模糊或没有中文粗体====<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
KDE环境及其他环境同上<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
没有中文粗体解决方法:<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
==中文字幕的显示==<br />
===mplayer===<br />
要使mplayer正确显示字幕,关键是要使字幕文件的编码和mplayer config里使用的编码相一致。字幕文件编码为gbk,则subcp=cp936;字幕文件编码为utf-8,则subcp=utf8。如果字幕文件编码为utf-8,而设置成subcp=cp936,则会出现部分乱码的情况。另一种更为简单的方法是设置成subcp=enca:zh:ucs-2,由enca负责字幕的编码显示问题。<br />
<br />
修改~/.mplayer/config<br />
font='文泉驿正黑'<br />
subcp=enca:zh:ucs-2<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===SMPlayer===<br />
SMPlayer 是一个基于QT的MPlayer前端。显示中文字幕很方便。只要在设置对话框里设定缺省字幕编码和字体即可。而且立即生效,无需重新启动程序。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以参考<br />
http://forum.ubuntu.org.cn/about2760.html<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
==中文乱码==<br />
<br />
===vim乱码===<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.virc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==='''MP3文件在播放器中乱码'''===<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
=== '''windows分区下的中文文件名乱码''' ===<br />
<br />
一般是因为挂载的字符集与locale不同,可以修改/etc/fstab(如果不了解请仔细阅读相关文档)。如果locale是utf8,例如:<br />
/dev/hdc5 /media/win ntfs-3g defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936<br />
<br />
==='''samba乱码'''===<br />
用Arch作为samba服务器时,在 /etc/samba/smb.conf 中加入下面一行就可以解决Windows客户端等乱码问题:<br />
unix charset=gb2312<br />
<br />
==='''ftp乱码'''===<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
===JAVA界面乱码===<br />
对于java 1.5来说(同样适用于java 1.6),只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文。例如,在已经安装 jre 和ttf-fireflysung 的情况下,执行下面的命令即可:<br />
ln -s /usr/share/fonts/TTF/odosung.ttc /opt/java/jre/lib/fonts/fallback/<br />
cd /opt/java/jre/lib/fonts/fallback/<br />
#以下两个命令要使用root权限<br />
mkfontdir<br />
mkfontscale<br />
<br />
<br />
如果是openjdk6 则需要复制这个文件:/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties.src 到/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties,并修改这个文件中的字体位置,因为文泉绎地址指错了。<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
#pacman -Syu openoffice-base openoffice-zh-CN<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
*目前,由于go-openoffice扩充了OpenOffice.org的功能(比如,完善了许多微软私有文档格式的兼容性),因此,我们推荐您使用go-openoffice。<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
'''Tips:''' 要正常显示所有的中文pdf(除了自定义字库外,比如文渊阁版四库全书),都需要安装poppler-data<br />
因为,linux下pdf大都以Poppler为解析PDF后端的,而Poppler已经提供了包含中文字体在内的包poppler-data,所以只要安装poppler-data,中文显示问题就可解决。 <br />
<br />
===okular===<br />
pacman -S kdegraphics-okular<br />
<br />
===arcobat===<br />
安装AUR里的acroread,并且安装相应中文包即可。<br />
<br />
=== Evince===<br />
<br />
pacman -S evince<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===其他可用的pdf阅读器===<br />
比如foxit<br />
<br />
===另外的问题===<br />
在中国知网、万方数据库上下载的一些论文没有明确指定字体,系统选用英文字体显示它们,于是导致中文无法显示。要解决这一问题,需要修改系统的字体配置,<br />
下面的方法更加建议使用:修改/etc/fonts/conf.d/65-nonlatin.conf<br />
把里面自己想使用的字体位置提到前面就可以了。<br />
<br />
'''Tips:''' 下面的建议是以前对字体配置文件不熟悉的时候经常使用的方法,现在建议不要采纳(虽然网上绝大部分流行的教程都是这么做的)<br />
<br />
====================================================================<br />
一种比较简便的方法是直接删除/etc/fonts/conf.d/49-sansserif.conf:<br />
<br />
# rm /etc/fonts/conf.d/49-sansserif.conf<br />
<br />
建议不要这么做,也可以将/etc/fonts/conf.d/49-sansserif.conf的<br />
<br />
<edit name="family" mode="append_last"><br />
<string>sans-serif</string><br />
</edit><br />
<br />
改成<br />
<br />
<edit name="family" mode="append_last"><br />
<string>文泉驿正黑</string><br />
</edit><br />
<br />
其中“文泉驿正黑”也可被其它所安装的中文字体代替。<br />
<br />
=======================================================================<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merriam Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=141543Localization (简体中文)/Simplified Chinese (简体中文)2011-05-15T16:06:57Z<p>Hongy19: </p>
<hr />
<div>[[Category:General (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch 之道 (简体中文)|Arch 之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用Arch Linux时,用户通常会遇上这些(典型)的问题:<br />
<br />
==中文界面的显示==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有(最直观的分别是可显示字的数量):<br />
zh_CN.GB2312<br />
zh_CN.GB18030<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce、zhcon或fbterm。<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S wqy-zenhei<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
wqy-bitmapfont<br />
wqy-zenhei<br />
wqy-microhei (AUR中)<br />
wqy-microhei-lite(AUR中)<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到~/.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
== 中文输入法设置 ==<br />
安装相应的输入法 [[scim]] 、 [[fcitx]] 或 [[ibus]]。<br />
<br />
scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔等基于码表的输入法<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在~/.xinitrc, ~/.bashrc或~/.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE="scim" #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE="scim" #设置scim为qt程序默认的输入法<br />
scim -d #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, 直接从mozilla.org下载的firefox, thunderbird,以及realplay。<br />
<br />
fcitx:<br />
与scim类似:<br />
pacman -S fcitx<br />
并将上述配置中的SCIM/scim 改成 FCITX/fcitx。<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文字体的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.fonts.conf中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,关闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
===中文显示模糊或没有中文粗体===<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:<br />
<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
==中文字幕的显示==<br />
===mplayer===<br />
要使mplayer正确显示字幕,关键是要使字幕文件的编码和mplayer config里使用的编码相一致。字幕文件编码为gbk,则subcp=cp936;字幕文件编码为utf-8,则subcp=utf8。如果字幕文件编码为utf-8,而设置成subcp=cp936,则会出现部分乱码的情况。另一种更为简单的方法是设置成subcp=enca:zh:ucs-2,由enca负责字幕的编码显示问题。<br />
<br />
修改~/.mplayer/config<br />
font='文泉驿正黑'<br />
subcp=enca:zh:ucs-2<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===SMPlayer===<br />
SMPlayer 是一个基于QT的MPlayer前端。显示中文字幕很方便。只要在设置对话框里设定缺省字幕编码和字体即可。而且立即生效,无需重新启动程序。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以参考<br />
http://forum.ubuntu.org.cn/about2760.html<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
==中文乱码==<br />
<br />
===vim乱码===<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.virc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==='''MP3文件在播放器中乱码'''===<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
=== '''windows分区下的中文文件名乱码''' ===<br />
<br />
一般是因为挂载的字符集与locale不同,可以修改/etc/fstab(如果不了解请仔细阅读相关文档)。如果locale是utf8,例如:<br />
/dev/hdc5 /media/win ntfs-3g defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936<br />
<br />
==='''samba乱码'''===<br />
用Arch作为samba服务器时,在 /etc/samba/smb.conf 中加入下面一行就可以解决Windows客户端等乱码问题:<br />
unix charset=gb2312<br />
<br />
==='''ftp乱码'''===<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
===JAVA界面乱码===<br />
对于java 1.5来说(同样适用于java 1.6),只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文。例如,在已经安装 jre 和ttf-fireflysung 的情况下,执行下面的命令即可:<br />
ln -s /usr/share/fonts/TTF/odosung.ttc /opt/java/jre/lib/fonts/fallback/<br />
cd /opt/java/jre/lib/fonts/fallback/<br />
#以下两个命令要使用root权限<br />
mkfontdir<br />
mkfontscale<br />
<br />
<br />
如果是openjdk6 则需要复制这个文件:/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties.src 到/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties,并修改这个文件中的字体位置,因为文泉绎地址指错了。<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
#pacman -Syu openoffice-base openoffice-zh-CN<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
*目前,由于go-openoffice扩充了OpenOffice.org的功能(比如,完善了许多微软私有文档格式的兼容性),因此,我们推荐您使用go-openoffice。<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
'''Tips:''' 要正常显示所有的中文pdf(除了自定义字库外,比如文渊阁版四库全书),都需要安装poppler-data<br />
因为,linux下pdf大都以Poppler为解析PDF后端的,而Poppler已经提供了包含中文字体在内的包poppler-data,所以只要安装poppler-data,中文显示问题就可解决。 <br />
<br />
===okular===<br />
pacman -S kdegraphics-okular<br />
<br />
===arcobat===<br />
安装AUR里的acroread,并且安装相应中文包即可。<br />
<br />
=== Evince===<br />
<br />
pacman -S evince<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===其他可用的pdf阅读器===<br />
比如foxit<br />
<br />
===另外的问题===<br />
在中国知网、万方数据库上下载的一些论文没有明确指定字体,系统选用英文字体显示它们,于是导致中文无法显示。要解决这一问题,需要修改系统的字体配置,<br />
下面的方法更加建议使用:修改/etc/fonts/conf.d/65-nonlatin.conf<br />
把里面自己想使用的字体位置提到前面就可以了。<br />
<br />
'''Tips:''' 下面的建议是以前对字体配置文件不熟悉的时候经常使用的方法,现在建议不要采纳(虽然网上绝大部分流行的教程都是这么做的)<br />
<br />
====================================================================<br />
一种比较简便的方法是直接删除/etc/fonts/conf.d/49-sansserif.conf:<br />
<br />
# rm /etc/fonts/conf.d/49-sansserif.conf<br />
<br />
建议不要这么做,也可以将/etc/fonts/conf.d/49-sansserif.conf的<br />
<br />
<edit name="family" mode="append_last"><br />
<string>sans-serif</string><br />
</edit><br />
<br />
改成<br />
<br />
<edit name="family" mode="append_last"><br />
<string>文泉驿正黑</string><br />
</edit><br />
<br />
其中“文泉驿正黑”也可被其它所安装的中文字体代替。<br />
<br />
=======================================================================<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merriam Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=141542Localization (简体中文)/Simplified Chinese (简体中文)2011-05-15T16:06:01Z<p>Hongy19: </p>
<hr />
<div>[[Category:General (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch 之道 (简体中文)|Arch 之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用Arch Linux时,用户通常会遇上这些(典型)的问题:<br />
<br />
==中文界面的显示==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有(最直观的分别是可显示字的数量):<br />
zh_CN.GB2312<br />
zh_CN.GB18030<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce、zhcon或fbterm。<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S wqy-zenhei<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
wqy-bitmapfont<br />
wqy-zenhei<br />
wqy-microhei (AUR中)<br />
wqy-microhei-lite(AUR中)<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到~/.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
== 中文输入法设置 ==<br />
安装相应的输入法 [[scim]] 、 [[fcitx]] 或 [[ibus]]。<br />
<br />
scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔等基于码表的输入法<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在~/.xinitrc, ~/.bashrc或~/.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE="scim" #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE="scim" #设置scim为qt程序默认的输入法<br />
scim -d #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, 直接从mozilla.org下载的firefox, thunderbird,以及realplay。<br />
<br />
fcitx:<br />
与scim类似:<br />
pacman -S fcitx<br />
并将上述配置中的SCIM/scim 改成 FCITX/fcitx。<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文字体的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.fonts.conf中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,关闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
===中文显示模糊或没有中文粗体===<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:<br />
<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
==中文字幕的显示==<br />
===mplayer===<br />
要使mplayer正确显示字幕,关键是要使字幕文件的编码和mplayer config里使用的编码相一致。字幕文件编码为gbk,则subcp=cp936;字幕文件编码为utf-8,则subcp=utf8。如果字幕文件编码为utf-8,而设置成subcp=cp936,则会出现部分乱码的情况。另一种更为简单的方法是设置成subcp=enca:zh:ucs-2,由enca负责字幕的编码显示问题。<br />
<br />
修改~/.mplayer/config<br />
font='文泉驿正黑'<br />
subcp=enca:zh:ucs-2<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===SMPlayer===<br />
SMPlayer 是一个基于QT的MPlayer前端。显示中文字幕很方便。只要在设置对话框里设定缺省字幕编码和字体即可。而且立即生效,无需重新启动程序。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以参考<br />
http://forum.ubuntu.org.cn/about2760.html<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
==中文乱码==<br />
<br />
==='''MP3文件在播放器中乱码'''===<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
=== '''windows分区下的中文文件名乱码''' ===<br />
<br />
一般是因为挂载的字符集与locale不同,可以修改/etc/fstab(如果不了解请仔细阅读相关文档)。如果locale是utf8,例如:<br />
/dev/hdc5 /media/win ntfs-3g defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936<br />
<br />
==='''samba乱码'''===<br />
用Arch作为samba服务器时,在 /etc/samba/smb.conf 中加入下面一行就可以解决Windows客户端等乱码问题:<br />
unix charset=gb2312<br />
<br />
==='''ftp乱码'''===<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
===JAVA界面乱码===<br />
对于java 1.5来说(同样适用于java 1.6),只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文。例如,在已经安装 jre 和ttf-fireflysung 的情况下,执行下面的命令即可:<br />
ln -s /usr/share/fonts/TTF/odosung.ttc /opt/java/jre/lib/fonts/fallback/<br />
cd /opt/java/jre/lib/fonts/fallback/<br />
#以下两个命令要使用root权限<br />
mkfontdir<br />
mkfontscale<br />
<br />
<br />
如果是openjdk6 则需要复制这个文件:/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties.src 到/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties,并修改这个文件中的字体位置,因为文泉绎地址指错了。<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
#pacman -Syu openoffice-base openoffice-zh-CN<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
*目前,由于go-openoffice扩充了OpenOffice.org的功能(比如,完善了许多微软私有文档格式的兼容性),因此,我们推荐您使用go-openoffice。<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
'''Tips:''' 要正常显示所有的中文pdf(除了自定义字库外,比如文渊阁版四库全书),都需要安装poppler-data<br />
因为,linux下pdf大都以Poppler为解析PDF后端的,而Poppler已经提供了包含中文字体在内的包poppler-data,所以只要安装poppler-data,中文显示问题就可解决。 <br />
<br />
===okular===<br />
pacman -S kdegraphics-okular<br />
<br />
===arcobat===<br />
安装AUR里的acroread,并且安装相应中文包即可。<br />
<br />
=== Evince===<br />
<br />
pacman -S evince<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===其他可用的pdf阅读器===<br />
比如foxit<br />
<br />
===另外的问题===<br />
在中国知网、万方数据库上下载的一些论文没有明确指定字体,系统选用英文字体显示它们,于是导致中文无法显示。要解决这一问题,需要修改系统的字体配置,<br />
下面的方法更加建议使用:修改/etc/fonts/conf.d/65-nonlatin.conf<br />
把里面自己想使用的字体位置提到前面就可以了。<br />
<br />
'''Tips:''' 下面的建议是以前对字体配置文件不熟悉的时候经常使用的方法,现在建议不要采纳(虽然网上绝大部分流行的教程都是这么做的)<br />
<br />
====================================================================<br />
一种比较简便的方法是直接删除/etc/fonts/conf.d/49-sansserif.conf:<br />
<br />
# rm /etc/fonts/conf.d/49-sansserif.conf<br />
<br />
建议不要这么做,也可以将/etc/fonts/conf.d/49-sansserif.conf的<br />
<br />
<edit name="family" mode="append_last"><br />
<string>sans-serif</string><br />
</edit><br />
<br />
改成<br />
<br />
<edit name="family" mode="append_last"><br />
<string>文泉驿正黑</string><br />
</edit><br />
<br />
其中“文泉驿正黑”也可被其它所安装的中文字体代替。<br />
<br />
=======================================================================<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.virc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merriam Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Cron&diff=141541Cron2011-05-15T15:49:48Z<p>Hongy19: /* Handling errors of jobs */</p>
<hr />
<div><!-- Categories by topic --><br />
[[Category:Daemons and system services (English)]]<br />
[[Category:Utilities (English)]]<br />
<!-- Categories by type --><br />
[[Category:HOWTOs (English)]]<br />
<!-- i18n, flags --><br />
{{i18n|cron}}<br />
[[fr:Cron]]<br />
<!-- Overview --><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 />
<br />
Cron is a powerful job scheduler for GNU/Linux and many other operating systems. It automates recurring tasks by executing commands at a given time. It has a wide range of potential applications; most simple recurring tasks, from backups to e-mail retrieval, can be automated using cron, saving users time and headaches.<br />
<br />
==Installation==<br />
<br />
There are multiple cron implementations available for users to choose from. {{Package Official|dcron}} (Dillon's Cron) is available in [core] and is installed as part of the '''base''' group.<br />
<br />
# pacman -S dcron<br />
<br />
Alternatively, users may wish to install {{Package Official|fcron}} from [community] or {{Package AUR|bcron}} or {{Package AUR|vixie-cron}} from the [[AUR]]; all offer a wider range of features and configuration options.<br />
<br />
The [http://www.gentoo.org/doc/en/cron-guide.xml Gentoo Linux Cron Guide] offers a comparison between these implementations.<br />
<br />
==Initial configuration==<br />
====Users & autostart====<br />
Cron should work "out-of-the-box" for most Arch Linux users. In order to use crontab, users must be members of a designated group, but in Arch Linux, that group is ''users'', of which all users should already be members. If for whatever reason some users are not members of this group, they can be added to it with the command:<br />
<br />
# gpasswd -a ''username'' users<br />
<br />
and they should then be able to edit their own crontabs.<br />
<br />
To ensure cron starts on boot, add the ''crond'' daemon to the daemons array of [[rc.conf]]. See [[Daemon#Starting_on_Boot]] for details.<br />
<br />
====Handling errors of jobs====<br />
Errors can occur during execution of jobs. When this happens cron register '''stderr''' output of job as e-mail and try to send it by default via '''sendmail''' command.<br />
To log this message you can use '''-M''' option of crontd and write you own script or install rudimentary SMTP subsystem ('''esmtp''' in this example):<br />
<br />
# pacman -S esmtp procmail<br />
<br />
After installation create file {{Filename|/etc/esmtprc}} with this content:<br />
<br />
mda "/usr/bin/procmail -d %T"<br />
<br />
To test that everything works correctly, create a file {{filename|message.txt}} with ''"test message"'' in it. <br />
<br />
From the directory containing {{filename|message.txt}} run: <br />
<br />
$ sendmail user_name < message.txt <br />
<br />
then: <br />
<br />
$ cat /var/spool/mail/user_name <br />
<br />
You should see in the terminal, the ''"test message"'', the time and date it was sent.<br />
<br />
Thats all, all error output of jobs now will be redirected to {{Filename|/var/spool/mail/$user_name}}.<br />
<br />
Due to the privileged issue, it is hard to create and send the email to root. So you could ask esmtp to forward all root's email to some ordinary users. Add the following lines in esmtprc<br />
force_mda="user-name"<br />
<br />
'''If the above test didn't work''', try creating a file {{filename|~/.esmtprc}} with the same content as {{filename|/etc/esmtprc}}, (you can just create a copy as normal user).<br />
<br />
Run the following command to make sure it has the correct 710 permission: <br />
<br />
$ chmod 710 ~/.esmtprc<br />
<br />
Now just repeat the test with {{filename|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 /home/user/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Codeline|i_love_cron.sh}} at five minute intervals from 9 AM to 4:55 PM every weekday of the month 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 ''crontab'' program to work with their crontabs. To be granted access to this command, user must be a member of the users group (see 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 -d<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 "-u ''username''" to a command) works for listing and deleting crontabs as well.<br />
<br />
<br />
To use nano rather than vi as crontab editor, add the following lines to /etc/bashrc:<br />
<br />
export EDITOR="/usr/bin/nano"<br />
<br />
And restart terminal/s<br />
<br />
==Examples==<br />
<br />
The entry:<br />
<br />
01 * * * * /bin/echo Hello, world!<br />
<br />
runs the command {{Codeline|/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 {{Codeline|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 ''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 {{Filename|/etc/crontab}} or the {{Filename|/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 />
{{File<br />
|name=/var/spool/cron/root<br />
|content=<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 {{Filename|/var/spool/cron/username}}. For example, root's crontab is found at {{Filename|/var/spool/cron/root}}<br />
<br />
See the crontab [[man page]] for further information and configuration examples, dcron's manpages are available [http://www.jimpryor.net/linux/dcron here] and [http://bbs.archlinux.org/viewtopic.php?id=78654&p=1 this] (note: yacron removed from repos?) forum post has lots of info. <br />
<br />
==Running X apps==<br />
<br />
If you find that you can't run X apps from cron jobs then put this before the<br />
command:<br />
<br />
export DISPLAY=:0.0 ;<br />
<br />
That sets the DISPLAY variable to the first display; which is usually right<br />
unless you like to run multiple xservers on your machine.<br />
<br />
If it still doesn't work then you need to use xhost to give your user control<br />
over X11:<br />
<br />
# xhost +si:localuser:$(whoami)<br />
<br />
I put it in my gnome `Startup Applications' like this:<br />
<br />
bash -c "xhost +si:localuser:$(whoami)"<br />
<br />
==Asynchronous job processing==<br />
<br />
If you regularly turn off your computer but don't want to miss jobs, there are some solutions available (easiest to hardest):<br />
<br />
; Dcron : Vanilla dcron (the default cron daemon in Arch) now supports asynchronous job processing. Just put it with @hourly, @daily, @weekly or @monthy with a jobname, like this:<br />
<br />
@hourly ID=greatest_ever_job echo This job is very useful.<br />
<br />
; Cronwhip ([http://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 />
; Anacron ([http://aur.archlinux.org/packages.php?ID=5196 AUR]): Full replacement for dcron, processes jobs asynchronously.</div>Hongy19https://wiki.archlinux.org/index.php?title=Cron&diff=141540Cron2011-05-15T15:49:10Z<p>Hongy19: /* Handling errors of jobs */</p>
<hr />
<div><!-- Categories by topic --><br />
[[Category:Daemons and system services (English)]]<br />
[[Category:Utilities (English)]]<br />
<!-- Categories by type --><br />
[[Category:HOWTOs (English)]]<br />
<!-- i18n, flags --><br />
{{i18n|cron}}<br />
[[fr:Cron]]<br />
<!-- Overview --><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 />
<br />
Cron is a powerful job scheduler for GNU/Linux and many other operating systems. It automates recurring tasks by executing commands at a given time. It has a wide range of potential applications; most simple recurring tasks, from backups to e-mail retrieval, can be automated using cron, saving users time and headaches.<br />
<br />
==Installation==<br />
<br />
There are multiple cron implementations available for users to choose from. {{Package Official|dcron}} (Dillon's Cron) is available in [core] and is installed as part of the '''base''' group.<br />
<br />
# pacman -S dcron<br />
<br />
Alternatively, users may wish to install {{Package Official|fcron}} from [community] or {{Package AUR|bcron}} or {{Package AUR|vixie-cron}} from the [[AUR]]; all offer a wider range of features and configuration options.<br />
<br />
The [http://www.gentoo.org/doc/en/cron-guide.xml Gentoo Linux Cron Guide] offers a comparison between these implementations.<br />
<br />
==Initial configuration==<br />
====Users & autostart====<br />
Cron should work "out-of-the-box" for most Arch Linux users. In order to use crontab, users must be members of a designated group, but in Arch Linux, that group is ''users'', of which all users should already be members. If for whatever reason some users are not members of this group, they can be added to it with the command:<br />
<br />
# gpasswd -a ''username'' users<br />
<br />
and they should then be able to edit their own crontabs.<br />
<br />
To ensure cron starts on boot, add the ''crond'' daemon to the daemons array of [[rc.conf]]. See [[Daemon#Starting_on_Boot]] for details.<br />
<br />
====Handling errors of jobs====<br />
Errors can occur during execution of jobs. When this happens cron register '''stderr''' output of job as e-mail and try to send it by default via '''sendmail''' command.<br />
To log this message you can use '''-M''' option of crontd and write you own script or install rudimentary SMTP subsystem ('''esmtp''' in this example):<br />
<br />
# pacman -S esmtp procmail<br />
<br />
After installation create file {{Filename|/etc/esmtprc}} with this content:<br />
<br />
mda "/usr/bin/procmail -d %T"<br />
<br />
To test that everything works correctly, create a file {{filename|message.txt}} with ''"test message"'' in it. <br />
<br />
From the directory containing {{filename|message.txt}} run: <br />
<br />
$ sendmail user_name < message.txt <br />
<br />
then: <br />
<br />
$ cat /var/spool/mail/user_name <br />
<br />
You should see in the terminal, the ''"test message"'', the time and date it was sent.<br />
<br />
Thats all, all error output of jobs now will be redirected to {{Filename|/var/spool/mail/$user_name}}.<br />
<br />
Due to the privileged issue, it is hard to create and send the email to root. So you could ask esmtp to forward all root's email to some ordinary users. Add the following lines in esmtprc<br />
force_mda="user-name"<br />
<br />
'''If the above test didn't work''', try creating a file {{filename|~/.esmtprc}} with the same content as {{filename|/etc/esmtprc}}, (you can just create a copy as normal user).<br />
<br />
Run the following command to make sure it has the correct 710 permission: <br />
<br />
$ chmod 710 ~/.esmtprc<br />
<br />
Now just repeat the test with {{filename|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 /home/user/bin/i_love_cron.sh<br />
<br />
Will execute the script {{Codeline|i_love_cron.sh}} at five minute intervals from 9 AM to 4:55 PM every weekday of the month 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 ''crontab'' program to work with their crontabs. To be granted access to this command, user must be a member of the users group (see 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 -d<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 "-u ''username''" to a command) works for listing and deleting crontabs as well.<br />
<br />
<br />
To use nano rather than vi as crontab editor, add the following lines to /etc/bashrc:<br />
<br />
export EDITOR="/usr/bin/nano"<br />
<br />
And restart terminal/s<br />
<br />
==Examples==<br />
<br />
The entry:<br />
<br />
01 * * * * /bin/echo Hello, world!<br />
<br />
runs the command {{Codeline|/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 {{Codeline|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 ''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 {{Filename|/etc/crontab}} or the {{Filename|/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 />
{{File<br />
|name=/var/spool/cron/root<br />
|content=<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 {{Filename|/var/spool/cron/username}}. For example, root's crontab is found at {{Filename|/var/spool/cron/root}}<br />
<br />
See the crontab [[man page]] for further information and configuration examples, dcron's manpages are available [http://www.jimpryor.net/linux/dcron here] and [http://bbs.archlinux.org/viewtopic.php?id=78654&p=1 this] (note: yacron removed from repos?) forum post has lots of info. <br />
<br />
==Running X apps==<br />
<br />
If you find that you can't run X apps from cron jobs then put this before the<br />
command:<br />
<br />
export DISPLAY=:0.0 ;<br />
<br />
That sets the DISPLAY variable to the first display; which is usually right<br />
unless you like to run multiple xservers on your machine.<br />
<br />
If it still doesn't work then you need to use xhost to give your user control<br />
over X11:<br />
<br />
# xhost +si:localuser:$(whoami)<br />
<br />
I put it in my gnome `Startup Applications' like this:<br />
<br />
bash -c "xhost +si:localuser:$(whoami)"<br />
<br />
==Asynchronous job processing==<br />
<br />
If you regularly turn off your computer but don't want to miss jobs, there are some solutions available (easiest to hardest):<br />
<br />
; Dcron : Vanilla dcron (the default cron daemon in Arch) now supports asynchronous job processing. Just put it with @hourly, @daily, @weekly or @monthy with a jobname, like this:<br />
<br />
@hourly ID=greatest_ever_job echo This job is very useful.<br />
<br />
; Cronwhip ([http://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 />
; Anacron ([http://aur.archlinux.org/packages.php?ID=5196 AUR]): Full replacement for dcron, processes jobs asynchronously.</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=141538Localization (简体中文)/Simplified Chinese (简体中文)2011-05-15T15:37:59Z<p>Hongy19: </p>
<hr />
<div>[[Category:General (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch 之道 (简体中文)|Arch 之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用Arch Linux时,用户通常会遇上这些(典型)的问题:<br />
<br />
==中文界面的显示==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有(最直观的分别是可显示字的数量):<br />
zh_CN.GB2312<br />
zh_CN.GB18030<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce、zhcon或fbterm。<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S wqy-zenhei<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
wqy-bitmapfont<br />
wqy-zenhei<br />
wqy-microhei (AUR中)<br />
wqy-microhei-lite(AUR中)<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到~/.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
== 中文输入法设置 ==<br />
安装相应的输入法 [[scim]] 、 [[fcitx]] 或 [[ibus]]。<br />
<br />
scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔等基于码表的输入法<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在~/.xinitrc, ~/.bashrc或~/.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE="scim" #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE="scim" #设置scim为qt程序默认的输入法<br />
scim -d #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, 直接从mozilla.org下载的firefox, thunderbird,以及realplay。<br />
<br />
fcitx:<br />
与scim类似:<br />
pacman -S fcitx<br />
并将上述配置中的SCIM/scim 改成 FCITX/fcitx。<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文字体的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.fonts.conf中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,关闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
===中文显示模糊或没有中文粗体===<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:<br />
<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
==中文字幕的显示==<br />
===mplayer===<br />
要使mplayer正确显示字幕,关键是要使字幕文件的编码和mplayer config里使用的编码相一致。字幕文件编码为gbk,则subcp=cp936;字幕文件编码为utf-8,则subcp=utf8。如果字幕文件编码为utf-8,而设置成subcp=cp936,则会出现部分乱码的情况。另一种更为简单的方法是设置成subcp=enca:zh:ucs-2,由enca负责字幕的编码显示问题。<br />
<br />
修改~/.mplayer/config<br />
font='文泉驿正黑'<br />
subcp=enca:zh:ucs-2<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===SMPlayer===<br />
SMPlayer 是一个基于QT的MPlayer前端。显示中文字幕很方便。只要在设置对话框里设定缺省字幕编码和字体即可。而且立即生效,无需重新启动程序。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以参考<br />
http://forum.ubuntu.org.cn/about2760.html<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
<br />
一般是因为挂载的字符集与locale不同,可以修改/etc/fstab(如果不了解请仔细阅读相关文档)。如果locale是utf8,例如:<br />
/dev/hdc5 /media/win ntfs-3g defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936<br />
<br />
=='''samba乱码'''==<br />
用Arch作为samba服务器时,在 /etc/samba/smb.conf 中加入下面一行就可以解决Windows客户端等乱码问题:<br />
unix charset=gb2312<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说(同样适用于java 1.6),只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文。例如,在已经安装 jre 和ttf-fireflysung 的情况下,执行下面的命令即可:<br />
ln -s /usr/share/fonts/TTF/odosung.ttc /opt/java/jre/lib/fonts/fallback/<br />
cd /opt/java/jre/lib/fonts/fallback/<br />
#以下两个命令要使用root权限<br />
mkfontdir<br />
mkfontscale<br />
<br />
<br />
如果是openjdk6 则需要复制这个文件:/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties.src 到/usr/lib/jvm/java-6-openjdk/jre/lib/fontconfig.properties,并修改这个文件中的字体位置,因为文泉绎地址指错了。<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
#pacman -Syu openoffice-base openoffice-zh-CN<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
*目前,由于go-openoffice扩充了OpenOffice.org的功能(比如,完善了许多微软私有文档格式的兼容性),因此,我们推荐您使用go-openoffice。<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
'''Tips:''' 要正常显示所有的中文pdf(除了自定义字库外,比如文渊阁版四库全书),都需要安装poppler-data<br />
因为,linux下pdf大都以Poppler为解析PDF后端的,而Poppler已经提供了包含中文字体在内的包poppler-data,所以只要安装poppler-data,中文显示问题就可解决。 <br />
<br />
===okular===<br />
pacman -S kdegraphics-okular<br />
<br />
===arcobat===<br />
安装AUR里的acroread,并且安装相应中文包即可。<br />
<br />
=== Evince===<br />
<br />
pacman -S evince<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===其他可用的pdf阅读器===<br />
比如foxit<br />
<br />
===另外的问题===<br />
在中国知网、万方数据库上下载的一些论文没有明确指定字体,系统选用英文字体显示它们,于是导致中文无法显示。要解决这一问题,需要修改系统的字体配置,<br />
下面的方法更加建议使用:修改/etc/fonts/conf.d/65-nonlatin.conf<br />
把里面自己想使用的字体位置提到前面就可以了。<br />
<br />
'''Tips:''' 下面的建议是以前对字体配置文件不熟悉的时候经常使用的方法,现在建议不要采纳(虽然网上绝大部分流行的教程都是这么做的)<br />
<br />
====================================================================<br />
一种比较简便的方法是直接删除/etc/fonts/conf.d/49-sansserif.conf:<br />
<br />
# rm /etc/fonts/conf.d/49-sansserif.conf<br />
<br />
建议不要这么做,也可以将/etc/fonts/conf.d/49-sansserif.conf的<br />
<br />
<edit name="family" mode="append_last"><br />
<string>sans-serif</string><br />
</edit><br />
<br />
改成<br />
<br />
<edit name="family" mode="append_last"><br />
<string>文泉驿正黑</string><br />
</edit><br />
<br />
其中“文泉驿正黑”也可被其它所安装的中文字体代替。<br />
<br />
=======================================================================<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.virc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merriam Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=141537Backlight2011-05-15T15:23:43Z<p>Hongy19: /* ACPI method */</p>
<hr />
<div>[[Category:Graphics]]<br />
==Introduction==<br />
Actually there are many ways to adjust the backlight of laptop screen. Sometimes only some of them are available on some kinds of the laptop. This article tries to summarize all possible ways to adjust the backlight.<br />
<br />
==Adjustment==<br />
===setpci method===<br />
It is possible to set the register of the graphic card to adjust the backlight. It means you adjust the backlight by manipulating the hardware which is not a good idea. And also not all of the graphic card support this method.<br />
By using this method, you need "lspci" first to find out where is your graphic card.<br />
setpci -s 00:02.0 F4.B=0<br />
<br />
===ACPI method===<br />
It is possible to adjust the laptop by ACPI. But sometimes ACPI doesn't work well due to different implementation on mother board. You could use following kernel parameters in grub to adjust ACPI model.<br />
acpi_osi=Linux <br />
acpi_backlight=vendor<br />
<br />
===xbacklight method===<br />
You also could adjust the backlight through the xorg-server command.<br />
xbacklight</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=141536Backlight2011-05-15T15:22:35Z<p>Hongy19: /* setpci method */</p>
<hr />
<div>[[Category:Graphics]]<br />
==Introduction==<br />
Actually there are many ways to adjust the backlight of laptop screen. Sometimes only some of them are available on some kinds of the laptop. This article tries to summarize all possible ways to adjust the backlight.<br />
<br />
==Adjustment==<br />
===setpci method===<br />
It is possible to set the register of the graphic card to adjust the backlight. It means you adjust the backlight by manipulating the hardware which is not a good idea. And also not all of the graphic card support this method.<br />
By using this method, you need "lspci" first to find out where is your graphic card.<br />
setpci -s 00:02.0 F4.B=0<br />
<br />
===ACPI method===<br />
It is possible to adjust the laptop by ACPI. But sometimes ACPI doesn't work well due to different implementation on mother board. You could use following command in grub to adjust ACPI model.<br />
acpi_osi=Linux <br />
acpi_backlight=vendor<br />
<br />
===xbacklight method===<br />
You also could adjust the backlight through the xorg-server command.<br />
xbacklight</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=141535Backlight2011-05-15T15:18:25Z<p>Hongy19: </p>
<hr />
<div>[[Category:Graphics]]<br />
==Introduction==<br />
Actually there are many ways to adjust the backlight of laptop screen. Sometimes only some of them are available on some kinds of the laptop. This article tries to summarize all possible ways to adjust the backlight.<br />
<br />
==Adjustment==<br />
===setpci method===<br />
It is possible to set the register of the graphic card to adjust the backlight<br />
setpci -s 00:02.0 F4.B=0<br />
<br />
===ACPI method===<br />
It is possible to adjust the laptop by ACPI. But sometimes ACPI doesn't work well due to different implementation on mother board. You could use following command in grub to adjust ACPI model.<br />
acpi_osi=Linux <br />
acpi_backlight=vendor<br />
<br />
===xbacklight method===<br />
You also could adjust the backlight through the xorg-server command.<br />
xbacklight</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=141534Backlight2011-05-15T15:10:37Z<p>Hongy19: </p>
<hr />
<div>[[Category:Graphics]]<br />
==Introduction==<br />
Actually there are many ways to adjust the backlight of laptop screen. Sometimes only some of them are available on some kinds of the laptop. This article tries to summarize all possible ways to adjust the backlight.<br />
<br />
==Adjustment==<br />
===setpci method===<br />
It is possible to set the register of the graphic card to adjust the backlight<br />
setpci -s 00:02.0 F4.B=0<br />
<br />
===ACPI method===<br />
It is possible to adjust the laptop by apci<br />
<br />
===xbacklight method===<br />
You also could adjust the backlight through the xorg-server command.<br />
xbacklight</div>Hongy19https://wiki.archlinux.org/index.php?title=Backlight&diff=141533Backlight2011-05-15T15:09:43Z<p>Hongy19: This article summarize all possible method to adjust backlight</p>
<hr />
<div>[[Category:Graphics]]<br />
==Introduction==<br />
Actually there are many ways to adjust the backlight of laptop screen. Sometimes only some of them are available on some kinds of the laptop. This article tries to summarize all possible ways to adjust the backlight.<br />
===setpci method===<br />
It is possible to set the register of the graphic card to adjust the backlight<br />
setpci -s 00:02.0 F4.B=0<br />
<br />
===ACPI method===<br />
It is possible to adjust the laptop by apci<br />
<br />
===xbacklight method===<br />
You also could adjust the backlight through the xorg-server command.<br />
xbacklight</div>Hongy19https://wiki.archlinux.org/index.php?title=Xen&diff=141188Xen2011-05-12T14:15:25Z<p>Hongy19: /* Notes */</p>
<hr />
<div>[[Category:Emulators (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|Xen}}<br />
This document explains how to setup Xen within Arch Linux.<br />
<br />
==What is Xen?==<br />
According to the Xen development team: "The Xen hypervisor, the powerful open source industry standard for virtualization, offers a powerful, efficient, and secure feature set for virtualization of x86, x86_64, IA64, PowerPC, and other CPU architectures. It supports a wide range of guest operating systems including Windows®, Linux®, Solaris®, and various versions of the BSD operating systems."<br />
<br />
The Xen hypervisor is a thin layer of software which emulates a computer architecture. It is started by the boot loader and allows several operating systems to run simultaneously on top of it. Once the Xen hypervisor is loaded, it starts the "dom0" (for "domain 0"), or privileged domain, which in our case runs a modified Linux kernel (other possible dom0 operating systems are NetBSD and OpenSolaris). The [http://aur.archlinux.org/packages.php?ID=29023 dom0 kernel in the AUR] is currently based on a recent version of Linux kernel 2.6 and there is [http://aur.archlinux.org/packages.php?ID=38175 a more unstable -dev version] as well; hardware must, of course, be supported by this kernel to run Xen. Once the dom0 has started, one or more "domU" (unprivileged) domains can be started and controlled from dom0.<br />
<br />
==Setting up Xen==<br />
<br />
===Installing the necessary packages===<br />
Before building xen, be sure you have gcc, make, patch, and python2 installed.<br />
<pre>pacman -S gcc make patch python2</pre><br />
<br />
The new xen package, contains Xen 4 and resolves almost all necessary dependencies automatically. But, due to changes in the official Python version of Arch Linux, some old scripts show errors when they're executed. To solve this issue, download python2.5 from the [[AUR]].<br />
<br />
And, when we are asked to edit PKGBUILD (preferably with nano), we must not forget to replace this:<br />
<pre>make PYTHON=python2 DESTDIR=$pkgdir install-xen<br />
make PYTHON=python2 DESTDIR=$pkgdir install-tools<br />
make PYTHON=python2 DESTDIR=$pkgdir install-docs</pre><br />
with this:<br />
<pre>make PYTHON=python2.5 DESTDIR=$pkgdir install-xen<br />
make PYTHON=python2.5 DESTDIR=$pkgdir install-tools<br />
make PYTHON=python2.5 DESTDIR=$pkgdir install-docs<br />
<br />
sed -i -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2.5|" \<br />
-e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2.5|" \<br />
$(find $pkgdir -name '*.py')</pre><br />
<br />
Xen-tools is a collection of simple perl scripts which allow you to easily create new guest Xen domains. [http://aur.archlinux.org/packages.php?ID=37421 xen-tools] is also available in the AUR.<br />
<br />
The next step is to build and install the dom0 kernel. To do so, build the [http://aur.archlinux.org/packages.php?ID=29023 kernel26-xen-dom0] package from the AUR.<br />
<br />
<br />
'''Please note:''' currently the kernel26-xen-dom0 is marked as out of date in AUR, and is not yet updated to 2.6.36. So you have to run through the new parameters of 2.6.36 and agree to use the defaults (or whatever else you may want) - so just press enter each time you are asked.<br />
<br />
The building part has been finished. Now you can configure Grub and boot into the kernel that's just been built.<br />
<br />
===Configuring GRUB===<br />
Grub must be configured so that the Xen hypervisor is booted followed by the dom0 kernel. Add the following entry to /boot/grub/menu.lst:<br />
<br />
<pre><br />
title Xen with Arch Linux<br />
root (hd0,X)<br />
kernel /xen.gz dom0_mem=524288<br />
module /vmlinuz26-xen-dom0 root=/dev/sdaY ro console=tty0<br />
module /kernel26-xen-dom0.img<br />
</pre><br />
<br />
where X and Y are the appropriate numbers for your disk configuration; and dom0_mem, console, and vga are optional, customizable parameters. Nice little detail: you can use LVM volumes too. So instead of /dev/sdaY you can also fill in /dev/mapper/somelvm. <br />
<br />
The standard arch kernel can be use to boot the domUs. In order for this to work one must add 'xen-blkfront' to the modules array in /etc/mkinitcpio.conf:<br />
<br />
<pre><br />
MODULES="... xen-blkfront ..."<br />
</pre><br />
<br />
So, next step is to reboot into the xen kernel. <br />
<br />
Next step: start xend:<br />
<br />
<pre><br />
# /etc/rc.d/xend start<br />
</pre><br />
<br />
Allocating a fixed amount of memory is recommended when using xen. Also, if you're running IO intensive guests it might be a good idea to dedicate (pin) a CPU core only for dom0 use. Please see the external [http://wiki.xensource.com/xenwiki/XenCommonProblems XenCommonProblems] wiki page section "Can I dedicate a cpu core (or cores) only for dom0?" for more information.<br />
<br />
===Configuring GRUB2===<br />
<br />
This works just like with Grub, but here you need to use the command 'multiboot' instead of using 'kernel'. So it becomes:<br />
<pre><br />
# (2) Arch Linux(XEN)<br />
menuentry "Arch Linux(XEN)" {<br />
set root=(hd0,X)<br />
multiboot /boot/xen.gz dom0_mem=2048M<br />
module /boot/vmlinuz26-xen-dom0 root=/dev/sdaY ro<br />
module /boot/kernel26-xen-dom0.gz<br />
}<br />
</pre><br />
If you had success when booting up into the dom0 kernel, we can continue.<br />
<br />
===Add domU instances===<br />
<br />
The basic idea behind adding a domU is as follows. We must get the domU kernels, allocate space for the virtual hard disk, create a configuration file for the domU, and finally start the domU with xm.<br />
<br />
<pre><br />
$ mkfs.ext4 /dev/sdb1 ## format partition<br />
$ mkdir /tmp/install<br />
$ mount /dev/sdb1 /tmp/install<br />
$ mkdir -p /tmp/install/{dev,proc,sys} /tmp/install/var/lib/pacman /tmp/install/var/cache/pacman/pkg<br />
$ mount -o bind /dev /tmp/install/dev<br />
$ mount -t proc none /tmp/install/proc<br />
$ mount -o bind /sys /tmp/install/sys<br />
$ pacman -Sy -r /tmp/install --cachedir /tmp/install/var/cache/pacman/pkg -b /tmp/install/var/lib/pacman base<br />
$ cp -r /etc/pacman* /tmp/install/etc<br />
$ chroot /tmp/install /bin/bash<br />
$ vi /etc/resolv.conf<br />
$ vi /etc/fstab<br />
/dev/xvda / ext4 defaults 0 1<br />
<br />
$ vi /etc/inittab<br />
c1:2345:respawn:/sbin/agetty -8 38400 hvc0 linux<br />
#c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux<br />
#c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux<br />
#c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux<br />
#c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux<br />
#c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux<br />
#c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux<br />
<br />
<br />
$ exit ## exit chroot<br />
$ umount /tmp/install/dev<br />
$ umount /tmp/install/proc<br />
$ umount /tmp/install/sys<br />
$ umount /tmp/install<br />
</pre><br />
If not starting from a fresh install and one wants to rsync from an existing system:<br />
<pre><br />
$ mkfs.ext4 /dev/sdb1 ## format lv partition<br />
$ mkdir /tmp/install<br />
$ mount /dev/sdb1 /tmp/install<br />
$ mkdir /tmp/install/{proc,sys}<br />
$ chmod 555 /tmp/install/proc<br />
$ rsync -avzH --delete --exclude=proc/ --exclude=sys/ old_ooga:/ /tmp/install/<br />
<br />
$ vi /etc/xen/dom01 ## create config file<br />
# -*- mode: python; -*-<br />
kernel = "/boot/vmlinuz26"<br />
ramdisk = "/boot/kernel26.img"<br />
memory = 1024<br />
name = "dom01"<br />
vif = [ 'mac=00:16:3e:00:01:01' ]<br />
disk = [ 'phy:/dev/sdb1,xvda,w' ]<br />
dhcp="dhcp"<br />
hostname = "ooga"<br />
root = "/dev/xvda ro"<br />
<br />
$ xm create -c dom01<br />
</pre><br />
<br />
===Hardware Virtualization===<br />
<br />
If we want to get hardware virtualization in our domUs, the host system hardware must include either Intel-VT or AMD-V virtualization support. In order to verify this, run the following commands on the host system:<br />
<br />
For Intel CPUs:<br />
<pre>grep vmx /proc/cpuinfo</pre><br />
<br />
For AMD CPUSs:<br />
<pre>grep svm /proc/cpuinfo</pre><br />
<br />
If neither of the above commands produce output then it is likely these features are unavailable and that your hardware is unable to run Xen HVM guests. It is also possible that the host CPU supports one of these features, but that the functionality is disabled by default in the system BIOS. To verify this, access the host system’s BIOS configuration menu during the boot process and look for an option related to virtualization support. If such an option exists and is disabled, enable it, boot the system and repeat the above commands.<br />
<br />
==Arch as Xen guest (PV mode)==<br />
<br />
To get paravirtualization you need to install:<br />
* [http://aur.archlinux.org/packages.php?ID=16087 kernel26-xen]<br />
* (optional) [http://aur.archlinux.org/packages.php?ID=28591 xe-guest-utilities]<br />
<br />
Change mode to PV with commands (on dom0):<br />
xe vm-param-set uuid=<vm uuid> HVM-boot-policy=""<br />
xe vm-param-set uuid=<vm uuid> PV-bootloader=pygrub<br />
<br />
Edit /boot/grub/menu.lst and add kernel26-xen:<br />
# (1) Arch Linux (domU)<br />
title Arch Linux (domU)<br />
root (hd0,0)<br />
kernel /boot/vmlinuz26-xen root=/dev/xvda1 ro console=hvc0<br />
initrd /boot/kernel26-xen.img<br />
<br />
Add the following xen modules to your initcpio by appending the following to MODULES in /etc/mkinitcpio.conf: "xen-blkfront xen-fbfront xenfs xen-netfront xen-kbdfront" and rebuild your initcpio:<br />
mkinitcpio -p kernel26-xen<br />
<br />
Uncomment the following line in /etc/inittab to enable console login:<br />
h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux<br />
<br />
=== xe-guest-utilities ===<br />
To use xe-guest-utilities, add xenfs mount point into /etc/fstab:<br />
xenfs /proc/xen xenfs defaults 0 0<br />
and add xe-linux-distribution into /etc/rc.conf:DAEMONS array.<br />
<br />
===Notes===<br />
* pygrub does not show boot menu. And some version pygrub doesn't support lzma compressed stock kernel. see https://bbs.archlinux.org/viewtopic.php?id=118525<br />
* i686 stock kernel doesn't support xen due to highmem, but x86_64 support. See https://bugs.archlinux.org/task/24207?project=1. But you could still use i686/x86_64 kernel26-xen as above mentioned and this kernel is compressed by gzip, not lzma or xz<br />
* To avoid hwclock error messages, set HARDWARECLOCK="xen" in /etc/rc.conf (actually you can use any value here except "UTC" and "localtime")<br />
* If you want to return to hardware VM, set HVM-boot-policy="BIOS order"<br />
* If you get a kernel panic when booting Xen and it suggests 'use apic="debug" and send an error report', try setting noapic on the kernel line in menu.lst<br />
<br />
==Xen Management Tools==<br />
The "Virtual Machine Manager" application is a desktop user interface for managing virtual machines. It presents a summary view of running domains, their live performance & resource utilization statistics. The detailed view graphs performance & utilization over time. Wizards enable the creation of new domains, and configuration & adjustment of a domain's resource allocation & virtual hardware. An embedded VNC client viewer presents a full graphical console to the guest domain.<br />
<pre>yaourt -S virt-manager-light</pre><br />
<br />
==Useful Packages==<br />
As there are quite some packages available in AUR and you can have a pretty hard time figuring out what is needed here a small collection of most of the (intersting) xen packages (last updated: 23.5.2010)<br />
<br />
* Open source multiplatform clone of XenCenter frontend: [http://aur.archlinux.org/packages.php?ID=34398 openxencenter]<br />
* Open source multiplatform clone of XenCenter frontend (svn version): [http://aur.archlinux.org/packages.php?ID=36074 openxencenter-svn]<br />
* Xen Cloud Platform frontend: [http://aur.archlinux.org/packages.php?ID=36458 xvp]<br />
<br />
==Resources==<br />
<br />
* Xen's homepage: [http://www.xen.org/]<br />
* The Xen Wiki: [http://wiki.xensource.com/xenwiki/]<br />
* Xen kernel patches: [http://code.google.com/p/gentoo-xen-kernel/]<br />
* Virtuatopia guide to get Windows Server 2008 working with Xen: [http://www.virtuatopia.com/index.php/Virtualizing_Windows_Server_2008_with_Xen]</div>Hongy19https://wiki.archlinux.org/index.php?title=Xen&diff=141187Xen2011-05-12T14:10:49Z<p>Hongy19: </p>
<hr />
<div>[[Category:Emulators (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|Xen}}<br />
This document explains how to setup Xen within Arch Linux.<br />
<br />
==What is Xen?==<br />
According to the Xen development team: "The Xen hypervisor, the powerful open source industry standard for virtualization, offers a powerful, efficient, and secure feature set for virtualization of x86, x86_64, IA64, PowerPC, and other CPU architectures. It supports a wide range of guest operating systems including Windows®, Linux®, Solaris®, and various versions of the BSD operating systems."<br />
<br />
The Xen hypervisor is a thin layer of software which emulates a computer architecture. It is started by the boot loader and allows several operating systems to run simultaneously on top of it. Once the Xen hypervisor is loaded, it starts the "dom0" (for "domain 0"), or privileged domain, which in our case runs a modified Linux kernel (other possible dom0 operating systems are NetBSD and OpenSolaris). The [http://aur.archlinux.org/packages.php?ID=29023 dom0 kernel in the AUR] is currently based on a recent version of Linux kernel 2.6 and there is [http://aur.archlinux.org/packages.php?ID=38175 a more unstable -dev version] as well; hardware must, of course, be supported by this kernel to run Xen. Once the dom0 has started, one or more "domU" (unprivileged) domains can be started and controlled from dom0.<br />
<br />
==Setting up Xen==<br />
<br />
===Installing the necessary packages===<br />
Before building xen, be sure you have gcc, make, patch, and python2 installed.<br />
<pre>pacman -S gcc make patch python2</pre><br />
<br />
The new xen package, contains Xen 4 and resolves almost all necessary dependencies automatically. But, due to changes in the official Python version of Arch Linux, some old scripts show errors when they're executed. To solve this issue, download python2.5 from the [[AUR]].<br />
<br />
And, when we are asked to edit PKGBUILD (preferably with nano), we must not forget to replace this:<br />
<pre>make PYTHON=python2 DESTDIR=$pkgdir install-xen<br />
make PYTHON=python2 DESTDIR=$pkgdir install-tools<br />
make PYTHON=python2 DESTDIR=$pkgdir install-docs</pre><br />
with this:<br />
<pre>make PYTHON=python2.5 DESTDIR=$pkgdir install-xen<br />
make PYTHON=python2.5 DESTDIR=$pkgdir install-tools<br />
make PYTHON=python2.5 DESTDIR=$pkgdir install-docs<br />
<br />
sed -i -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2.5|" \<br />
-e "s|#![ ]*/usr/bin/env python$|#!/usr/bin/env python2.5|" \<br />
$(find $pkgdir -name '*.py')</pre><br />
<br />
Xen-tools is a collection of simple perl scripts which allow you to easily create new guest Xen domains. [http://aur.archlinux.org/packages.php?ID=37421 xen-tools] is also available in the AUR.<br />
<br />
The next step is to build and install the dom0 kernel. To do so, build the [http://aur.archlinux.org/packages.php?ID=29023 kernel26-xen-dom0] package from the AUR.<br />
<br />
<br />
'''Please note:''' currently the kernel26-xen-dom0 is marked as out of date in AUR, and is not yet updated to 2.6.36. So you have to run through the new parameters of 2.6.36 and agree to use the defaults (or whatever else you may want) - so just press enter each time you are asked.<br />
<br />
The building part has been finished. Now you can configure Grub and boot into the kernel that's just been built.<br />
<br />
===Configuring GRUB===<br />
Grub must be configured so that the Xen hypervisor is booted followed by the dom0 kernel. Add the following entry to /boot/grub/menu.lst:<br />
<br />
<pre><br />
title Xen with Arch Linux<br />
root (hd0,X)<br />
kernel /xen.gz dom0_mem=524288<br />
module /vmlinuz26-xen-dom0 root=/dev/sdaY ro console=tty0<br />
module /kernel26-xen-dom0.img<br />
</pre><br />
<br />
where X and Y are the appropriate numbers for your disk configuration; and dom0_mem, console, and vga are optional, customizable parameters. Nice little detail: you can use LVM volumes too. So instead of /dev/sdaY you can also fill in /dev/mapper/somelvm. <br />
<br />
The standard arch kernel can be use to boot the domUs. In order for this to work one must add 'xen-blkfront' to the modules array in /etc/mkinitcpio.conf:<br />
<br />
<pre><br />
MODULES="... xen-blkfront ..."<br />
</pre><br />
<br />
So, next step is to reboot into the xen kernel. <br />
<br />
Next step: start xend:<br />
<br />
<pre><br />
# /etc/rc.d/xend start<br />
</pre><br />
<br />
Allocating a fixed amount of memory is recommended when using xen. Also, if you're running IO intensive guests it might be a good idea to dedicate (pin) a CPU core only for dom0 use. Please see the external [http://wiki.xensource.com/xenwiki/XenCommonProblems XenCommonProblems] wiki page section "Can I dedicate a cpu core (or cores) only for dom0?" for more information.<br />
<br />
===Configuring GRUB2===<br />
<br />
This works just like with Grub, but here you need to use the command 'multiboot' instead of using 'kernel'. So it becomes:<br />
<pre><br />
# (2) Arch Linux(XEN)<br />
menuentry "Arch Linux(XEN)" {<br />
set root=(hd0,X)<br />
multiboot /boot/xen.gz dom0_mem=2048M<br />
module /boot/vmlinuz26-xen-dom0 root=/dev/sdaY ro<br />
module /boot/kernel26-xen-dom0.gz<br />
}<br />
</pre><br />
If you had success when booting up into the dom0 kernel, we can continue.<br />
<br />
===Add domU instances===<br />
<br />
The basic idea behind adding a domU is as follows. We must get the domU kernels, allocate space for the virtual hard disk, create a configuration file for the domU, and finally start the domU with xm.<br />
<br />
<pre><br />
$ mkfs.ext4 /dev/sdb1 ## format partition<br />
$ mkdir /tmp/install<br />
$ mount /dev/sdb1 /tmp/install<br />
$ mkdir -p /tmp/install/{dev,proc,sys} /tmp/install/var/lib/pacman /tmp/install/var/cache/pacman/pkg<br />
$ mount -o bind /dev /tmp/install/dev<br />
$ mount -t proc none /tmp/install/proc<br />
$ mount -o bind /sys /tmp/install/sys<br />
$ pacman -Sy -r /tmp/install --cachedir /tmp/install/var/cache/pacman/pkg -b /tmp/install/var/lib/pacman base<br />
$ cp -r /etc/pacman* /tmp/install/etc<br />
$ chroot /tmp/install /bin/bash<br />
$ vi /etc/resolv.conf<br />
$ vi /etc/fstab<br />
/dev/xvda / ext4 defaults 0 1<br />
<br />
$ vi /etc/inittab<br />
c1:2345:respawn:/sbin/agetty -8 38400 hvc0 linux<br />
#c1:2345:respawn:/sbin/agetty -8 38400 tty1 linux<br />
#c2:2345:respawn:/sbin/agetty -8 38400 tty2 linux<br />
#c3:2345:respawn:/sbin/agetty -8 38400 tty3 linux<br />
#c4:2345:respawn:/sbin/agetty -8 38400 tty4 linux<br />
#c5:2345:respawn:/sbin/agetty -8 38400 tty5 linux<br />
#c6:2345:respawn:/sbin/agetty -8 38400 tty6 linux<br />
<br />
<br />
$ exit ## exit chroot<br />
$ umount /tmp/install/dev<br />
$ umount /tmp/install/proc<br />
$ umount /tmp/install/sys<br />
$ umount /tmp/install<br />
</pre><br />
If not starting from a fresh install and one wants to rsync from an existing system:<br />
<pre><br />
$ mkfs.ext4 /dev/sdb1 ## format lv partition<br />
$ mkdir /tmp/install<br />
$ mount /dev/sdb1 /tmp/install<br />
$ mkdir /tmp/install/{proc,sys}<br />
$ chmod 555 /tmp/install/proc<br />
$ rsync -avzH --delete --exclude=proc/ --exclude=sys/ old_ooga:/ /tmp/install/<br />
<br />
$ vi /etc/xen/dom01 ## create config file<br />
# -*- mode: python; -*-<br />
kernel = "/boot/vmlinuz26"<br />
ramdisk = "/boot/kernel26.img"<br />
memory = 1024<br />
name = "dom01"<br />
vif = [ 'mac=00:16:3e:00:01:01' ]<br />
disk = [ 'phy:/dev/sdb1,xvda,w' ]<br />
dhcp="dhcp"<br />
hostname = "ooga"<br />
root = "/dev/xvda ro"<br />
<br />
$ xm create -c dom01<br />
</pre><br />
<br />
===Hardware Virtualization===<br />
<br />
If we want to get hardware virtualization in our domUs, the host system hardware must include either Intel-VT or AMD-V virtualization support. In order to verify this, run the following commands on the host system:<br />
<br />
For Intel CPUs:<br />
<pre>grep vmx /proc/cpuinfo</pre><br />
<br />
For AMD CPUSs:<br />
<pre>grep svm /proc/cpuinfo</pre><br />
<br />
If neither of the above commands produce output then it is likely these features are unavailable and that your hardware is unable to run Xen HVM guests. It is also possible that the host CPU supports one of these features, but that the functionality is disabled by default in the system BIOS. To verify this, access the host system’s BIOS configuration menu during the boot process and look for an option related to virtualization support. If such an option exists and is disabled, enable it, boot the system and repeat the above commands.<br />
<br />
==Arch as Xen guest (PV mode)==<br />
<br />
To get paravirtualization you need to install:<br />
* [http://aur.archlinux.org/packages.php?ID=16087 kernel26-xen]<br />
* (optional) [http://aur.archlinux.org/packages.php?ID=28591 xe-guest-utilities]<br />
<br />
Change mode to PV with commands (on dom0):<br />
xe vm-param-set uuid=<vm uuid> HVM-boot-policy=""<br />
xe vm-param-set uuid=<vm uuid> PV-bootloader=pygrub<br />
<br />
Edit /boot/grub/menu.lst and add kernel26-xen:<br />
# (1) Arch Linux (domU)<br />
title Arch Linux (domU)<br />
root (hd0,0)<br />
kernel /boot/vmlinuz26-xen root=/dev/xvda1 ro console=hvc0<br />
initrd /boot/kernel26-xen.img<br />
<br />
Add the following xen modules to your initcpio by appending the following to MODULES in /etc/mkinitcpio.conf: "xen-blkfront xen-fbfront xenfs xen-netfront xen-kbdfront" and rebuild your initcpio:<br />
mkinitcpio -p kernel26-xen<br />
<br />
Uncomment the following line in /etc/inittab to enable console login:<br />
h0:2345:respawn:/sbin/agetty -8 38400 hvc0 linux<br />
<br />
=== xe-guest-utilities ===<br />
To use xe-guest-utilities, add xenfs mount point into /etc/fstab:<br />
xenfs /proc/xen xenfs defaults 0 0<br />
and add xe-linux-distribution into /etc/rc.conf:DAEMONS array.<br />
<br />
===Notes===<br />
* pygrub does not show boot menu. And some version pygrub doesn't support lzma compressed stock kernel. see https://bbs.archlinux.org/viewtopic.php?id=118525<br />
* i686 stock kernel doesn't support xen due to highmem, but x86_64 support. See https://bugs.archlinux.org/task/24207?project=1. But you could still use kernel26-xen as above mentioned and this kernel is compressed by gzip, not lzma or xz<br />
* To avoid hwclock error messages, set HARDWARECLOCK="xen" in /etc/rc.conf (actually you can use any value here except "UTC" and "localtime")<br />
* If you want to return to hardware VM, set HVM-boot-policy="BIOS order"<br />
* If you get a kernel panic when booting Xen and it suggests 'use apic="debug" and send an error report', try setting noapic on the kernel line in menu.lst<br />
<br />
==Xen Management Tools==<br />
The "Virtual Machine Manager" application is a desktop user interface for managing virtual machines. It presents a summary view of running domains, their live performance & resource utilization statistics. The detailed view graphs performance & utilization over time. Wizards enable the creation of new domains, and configuration & adjustment of a domain's resource allocation & virtual hardware. An embedded VNC client viewer presents a full graphical console to the guest domain.<br />
<pre>yaourt -S virt-manager-light</pre><br />
<br />
==Useful Packages==<br />
As there are quite some packages available in AUR and you can have a pretty hard time figuring out what is needed here a small collection of most of the (intersting) xen packages (last updated: 23.5.2010)<br />
<br />
* Open source multiplatform clone of XenCenter frontend: [http://aur.archlinux.org/packages.php?ID=34398 openxencenter]<br />
* Open source multiplatform clone of XenCenter frontend (svn version): [http://aur.archlinux.org/packages.php?ID=36074 openxencenter-svn]<br />
* Xen Cloud Platform frontend: [http://aur.archlinux.org/packages.php?ID=36458 xvp]<br />
<br />
==Resources==<br />
<br />
* Xen's homepage: [http://www.xen.org/]<br />
* The Xen Wiki: [http://wiki.xensource.com/xenwiki/]<br />
* Xen kernel patches: [http://code.google.com/p/gentoo-xen-kernel/]<br />
* Virtuatopia guide to get Windows Server 2008 working with Xen: [http://www.virtuatopia.com/index.php/Virtualizing_Windows_Server_2008_with_Xen]</div>Hongy19https://wiki.archlinux.org/index.php?title=Mobile_broadband_modem&diff=135858Mobile broadband modem2011-04-04T03:35:10Z<p>Hongy19: /* =Baud parameter */</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
A number of mobile telephone networks around the world offer mobile internet connections over UMTS (or EDGE or GSM) using a portable USB modem device.<br />
<br />
==Device identification==<br />
Install usbutils<br />
pacman -S usbutils<br />
and then examine the output of<br />
$ lsusb<br />
which will show the vendor and product IDs of the device. Note that some devices will show ''two'' different product IDs at different times as explained below.<br />
<br />
==Mode switching==<br />
<br />
Often these devices will have two modes (1) USB flash memory storage (2) USB Modem. The first mode, sometimes known as ZeroCD, is often used to deliver an internet communications program for another operating system and is generally of no interest to Linux users. Additionally some have a slot into which the user can insert an additional flash memory card.<br />
<br />
A useful utility for switching these devices into modem mode is [https://www.archlinux.org/packages/?q=usb_modeswitch usb_modeswitch], available in <code>[community]</code>:<br />
<br />
pacman -S usb_modeswitch<br />
<br />
Udev rules are supplied with the package in {{Filename|/lib/udev/rules.d/40-usb_modeswitch.rules}}. This contains entries for many devices, which it will switch to modem mode upon insertion.<br />
<br />
When a device is switched, its product ID may change to a different value. The vendor ID will remain unchanged. This can be seen in the output of <code>lsusb</code>.<br />
<br />
Some devices are supported in the USB serial kernel module called "option" (after the Option devices, but not limited to just those) and may be used without usb_modeswitch.<br />
<br />
Udev itself included a utility called {{Filename|/lib/udev/modem-modeswitch}}. In udev 157 this was renamed to {{Filename|/lib/udev/mobile-action-modeswitch}} and morphed into a tool that only switches Mobile Action cables. For other devices use <code>usb_modeswitch</code>.<br />
<br />
==Connection==<br />
<br />
=== Network Manager ===<br />
<br />
After installing usbutils and usb_modeswitch you just need to install modemmanager to make the modem work with NetworkManager:<br />
# pacman -S modemmanager<br />
After you restart the NetworkManager-applet and plug the modem in again NetworkManager should recognize the modem in the menu without further configuration. Setting up the modem in NetworkManager is self-explanatory, you should only need the login-information provided by your network provider.<br />
<br />
=== wvdial ===<br />
<br />
The general procedure is to switch the device into modem mode, make sure the ttyUSB device(s) are recognized by the usbserial kernel module, and then to run wvdial to dial, connect and start pppd.<br />
<br />
Install wvdial<br />
# pacman -S wvdial<br />
The configuration file /etc/wvdial.conf will in general depend on (a) which device you have (b) which mobile network you are connecting to. A single wvdial.conf file can be defined with named sections to be usable with several USB modems and networks, should you need them.<br />
<br />
Run (as root)<br />
# wvdialconf<br />
which will attempt to write /etc/wvdial.conf correctly. You will need to add the user, password and Access Point Name (APN). You can obtain these (i) from your network provider,<br />
(ii) from other users via published wvdial.confs, or (iii) by logging the USB tty traffic under another operating system (Sysinternals' Portmon).<br />
<br />
A typical /etc/wvdial.conf looks like this:<br />
<br />
<pre><br />
[Dialer Defaults]<br />
Init1 = ATZ<br />
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0<br />
Modem Type = Analog Modem<br />
ISDN = 0<br />
Modem = /dev/ttyUSB2<br />
Baud = 9600<br />
<br />
[Dialer thenet]<br />
Phone = *99***1#<br />
Username = thenetuser<br />
Password = thenetpw<br />
Stupid Mode = 1<br />
Baud = 460800<br />
Init3 = AT+CGDCONT=1,"IP","apn.thenet.net"<br />
<br />
[Dialer mypin]<br />
Init4 = AT+CPIN=1234<br />
</pre><br />
<br />
Often there will be several devices (at /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2 for example). If in doubt about which to use, try each of them in turn or use /dev/gsmmodem (a link set up by usb_modeswitch) which should point to the correct one. Once the configuration files are prepared, the internet connection is established by running<br />
<br />
$ wvdial <section><br />
<br />
If necessary additional setup commands can be placed simple script like this:<br />
<br />
usbmodeswitch<br />
sleep 2<br />
modprobe usbserial vendor=0xVVVV product=0xMMMM maxSize=4096<br />
sleep 2<br />
wvdial thenet<br />
<br />
where VVVV is the hexadecimal vendor ID from lsusb, and MMMM is the hexadecimal product ID ''when in modem mode'', and "thenet" is the name of the section in wvdial.conf which you wish to use. The maxSize option may or may not be necessary. It simplifies matters if you disable the SIM PIN, but if you require it, run "wvdial mypin" before "wvdial thenet".<br />
<br />
The final wvdial command should start pppd and the obained IP address should be visible in the terminal output. At that point the internet connection should be live, which can be easily checked with a web browser or by pinging an external IP address.<br />
<br />
=== Low connection speed ===<br />
Someone claims that the connection speed under linux is lower than Windows.<br />
https://bbs.archlinux.org/viewtopic.php?id=111513<br />
<br />
A short summary for possible solutions which are not fully verified.<br />
In most of conditions, the low speed is caused by bad receiver signals and too many people in cell. But you still could use the following method to try to improve the connection speed.<br />
====QoS parameter====<br />
AT+CGEQMIN and AT+CGEQREQ command could used to set the Qos command. And also it should be possible to used to decrease and limit the connect speed.<br />
Add the following Init command in wvdial.conf.<br />
Init6 = AT+CGEQMIN=1,4,64,640,64,640<br />
Init7 = AT+CGEQREQ=1,4,64,640,64,640<br />
====Baud parameter====<br />
Baud parameter in wvdial.conf could used to increase the connection speed.<br />
Baud = 460800<br />
But the official Huawei E261 windows application set the Baud=9600 under Windows Vista.<br />
More verifications are needed to double check this point.<br />
<br />
==Related Articles==<br />
[[Huawei E220]]<br><br />
[[Allow users to dial with wvdial]]<br><br />
[[Idea_netsetter(Huawei_EG162G)]]<br><br />
[[ZTE MF636]]<br><br />
[[Internet key Momo Design]]<br><br />
[[Dialup_without_a_dialer_HOWTO]]<br><br />
[[3G and GPRS modems with pppd alone]]<br><br />
[[Huawei E1550 3G modem]]</div>Hongy19https://wiki.archlinux.org/index.php?title=Mobile_broadband_modem&diff=135857Mobile broadband modem2011-04-04T03:34:46Z<p>Hongy19: low speed improvement</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
A number of mobile telephone networks around the world offer mobile internet connections over UMTS (or EDGE or GSM) using a portable USB modem device.<br />
<br />
==Device identification==<br />
Install usbutils<br />
pacman -S usbutils<br />
and then examine the output of<br />
$ lsusb<br />
which will show the vendor and product IDs of the device. Note that some devices will show ''two'' different product IDs at different times as explained below.<br />
<br />
==Mode switching==<br />
<br />
Often these devices will have two modes (1) USB flash memory storage (2) USB Modem. The first mode, sometimes known as ZeroCD, is often used to deliver an internet communications program for another operating system and is generally of no interest to Linux users. Additionally some have a slot into which the user can insert an additional flash memory card.<br />
<br />
A useful utility for switching these devices into modem mode is [https://www.archlinux.org/packages/?q=usb_modeswitch usb_modeswitch], available in <code>[community]</code>:<br />
<br />
pacman -S usb_modeswitch<br />
<br />
Udev rules are supplied with the package in {{Filename|/lib/udev/rules.d/40-usb_modeswitch.rules}}. This contains entries for many devices, which it will switch to modem mode upon insertion.<br />
<br />
When a device is switched, its product ID may change to a different value. The vendor ID will remain unchanged. This can be seen in the output of <code>lsusb</code>.<br />
<br />
Some devices are supported in the USB serial kernel module called "option" (after the Option devices, but not limited to just those) and may be used without usb_modeswitch.<br />
<br />
Udev itself included a utility called {{Filename|/lib/udev/modem-modeswitch}}. In udev 157 this was renamed to {{Filename|/lib/udev/mobile-action-modeswitch}} and morphed into a tool that only switches Mobile Action cables. For other devices use <code>usb_modeswitch</code>.<br />
<br />
==Connection==<br />
<br />
=== Network Manager ===<br />
<br />
After installing usbutils and usb_modeswitch you just need to install modemmanager to make the modem work with NetworkManager:<br />
# pacman -S modemmanager<br />
After you restart the NetworkManager-applet and plug the modem in again NetworkManager should recognize the modem in the menu without further configuration. Setting up the modem in NetworkManager is self-explanatory, you should only need the login-information provided by your network provider.<br />
<br />
=== wvdial ===<br />
<br />
The general procedure is to switch the device into modem mode, make sure the ttyUSB device(s) are recognized by the usbserial kernel module, and then to run wvdial to dial, connect and start pppd.<br />
<br />
Install wvdial<br />
# pacman -S wvdial<br />
The configuration file /etc/wvdial.conf will in general depend on (a) which device you have (b) which mobile network you are connecting to. A single wvdial.conf file can be defined with named sections to be usable with several USB modems and networks, should you need them.<br />
<br />
Run (as root)<br />
# wvdialconf<br />
which will attempt to write /etc/wvdial.conf correctly. You will need to add the user, password and Access Point Name (APN). You can obtain these (i) from your network provider,<br />
(ii) from other users via published wvdial.confs, or (iii) by logging the USB tty traffic under another operating system (Sysinternals' Portmon).<br />
<br />
A typical /etc/wvdial.conf looks like this:<br />
<br />
<pre><br />
[Dialer Defaults]<br />
Init1 = ATZ<br />
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0<br />
Modem Type = Analog Modem<br />
ISDN = 0<br />
Modem = /dev/ttyUSB2<br />
Baud = 9600<br />
<br />
[Dialer thenet]<br />
Phone = *99***1#<br />
Username = thenetuser<br />
Password = thenetpw<br />
Stupid Mode = 1<br />
Baud = 460800<br />
Init3 = AT+CGDCONT=1,"IP","apn.thenet.net"<br />
<br />
[Dialer mypin]<br />
Init4 = AT+CPIN=1234<br />
</pre><br />
<br />
Often there will be several devices (at /dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2 for example). If in doubt about which to use, try each of them in turn or use /dev/gsmmodem (a link set up by usb_modeswitch) which should point to the correct one. Once the configuration files are prepared, the internet connection is established by running<br />
<br />
$ wvdial <section><br />
<br />
If necessary additional setup commands can be placed simple script like this:<br />
<br />
usbmodeswitch<br />
sleep 2<br />
modprobe usbserial vendor=0xVVVV product=0xMMMM maxSize=4096<br />
sleep 2<br />
wvdial thenet<br />
<br />
where VVVV is the hexadecimal vendor ID from lsusb, and MMMM is the hexadecimal product ID ''when in modem mode'', and "thenet" is the name of the section in wvdial.conf which you wish to use. The maxSize option may or may not be necessary. It simplifies matters if you disable the SIM PIN, but if you require it, run "wvdial mypin" before "wvdial thenet".<br />
<br />
The final wvdial command should start pppd and the obained IP address should be visible in the terminal output. At that point the internet connection should be live, which can be easily checked with a web browser or by pinging an external IP address.<br />
<br />
=== Low connection speed ===<br />
Someone claims that the connection speed under linux is lower than Windows.<br />
https://bbs.archlinux.org/viewtopic.php?id=111513<br />
<br />
A short summary for possible solutions which are not fully verified.<br />
In most of conditions, the low speed is caused by bad receiver signals and too many people in cell. But you still could use the following method to try to improve the connection speed.<br />
====QoS parameter====<br />
AT+CGEQMIN and AT+CGEQREQ command could used to set the Qos command. And also it should be possible to used to decrease and limit the connect speed.<br />
Add the following Init command in wvdial.conf.<br />
Init6 = AT+CGEQMIN=1,4,64,640,64,640<br />
Init7 = AT+CGEQREQ=1,4,64,640,64,640<br />
=====Baud parameter====<br />
Baud parameter in wvdial.conf could used to increase the connection speed.<br />
Baud = 460800<br />
But the official Huawei E261 windows application set the Baud=9600 under Windows Vista.<br />
More verifications are needed to double check this point.<br />
<br />
==Related Articles==<br />
[[Huawei E220]]<br><br />
[[Allow users to dial with wvdial]]<br><br />
[[Idea_netsetter(Huawei_EG162G)]]<br><br />
[[ZTE MF636]]<br><br />
[[Internet key Momo Design]]<br><br />
[[Dialup_without_a_dialer_HOWTO]]<br><br />
[[3G and GPRS modems with pppd alone]]<br><br />
[[Huawei E1550 3G modem]]</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=19643Localization (简体中文)/Simplified Chinese (简体中文)2007-01-20T01:55:14Z<p>Hongy19: /* xine */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以参考<br />
http://forum.ubuntu.org.cn/about2760.html<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merrian Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=19642Localization (简体中文)/Simplified Chinese (简体中文)2007-01-20T01:50:38Z<p>Hongy19: /* '''MP3文件在播放器中乱码''' */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以询问google。<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merrian Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=19641Localization (简体中文)/Simplified Chinese (简体中文)2007-01-20T01:49:47Z<p>Hongy19: /* '''MP3文件在播放器中乱码''' */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以询问google。<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
解决方法:<br />
对于所有用gstreamer做后端的播放器,如Rhythmbox,totem,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merrian Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=19640Localization (简体中文)/Simplified Chinese (简体中文)2007-01-20T01:47:56Z<p>Hongy19: /* '''MP3文件在播放器中乱码''' */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
参考网点:<br />
*http://wiki.debian.org.hk/w/Where_can_I_find_fonts_for_GNU/Linux<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
*正体中文 codepage 为 cp950。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以询问google。<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
解决方法:<br />
对于Rhythmbox,设置如下的环境变量后正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
*'''小贴士:'''适用于所有用gstreamer做后端的播放器。<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
Quod Libet播放器支持tag编辑及设置id3v2编码。可以在~/.quodlibet/config中设置<br />
id3encoding = gbk<br />
注意:Quod Libet默认支持utf8编码<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
*正体中文包 openoffice-zh_tw。<br />
*开启 amd_64 的 openoffice 时可能发生异常,此时可安装 libsndfile 进行修正。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merrian Webster 10th dictionary<br />
*牛津现代英汉双解辞典(正体中文)<br />
*朗道英汉词典(正体中文)</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=18974Localization (简体中文)/Simplified Chinese (简体中文)2006-12-09T09:32:01Z<p>Hongy19: /* '''MP3文件在播放器中乱码''' */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以询问google。<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
解决方法:<br />
对于Rhythmbox,设置如下的环境变量后正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
*'''小贴士:'''适用于所有用gstreamer做后端的播放器。<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
最为彻底的解决方法为将编码为gbk的id3 tag转化为utf8编码。首先安装mutagen,然后利用下面的命令转化:<br />
mid3iconv -e gbk test.mp3<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merrian Webster 10th dictionary</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=12537Localization (简体中文)/Simplified Chinese (简体中文)2006-05-01T12:09:58Z<p>Hongy19: /* locale的设定 */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
*.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
*.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
*.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以询问google。<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
解决方法:<br />
对于Rhythmbox,设置如下的环境变量后正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
*'''小贴士:'''适用于所有用gstreamer做后端的播放器。<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merrian Webster 10th dictionary</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=12536Localization (简体中文)/Simplified Chinese (简体中文)2006-05-01T12:09:04Z<p>Hongy19: /* 如何使用字典 */</p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以询问google。<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
解决方法:<br />
对于Rhythmbox,设置如下的环境变量后正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
*'''小贴士:'''适用于所有用gstreamer做后端的播放器。<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
*xdict英汉字典 <br />
*Merrian Webster 10th dictionary</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=12535Localization (简体中文)/Simplified Chinese (简体中文)2006-05-01T12:08:24Z<p>Hongy19: </p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以询问google。<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
解决方法:<br />
对于Rhythmbox,设置如下的环境变量后正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
*'''小贴士:'''适用于所有用gstreamer做后端的播放器。<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版<br />
<br />
==如何使用字典==<br />
首先请先安装stardict<br />
pacman -S stardict<br />
stardict默认是不带字典的,需要去http://stardict.sourceforge.net/ 下载字典安装。安装方法如下<br />
tar -xjvf testdict.tar.bz2<br />
mv testdict /usr/share/stardict/dic<br />
推荐使用<br />
xdict英汉字典<br />
Merrian Webster 10th dictionary</div>Hongy19https://wiki.archlinux.org/index.php?title=GNOME_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=12382GNOME (简体中文)2006-04-27T13:49:20Z<p>Hongy19: /* 其它提示和小技巧 */</p>
<hr />
<div>[[Category:Desktop (简体中文)]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Gnome}}<br />
{{i18n_entry|简体中文|GNOME (简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
==什么是 GNOME?==<br />
<br />
[http://www.gnome.org/ GNOME] 项目为您提供两个东西:GNOME桌面环境,为用户提供易用且有吸引力的桌面;和GNOME开发平台,用于开发应用程序的多功能开发环境,由此开发的程序可集成于GNOME桌面中。<br />
<br />
==如何安装 GNOME 桌面 ==<br />
<br />
您可以键入以下命令,安装 GNOME 基本桌面:<br />
pacman -S gnome<br />
<br />
键入下面命令安装 GNOME 桌面的余下部分(强烈推荐):<br />
pacman -S gnome-extra<br />
<br />
在系统启动时要起用合适的进程,需要修改/etc/rc.conf,在DAEMONZS=()这一行里,加入“portmap”,“fam”,“dbus”和“hal”。<br />
<br />
==运行 GNOME 桌面==<br />
<br />
要从命令行环境启动 GNOME,可运行:<br />
gnome-session<br />
<br />
如果您在$HOME/.xinitrc中加入这一行:(必须保证该文件中只此一行以“exec”打头)<br />
exec gnome-session<br />
<br />
GNOME 将会由此命令启动。<br />
startx<br />
<br />
<br />
==GDM (GNOME Display Manager, GNMOE 显示管理器)==<br />
<br />
您需要安装 [http://yippi.hypermall.com/gdm/index.shtml GDM] 来使用图形登录界面。要安装GDM,您需要在命令行环境下发出下面命令:<br />
pacman -S gdm<br />
<br />
修改 /etc/inittab ,以使系统默认采用图形登录方式:<br />
<br />
#修改此行 (若没有,就加上它)<br><pre>id:3:initdefault:</pre>to<br><pre>id:5:initdefault:</pre><br />
#修改此行 (若没有,就加上它)<br><pre>x:5:respawn:/usr/X11R6/bin/xdm -nodaemon</pre>to<br><pre>x:5:respawn:/opt/gnome/sbin/gdm -nodaemon</pre><br />
<br />
如果您习惯使用 '''$HOME/.xinitrc''','''xmodmap''' 或是 '''xsetroot''' 这些文件来配置启动X,您就应该把这些文件中的配置用的命令放入 '''$HOME/.xprofile'''里。我的 .xprofile 文件是这样的:<br />
<br />
<pre><br />
#!/bin/sh<br />
<br />
#<br />
# ~/.xprofile<br />
#<br />
# Executed by gdm at login<br />
#<br />
<br />
xmodmap -e "pointer = 1 2 3 6 7 4 5" #set mouse buttons up correctly<br />
xsetroot -solid black #sets the background to black<br />
</pre><br />
<br />
要了解更多关于图形登录的信息,请参阅 [http://endor.clublinux.org/RHCE-21.html 这个很棒的网页]。<br />
<br />
==其它提示和小技巧==<br />
===在登录 GNOME 时,打开数字键盘锁===<br />
#安装 numlockx<br><pre>pacman -Sy numlockx</pre><br />
#在登录时启动 numlockx<br />
##选择 Desktop -> Preferences -> Sessions<br />
##选择“启动程序”标签栏 (如果您发现没有“启动程序”这个栏,请直接修改本文)<br />
##点击“添加”按钮<br />
##在启动命令选择框里,加入 /usr/bin/numlockx<br />
##把次序设为 55<br />
<br />
===获得 桌面->屏幕锁定 功能===<br />
#进入 桌面->参数设置->屏幕锁定<br />
#开启一个或多个屏幕保护程序<br />
#现在点击屏幕锁定,将会启动屏幕保护程序,并提示要求输入密码。<br />
<br />
===Nautilus===<br />
打开地址栏<br />
control + L<br />
<br />
====browser mode====<br />
不喜欢Nautilus默认的spatial模式? 那么打开gconf-editor,编辑apps/nautilus/preferences,将always_use_browser的值改为“true”。<br />
<br />
==一些关于 GNOME 链接==<br />
===Arch Wiki 链接===<br />
* [[Gnome Menu tweaking]]<br />
<br />
===外部链接===<br />
* 官方文档: http://www.gnome.org/learn/<br />
* 关于风格,图标和前景等:http://www.gnome-look.org/ or http://art.gnome.org/<br />
* 关于GTK程序和一些风格等:http://www.gnomefiles.org/</div>Hongy19https://wiki.archlinux.org/index.php?title=Localization_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)/Simplified_Chinese_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=12248Localization (简体中文)/Simplified Chinese (简体中文)2006-04-25T14:18:26Z<p>Hongy19: </p>
<hr />
<div>[[Category:General (简体中文)]]<br />
<br />
请再仔细看看Arch的哲学"[[Arch之道]]":<br />
这意味着我们不会为你配置好一切,因为“喜好和需求,每人皆不同”,但是我们会尽量确保让你自行配置时,方便和简单。事实上,甚至远比你使用一些可能的Linux中文版本容易。<br />
<br />
第一次使用ArchLinux时,用户通常会遇上这些(典型)的问题:<br />
<br />
== '''怎么显示中文的界面?''' ==<br />
要正确实现中文,必需设置正确的locale和安装合适的中文字体。<br />
<br />
===locale的设定===<br />
Linux中通过locale来设置程序运行的不同环境。一般常用的中文locale有:<br />
zh_CN.GBK<br />
zh_CN.GB2312<br />
zh_CN.UTF-8<br />
推荐使用UTF8的locale。需要注意的是,对于glibc(>=2.3.6),需要修改/etc/locale.gen文件来设定系统中可以使用的locale<br />
en_US.UTF8 UTF-8<br />
zh_CN.UTF8 UTF-8<br />
zh_CN.GBK GBK<br />
zh_CN.GB2312 GB2312<br />
zh_CN.GB18030 GB18030<br />
然后执行locale-gen命令,这样便可以在系统中使用zh_CN.UTF8,zh_CN.GBK,zh_CN.GB2312,zh_CN.GB18030,en_US.UTF8等locale。可以通过locale命令来查看当前使用的locale<br />
locale<br />
可以通过locale命令来查看目前可以使用的locale<br />
locale -a<br />
<br />
Archlinux中,通过rc.conf文件可以设置全局有效的locale:<br />
LOCALE=en_US.UTF-8<br />
<br />
对于个人用户,还可以在.bashrc或.xprofile中设置自己的用户环境,不同之处在于:<br />
.bashrc: 每次'''终端登录时'''读取并运用里面的设置。<br />
.xinitrc: 每次'''startx启动X界面时'''读取并运用里面的设置<br />
.xprofile: 每次'''使用gdm等图形登录时'''读取并运用里面的设置<br />
<br />
在终端(文字)界面下也可以显示和输入中文,但需要安装cce和zhcon。<br />
更多的locale信息可以参见:<br />
<br />
===安装中文字体===<br />
除了设置好locale,你还需要安装中文字体:<br />
pacman -S ttf-arphic-uming<br />
<br />
常用的免费(GPL或兼容版权)中文字体有<br />
ttf-arphic-ukai<br />
ttf-arphic-uming<br />
ttf-fireflysung<br />
另外文泉驿的中文点阵字体也非常不错,你可以从http://www.linuxsir.org 上的Archlinux版上下载文泉驿点阵字体的PKGBUILD来自行安装。<br />
<br />
系统字体将默认安装到/usr/share/fonts,如果你没有root权限或者只打算自己使用某些字体,你可以直接复制这些字体到.fonts(或者其他)目录下面,并把该路径加入/etc/fonts/local.conf中,参见后面章节。<br />
<br />
已知问题:<br />
*官方软件库中没有文泉驿字体包,你需要自己下载。<br />
*ttf-fireflysung错误的依赖了xorg-clients-utils而不是xorg-fonts-utiles,参见bug报告:<br />
<br />
==fontconfig设置==<br />
安装好字体以后,你可能对中文自己的显示不太满意。这时需要对fontconfig做某些设置。你可以在~/.font.config中设定,也可以在/etc/fonts/conf.d中设定。<br />
<br />
===重排字型的显示顺序===<br />
Serifs字型<br />
<alias><br />
<family>serif</family><br />
<prefer><br />
<family>Bitstream Vera Serif</family><br />
<family>Times New Roman</family><br />
<family>Nimbus Roman No9 L</family><br />
<family>Luxi Serif</family><br />
<family>Times</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
Sans字型<br />
<alias><br />
<family>sans-serif</family><br />
<prefer><br />
<family>Bitstream Vera Sans</family><br />
<family>Verdana</family><br />
<family>Arial</family><br />
<family>Tahoma</family><br />
<family>WenQuanYi Bitmap Song</family> <br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Helvetica</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Gothic</family><br />
<family>Baekmuk Dotum</family><br />
</prefer><br />
</alias><br />
Mononspace字型 <br />
<alias><br />
<family>monospace</family><br />
<prefer><br />
<family>Bitstream Vera Sans Mono</family><br />
<family>Courier</family><br />
<family>Courier New</family><br />
<family>Andale Mono</family><br />
<family>Luxi Mono</family><br />
<family>Nimbus Mono L</family><br />
<family>WenQuanYi Bitmap Song</family><br />
<family>AR PL ShanHeiSun Uni</family><br />
<family>AR PL New Sung</family><br />
<family>AR PL ZenKai Uni</family><br />
<family>Ming(ISO10646)</family><br />
<family>Kochi Mincho</family><br />
<family>Baekmuk Batung</family><br />
</prefer><br />
</alias><br />
<br />
===关闭小号字体的AA(反锯齿)===<br />
对于比较小的字体,闭小号字体的反锯齿,会更加清晰。<br />
<match target="font" ><br />
<test compare="eq" name="family" qual="any" ><br />
<string>AR PL New Sung</string><br />
<string>AR PL ShanHeiSun Uni</string><br />
<string>AR PL ZenKai Uni</string><br />
<string>AR PL Mingti2L Big5</string><br />
<string>AR PL SungtiL Big5</string><br />
<string>MingLiu</string><br />
<string>PMingLiu</string><br />
</test><br />
<test compare="more_eq" name="pixelsize" ><br />
<double>8</double><br />
</test><br />
<test compare="less_eq" name="pixelsize" ><br />
<double>15</double><br />
</test><br />
<edit name="antialias" ><br />
<bool>false</bool><br />
</edit><br />
<edit name="hinting" ><br />
<bool>true</bool><br />
</edit><br />
</match><br />
<br />
'''Tips:'''可以到这里得到更详细的[[字体设置]]文档和完整的[[中文字体配置范例]]<br />
<br />
'''参考文档'''<br />
*Fontconfig用户手册 http://www.chinalinuxpub.com/read.php?wid=634<br />
*令Debian支援中文 http://wiki.linux.org.hk/w/Make_Debian_support_Chinese<br />
*http://www.higherorder.org/wiki/Fontconfig<br />
<br />
== '''怎么输入中文?''' ==<br />
安装相应的输入法scim或者fcitx。推荐使用scim:<br />
pacman -S scim-pinyin<br />
简体中文的用户推荐:<br />
scim-pinyin 智能拼音<br />
scim-tables 五笔<br />
繁体中文的用户推荐:<br />
scim-chewing<br />
<br />
要使用scim,还应该设置以下的环境变量(以scim为例),(可在xinitrc, .bashrc或.xprofile中设置)<br />
export XIM="SCIM"<br />
export XMODIFIERS=@im=SCIM #设置scim为xim默认输入法<br />
export GTK_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export QT_IM_MODULE=scim #设置scim为gtk程序默认的输入法<br />
export XIM_PROGRAM="scim -d" #使可以自动启动<br />
<br />
已知问题:<br />
*由于SCIM的ABI兼容性问题,目前可能会造成一些软件拒绝运行,这些软件包括但不限于:Acrobat Reader, openoffice,直接从mozilla.org下载的firefox, thunderbird,以及realplay。权宜之计: 在程序的启动文件头输入:<br />
*目前scim在QT程序中还不能做到光标跟随<br />
<br />
'''Tip''':为什么推荐使用SCIM?<br />
*因为到目前为止,SCIM是惟一的“傻瓜式”输入法(感谢作者付出的很多努力,最终让我们打包和维护相当的轻松,而且对于用户来说,也基本不需要什么设置)。<br />
<br />
== '''中文显示很模糊(淡),或没有中文粗体?''' ==<br />
在正常情况下,gnome本身已经转由cairo+pango来渲染字体,不存在这个问题了,但是你很可能在浏览一些网页时,还会发生这些问题。<br />
<br />
没有中文粗体解决方法:<br />
<br />
把下面的配置加入/etc/fonts/local.conf<br />
<pre><br />
<!--<br />
Synthetic emboldening for fonts that do not have bold face available<br />
--><br />
<br />
<match target="font"><br />
<!-- check to see if the font is just regular --><br />
<test name="weight" compare="less_eq"><br />
<const>medium</const><br />
</test><br />
<!-- check to see if the pattern requests bold --><br />
<test target="pattern" name="weight" compare="more"><br />
<const>medium</const><br />
</test><br />
<!--<br />
set the embolden flag<br />
needed for applications using cairo, e.g. gucharmap, gedit, ...<br />
--><br />
<edit name="embolden" mode="assign"><br />
<bool>true</bool><br />
</edit><br />
<!--<br />
set weight to bold<br />
needed for applications using Xft directly, e.g. Firefox, ...<br />
--><br />
<edit name="weight" mode="assign"><br />
<const>bold</const><br />
</edit><br />
</match><br />
</pre><br />
<br />
或者使用了下面的local.conf文件替换系统默认的local.conf文件。<br />
cp local.conf /etc/fonts/ <br />
或者,自行编译fontconfig2.3.92以上的版本,并打开local.conf中的autohint<br />
<br />
KDE环境:对不起,我不知道,我已经超过1年多没有用KDE了。欢迎各位的补充<br />
其他环境:见上。<br />
<br />
*官方新版本的mozila firefox(大于1.5.0.1)已经使用cairo+pango,但是在某些网站时会相当的慢。<br />
<br />
== '''如何显示影片的中文字幕?''' ==<br />
===mplayer===<br />
修改~/.mplayer/config<br />
font=/usr/share/fonts/TTF/uming.ttf<br />
subcp=cp936<br />
<br />
可以使用下面的命令手动加载字幕<br />
mplayer xxx.avi -sub xxxxx.srt<br />
同时,你还可以设置mplayer自动加载字幕。如果你无法在gmplayer的选项中找到这个选项(天知道你会有这样粗心),直接修改~/.mplayer/gui.conf如下:<br />
sub_auto_load = "yes"<br />
sub_unicode = "yes"<br />
sub_pos = "100"<br />
sub_overlap = "no"<br />
sub_cp = "cp936"<br />
font_factor = "0.750000"<br />
font_encoding = "unicode"<br />
<br />
*mplayer cvs(2005.12以后)已经使用了gtk2的界面,但是很遗憾的是并没有完全利用gtk2良好的国际支持,甚至没有使用gtk.filechooser。<br />
<br />
===xine===<br />
xine也可以显示中文字幕,但需要制作自己的中文字体。具体可以询问google。<br />
<br />
===gstreamer===<br />
在totem 1.4.0,由于使用gstreamer0.10,应该是可以自动加载同名的srt字幕。<br />
<br />
== '''MP3文件在播放器中乱码''' ==<br />
解决方法:<br />
对于Rhythmbox,设置如下的环境变量后正确读取mp3中GBK编码的id3 tag。<br />
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030<br />
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030<br />
*'''小贴士:'''适用于所有用gstreamer做后端的播放器。<br />
<br />
对于Beep media player,可以在pefenrence->plugins->media中选中MPEG Audio plugin然后点击下方的Penfenrences,此时会出现一个对话框,选择title,将Disable ID3v2和Convert non-UTF8 ID3 tags to UTF8前的选择框选中。然后在ID3 encoding中填入 gbk。这样bmp就能正确显示GBK编码的ID3 tag。<br />
<br />
== '''windows分区下的中文文件是乱码?''' ==<br />
如果使用了hal,应该是没有问题了,但是如果没有,请不妨试一下:<br />
在/etc/rc.conf中的daemon一段中添加hal。<br />
<br />
或者直接修改/etc/fstab,'''注意危险''',你如果不懂,就不要学我:-)。如果locale是utf8,挂载windows分区时应该做如下设置<br />
/dev/hdc5 / reiserfs defaults iocharset=utf8 0 0<br />
<br />
如果locale是GBK,则应该是<br />
iocharset=cp936 <br />
<br />
已知问题:<br />
<br />
=='''ftp乱码'''==<br />
很多ftp站点是GBK编码,如果使用UTF8的locale,下载的文件名可能会乱码。对于lftp,在.lftp/rc下做如下设置<br />
set ftp:charset "gbk"<br />
set file:charset "UTF-8"<br />
对于gftp,可以在.gftp/gftprc中做如下设置即可正确显示服务器端gbk编码的文件名<br />
remote_charsets=gb2312<br />
但下载下来的文件名仍然是乱码,此时需要打补丁。补丁地址为:<br />
http://www.teatime.com.tw/%7Etommy/linux/gftp_remote_charsets.patch<br />
<br />
==JAVA界面乱码==<br />
对于java 1.5来说,只要在<br />
/opt/java/jre/lib/fonts<br />
中建立fallback目录,然后链接或拷贝若干中文字体到该目录就能使java程序正确显示中文<br />
<br />
== '''Doc文件无法打开或显示不正常?''' ==<br />
安装openoffice。<br />
pacman -S openoffice-zh_cn<br />
*如果你打算使用英文版的openoffice,你只需要安装openoffice-base包。<br />
<br />
已知问题:官方库中的openoffice<br />
<br />
=='''正确显示中文PDF文件'''==<br />
<br />
=== Evince===<br />
<br />
pacman -S evince xpdf-chinese-simplified<br />
<br />
===xpdf===<br />
<br />
pacman -S xpdf-chinese-simplified<br />
<br />
===kpdf===<br />
<br />
===arcobat===<br />
<br />
'''Tips:''' Evince,Xpdf,Kpdf都能正确显示大部分中文PDF文件,但是一些没有内嵌中文字体的PDF文件需要CMap文件, 文本编码, 和其他各种配置信息等才能正确显示。这些附加信息包含在xpdf-chinese-simplified中,xpdf-chinese-simplified可以不依赖Xpdf而独立安装,但是Arch 中<br />
xpdf-chinese-simplified依赖于Xpdf这个包,这个依赖性的处理不太合理,用户可以自行修改。或者给包维护者[http://bugs.archlinux.org/ 提交解决方法]<br />
<br />
==vim乱码==<br />
如果locale是utf8编码,用vim显示gbk编码的文件可能会乱码。因此需要在.vimrc做如下设置<br />
"Chinese GBK support<br />
set fileencodings=utf8,gbk<br />
<br />
==Latex中如何使用中文==<br />
首先需要安装CJK包,然后需要安装合适的字体。具体可以参考<br />
*http://www.ctex.org<br />
*http://www.newsmth.net 的Tex版</div>Hongy19