FAQ/zh

为什么叫awesome?
awesome 这个名字来自于英文单词awesome 经常被电视剧 HIMYM 中的角色Barney Stinson 所使用.

awesome 依赖包?
查看 README.

如何改变默认的窗口管理布局?
在默认配置文件中所有的标签使用同一个布局,设置成 floating. 你可以通过编辑 rc.lua 中的标签创建循环语句进行修改:

-- Each screen has its own tag table. tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])

注意默认的设置为所有的标签使用在前面的部分定义的窗口布局表中的第一种. 改变布局编号可以使用其他的窗口布局类型.

如何设置每个标签的名字和布局?
你可以修改配置文件中的标签创建部分,有很多种方法都可以实现,下面显示了其中的一种:

--

如何在每个不同的屏幕中设置不同的标签和布局?
下面显示了标签段的另一种示例代码:

--

如何自动启动程序?
传统的方法是使用 ~/.xinitrc ,你可以查看 Autostart 页寻找其它的解决方案.

如何使用多显示器?
Awesome能够真正支持每个屏幕桌面(标签)的多点输入 (XRandR, Xinerama or Zaphod 模式), 在它的发布包中的示例配置文件中已经设置好为多显示器使用(输入框, 任务条, 挂件以及允许你在不同的屏幕中移动程序和切换焦点后的输入). 查看 "Using Multiple Screens" 的完全手册以获得更多的说明.

当我离开时如何锁定屏幕?
你可使用一些屏幕锁定程序: xlock, xscreensaver, slock, kscreenlocker...

然后在 globalkeys 绑定快捷键,示例:

awful.key({ modkey }, "F12", function awful.util.spawn("xlock") end)

如何执行Shell命令?
如果你想执行shell命令或者一些用户命令,管道命令等等,不要使用 awful.util.spawn 函数,而应该用 awful.util.spawn_with_shell. 示例:

awful.key({ modkey }, "F10", function awful.util.spawn_with_shell("cal -m | xmessage -timeout 10 -file -") end)

How to fix and improve usability of Java applications?
Java applications which use the XToolkit/XAWT back-end may draw grey windows only. The XToolkit/XAWT back-end breaks ICCCM-compliance in recent JDK 1.5 and early JDK 1.6 versions, because it assumes a reparenting window manager. You can find solutions and workarounds on the Problems with Java wiki page.

How to remove gaps between windows?
In awesome 3.4 you can add size_hints_honor = false to the properties section in your awful.rules.rules table, it will match and apply this rule to all clients. As an alternative (or in older versions) you can do it by adding c.size_hints_honor = false in the manage signal function (or manage hook in older versions).

If you want to know what are size hints it has been debated many times on the mailing list, so you can read the explanation: http://www.mail-archive.com/awesome@naquadah.org/msg01767.html

如何控制标题条?
要在所有的客户程序中禁止标题条你应该从 manage 信号处理过程中移除包含内容 awful.titlebar.add(c, { modkey = modkey }) 的行(老版本中为 manage 钩子过程). 如果你只需要特定的客户显示标题条, 不需要那么做, 你可以在 awful.rules.rules 表中加入规则就可以了. 示例规则:

{ rule = { class = "Gimp" }, callback = awful.titlebar.add },

How to add an application switcher?
You can use the Clients Menu as an application switcher. By default it will open if you right-click on your taskbar, but you may also bind it to a key combination. Here is an example, toggled by "Alt + Esc", that you can add to your globalkeys:

awful.key({ "Mod1" }, "Escape", function      -- If you want to always position the menu on the same place set coordinates      awful.menu.menu_keys.down = { "Down", "Alt_L" }      local cmenu = awful.menu.clients({width=245}, { keygrabber=true, coords={x=525, y=330} })  end),

How to configure and use widgets?
You can learn all about widgets, and how to create them on the Widgets in awesome page.

Some users created widget libraries applying the above principles. They try to simplify widget creation for others, and have the advantage of being distributed with a big number of system monitors, so you don't have to write your own. Two popular projects are Vicious and Obvious.

How to setup horizontal widgets on a vertical wibox?
Left or right placement of the wibox is cool, but vertical text is hard to read. At the moment, in awesome v3.4, it is tricky to get a perfect result, but in the development branch of awesome the widget layouts have already been rewritten with this in mind. This code allows to easily setup complex vertical panels, like some desktop environments provide.

How to toggle wibox visibility?
Add the following key binding to your globalkeys:

awful.key({ modkey }, "b", function      mywibox[mouse.screen].visible = not mywibox[mouse.screen].visible  end),

如何切换窗口的浮动状态?
默认的配置文件 rc.lua 中已经有一个快捷键 "Mod4 + Control + Space" 绑定为该功能. 你可以按自己的习惯简单的修改它, 比如设为 "Mod4 + f" 或者 "Mod4 + Shift + f".

awful.key({ modkey, "Shift" }, "f", awful.client.floating.toggle ),

为什么一些浮动的窗口不能为自动平铺好?
一些应用程序(如:Firefox, Opera...)浮动出来又不能自动平铺, 而且可能还有一些奇怪的特性(不能被打标, 总是在最前面...), 不用担心, 这只是在最近调用窗口被最大化了, 默认的快捷键 "Mod4 + m" 可以切换它的最大化状态.

你可以确保在 awful.rules.rules 表的规则中没有应用程序被定义为最大化启动, 对所有的程序应用可以添加:

-- Search for this rule, keys = clientkeys, -- add the following two: maximized_vertical  = false, maximized_horizontal = false,

如何用键盘移动和调整浮动窗口?
你可以使用 awful.client.moveresize 函数. 在下面的 clientkeys 示例中移动浮窗使用 "Mod4 + Arrow keys" 而调整浮窗大小使用 "Mod4 + PgUP/DN" 键:

awful.key({ modkey }, "Next", function  awful.client.moveresize( 20,  20, -40, -40) end), awful.key({ modkey }, "Prior", function awful.client.moveresize(-20, -20,  40,  40) end), awful.key({ modkey }, "Down", function  awful.client.moveresize(  0,  20,   0,   0) end), awful.key({ modkey }, "Up",   function  awful.client.moveresize(  0, -20,   0,   0) end), awful.key({ modkey }, "Left", function  awful.client.moveresize(-20,   0,   0,   0) end), awful.key({ modkey }, "Right", function awful.client.moveresize( 20,   0,   0,   0) end),

如何调整排列窗口的大小?
你可以使用 awful.tag.incmwfact 函数调整主应用和 awful.client.incwfact 函数调整从应用窗口的大小. globalkeys 中设置示例如下:

awful.key({ modkey }, "l",         function  awful.tag.incmwfact( 0.05) end), awful.key({ modkey }, "h",         function  awful.tag.incmwfact(-0.05) end), awful.key({ modkey, "Shift" }, "l", function awful.client.incwfact(-0.05) end), awful.key({ modkey, "Shift" }, "h", function awful.client.incwfact( 0.05) end),

如何在awesome运行的时候改变配置?
你可以修改 rc.lua, 但是你必须重启 awesome 以生效. 默认的重启 awesome 快捷键绑定为 "Mod4 + Control + r".

如何改变光标主题?
光标重置为默认外观的原因是因XCB不支持Xcursor. 在邮件列表a few times中曾被讨论过.

使用xsetroot 命令可以使用你的光标主题启用:

$ xsetroot -cursor_name left_ptr

你可以将上面的命令加入 ~/.xinitrc 文件. 另一个通用的解决方案是使用 Neutral Plus 主题, 这个光标主题和X默认主题类似,但是包括了阴影和动画效果.

如何找出窗口的类名以及其它的一些标识信息?
你可以使用 xprop 工具, 你可以观注输出信息中的 WM_CLASS 和 WM_NAME 部分:

$ xprop

当光标变为 "+" 时点击你想查看的客户窗口,在它的输出信息中你可以参考下面的图示应用在awesome的match中:

WM_CLASS(STRING) = "smplayer", "Smplayer" |          |                      |           |--- class |                     |--- instance WM_NAME(STRING) = "SMPlayer" |                    |--- name

或者你也可以将以下的别名放入Shell的配置文件中, 可以快速获取当前客户窗口的信息(你可以将 xmessage 替换成 zenity 或者 notify-send 给 Naughty 使用):

xpop= $( xprop | grep --color=none "WM_CLASS\|^WM_NAME" | xmessage -file - )

你可以将上面的标识信息(实例,类和名称)应用于 awful.rules.rules 表中进行匹配, 打标或者其它一些操作. 查看后面的FAQ和示例.

How to start clients on specific tags and others as floating?
You can add matching rules to your awful.rules.rules table. The default rc.lua already has several examples, but here are some more:

-- Set Firefox to always map on tag number 2 of screen 1 { rule = { class = "Firefox" }, properties = {tag = tags[1][2]}}, -- Set Smplayer to tag 4 of screen 1 { rule = { class = "Smplayer" }, properties = {tag = tags[1][4]}}, -- Set Emacs to tag 5 of screen 2 { rule = { class = "Emacs", instance = "emacs" }, properties = {tag = tags[2][5]}}, -- Set Alpine to tag 6 of the last screen { rule = { name = "Alpine" },   properties = {tag = tags[screen.count][6]}}, -- Set Akregator to tag 8 of the last screen and add a titlebar trough callback { rule = { class = "Akregator" },properties = {tag = tags[screen.count][8]}, callback = awful.titlebar.add}, -- Set Xterm to multiple tags on screen 1 { rule = { class = "XTerm" }, callback = function(c) c:tags({tags[1][5], tags[1][6]}) end}, -- Set ROX-Filer to tag 2 of the currently selected and active screen { rule = { class = "ROX-Filer" }, callback = function(c) awful.client.movetotag(tags[mouse.screen][2], c) end}, -- Set Geeqie to the currently focused tag, as floating { rule = { instance = "geeqie" }, properties = {floating = true}}, -- Set Xterm as floating with a fixed position { rule = { class = "XTerm" }, properties = {floating = true}, callback = function(c) c:geometry({x=0, y=0}) end},

如何启动客户程序作为从窗口而不是主窗口?
你可以设置下面的规则让所有客户程序的窗口打开始为从窗口:

-- Start windows as slave { rule = { }, properties = { }, callback = awful.client.setslave }

How to use a keycode in a keybinding?
You can use the format #XYZ for keycodes in your bindings. The following example shows a mapped multimedia/extra key, that's why the modifier is not present (but it could be):

awful.key({}, "#160", function exec("kscreenlocker --forcelock") end),

How to add a keyboard layout switcher ?
You can use the xxkb utility. It has a tray icon and supports settings layouts per client. As an alternative you can use an awesome widget, you can even find some examples on the "Change keyboard maps" wiki page, or in the Obvious widget library.

I can also be done by adding a keybind to awful.util.spawn("setxkbmap ")

How to use this thing?
Default binding to open a terminal is "Mod4 + Enter" (where Mod4 is usually the "Windows" key). You can also click on the desktop background with the right button, to open the awesome menu.

From there you can proceed to open man awesome which has a good guide, including the list of default keybindings.

Layouts
With the default config, you can cycle through window layouts by pressing mod4+space (mod4+shift+space to go back) or clicking the layout button in the upper right corner of the screen.

See the layout page for descriptions of what the different layouts do.

怎样重启或者退出awesome？
你可以使用快捷键 "Mod4+Ctrl+r" 或者在菜单中选择 restart 来重启awesome. 也可以在Lua prompt widget中调用 awesome.restart ，或者把它传给awesome-client:

$ echo 'awesome.restart' | awesome-client

也可以发送 SIGHUP 信号到 awesome 进程. 用ps, pgrep 查找PID， 或者用 pkill:

$ pkill -HUP awesome

你可以使用快捷键 "Mod4+Shift+q" 或者在菜单中选择quit来退出awesome. 也在Lua prompt widget中调用 awesome.quit ，或者把它传给 awesome-client.

$ echo 'awesome.quit' | awesome-client

也可以发送 SIGINT 信号到 awesome 进程. 用ps, pgrep 查找PID， 或者用 pkill:

$ pkill -INT awesome

Where are logs, error messages or something?
When hacking your own configuration, something inevitably would go wrong. awesome prints error messages to its stderr stream. When run with usual $ startx, it'd be printed right in tty. If you use something more complicated (some kind of DM, like kdm or gdm), stderr is usually redirected somewhere else. To see where, run the following command:

$ ls -l /proc/$(pidof awesome)/fd/2

There's handy way to run awesome and redirect both its standard output and error streams to files:

exec /usr/bin/awesome >> ~/.cache/awesome/stdout 2>> ~/.cache/awesome/stderr

If you put it into .xinitrc (for startx) or ~/.xsession (qingy uses it, for example), you'll be able to watch (with tail -f) everything right from awesome.

如何报告 bugs?
首先请测试开发版本看bug是否依然存在. 如果bug类型是与你期待的目的不一致,请说明你想更改的后的情况. 如果bug是段错误,请提交完整的backtrace (使用 gdb).

你可以提交到这里: http://awesome.naquadah.org/bugs/

请尽可能地说明如何再现bug.

是否接受补丁和程序?
当然.请发送给 Julien 或者邮件列表. 请查看 development page.

如何跟踪 awesome-branches?
用git clone开发版源程序:

git clone git://git.naquadah.org/awesome.git/ cd awesome/

如获取分支 'awesome-3':

git fetch origin awesome-3:awesome-3 git checkout awesome-3

git-branch 将提示你当前所在的分支. 在一些系统版本中你可以通过按 键补全git命令.

在awesome目录中运行下面的命令可以更新 'awesome-3' 分支:

git fetch origin git reset --hard origin/awesome-3

创建补丁:

git clone git://git.naquadah.org/awesome.git/ edit file git commit filename git format-patch origin

将产生类似于下面的文件 0001-the-title-you-gave-it.patch