https://wiki.archlinux.org/api.php?action=feedcontributions&user=Doze+worm&feedformat=atomArchWiki - User contributions [en]2024-03-28T12:37:59ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=VCS_package_guidelines_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=63013VCS package guidelines (简体中文)2009-02-25T09:05:34Z<p>Doze worm: /* 一些小提示 */</p>
<hr />
<div>{{i18n_links_start}}<br />
{{i18n_entry|English|Arch CVS %26 SVN PKGBUILD guidelines}}<br />
{{i18n_entry|正體中文|Arch CVS %26 SVN PKGBUILD 編寫指南}}<br />
{{i18n_entry|简体中文|Arch CVS %26 SVN %26 GIT PKGBUILD 编写指南}}<br />
{{i18n_links_end}}<br />
<br />
[[Category:简体中文]]<br />
<br />
==用 makepkg 打包 CVS, SVN & GIT 文件==<br />
<br />
事实上,这个工作非常简单,您不需要什么特殊的知识。当然,您对CVS和SVN的知识懂得越多越好。很多人在 PKGBUILD 文件里面引入了不必要(译注:这个词是译者加的,在尽量不影响理解的前提下,译者可能会不自觉的使用自己的语言,后面不再声明)的自定义变量,这样会使工作变得复杂。这些看起来很复杂的语句并不是''必须的'',但是对于使语法结构清洗,是很有帮助的。<br />
<br />
===一些小提示===<br />
<br />
* 在可行的情况下,请给 <code>pkgname</code> 加上 <code>-cvs</code> 或者 <code>-svn</code> 或者 <code>-git</code> 这样的后缀 - 这样可以防止和非devel版本的包名混淆,比如 fluxbox-svn , fvwm-cvs 对 fluxbox , fvwm.<br />
* 您还必须小心处理 pacman 的冲突(依赖关系冲突)。比如 fluxbox-svn will 与 fluxbox 冲突。这样您就需要使用 <tt>conflicts=</tt> 字段(field)<br />
conflicts=('fluxbox')<br />
: 您还应该使用 <tt>provides=</tt> 字段,以便让需要 fluxbox (作者这里用fluxbox来举例)的包知道 fluxbox-svn 就是 fluxbox<br />
provides=('fluxbox')<br />
: 您最好不要使用(your should avoid using) <tt>replaces=</tt> ,它可能会产生不必要的麻烦<br />
*When using/defining the cvsroot use anonymous<b>:</b>@ rather than anonymous@ to avoid having to press enter to give blank password ''OR'' anonymous<b>:password</b>@ - if a password is required.<br />
* cvs and svn PKGBUILDs may not require a source or md5sum array but these fields '''must''' be included in the PKGBUILD if you wish to submit it to the AUR, otherwise the pkg will be rejected. They may be left blank though.<br />
<pre>source=()<br />
md5sums=()</pre><br />
* 使用 CVS/SVN/GIT 的时候,我们极少用到 pkgrel 字段,因为源文件时有改动,所以我们通常用 pkgver 来标记改动(假定我们用 pkgver 来保存日期)(英文原文:It is rarely necessary to use the pkgrel field when building CVS/SVN/GIT pkgs - any changes to the pkg will often be on another day and so are usually accounted for by a change in pkgver (assuming pkgver is used to hold a date format),英语不到家,有人会翻译的mail:fluke at sfcube.net)<br />
* 不要忘记把 svn 或者 cvs 包含在 <code>makedepends=</code> 里面,如果必须的话(译注:如果你要从 svn 来 checkout 源码包,自然要要保证你有 svn 客户端)<br />
* 为了保证 check out(译注:cvs和svn的术语,就不翻译了) 下来的 code 的完整性,我们建立一个独立的 build 目录,比如你已经在 $startdir 把代码 ckeck out 到了 src/$_cvsmod 目录你可以:<br />
<pre> mkdir src/$_cvsmod-build<br />
<br />
cd src/$_cvsmod-build<br />
../$_cvsmod/configure</pre><br />
''万一'' 这种方法失败了,你可以尝试:<br />
<pre> cp -r src/$_cvsmod src/$_cvsmod-build<br />
cd src/$_cvsmod-build</pre><br />
<br />
* AUR的介绍中说最重要的是不要使用 backtick 扩展去创建 pkg 变量(With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables)<br />
** 对于 cvs 包 您应该避免 <code>pkgver=`date +%y%m%d`</code> - (译注:this also inteferes with the functionality of the AUR.,这句话不好翻译,我不知道inteferes什么意思) 作为替代的方案,还可以用日期格式的 $pkgver 变量,并且使用 cvs -D 去获取从那个日期起的代码 (看下面)<br />
** 对于 svn 您可以使用修正号(revision number)。下面是一种简易的获取修正号的方法:<br />
svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g<br />
这条命令从 svn repo (译注:就是 svn 的源)最近额记录里面取得修正号--修正号的前面带有''r''字母。下面的来自于 fluxbox 的 svn 记录,修正号就在左上角,r4084。<br />
<pre><br />
------------------------------------------------------------------------<br />
r4084 | mathias | 2005-07-20 19:29:01 +0100 (Wed, 20 Jul 2005) | 16 lines<br />
<br />
Changed some *Focus options, just to make some things a bit more clear.<br />
the "Sloppy" was always a bit .. unprecise.<br />
</pre><br />
<br />
===CVS PKGBUILD 样例===<br />
<br />
这里用一个 bmp-cvs 的 PKGBUILD 来说明上面的一些技巧(一些小提示)<br />
<br />
<pre># Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
pkgname=bmp-cvs<br />
pkgver=20050728<br />
pkgrel=1<br />
pkgdesc="BeepMP is a multimedia player that uses the WinAmp 2.x UI, GTK2, and is based on XMMS. This will checkout and package the latest CVS version."<br />
url="http://beepmp.sourceforge.net/"<br />
license=<br />
depends=('gtk2' 'libvorbis' 'alsa-lib' 'audiofile' 'libglade' 'id3lib' 'x-server')<br />
provides=('bmp')<br />
conflicts=('bmp')<br />
makedepends=('cvs')<br />
install=$pkgname.install<br />
<br />
_cvsroot=":pserver:anonymous:@cvs.sourceforge.net:/cvsroot/beepmp"<br />
_cvsmod="bmp"<br />
<br />
build() {<br />
cd $startdir/src<br />
msg "Connecting to $_cvsmod.sourceforge.net CVS server...."<br />
cvs -z3 -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
cd $_cvsmod<br />
./autogen.sh<br />
<br />
msg "CVS checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r ../$_cvsmod ../$_cvsmod-build<br />
cd ../$_cvsmod-build<br />
<br />
./configure --prefix=/usr<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install || return 1<br />
<br />
mkdir -p $startdir/pkg/usr/share/xmms/Skins<br />
mv $startdir/pkg/usr/share/bmp/Skins/* $startdir/pkg/usr/share/xmms/Skins<br />
rmdir $startdir/pkg/usr/share/bmp/Skins<br />
<br />
rm -r $startdir/src/$_cvsmod-build<br />
}<br />
# vim:syntax=sh<br />
</pre><br />
<br />
===SVN PKGBUILD 样例===<br />
<br />
假如您第一次对 PKGBUILD 使用 <tt>source</tt> 命令,它会填充(store) _svntrunk 和 _svnmod 变量。所以如果您运行:<br />
source PKGBUILD<br />
svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g<br />
你可以得到用于 pkgver 的修正号<br />
<br />
<pre><br />
# Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
pkgname=fluxbox-svn<br />
pkgver=4084<br />
pkgrel=1<br />
pkgdesc="Fluxbox-svn is the bleeding edge version of a lightweight yet \<br />
customizable windowmanager for X. This will checkout and package the latest SVN version."<br />
url="http://www.fluxbox.org"<br />
depends=('bash' 'x-server')<br />
makedepends=('subversion')<br />
conflicts=('blackbox' 'fluxbox' 'fluxbox-devel' 'fluxbox-cvs')<br />
replaces=('fluxbox-cvs')<br />
provides=('fluxbox')<br />
<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
<br />
build() {<br />
cd $startdir/src<br />
<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
cd $_svnmod<br />
./autogen.sh<br />
<br />
msg "SVN checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
mkdir ../$_svnmod-build<br />
cd ../$_svnmod-build<br />
<br />
# fix for crap fb issue<br />
mkdir data<br />
cp ../$_svnmod/data/keys data/<br />
<br />
../$_svnmod/configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug<br />
#./configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug<br />
make || return 1<br />
make DESTDIR=$startdir/pkg/ install<br />
<br />
rm -r $startdir/src/$_svnmod-build<br />
}<br />
# vim:syntax=sh</pre><br />
<br />
===GIT PKGBUILD 样例===<br />
<br />
<pre><br />
pkgname=compiz-git<br />
pkgver=20060707<br />
pkgrel=1<br />
pkgdesc="Composite and window manager for Xgl"<br />
url="http://en.opensuse.org/Compiz"<br />
license=""<br />
depends=('xgl-cvs' 'mesa-xgl-cvs' 'cairo-devel' 'libxevie' \<br />
'startup-notification' 'libpng' 'libxdamage' \<br />
'libxrandr' 'libwnck-compiz' 'gnome-desktop' 'control-center' \<br />
'libsvg-cairo' 'libxcomposite')<br />
makedepends=('git')<br />
conflicts=()<br />
replaces=()<br />
backup=()<br />
install=compiz.install<br />
source=(compiz-intel-copy-pixel-issue-workaround-1.diff)<br />
md5sums=('10a157b86d528bca2be6731c5eaff7b3')<br />
<br />
_gitroot="git://anongit.freedesktop.org/git/xorg/app/compiz"<br />
_gitname="compiz"<br />
build() {<br />
export CFLAGS="$CFLAGS -I/opt/mesa-xgl-cvs/include"<br />
cd $startdir/src<br />
msg "Connecting to git.freedesktop.org GIT server...."<br />
<br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
<br />
msg "GIT checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r $startdir/src/$_gitname $startdir/src/$_gitname-build<br />
cd $startdir/src/$_gitname-build<br />
patch -Np0 -i ${startdir}/src/compiz-intel-copy-pixel-issue-workaround-1.diff<br />
<br />
ACLOCAL="aclocal -I /opt/gnome/share/aclocal" ./autogen.sh --host=${CHOST} \<br />
--prefix=/usr \<br />
--infodir=/usr/share/info \<br />
--mandir=/usr/man \<br />
--sysconfdir=/opt/gnome/etc \<br />
--enable-gnome \<br />
--enable-libsvg-cairo \<br />
--enable-gconf-dump \<br />
--disable-kde || return 1<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install<br />
<br />
find $startdir/pkg -type f -name '*.la' -exec rm {} \;<br />
} <br />
</pre><br />
如您所见,我在 pkgname 后面使用 "-git" 后缀,另外两个变量 -- _gitroot 和 _gitname 用来表示包的“源”和包名字。<br />
我需要解释一个 if 条件:<br />
<pre><br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
</pre><br />
因为我们有两个命令,一个用来更新,一个迎来取得代码。我把源代码 copy 到一个 "-build" 目录(在 cvs 和 svn 版本的包里面,我们也这样做)。<br />
<br />
===versionpkg - a <tt>makepkg</tt> wrapper for CVS/SVN builds===<br />
这是一个很简单的脚本,它能够让你在不改动 PKGBUILD 文件里面的日期或者修正号的前提下更新你的 CVS 或者 SVN 包。<br />
<br />
简单地在你的 build 目录运行这个命令,代替 <tt>makepkg</tt>。这个脚本完全免除了用 backtick 扩展来设置 PKGBUILD 中的日期或者版本标记的必要。 (This script completely removes the need for backtick execution to set the date or tag version in PKGBUILDs.)<br />
<br />
使用这个脚本之前;<br />
* 确保在 PKGBUILD 的前10行的位置已经声明了 pkgver, 否则这个脚本不会正常工作! <br />
* 确保你的文件包含了下面的变量以及 checkout 命令:<br />
* CVS<br />
_cvsroot=<br />
: CVS 服务器根目录(The root of the CVS server) - 即的包含一个半角冒号 (:) 在用户名后面,就像上面提到的一样。<br />
_cvsmod=<br />
: 你要 check out 的 CVS 模块,如:<br />
_cvsroot=":pserver:anonymous:@mplayerhq.hu:/cvsroot/ffmpeg"<br />
_cvsmod="ffmpeg"<br />
: 下面这个 check out 的例子用到了上面提到的变来嗯。<strong>-D</strong> 选项对于正确使用 <code>versionpkg</code> 是必须的,它和 <strong>-f</strong> 选项是很好的组合. 在不使用 <strong>-f</strong> 选项的情况下使用 <strong>-D</strong> 可能会导致错误<br />
cvs -z9 -q -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
: -z 控制压缩级别(1低9高)<br />
: -D 指定 check out 的日期,这这个脚本里面我们用 $pkgver 来在设置时间。<br />
: -q 是 quiet (关闭详细信息)模式开关。<br />
* SVN<br />
_svntrunk=<br />
: SVN trunk 地址 (译注,相当于 CVS root)<br />
_svnmod=<br />
: 在说一次,这个是你想要 ckeck out 的模块名,如:<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
: 下面这个例子使用了上面的变量。<strong>-r</strong> 选项对于正确使用 <code>versionpkg</code> 是必要的(译注,这个是用来设置修改号的,显然).<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
: 这里的 -r 指定修改号, 我们用 $pkgver 来表示修改号。<br />
<br />
====看看这个脚本!====<br />
为了提高安全性, versionpkg 现在可以直接从 [community] 安装,<code>pacman -S versionpkg</code>。 我强烈建议您这样做(I strongly recommend that you use that. )下面的脚本纯粹用来解释 :)<br><br />
Changelog (修改记录):<br />
* check for both CVS/SVN vars (检查 SVN 和 CVS vars)<br />
* 如果失败了,就回退到上一个 pkgver ,以便允许正确的 gensync 操作(译注,我不知道 gensync, 从名字看应该是和更新有关,英文原文:If build fails revert to previous pkgver to allow correct gensync operation)<br />
* 加入了有色消息(coloured messages)的支持 <br />
<pre>#!/bin/bash<br />
<br />
# versionpkg - a makepkg wrapper for building CVS/SVN pkgs<br />
# dibblethewrecker.at.jiwe.org<br />
<br />
# makepkg configuration<br />
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf<br />
<br />
# SUBROUTINES<br />
plain() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e " \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo " $1" >&2<br />
fi<br />
}<br />
msg() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> $1" >&2<br />
fi<br />
}<br />
warning() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> WARNING: $1" >&2<br />
fi<br />
}<br />
error() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> ERROR: $1" >&2<br />
fi<br />
return 1<br />
}<br />
<br />
source ./PKGBUILD<br />
oldpkgver=$pkgver<br />
<br />
if [ ! -z ${_cvsroot} ] && [ ! -z ${_cvsmod} ] ; then<br />
cvsdate=`date +%Y%m%d`<br />
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$cvsdate|" ./PKGBUILD<br />
makepkg $@<br />
if [ $? -gt 0 ] ; then<br />
error "Reverting pkgver..."<br />
sed -i "1,11 s|pkgver=$cvsdate|pkgver=$oldpkgver|" ./PKGBUILD<br />
fi <br />
elif [ ! -z ${_svntrunk} ] && [ ! -z ${_svnmod} ] ; then<br />
svnrevno=`svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g`<br />
msg "Current revision number is $svnrevno"<br />
if [ "${1}" != "-f" ] && [ "${oldpkgver}" == "${svnrevno}" ] ; then<br />
error "No new revision available. (use -f to overwrite)"<br />
exit<br />
fi<br />
sleep 3<br />
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$svnrevno|" ./PKGBUILD<br />
makepkg $@<br />
if [ $? -gt 0 ] ; then<br />
error "Reverting pkgver..."<br />
sed -i "1,11 s|pkgver=$svnrevno|pkgver=$oldpkgver|" ./PKGBUILD<br />
fi <br />
else<br />
error "No SVN or CVS variables found! Aborting..."<br />
exit<br />
fi<br />
</pre><br />
<br />
== 译者声明 ==<br />
译者对本文的翻译全凭理解,部分内容可能没有经过实践,有错误的话,请直接编辑本文。</div>Doze wormhttps://wiki.archlinux.org/index.php?title=VCS_package_guidelines_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=63012VCS package guidelines (简体中文)2009-02-25T09:04:00Z<p>Doze worm: /* 用 makepkg 打包 CVS, SVN & GIT 文件 */</p>
<hr />
<div>{{i18n_links_start}}<br />
{{i18n_entry|English|Arch CVS %26 SVN PKGBUILD guidelines}}<br />
{{i18n_entry|正體中文|Arch CVS %26 SVN PKGBUILD 編寫指南}}<br />
{{i18n_entry|简体中文|Arch CVS %26 SVN %26 GIT PKGBUILD 编写指南}}<br />
{{i18n_links_end}}<br />
<br />
[[Category:简体中文]]<br />
<br />
==用 makepkg 打包 CVS, SVN & GIT 文件==<br />
<br />
事实上,这个工作非常简单,您不需要什么特殊的知识。当然,您对CVS和SVN的知识懂得越多越好。很多人在 PKGBUILD 文件里面引入了不必要(译注:这个词是译者加的,在尽量不影响理解的前提下,译者可能会不自觉的使用自己的语言,后面不再声明)的自定义变量,这样会使工作变得复杂。这些看起来很复杂的语句并不是''必须的'',但是对于使语法结构清洗,是很有帮助的。<br />
<br />
===一些小提示===<br />
<br />
* 给 <code>pkgname</code> 加上 <code>-cvs</code> 或者 <code>-svn</code> 或者 <code>-git</code> 这样的后缀 (where applicable, 这个不知道怎么翻译) - 这样可以防止和非devel版本的包名混淆,比如 fluxbox-svn , fvwm-cvs 对 fluxbox , fvwm.<br />
* 您还必须小心处理 pacman 的冲突(依赖关系冲突)。比如 fluxbox-svn will 与 fluxbox 冲突。这样您就需要使用 <tt>conflicts=</tt> 字段(field)<br />
conflicts=('fluxbox')<br />
: 您还应该使用 <tt>provides=</tt> 字段,以便让需要 fluxbox (作者这里用fluxbox来举例)的包知道 fluxbox-svn 就是 fluxbox<br />
provides=('fluxbox')<br />
: 您最好不要使用(your should avoid using) <tt>replaces=</tt> ,它可能会产生不必要的麻烦<br />
*When using/defining the cvsroot use anonymous<b>:</b>@ rather than anonymous@ to avoid having to press enter to give blank password ''OR'' anonymous<b>:password</b>@ - if a password is required.<br />
* cvs and svn PKGBUILDs may not require a source or md5sum array but these fields '''must''' be included in the PKGBUILD if you wish to submit it to the AUR, otherwise the pkg will be rejected. They may be left blank though.<br />
<pre>source=()<br />
md5sums=()</pre><br />
* 使用 CVS/SVN/GIT 的时候,我们极少用到 pkgrel 字段,因为源文件时有改动,所以我们通常用 pkgver 来标记改动(假定我们用 pkgver 来保存日期)(英文原文:It is rarely necessary to use the pkgrel field when building CVS/SVN/GIT pkgs - any changes to the pkg will often be on another day and so are usually accounted for by a change in pkgver (assuming pkgver is used to hold a date format),英语不到家,有人会翻译的mail:fluke at sfcube.net)<br />
* 不要忘记把 svn 或者 cvs 包含在 <code>makedepends=</code> 里面,如果必须的话(译注:如果你要从 svn 来 checkout 源码包,自然要要保证你有 svn 客户端)<br />
* 为了保证 check out(译注:cvs和svn的术语,就不翻译了) 下来的 code 的完整性,我们建立一个独立的 build 目录,比如你已经在 $startdir 把代码 ckeck out 到了 src/$_cvsmod 目录你可以:<br />
<pre> mkdir src/$_cvsmod-build<br />
<br />
cd src/$_cvsmod-build<br />
../$_cvsmod/configure</pre><br />
''万一'' 这种方法失败了,你可以尝试:<br />
<pre> cp -r src/$_cvsmod src/$_cvsmod-build<br />
cd src/$_cvsmod-build</pre><br />
<br />
* AUR的介绍中说最重要的是不要使用 backtick 扩展去创建 pkg 变量(With the introduction of the AUR it is most important to avoid using backtick execution to create pkg variables)<br />
** 对于 cvs 包 您应该避免 <code>pkgver=`date +%y%m%d`</code> - (译注:this also inteferes with the functionality of the AUR.,这句话不好翻译,我不知道inteferes什么意思) 作为替代的方案,还可以用日期格式的 $pkgver 变量,并且使用 cvs -D 去获取从那个日期起的代码 (看下面)<br />
** 对于 svn 您可以使用修正号(revision number)。下面是一种简易的获取修正号的方法:<br />
svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g<br />
这条命令从 svn repo (译注:就是 svn 的源)最近额记录里面取得修正号--修正号的前面带有''r''字母。下面的来自于 fluxbox 的 svn 记录,修正号就在左上角,r4084。<br />
<pre><br />
------------------------------------------------------------------------<br />
r4084 | mathias | 2005-07-20 19:29:01 +0100 (Wed, 20 Jul 2005) | 16 lines<br />
<br />
Changed some *Focus options, just to make some things a bit more clear.<br />
the "Sloppy" was always a bit .. unprecise.<br />
</pre><br />
<br />
===CVS PKGBUILD 样例===<br />
<br />
这里用一个 bmp-cvs 的 PKGBUILD 来说明上面的一些技巧(一些小提示)<br />
<br />
<pre># Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
pkgname=bmp-cvs<br />
pkgver=20050728<br />
pkgrel=1<br />
pkgdesc="BeepMP is a multimedia player that uses the WinAmp 2.x UI, GTK2, and is based on XMMS. This will checkout and package the latest CVS version."<br />
url="http://beepmp.sourceforge.net/"<br />
license=<br />
depends=('gtk2' 'libvorbis' 'alsa-lib' 'audiofile' 'libglade' 'id3lib' 'x-server')<br />
provides=('bmp')<br />
conflicts=('bmp')<br />
makedepends=('cvs')<br />
install=$pkgname.install<br />
<br />
_cvsroot=":pserver:anonymous:@cvs.sourceforge.net:/cvsroot/beepmp"<br />
_cvsmod="bmp"<br />
<br />
build() {<br />
cd $startdir/src<br />
msg "Connecting to $_cvsmod.sourceforge.net CVS server...."<br />
cvs -z3 -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
cd $_cvsmod<br />
./autogen.sh<br />
<br />
msg "CVS checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r ../$_cvsmod ../$_cvsmod-build<br />
cd ../$_cvsmod-build<br />
<br />
./configure --prefix=/usr<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install || return 1<br />
<br />
mkdir -p $startdir/pkg/usr/share/xmms/Skins<br />
mv $startdir/pkg/usr/share/bmp/Skins/* $startdir/pkg/usr/share/xmms/Skins<br />
rmdir $startdir/pkg/usr/share/bmp/Skins<br />
<br />
rm -r $startdir/src/$_cvsmod-build<br />
}<br />
# vim:syntax=sh<br />
</pre><br />
<br />
===SVN PKGBUILD 样例===<br />
<br />
假如您第一次对 PKGBUILD 使用 <tt>source</tt> 命令,它会填充(store) _svntrunk 和 _svnmod 变量。所以如果您运行:<br />
source PKGBUILD<br />
svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g<br />
你可以得到用于 pkgver 的修正号<br />
<br />
<pre><br />
# Contributor: Lukas Sabota <punkrockguy318@comcast.net><br />
# Contributor: dibblethewrecker dibblethewrecker.at.jiwe.dot.org<br />
pkgname=fluxbox-svn<br />
pkgver=4084<br />
pkgrel=1<br />
pkgdesc="Fluxbox-svn is the bleeding edge version of a lightweight yet \<br />
customizable windowmanager for X. This will checkout and package the latest SVN version."<br />
url="http://www.fluxbox.org"<br />
depends=('bash' 'x-server')<br />
makedepends=('subversion')<br />
conflicts=('blackbox' 'fluxbox' 'fluxbox-devel' 'fluxbox-cvs')<br />
replaces=('fluxbox-cvs')<br />
provides=('fluxbox')<br />
<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
<br />
build() {<br />
cd $startdir/src<br />
<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
cd $_svnmod<br />
./autogen.sh<br />
<br />
msg "SVN checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
mkdir ../$_svnmod-build<br />
cd ../$_svnmod-build<br />
<br />
# fix for crap fb issue<br />
mkdir data<br />
cp ../$_svnmod/data/keys data/<br />
<br />
../$_svnmod/configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug<br />
#./configure --prefix=/usr --enable-xinerama --enable-imlib2 --enable-debug<br />
make || return 1<br />
make DESTDIR=$startdir/pkg/ install<br />
<br />
rm -r $startdir/src/$_svnmod-build<br />
}<br />
# vim:syntax=sh</pre><br />
<br />
===GIT PKGBUILD 样例===<br />
<br />
<pre><br />
pkgname=compiz-git<br />
pkgver=20060707<br />
pkgrel=1<br />
pkgdesc="Composite and window manager for Xgl"<br />
url="http://en.opensuse.org/Compiz"<br />
license=""<br />
depends=('xgl-cvs' 'mesa-xgl-cvs' 'cairo-devel' 'libxevie' \<br />
'startup-notification' 'libpng' 'libxdamage' \<br />
'libxrandr' 'libwnck-compiz' 'gnome-desktop' 'control-center' \<br />
'libsvg-cairo' 'libxcomposite')<br />
makedepends=('git')<br />
conflicts=()<br />
replaces=()<br />
backup=()<br />
install=compiz.install<br />
source=(compiz-intel-copy-pixel-issue-workaround-1.diff)<br />
md5sums=('10a157b86d528bca2be6731c5eaff7b3')<br />
<br />
_gitroot="git://anongit.freedesktop.org/git/xorg/app/compiz"<br />
_gitname="compiz"<br />
build() {<br />
export CFLAGS="$CFLAGS -I/opt/mesa-xgl-cvs/include"<br />
cd $startdir/src<br />
msg "Connecting to git.freedesktop.org GIT server...."<br />
<br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
<br />
msg "GIT checkout done or server timeout"<br />
msg "Starting make..."<br />
<br />
cp -r $startdir/src/$_gitname $startdir/src/$_gitname-build<br />
cd $startdir/src/$_gitname-build<br />
patch -Np0 -i ${startdir}/src/compiz-intel-copy-pixel-issue-workaround-1.diff<br />
<br />
ACLOCAL="aclocal -I /opt/gnome/share/aclocal" ./autogen.sh --host=${CHOST} \<br />
--prefix=/usr \<br />
--infodir=/usr/share/info \<br />
--mandir=/usr/man \<br />
--sysconfdir=/opt/gnome/etc \<br />
--enable-gnome \<br />
--enable-libsvg-cairo \<br />
--enable-gconf-dump \<br />
--disable-kde || return 1<br />
make || return 1<br />
make DESTDIR=$startdir/pkg install<br />
<br />
find $startdir/pkg -type f -name '*.la' -exec rm {} \;<br />
} <br />
</pre><br />
如您所见,我在 pkgname 后面使用 "-git" 后缀,另外两个变量 -- _gitroot 和 _gitname 用来表示包的“源”和包名字。<br />
我需要解释一个 if 条件:<br />
<pre><br />
if [ -d $startdir/src/$_gitname ] ; then<br />
cd $_gitname && git-pull origin<br />
msg "The local files are updated."<br />
else<br />
git clone $_gitroot<br />
fi<br />
</pre><br />
因为我们有两个命令,一个用来更新,一个迎来取得代码。我把源代码 copy 到一个 "-build" 目录(在 cvs 和 svn 版本的包里面,我们也这样做)。<br />
<br />
===versionpkg - a <tt>makepkg</tt> wrapper for CVS/SVN builds===<br />
这是一个很简单的脚本,它能够让你在不改动 PKGBUILD 文件里面的日期或者修正号的前提下更新你的 CVS 或者 SVN 包。<br />
<br />
简单地在你的 build 目录运行这个命令,代替 <tt>makepkg</tt>。这个脚本完全免除了用 backtick 扩展来设置 PKGBUILD 中的日期或者版本标记的必要。 (This script completely removes the need for backtick execution to set the date or tag version in PKGBUILDs.)<br />
<br />
使用这个脚本之前;<br />
* 确保在 PKGBUILD 的前10行的位置已经声明了 pkgver, 否则这个脚本不会正常工作! <br />
* 确保你的文件包含了下面的变量以及 checkout 命令:<br />
* CVS<br />
_cvsroot=<br />
: CVS 服务器根目录(The root of the CVS server) - 即的包含一个半角冒号 (:) 在用户名后面,就像上面提到的一样。<br />
_cvsmod=<br />
: 你要 check out 的 CVS 模块,如:<br />
_cvsroot=":pserver:anonymous:@mplayerhq.hu:/cvsroot/ffmpeg"<br />
_cvsmod="ffmpeg"<br />
: 下面这个 check out 的例子用到了上面提到的变来嗯。<strong>-D</strong> 选项对于正确使用 <code>versionpkg</code> 是必须的,它和 <strong>-f</strong> 选项是很好的组合. 在不使用 <strong>-f</strong> 选项的情况下使用 <strong>-D</strong> 可能会导致错误<br />
cvs -z9 -q -d $_cvsroot co -D $pkgver -f $_cvsmod<br />
: -z 控制压缩级别(1低9高)<br />
: -D 指定 check out 的日期,这这个脚本里面我们用 $pkgver 来在设置时间。<br />
: -q 是 quiet (关闭详细信息)模式开关。<br />
* SVN<br />
_svntrunk=<br />
: SVN trunk 地址 (译注,相当于 CVS root)<br />
_svnmod=<br />
: 在说一次,这个是你想要 ckeck out 的模块名,如:<br />
_svntrunk=svn://svn.berlios.de/fluxbox/trunk<br />
_svnmod=fluxbox<br />
: 下面这个例子使用了上面的变量。<strong>-r</strong> 选项对于正确使用 <code>versionpkg</code> 是必要的(译注,这个是用来设置修改号的,显然).<br />
svn co $_svntrunk --config-dir ./ -r $pkgver $_svnmod<br />
: 这里的 -r 指定修改号, 我们用 $pkgver 来表示修改号。<br />
<br />
====看看这个脚本!====<br />
为了提高安全性, versionpkg 现在可以直接从 [community] 安装,<code>pacman -S versionpkg</code>。 我强烈建议您这样做(I strongly recommend that you use that. )下面的脚本纯粹用来解释 :)<br><br />
Changelog (修改记录):<br />
* check for both CVS/SVN vars (检查 SVN 和 CVS vars)<br />
* 如果失败了,就回退到上一个 pkgver ,以便允许正确的 gensync 操作(译注,我不知道 gensync, 从名字看应该是和更新有关,英文原文:If build fails revert to previous pkgver to allow correct gensync operation)<br />
* 加入了有色消息(coloured messages)的支持 <br />
<pre>#!/bin/bash<br />
<br />
# versionpkg - a makepkg wrapper for building CVS/SVN pkgs<br />
# dibblethewrecker.at.jiwe.org<br />
<br />
# makepkg configuration<br />
[ -f /etc/makepkg.conf ] && source /etc/makepkg.conf<br />
<br />
# SUBROUTINES<br />
plain() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e " \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo " $1" >&2<br />
fi<br />
}<br />
msg() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;32m==>\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> $1" >&2<br />
fi<br />
}<br />
warning() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;33m==> WARNING:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> WARNING: $1" >&2<br />
fi<br />
}<br />
error() {<br />
if [ "$USE_COLOR" = "Y" -o "$USE_COLOR" = "y" ]; then<br />
echo -e "\033[1;31m==> ERROR:\033[1;0m \033[1;1m$1\033[1;0m" >&2<br />
else<br />
echo "==> ERROR: $1" >&2<br />
fi<br />
return 1<br />
}<br />
<br />
source ./PKGBUILD<br />
oldpkgver=$pkgver<br />
<br />
if [ ! -z ${_cvsroot} ] && [ ! -z ${_cvsmod} ] ; then<br />
cvsdate=`date +%Y%m%d`<br />
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$cvsdate|" ./PKGBUILD<br />
makepkg $@<br />
if [ $? -gt 0 ] ; then<br />
error "Reverting pkgver..."<br />
sed -i "1,11 s|pkgver=$cvsdate|pkgver=$oldpkgver|" ./PKGBUILD<br />
fi <br />
elif [ ! -z ${_svntrunk} ] && [ ! -z ${_svnmod} ] ; then<br />
svnrevno=`svn log $_svntrunk --limit 1 | grep -m 1 -o "r.*" | cut -d \| -f 1 | sed s@r@@g`<br />
msg "Current revision number is $svnrevno"<br />
if [ "${1}" != "-f" ] && [ "${oldpkgver}" == "${svnrevno}" ] ; then<br />
error "No new revision available. (use -f to overwrite)"<br />
exit<br />
fi<br />
sleep 3<br />
sed -i "1,11 s|pkgver=$oldpkgver|pkgver=$svnrevno|" ./PKGBUILD<br />
makepkg $@<br />
if [ $? -gt 0 ] ; then<br />
error "Reverting pkgver..."<br />
sed -i "1,11 s|pkgver=$svnrevno|pkgver=$oldpkgver|" ./PKGBUILD<br />
fi <br />
else<br />
error "No SVN or CVS variables found! Aborting..."<br />
exit<br />
fi<br />
</pre><br />
<br />
== 译者声明 ==<br />
译者对本文的翻译全凭理解,部分内容可能没有经过实践,有错误的话,请直接编辑本文。</div>Doze wormhttps://wiki.archlinux.org/index.php?title=Extra_keyboard_keys_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=62960Extra keyboard keys (简体中文)2009-02-24T07:42:40Z<p>Doze worm: /* 简介 */</p>
<hr />
<div>{{translateme}}<br />
<br />
[[Category:输入设备|rj]]<br />
[[Category:简体中文]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|Hotkeys}}<br />
{{i18n_entry|简体中文|热键}}<br />
{{i18n_links_end}}<br />
<br />
=简介=<br />
许多键盘(主要是笔记本电脑)含有一些"特殊按键",用于执行一个应用程序或者输入特殊字符(不包含在国家标准键盘映射)。种类繁多的键盘布局导致了一些安装linux时的问题,因为这些按键无效;然而linux再一次给了你配置这些按键如你所愿地工作的自由。只有少数特殊按键不被linux内核支持而不能工作。<br />
<br />
Linux下有许多方式来处理特殊按键(下面简称为“热键”)。本文档所讨论的解决方案允许你在你所选择的窗口管理器或是桌面系统中独立地使用;更进一步讲,有三种可行的使用方法供你选择(第二种和第三种方法不能同时使用在同一个按键上):<br />
#to print a character in console;<br />
#to print a character in X;<br />
#to execute an app in X.<br />
Actually, you can do also the fourth thing, i.e. to execute an app in console, but this is made with a silly work-around and will be briefly described when discussing the first use in the list above (see [[#Printing characters in the console|below]]).<br />
<br />
Other approaches use comprehensive applications aiming to solve these problems (see e.g. the wiki howtos for [[Extra Keyboard Keys|keytouch]] and for [[Lineak]]), but these solutions are generally built on a wide database of known models of keyboards: this database seems to be condemned to be incomplete, since the variety of keyboard models does never stop to grow. The approach here considered allows the user to work with the internals of the system, tailoring the configuration to his own system as it is. Moreover, the other solutions assume that you want to use the hotkeys only when you are in X, while it is possible to take profit of them also if you are a console lover.<br />
<br />
All the keys we can hope to use in linux has a scancode. This scancode is generally associated with a keycode. This keycode is generally associated with a character to print in the console keymap. This keycode is also translated by X in another code, which the X keymaps generally bind to a certain character or to a certain command to run. Well, when an hotkey does not work for us, one or more of these things that generally happen do not happen. <br />
First of all, we have to discover what is the problem. <br />
This diagnosis will be explained in the [[#The diagnosis|first section]], but we sum up the possible scenarios, so that after the diagnosis we know where to look for a suitable medicine. We have to verify if the key has a scancode. If it has not a scancode, there is no hope that it works, so we have to give up. If it has a scancode but no keycode, we have to associate the scancode with a keycode: this will be explained in the [[#Associate scancodes with keycodes|second section]]. If it has already a keycode or if you gave it a keycode thanks to the second section, then we have to bind it to one or more of the three possible uses listed above: the [[#Printing characters in the console|third section]] explains how to make the key print a character in console; the [[#Printing characters in X|fourth section]] explains how to make the key print a character in X using xmodmap; the [[#Running applications in X|fifth section]] explains how to make the key run an application when in X, using xbindkeys.<br />
<br />
= The diagnosis =<br />
The most global way to diagnose the situation is to go in console and use the 'showkey' utility. Please note that this utility will not work when in X so you'll need to switch to another tty (e.g. CTRL+ALT+F6).<br />
<br />
First of all we run:<br />
$ showkey <br />
without options: 'showkey' waits for ten seconds that we press a key (after ten seconds it quits automatically) and displays the keycode of the key we pressed. Two scenarios are possible:<br />
#nothing is displayed: in this case the key has not a keycode and you have to read further this section;<br />
#some mysterious hexadecimal numbers are displayed; in this case the kernel already assigns a keycode to the key; we can pass over to sections [[#Printing characters in the console|3]], [[#Printing characters in X|4]] or [[#Running applications in X|5]], according to what we want to do with that key.<br />
In the first scenario, we have to investigate if the key has at least a scancode. The 'showkey' utility can help us again. Just use the '-s' option:<br />
$ showkey -s<br />
When we press our hotkey, two scenarios are possible:<br />
#nothing is displayed: the key is not seen in any way by our os, we whould give up;<br />
#a decimal code is displayed; the hotkey has a scancode; the [[#Associate_scancodes_with_keycodes|next section]] will help you to associate this scancode with a keycode.<br />
<br />
= Associate scancodes with keycodes =<br />
In order to accomplish this task, we need to resort to the utility 'setkeycodes', which, as you can see in its man page, associates scancodes to keycodes. Obviously enough, it takes two arguments: the first argument is the scancode, the second argument is the keycode. However, it is not always easy to determine these arguments. In order to determine the scancode, the output of the 'showkey -s' we used in the section above is not always illuminating, since sometimes the hotkeys - and the normal keys too - generate a double scancode. The simplest way to determine the exact scancode is to look at the system log: in fact, any time we press a key which has a scancode but no keycode, the kernel suggests us to use just 'setkeycodes' to assign a keycode to it. In the message the kernel gives us also the scancode we have to use actually. We will find it in the system log. However, also this code is not always usable as it is: when it is composed of four characters and starts with an 'e', then we can use it as it is as the first argument for 'setkeycodes'. On the contrary, when the kernel gives us only two digits, we have to prepend '0x' to it. As an example, suppose that the kernel tells us that the scancode is 71; then the first argument for 'setkeycodes' will be 0x71.<br />
<br />
The second argument is partially arbitrary. Partially! In fact:<br />
#the keycode has to be in the range 1-127;<br />
#it should not conflict with the keycodes already mapped to a character in your keymap.<br />
In order to respect the second condition, you have to look at your keymap. In configuring your system through /etc/rc.conf, you have chosen your keymap, or decided to stay with the default one: in fact rc.conf includes a 'KEYMAP' setting. The keymaps are stored in your system in one of the subfolders into /usr/share/kbd/keymaps/i386/. E.g., mine is the Italian keymap and its path is /usr/share/kbd/keymaps/i386/qwerty/it.map.gz. It is a text file compressed with gzip2. Let us gunzip it.<br />
# gunzip /usr/share/kbd/keymaps/i386/qwerty/it.map.gz<br />
Now we can read it (sometimes less is able to read also gzipped files: in this case the above passage is dispensable):<br />
# less /usr/share/kbd/keymaps/i386/qwerty/it.map<br />
We have to choose a keycode not conflicting with those already associated with characters. Most of the lines in the keymap are of the following format:<br />
keycode <keycode> = <keysym><br />
These lines are ordered according to the numeric value of the keycode, thus it is easy to find the highest keycode used by the keymap. Thus, the second argument for 'setkeycodes" has to in the range between the successor of this highest keycode and 127. <br />
<br />
Let us say that 112 is in this range (this is actually true with the italian keymap): now we can actually use 'setkeycodes':<br />
# setkeycodes 0x71 112<br />
If we run 'showkey' again, we can see that our hotkey has now the keycode 112. However, this is true only for the current session. To make this permanent, we need to execute 'setkeycodes' each time we boot our system. This can be done inserting the following line in /etc/rc.local:<br />
setkeycodes 0x71 112 &<br />
<br />
== Printing characters in the console ==<br />
When we are in console, we can use our hotkeys to print a certain character. Moreover we can also print a sequence of characters and some escape sequences. Thus, if we print the sequence of characters constituting a command and afterwards an escape character for a new line, that command will be executed!<br />
<br />
In order to do this, we could modify our console keymap. However, I suggest not to do this, since that is a delicate file and since it will be rewritten anytime we update the package it belongs to. It is better to integrate the existing keymap with a personal keymap. The utility 'loadkeys' can do this. <br />
<br />
First of all, we need to write down this file. You can put it as you prefer, but I prefer to mimic partially the hierarchy of the default keymaps into /usr/local. So:<br />
# mkdir -p /usr/local/share/kbd/keymaps<br />
# vim /usr/local/share/kbd/keymaps/personal.map<br />
As a side note, it is worth noting that such a personal keymap is useful also to redefine the behavior of keys already treated by the default keymap: in fact, when we load it with 'loadkeys' the directives in the default keymap will be replaced when they conflict with the new directives and conserved otherwise. <br />
<br />
Anyway, we need two kinds of directives in our personal keymaps. First of all, the keycode directives, with the format we have seen above in the default keymaps. These directives associate a keycode with a keysym. Keysyms represent keyboard actions. The actions available include outputting character codes or character sequences, switching consoles or keymaps, booting the machine etc. (The complete list can be obtained with <br />
$ dumpkeys -l<br />
Anyway, most of them are intuitive. If we want our key to output an 'e', the directive will be:<br />
keycode 112 = e<br />
If we want our hotkey to output the symbol of the euro currency, the directive will be:<br />
keycode 112 = euro<br />
Some keysym are not immediately connected to a keyboard actions. In particular the keysyms constituted by a capital F and two digits constituting a number greater than 30 are always free. This is useful for us if we want our hotkey to output a sequence of characters and other actions. In fact we can first of all bind our character to such a keysym:<br />
keycode 112 = F70<br />
Then we use another kind of directive, which binds the keysym to an action. E.g., if we want our hotkey to output a literal "Hello":<br />
string F70 = "Hello"<br />
This can seem not very useful. But we can use it to print and execute commands. In order to execute the printed command, I need to use an escape sequence corresponding to a new line. E.g., I can want an hotkey to hibernate my laptop also when I am a user (through sudo). In this case I write the following directive in my personal keymap.<br />
string F70 = "sudo /usr/sbin/hibernate\n"<br />
In order to take profit of my personal keymap, I have to load it with 'loadkeys':<br />
$ loadkeys /usr/local/share/kbd/keymaps/personal.map<br />
Also in this case, this is valid only for the current session. In order to accomplish the same result each time I boot my machine, I have to insert another line in /etc/rc.local. This line should come after the occurrences of 'setkeycodes' discussed in section 2, since the personal keymap resorts to the keycodes assigned through 'setkeycodes':<br />
loadkeys -q /usr/local/share/kbd/keymaps/personal.map&<br />
The '-q' option simply avoids that a confirmation message is printed to stdin during the boot process.<br />
<br />
== Printing characters in X ==<br />
Fortunately, when a character has a keycode in the system it is also seen inside X. X gives it a keycode: however, it is very important to stress that the X keycode is DIFFERENT from the system keycode. If you had to pass through section 1 of this article to assign a system keycode to your hotkey, you MUST forget this keycode when dealing with X, because X assigns a different keycode to the key (but requires that the key has a system keycode whatsoever). <br />
<br />
The most traditional and proficient way to make a key output a character when you are in X is to use xmodmap. Xmodmap is roughly the X equivalent of 'loadkeys' (see section 3): it reads a file containing some directives. As 'loadkeys', it can be used to modify many aspects of the behaviour of your keyboard (such as modifiers, etc.), but I will not cover these aspects in this article. The only kind of directive I am interested in here associates an X keycode to a keysym. 'xmodmap' is included in the 'xorg-server-utils' package.<br />
# pacman -S xorg-server-utils<br />
In order to use it we need to discover the X keycode of our beloved hotkey: we resort to 'xev'. 'xev' is included in the 'xorg-utils' package.<br />
# pacman -S xorg-utils<br />
'xev' (run it from a terminal window) open a white window and outputs in the terminal some codes and infos when you press (or relase) a key or move your mouse. Its output is redundant and difficult. Anyway, you will see clearly into it when you press your hotkey:<br />
keycode: <theXkeycodeofyourhotkey><br />
Once you have discovered the X keycodes of your hotkeys, you are ready to write the file that 'xmodmap' will parse. You can put it where you like, but since the xserver is executed by a user, it is customary to make it an hidden file in the home directory of the user:<br />
$ vim ~/.Xmodmap<br />
In this file, you have to list the keycode directives, with the following syntax:<br />
keycode <Xkeycode> = <keysym><br />
The list of X keysyms can be read in /usr/include/X11/keysymdef.h. Anyway, most of them are intuitive. Let us say that 'xev' has said that the X keycode of my hotkey is 239. If I want it to output a literal 'e', I will write the following directive:<br />
keycode 239 = e<br />
If I want it to output the symbol of the American currency, I will write the following directive:<br />
keycode 239 = dollar<br />
Finally I have to source the file with xmodmap:<br />
$ xmodmap ~/.Xmodmap<br />
Obviously, this will work only for the current X session, but it is better to make this automatically anytime I start X. This should be done in different ways according to your system configuration. E.g., if you use the old plain 'startx', you have to put the following line in .xinitrc before the line when you launch your window manager:<br />
xmodmap ~/.Xmodmap &<br />
<br />
<b>NOTE:</b><br />
This can also be used to assign functions to multimedia keys. Special functions can be found in /usr/share/X11/XKeysymDB.<br />
<br />
My (tkjacobsen) ~/.Xmodmap:<br />
<pre><br />
keycode 160 = XF86AudioMute<br />
keycode 176 = XF86AudioRaiseVolume<br />
keycode 174 = XF86AudioLowerVolume<br />
</pre><br />
<br />
Multimedia programs such as Rhythmbox and Exaile are designed to work with keys assigned to XF86 Symbols out-of-the-box, without the need to configure a third-party application.<br />
<br />
== Running applications in X ==<br />
There are several utilities which aim to help you to bind keys (or keys combinations) to certain apps. Basically, they follow two main philosophies: some of them include a database of existing keyboards and, once you have defined the model of your keyboard, should associate to keys the 'right' action (i.e. corresponding to the icon on the key...); some others allow you to associate the action you like to whatever key or key combination, disregarding stuff like icons. I have a strong preference for this second philosophy and will propose to use one of the utilities of this second kind. [[Lineak]] is an example of the first approach.<br />
<br />
Another option is to use the configuration files of the window manager. This is a very good solution, although it often requires that the key is associated (through xmodmap) with a keysym which the window manager then associates to an app to run. However, it is different for each of the existing window managers and can not be covered in this article.<br />
<br />
I propose to use xbindkeys. xbindkeys can be used together with any window manager (but its shortcuts can conflict with the shortcuts defined by the window manager).<br />
# pacman -S xbindkeys<br />
xbindkeys is widely documented in its man page:<br />
$ man xbindkeys <br />
Xbindkeys includes an utility to detect the X keycodes of keys and key combinations without resorting to 'xev'. Its output is much more readable than 'xev' output.<br />
$ xbindkeys -mk<br />
In the configuration file you can associate commands both to X keycodes and to keysyms. Your hotkeys, if you haven't already configured them through 'xmodmap' (see Section 4 above) are actually identifiable only through an X keycode. The man page explains the syntax of the configuration file (~/.xbindkeysrc) in great detail. The following is just one example of what can be done with Volume/Mute keys:<br />
<pre><br />
# vol mute<br />
"amixer set Master mute"<br />
m:0x10 + c:160<br />
# vol up<br />
"amixer set Master 2dB+ unmute"<br />
m:0x10 + c:176<br />
# vol dn<br />
"amixer set Master 2dB- unmute"<br />
m:0x10 + c:174<br />
</pre><br />
<br />
Once configured, 'xbindkeys' should be run when an X syntax starts. Thus, provided that you use 'startx' to start your x session, you can add the following line to your .xinitrc:<br />
xbindkeys &<br />
<br />
In this way, xbindkeys will fork in the background and be ready to react when you press the hotkeys (or the normal keys, or key combinations) you defined in the config file.</div>Doze wormhttps://wiki.archlinux.org/index.php?title=PowerNow_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&diff=62959PowerNow (简体中文)2009-02-24T07:21:47Z<p>Doze worm: /* 查看你的CPU是否支持PowerNow! */</p>
<hr />
<div>[[Category:CPU (简体中文)]]<br />
[[Category:能源管理]]<br />
[[Category:HOWTOs (简体中文)]]<br />
[[Category:简体中文]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|PowerNow}}<br />
{{i18n_entry|Русский|PowerNow-ru}}<br />
{{i18n_entry|简体中文|PowerNow (简体中文)}}<br />
{{i18n_links_end}}<br />
<br />
'''PowerNow!'''是一种在某些AMD处理器上可以实现的技术. 这种技术能动态改变电压和速度来减少处理器电能消耗和发热. 它也被称为 ''Cool'n'Quiet''.<br />
<br />
== 查看你的CPU是否支持PowerNow! ==<br />
<br />
如果你有AMD64处理器:<br />
# modprobe powernow-k8<br />
<br />
如果你的CPU比较老, 模块的名字可能是<tt>powernow-k7</tt>或者<tt>powernow-k6</tt>.<br />
<br />
如果处理器不支持PowerNow!, 或者Cool'n'Quiet选项在BIOS里面没有开启, 在加载模块的时候将会立刻提示一个错误:<br />
<br />
FATAL: Error inserting powernow_k8 (/lib/modules/2.6.16-ARCH/kernel/arch/i386/kernel/cpu/cpufreq/powernow-k8.ko): No such device<br />
<br />
查看你目前使用的内核是否支持PowerNow!: <br />
# dmesg | grep powernow<br />
<br />
输出应该类似这样(以AMD64 3400+ Clawhammer为例)<br />
<br />
powernow-k8: Found 1 AMD Athlon 64 / Opteron processors (version 1.60.2)<br />
powernow-k8: 0 : fid 0x10 (2400 MHz), vid 0x2 (1500 mV)<br />
powernow-k8: 1 : fid 0xe (2200 MHz), vid 0x6 (1400 mV)<br />
powernow-k8: 2 : fid 0xc (2000 MHz), vid 0xa (1300 mV)<br />
powernow-k8: 3 : fid 0xa (1800 MHz), vid 0xe (1200 mV)<br />
powernow-k8: 4 : fid 0x2 (1000 MHz), vid 0x12 (1100 mV)<br />
<br />
== 在内核中设置PowerNow ==<br />
<br />
使用<tt>modprobe</tt>加载<tt>powernow-k8</tt>, <tt>cpufreq_powersave</tt>, <tt>cpufreq_userspace</tt>, <tt>cpufreq_conservative</tt>, <tt>cpufreq_ondemand</tt> 和 <tt>freq_table</tt> 模块, 并把它们加入到<tt>/etc/rc.conf</tt>里面的<tt>MODULES</tt>那一行里面去 .<br />
<br />
== 在用户空间(userspace)设置Frequency Scaling(频率调整)(利用cpudyn) ==<br />
# pacman -S acpid cpudyn<br />
<br />
启动cpudyn:<br />
# /etc/rc.d/cpudyn start<br />
<br />
在 <tt>/etc/rc.conf</tt>里面,添加<tt>cpudyn</tt>到<tt>DAEMONS</tt> 行.<br />
<br />
关于配置cpudyn和acpid本文就不多叙述.<br />
<br />
== 测试 ==<br />
<br />
测试动态调整是否在工作:<br />
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq<br />
<br />
然后和下面的进行比较:<br />
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq<br />
<br />
你也可以在另一个控制台运行:<br />
cat /dev/urandom > /dev/null<br />
<br />
<tt>scaling_cur_freq</tt>应该和<tt>scaling_max_freq</tt>是一样的.<br />
<br />
== 其他方法: 使用cpufrequtils ==<br />
这是一种简单而直接的方法来完成这个工作.<br />
<br />
1. 安装cpufrequtils<br />
pacman -S cpufrequtils<br />
<br />
2. 编辑/etc/conf.d/cpufreq,设置你需要的模式<br />
# valid governors:<br />
# ondemand, performance, powersave, conservative, userspace<br />
governor="ondemand"<br />
<br />
# valid freq suffixes: Hz, kHz (default), MHz, GHz, THz<br />
min_freq="2.25GHz"<br />
max_freq="3GHz"<br />
<br />
3. 为你处理器添加cpufreq模块(例如. powernow, powernow-k6, or powernow-k8) 到/etc/rc.conf的MODULES行 - 这些默认不是自动加载的.<br />
<br />
4. 添加'cpufreq'DAEMONS行,来让它在启动的时候加载. 也可以马上加载一次:<br />
/etc/rc.d/cpufreq start</div>Doze wormhttps://wiki.archlinux.org/index.php?title=Advanced_Linux_Sound_Architecture&diff=61657Advanced Linux Sound Architecture2009-02-12T13:25:01Z<p>Doze worm: /* No Sound with Onboard Intel Sound Card */</p>
<hr />
<div>[[Category:Sound (English)]]<br />
[[Category:Audio/Video (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|ALSA}}<br />
{{i18n_entry|Español|ALSA (Español)}}<br />
{{i18n_entry|Deutsch|ALSA Einrichten}}<br />
{{i18n_entry|Italiano|ALSA (Italiano)}}<br />
{{i18n_entry|Nederlands|ALSA instellen}}<br />
{{i18n_entry|Русский|ALSA_(Russian)}}<br />
{{i18n_entry|Slovensky|Nastavenie ALSA}}<br />
{{i18n_entry|Česky|ALSA (Česky)}}<br />
{{i18n_entry|简体中文|ALSA 安装设置 (简体中文)}}<br />
{{i18n_entry|עברית|הגדרת ALSA}}<br />
{{i18n_entry|Рolski|ALSA Setup (Polski)}}<br />
{{i18n_entry|Português do Brasil|Instalação ALSA}}<br />
{{i18n_entry|ไทย|ALSA Setup (ไทย)}}<br />
{{i18n_entry|Türkçe|ALSA (Türkçe)}}<br />
{{i18n_links_end}}<br />
<br />
= Introduction =<br />
The Advanced Linux Sound Architecture (ALSA) is a Linux kernel component intended to provide device drivers for sound cards.<br />
<br />
See [[OSS]] if you are looking for alternatives.<br />
<br />
This document tells how to get ALSA working with 2.6 kernels. Also see how to <br />
[[Allow_multiple_programs_to_play_sound_at_once|allow multiple programs to play sound at once]].<br />
<br />
=Installation=<br />
<br />
==Kernel drivers==<br />
<br />
ALSA has been included in the 2.6 kernels and is included in all arch '''kernel26*''' packages. If you build a custom kernel, do not forget to enable the correct ALSA driver.<br />
<br />
All necessary modules should be detected and loaded automatically by udev. No special configuration has to be done unless you use ISA cards. '''NEVER''' use alsaconf if you have a PCI or ISAPNP sound card, as the entries alsaconf adds to the modprobe.conf file might break udev's autodetection.<br />
<br />
==Userspace utilities==<br />
<br />
* Required for native ALSA programs and administration<br />
# pacman -Sy alsa-lib alsa-utils<br />
* Recommended if you want to use applications with OSS sound support in combination with dmix:<br />
# pacman -S alsa-oss<br />
<br />
All ALSA programs will most likely have alsa-lib as a dependency.<br />
<br />
=Configuration=<br />
==Make sure snd_pcsp gets loaded last==<br />
<br />
By default the kernel ships with snd_pcsp. In most cases this gets loaded before your "actual" sound card. snd_pcsp is an alsa module for your internal pc speaker.<br />
<br />
To have snd_pcsp load last, add the following to<br />
<br />
/etc/modprobe.conf<br />
options snd-pcsp index=2<br />
<br />
If you do not want snd_pcsp to load at all you can add the following to<br />
<br />
/etc/rc.conf<br />
MODULES=(... !snd_pcsp)<br />
<br />
{{Box Note | You will need to unload all your sound modules and reload them for the changes to take affect. It might be easier to reboot. Your choice. }}<br />
<br />
==Making sure the sound modules are loaded==<br />
<br />
You can assume that udev will autodetect your sound properly, including the OSS compatibility modules. You can check this with the command<br />
<br />
$ lsmod|grep '^snd'<br />
snd_usb_audio 69696 0 <br />
snd_usb_lib 13504 1 snd_usb_audio<br />
snd_rawmidi 20064 1 snd_usb_lib<br />
snd_hwdep 7044 1 snd_usb_audio<br />
snd_seq_oss 29412 0 <br />
snd_seq_midi_event 6080 1 snd_seq_oss<br />
snd_seq 46220 4 snd_seq_oss,snd_seq_midi_event<br />
snd_seq_device 6796 3 snd_rawmidi,snd_seq_oss,snd_seq<br />
snd_pcm_oss 45216 0 <br />
snd_mixer_oss 15232 1 snd_pcm_oss<br />
snd_intel8x0 27932 0 <br />
snd_ac97_codec 87648 1 snd_intel8x0<br />
snd_ac97_bus 1792 1 snd_ac97_codec<br />
snd_pcm 76296 4 snd_usb_audio,snd_pcm_oss,snd_intel8x0,snd_ac97_codec<br />
snd_timer 19780 2 snd_seq,snd_pcm<br />
snd 43776 12 snd_usb_audio,snd_rawmidi,snd_hwdep,snd_seq_oss,snd_seq,snd_seq_device,snd_pcm_oss,snd_mixer_oss,snd_intel8x0,snd_ac97_codec,snd_pcm,snd_timer<br />
snd_page_alloc 7944 2 snd_intel8x0,snd_pcm<br />
<br />
If the output looks similar, your sound drivers have been successfully autodetected (note that in this case, snd_intel8x0 and snd_usb_audio are the drivers for the hardware devices). You might also want to check the directory '''/dev/snd''' for the right device files:<br />
<br />
$ ls -l /dev/snd/<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 />
<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 />
<br />
If this is not the case, your sound modules have not been detected properly. '''If you want any help on IRC or the forums, please post the output of the above commands.''' To solve this, you can try loading the modules manually:<br />
<br />
* Locate the module for your soundcard: [http://www.alsa-project.org/main/index.php/Matrix:Main ALSA Soundcard Matrix] The module will be prefixed with 'snd-' (for example: 'snd-via82xx').<br />
* Load modules:<br />
# modprobe snd-NAME-OF-MODULE<br />
# modprobe snd-pcm-oss<br />
* Check for the device files in '''/dev/snd''' (see above) and/or try if '''alsamixer''' or '''amixer''' have reasonable output.<br />
* Add '''snd-NAME-OF-MODULE''' and '''snd-pcm-oss''' to the list of MODULES in '''/etc/rc.conf''' to ensure they are loaded next time (make sure '''snd-NAME-OF-MODULE''' is before '''snd-pcm-oss''').<br />
<br />
==Unmute the channels and test==<br />
<br />
In this section, we assume that you are logged in as root. If you want to perform these steps as an unprivileged user, you have to skip to the next section ''Setup Permissions'' first.<br />
<br />
* Unmute Soundcard<br />
<br />
The current version of ALSA installs with all channels '''muted by default''', so even if installation completes successfully and all devices are working properly you will hear no sound. You will need to unmute the channels manually. It is recommended to use '<code>alsamixer</code>' to accomplish this. From the alsamixer text ui, the label "MM" below a channel indicates that the channel is muted, and "00" indicates that it is open. Press the 'm' key to toggle MM/00. Use arrow-keys left and right to navigate through the channels and the arrow-keys up and down to adjust the volume. Such things as Master and PCM and possibly Speaker will need to unmuted for your sound to work.<br><br><br />
'''NOTE:''' When using '''<code>amixer</code>''', be sure to '''unmute''' as well as bring volumes up to a specific level in percent, i.e you need to use that % sign. '''<code>amixer</code>''' understands the percent sign (%), not numbers. If you use a number (say, 90) then '''<code>amixer</code>''' will take it as 100%, which can harm your speakers.<br />
<br />
# amixer set Master 90% unmute<br />
# amixer set PCM 85% unmute<br />
<br />
* Try to play a WAV file<br />
<br />
# aplay /usr/share/sounds/alsa/Front_Center.wav<br />
<br />
'''NOTE:''' Some cards (well, at least Soundblaster Audigy LS) need to have digital output muted/turned off in order to hear analog sound.<br />
<br />
If you cannot hear anything, double check your mixer settings, being sure to unmute PCM, MASTER (and some machines such as the IBM Thinkpad have an additional 'SPEAKER' channel) and try the alsaconf utility as root:<br />
# alsaconf<br />
<br />
* [[Allow multiple programs to play sound at once]]<br />
<br />
==Setup Permissions==<br />
<br />
To be able to use the sound card as a user, follow these steps:<br />
<br />
* Add your user to the audio group:<br />
# gpasswd -a USERNAME audio<br />
<br />
* Log your user out and back in to ensure the audio group is loaded.<br />
<br />
==Restore ALSA Mixer settings at startup==<br />
<br />
* Run 'alsactl' once to create '<code>/etc/asound.state</code>'<br />
<br />
alsactl store<br />
<br />
* Edit '/etc/rc.conf' and add 'alsa' to the list of daemons to start on boot-up. This will store the mixer settings on every shutdown and restore them when you boot.<br />
<br />
* If the mixer settings are not loaded on boot-up, add the following line to '<code>/etc/rc.local</code>'<br />
<br />
alsactl restore<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 don't have GNOME Volume Control installed,<br />
** Edit /etc/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 value:false. Change it to 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 />
* add following lines to /etc/rc.local:<br />
<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 />
<br />
amixer scontrols<br />
<br />
==KDE Settings==<br />
* Start up KDE:<br />
# startx<br />
<br />
* Set up the volumes as you want them for this user (each user has their own settings):<br />
# alsamixer<br />
<br />
log out and log back in as user xyz to get sound to work (I had to kill x logout then log back in as user xyz, then start x and open firefox and bam audio working on youtube)<br />
<br />
* <b>KDE 3.3</b> Go to K Menu > Multimedia > KMix<br />
** Choose Settings > Configure KMix...<br />
** Uncheck the option "Restore volumes on logon"<br />
** Press OK, and you should be all set. Now your volumes will be the same from the command line or within KDE.<br />
<br />
==System-Wide Equalizer==<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 />
* you will need, in addition to the aforementioned userspace utilities, alsa-plugins<br />
pacman -S alsa-plugins<br />
* get the ladspa and swh-plugins packages too if you don't already have them<br />
pacman -S ladspa swh-plugins<br />
* if you haven't already created either an ~/.asoundrc or a /etc/asound.conf file, then create either one<br />
vim ~/.asoundrc<br />
* insert the following into your alsa configuration file (~/.asoundrc or /etc/asound.conf)<br />
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've just installed them. Once you've logged<br />
# out/restarted this shouldn't 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're 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 />
<br />
*reload your alsa settings (as root)<br />
/etc/rc.d/alsa restart<br />
<br />
*you should be good to go (if not, ask in the forum)<br />
<br />
=Troubleshooting=<br />
==Still Getting No Sound?==<br />
<br />
Remember, ALSA installs with all channels '''muted by default''' (see previous section, [[ALSA#Unmuting_the_channels_and_testing_the_sound_card|unmuting your soundcard]]).<br />
<br />
However, if you're 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 blacklisting snd_pcsp from your modules array in rc.conf:<br />
<br />
MODULES=(!snd_pcsp ... )<br />
<br />
Note that this will disable your PC's internal speaker.<br />
If that doesn't work, then try adding the following line to <code>/etc/modprobe.conf</code>:<br />
<br />
options snd-NAME-OF-MODULE ac97_quirk=0<br />
<br />
The above fix has been observed to work with <code>via82xx</code><br />
options snd-NAME-OF-MODULE ac97_quirk=1<br />
The above fix has been reported to work with <code>snd_intel8x0</code><br />
<br />
==No Sound with Onboard Intel Sound Card==<br />
<br />
There may be an issue with two conflicting modules loaded, namely <code>snd_intel8x0</code> and <code>snd_intel8x0m</code>. In this case, edit <code>rc.conf</code> and in the MODULES array blacklist the latter one so that it reads <code>!snd_intel8x0m</code> afterwards.<br />
<br />
''Muting'' the "External Amplifier" in <code>alsamixer</code> or <code>amixer</code> may also help. See [http://alsa.opensrc.org/index.php/Intel8x0#Dell_Inspiron_8600_.28and_probably_others.29 the ALSA wiki].<br />
<br />
With '''Intel Corporation 82801 I (ICH9 Family) HD Audio Controller''' on laptop, you may need to add this line to<br />
<br />
/etc/modprobe.d/sound<br />
options snd-hda-intel model=laptop<br />
<br />
or<br />
options snd-hda-intel model=laptop enalbe=1 index=0<br />
<br />
Otherwise, the pcspkr may not work, and only the headphone have sound.<br />
<br />
==Poor Sound Quality?==<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 />
==Pops when Starting and Stopping Playback?==<br />
<br />
Some modules can power off your sound card when not in use. this can make an audible noise when powering down your sound card. If you find this annoying try "modinfo snd-MY-MODULE", and look for a module option that adjusts or disables this feature. <br />
<br />
for example: to disable the power saving mode using snd-hda-intel add "options snd-hda-intel power_save=0" in /etc/modprobe.conf. or try it with "modprobe snd-hda-intel power_save=0"<br />
<br />
==Alsamixer does not run==<br />
If running alsamixer does not work and you wind up with the following error<br />
alsamixer: function snd_ctl_open failed for default: No such device or directory<br />
<br />
You should first check /etc/group to ensure that your current user is in the 'audio' group. Don't forget to log out and log in again for the group changes.<br />
<br />
Then you might need to re-install your kernel. Run 'pacman -S kernel26' or whichever patchset you prefer to use.<br />
<br />
==S/PDIF output does not work==<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 />
as root.<br />
<br />
You can also put this command in rc.local as it sometimes it may stop working after a reboot.<br />
<br />
==No adjustable PCM channel==<br />
You may find that you lack adjustable PCM channel. In this case try to remove all sound-related stuff from MODULES section in /etc/rc.conf, except for snd-NAME-OF-MODULE and snd-pcm-oss.<br />
<br />
== HP TX2500 ==<br />
<br />
Add these 2 lines into /etc/modprobe.conf:<br />
<br />
options snd-cmipci mpu_port=0x330 fm_port=0x388<br />
<br />
options snd-hda-intel index=0 model=toshiba position_fix=1<br />
<br />
And don't forget to enable 'hal' in the DAEMONS section of your /etc/rc.conf<br />
<br />
== Skipping sound when playing MP3's ==<br />
<br />
If you have sound skipping when playing MP3 files and you have more then 2 speakers attacked to your computer (i.e. > 2 speaker system), run alsamixer and disable the channels for the speakers that you '''DON'T''' have (i.e. don't enable the sound for the center speaker if you don't have a center speaker<br />
<br />
= External Resources =<br />
More info can be found here<br />
* [http://alsa.opensrc.org/index.php/Main_Page Unofficial ALSA Wiki]<br />
* [http://alsa.opensrc.org/index.php/Aadebug A simple shell script to aid ALSA audio debugging]<br />
* [http://bbs.archlinux.org/viewtopic.php?id=36815 HOWTO: Compile driver from svn]<br />
* [http://gentoo-wiki.com/HOWTO_Set_up_a_system-wide_equaliser_with_ALSA_and_LADSPA HOWTO Set up a system-wide equaliser with ALSA and LADSPA]</div>Doze wormhttps://wiki.archlinux.org/index.php?title=Apache_OpenOffice&diff=54907Apache OpenOffice2008-12-05T07:09:19Z<p>Doze worm: /* Introduction */</p>
<hr />
<div>[[Category:Office (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|OpenOffice}}<br />
{{i18n_entry|Italiano|OpenOffice_(Italiano)}}<br />
{{i18n_entry|Ελληνικά|OpenOffice (Ελληνικά)}}<br />
{{i18n_entry|简体中文|OpenOffice_(简体中文)}}<br />
{{i18n_entry|Português|OpenOffice_(Português)}}<br />
{{i18n_entry|Türkçe|OpenOffice_(Türkçe)}}<br />
{{i18n_links_end}}<br />
==Introduction==<br />
[http://www.openoffice.org/ OpenOffice.org] is a leading open-source office software suite for word processing, spreadsheets, presentations, graphics, databases and more. <br />
<br />
Arch offers 3 trees of binary packages for OpenOffice with different pkg names:<br />
<br />
'''openoffice-base'''<br />
<br />
This will always be the last released stable version of OpenOffice. <br><br />
Current version: 3.0.0 <br><br />
start it with "soffice" or from Desktop menu <br><br />
<br />
'''openoffice-base-beta''' - currently not updated<br />
<br />
This package will be only present when a new release is not far away. It will be the alpha, beta, and release candidates packages for the next stable release. <br><br />
Current version: 3.0_ooo300_m6 (a version past 3.0 RC1 that will lead to stable 3.0 release) <br><br />
start it with "soffice-beta" or from Desktop menu <br><br />
It's safe to install it together with the stable and devel version.<br><br />
Please test it carefully and report upstream bugs to OpenOffice and packaging bugs in our flyspray <br><br />
see http://wiki.services.openoffice.org/wiki/OOoRelease30 for roadmap<br />
<br />
'''openoffice-base-devel'''<br />
<br />
This packages will be updated from time to time and is a playground for the packager and for testing latest features. Please test and file upstream issues at http://www.openoffice.org/issues/query.cgi<br><br />
Current version: 3.1_dev300_m35 / snapshot DEV300_m35 (snapshots past branching the 3.0 stable tree that will lead to 3.1 release and beyond) <br><br />
start it with "soffice-dev" or from Desktop menu <br><br />
It's safe to install it together with the stable and beta version<br />
Attention: if you play with more than one openoffice-base version it's highly recommended to always backup your<br />
configuration directory ~/.openoffice{2,3} !<br />
<br />
==Installation==<br />
* First, install a Java Runtime Environment (optional, highly recommended):<br />
# pacman -S openjdk6 or<br />
# pacman -S jre<br />
* Download the base for stable and/or beta and/or devel:<br />
# pacman -S openoffice-base openoffice-base-beta openoffice-base-devel<br />
<br />
===Extension management and spell checking for OpenOffice 3.x===<br />
* see [http://extensions.services.openoffice.org/getmore?cid=920794 OpenOffice Extension site]<br />
* Old openoffice-spell packages are obsolete. <br />
* Spell checking is done via new [http://extensions.services.openoffice.org/dictionary extensions]. There are three ways to install such a extension:<br />
* 1) Use the Extension manager from OOo menu for download and installation - installs only for the user into his ~/.openoffice.org/3/user/uno_packages/cache<br />
* 2) Download the extension and install it using "unopkg add extension" for the user or<br />
* 3) Download the extension and install it using "unopkg add --shared extension" for every user on the system (requires root permission)<br />
* 4) The Arch package is now shipped with some dictionaries and these get deployed automatically. Check Extension manager if your language is already there.<br />
<br />
If spellcheck does not work for you immediately after install, check the directory<br />
/opt/openoffice/share/extension/install<br />
Inside there should be several files called <br />
/opt/openoffice/share/extension/install/dict-<LANG>.oxt<br />
Use the Extension Manager to add your language dictionary; this often enables spellcheck.<br />
<br />
====French dictionary====<br />
As of openoffice 3.0.0-2 the french dictionary is buggy due to a character encoding problem. To solve this problem, first execute the following commands (you'll need '''zip''' and '''unzip''' packages):<br />
$ cp /opt/openoffice/share/extension/install/dict-fr.oxt dict-fr.oxt<br />
$ unzip dict-fr.oxt -d dict-fr<br />
$ cd dict-fr<br />
$ iconv -f ISO-8859-15 -t UTF-8 dictionaries.xcu > dictionaries.xcu.utf<br />
$ mv dictionaries.xcu.utf dictionaries.xcu<br />
$ zip ../dict-fr.oxt *<br />
$ cd ../<br />
$ rm -r dict-fr<br />
then go in the openoffice extension manager (Tools menu) and install the dictionary from the new dict-fr.oxt file.<br />
<br />
===Set OOo environment variable===<br />
OpenOffice2 introduced the ability to use several toolkits for drawing and integrates into different desktop environments in a clean way. To choose by hand, you need to set the OOO_FORCE_DESKTOP environment variable.<br />
<br />
To run OpenOffice.org in GTK2 mode, you can issue (using bash):<br />
# OOO_FORCE_DESKTOP=gnome soffice<br />
To run OpenOffice.org in QT/KDE3 mode, you can issue (using bash):<br />
# OOO_FORCE_DESKTOP=kde soffice<br />
<br />
{{Box Note | As KDE look will be removed in Openoffice3 it is highly recommended to use the GTK mode for all users. }}<br />
<br />
====Configure globally====<br />
To configure the look for anytime OpenOffice gets started, you can export the variable in one of the startup scripts, either system wide or for a specific user. <br />
<br />
Put<br />
export OOO_FORCE_DESKTOP=gnome<br />
in ~/.bashrc, ~/.config/openbox/autostart.sh, or similar to configure for one user. <br />
<br />
For all users, create the file "/etc/profile.d/openoffice.sh", put the export in there, and make the file executable.<br />
# chmod +x /etc/profile.d/openoffice.sh<br />
You could also put the export in /etc/profile directly, or in rc.local, but this is less clean.<br />
<br />
This export is obsolete for all OOo versions >= 3.0.0-2. Since that version the official package ships its own /etc/profile.d/openoffice.sh!<br />
<br />
====Environment variable scripts====<br />
If for whatever reason you don't want to configure the look globaly, as a non-gnome/kde user you may run into problems when trying to add the environment variable to the command in a *box menu, as such menus don't seem to like environment variables.<br />
<br />
This script will run openoffice using the GTK look while still accepting command line options like -writer.<br />
#!/bin/sh<br />
<br />
#### openoffice-gtk - A script to start openoffice with the GNOME/GTK environment<br />
<br />
OOO_FORCE_DESKTOP=gnome /opt/openoffice/program/soffice "$@"<br />
<br />
Just use this script as a command (e.g, /usr/bin/openoffice-gtk) for your menu or whatever other sort of launcher you use.<br />
<br />
{{Box Note | If you open a file in a filemanager, for example Thunar, the default look will be used, as the file association will not use your personal script. }}<br />
<br />
=== Adding media support to OpenOffice.org 2 ===<br />
<br />
If you want to be able to use sound and video in OpenOffice.org Impress presentations, you need to install the [[Java Media Framework]] and [[Java_Media_Framework#Adding_media_support_to_OpenOffice.org|configure OpenOffice.org to use it]]<br />
<br />
==Running OpenOffice==<br />
<br />
If you want to run a specific module of OpenOffice.org (instead of the soffice default), for example the word processor (Write), spreadsheet application (Calc) or presentation program (Impress), check for the following script front-ends:<br />
<br />
Writer<br />
/opt/openoffice/program/swriter<br />
<br />
Calc<br />
/opt/openoffice/program/scalc<br />
<br />
Impress<br />
/opt/openoffice/program/simpress<br />
<br />
Math (Formula Editor)<br />
/opt/openoffice/program/smath<br />
<br />
Base (Database frontend)<br />
/opt/openoffice/program/sbase<br />
<br />
Printer Administration (Recommended to run as root)<br />
/opt/openoffice/program/spadmin<br />
<br />
==Known Problems==<br />
* extension handling in versions >=3.0<br />
* qt look'n feel since kde4 release</div>Doze wormhttps://wiki.archlinux.org/index.php?title=Apache_OpenOffice&diff=54906Apache OpenOffice2008-12-05T07:08:41Z<p>Doze worm: /* Introduction */</p>
<hr />
<div>[[Category:Office (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
{{i18n_links_start}}<br />
{{i18n_entry|English|OpenOffice}}<br />
{{i18n_entry|Italiano|OpenOffice_(Italiano)}}<br />
{{i18n_entry|Ελληνικά|OpenOffice (Ελληνικά)}}<br />
{{i18n_entry|简体中文|OpenOffice_(简体中文)}}<br />
{{i18n_entry|Português|OpenOffice_(Português)}}<br />
{{i18n_entry|Türkçe|OpenOffice_(Türkçe)}}<br />
{{i18n_links_end}}<br />
==Introduction==<br />
[http://www.openoffice.org/ OpenOffice.org] is a leading open-source office software suite for word processing, spreadsheets, presentations, graphics, databases and more. <br />
<br />
Arch offers 3 trees of binary packages for OpenOffice with different pkg names:<br />
<br />
'''openoffice-base'''<br />
<br />
This will always be the last released stable version of OpenOffice. <br><br />
Current version: 3.0.0 <br><br />
start it with "soffice" or from Desktop menu <br><br />
<br />
'''openoffice-base-beta''' - currently not updated<br />
<br />
This package will be only present when a new release is not far away. It will be the alpha, beta, and release candidates packages for the next stable release. <br><br />
Current version: 3.0_ooo300_m6 (a version past 3.0 RC1 that will lead to stable 3.0 release) <br><br />
start it with "soffice-beta" or from Desktop menu <br><br />
It's safe to install it together with the stable and devel version.<br><br />
Please test it carefully and report upstream bugs to OpenOffice and packaging bugs in our flyspray <br><br />
see http://wiki.services.openoffice.org/wiki/OOoRelease30 for roadmap<br />
<br />
'''openoffice-base-devel'''<br />
<br />
This packages will be updated from time to time and is a playground for the packager and for testing latest features. Please test and file upstream issues at http://www.openoffice.org/issues/query.cgi<br><br />
Current version: 3.1_dev300_m35 / snapshot DEV300_m33 (snapshots past branching the 3.0 stable tree that will lead to 3.1 release and beyond) <br><br />
start it with "soffice-dev" or from Desktop menu <br><br />
It's safe to install it together with the stable and beta version<br />
Attention: if you play with more than one openoffice-base version it's highly recommended to always backup your<br />
configuration directory ~/.openoffice{2,3} !<br />
<br />
==Installation==<br />
* First, install a Java Runtime Environment (optional, highly recommended):<br />
# pacman -S openjdk6 or<br />
# pacman -S jre<br />
* Download the base for stable and/or beta and/or devel:<br />
# pacman -S openoffice-base openoffice-base-beta openoffice-base-devel<br />
<br />
===Extension management and spell checking for OpenOffice 3.x===<br />
* see [http://extensions.services.openoffice.org/getmore?cid=920794 OpenOffice Extension site]<br />
* Old openoffice-spell packages are obsolete. <br />
* Spell checking is done via new [http://extensions.services.openoffice.org/dictionary extensions]. There are three ways to install such a extension:<br />
* 1) Use the Extension manager from OOo menu for download and installation - installs only for the user into his ~/.openoffice.org/3/user/uno_packages/cache<br />
* 2) Download the extension and install it using "unopkg add extension" for the user or<br />
* 3) Download the extension and install it using "unopkg add --shared extension" for every user on the system (requires root permission)<br />
* 4) The Arch package is now shipped with some dictionaries and these get deployed automatically. Check Extension manager if your language is already there.<br />
<br />
If spellcheck does not work for you immediately after install, check the directory<br />
/opt/openoffice/share/extension/install<br />
Inside there should be several files called <br />
/opt/openoffice/share/extension/install/dict-<LANG>.oxt<br />
Use the Extension Manager to add your language dictionary; this often enables spellcheck.<br />
<br />
====French dictionary====<br />
As of openoffice 3.0.0-2 the french dictionary is buggy due to a character encoding problem. To solve this problem, first execute the following commands (you'll need '''zip''' and '''unzip''' packages):<br />
$ cp /opt/openoffice/share/extension/install/dict-fr.oxt dict-fr.oxt<br />
$ unzip dict-fr.oxt -d dict-fr<br />
$ cd dict-fr<br />
$ iconv -f ISO-8859-15 -t UTF-8 dictionaries.xcu > dictionaries.xcu.utf<br />
$ mv dictionaries.xcu.utf dictionaries.xcu<br />
$ zip ../dict-fr.oxt *<br />
$ cd ../<br />
$ rm -r dict-fr<br />
then go in the openoffice extension manager (Tools menu) and install the dictionary from the new dict-fr.oxt file.<br />
<br />
===Set OOo environment variable===<br />
OpenOffice2 introduced the ability to use several toolkits for drawing and integrates into different desktop environments in a clean way. To choose by hand, you need to set the OOO_FORCE_DESKTOP environment variable.<br />
<br />
To run OpenOffice.org in GTK2 mode, you can issue (using bash):<br />
# OOO_FORCE_DESKTOP=gnome soffice<br />
To run OpenOffice.org in QT/KDE3 mode, you can issue (using bash):<br />
# OOO_FORCE_DESKTOP=kde soffice<br />
<br />
{{Box Note | As KDE look will be removed in Openoffice3 it is highly recommended to use the GTK mode for all users. }}<br />
<br />
====Configure globally====<br />
To configure the look for anytime OpenOffice gets started, you can export the variable in one of the startup scripts, either system wide or for a specific user. <br />
<br />
Put<br />
export OOO_FORCE_DESKTOP=gnome<br />
in ~/.bashrc, ~/.config/openbox/autostart.sh, or similar to configure for one user. <br />
<br />
For all users, create the file "/etc/profile.d/openoffice.sh", put the export in there, and make the file executable.<br />
# chmod +x /etc/profile.d/openoffice.sh<br />
You could also put the export in /etc/profile directly, or in rc.local, but this is less clean.<br />
<br />
This export is obsolete for all OOo versions >= 3.0.0-2. Since that version the official package ships its own /etc/profile.d/openoffice.sh!<br />
<br />
====Environment variable scripts====<br />
If for whatever reason you don't want to configure the look globaly, as a non-gnome/kde user you may run into problems when trying to add the environment variable to the command in a *box menu, as such menus don't seem to like environment variables.<br />
<br />
This script will run openoffice using the GTK look while still accepting command line options like -writer.<br />
#!/bin/sh<br />
<br />
#### openoffice-gtk - A script to start openoffice with the GNOME/GTK environment<br />
<br />
OOO_FORCE_DESKTOP=gnome /opt/openoffice/program/soffice "$@"<br />
<br />
Just use this script as a command (e.g, /usr/bin/openoffice-gtk) for your menu or whatever other sort of launcher you use.<br />
<br />
{{Box Note | If you open a file in a filemanager, for example Thunar, the default look will be used, as the file association will not use your personal script. }}<br />
<br />
=== Adding media support to OpenOffice.org 2 ===<br />
<br />
If you want to be able to use sound and video in OpenOffice.org Impress presentations, you need to install the [[Java Media Framework]] and [[Java_Media_Framework#Adding_media_support_to_OpenOffice.org|configure OpenOffice.org to use it]]<br />
<br />
==Running OpenOffice==<br />
<br />
If you want to run a specific module of OpenOffice.org (instead of the soffice default), for example the word processor (Write), spreadsheet application (Calc) or presentation program (Impress), check for the following script front-ends:<br />
<br />
Writer<br />
/opt/openoffice/program/swriter<br />
<br />
Calc<br />
/opt/openoffice/program/scalc<br />
<br />
Impress<br />
/opt/openoffice/program/simpress<br />
<br />
Math (Formula Editor)<br />
/opt/openoffice/program/smath<br />
<br />
Base (Database frontend)<br />
/opt/openoffice/program/sbase<br />
<br />
Printer Administration (Recommended to run as root)<br />
/opt/openoffice/program/spadmin<br />
<br />
==Known Problems==<br />
* extension handling in versions >=3.0<br />
* qt look'n feel since kde4 release</div>Doze worm