Awesome

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Awesome and the translation is 55% complete.
Outdated translations are marked like this.


awesome 是 一个高度可定制的用于X的下一代动态窗口管理器。 它主要定位于顶级用户、开发者、每天都要与计算任务打交道的人以及那些想要很好的控制他们图形界面环境的人。它使用Lua编程语言进行扩展。

服务

仅选择以下之一:

  • elogind:独立的 logind 包,从 systemd 项目中提取,用于 OpenRC 或其他初始化系统。
  • systemd:使用 systemd 的会话跟踪器部分。 systemd 的用户在这里不需要采取任何其他措施。

杂项

  • D-Bus:启用 D-Bus 消息总线系统。
  • polkit:启用 polkit 框架以获得控制全局服务的权限。
  • udisks:启用对一些存储相关服务的支持。

X 服务

按照 Xorg/Guide/zh-cn 上的说明设置 X 环境。

启动 X 服务器

可以使用以下方法之一启动 X

安装

USE 标记

USE flags for x11-wm/awesome A dynamic floating and tiling window manager

dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
gnome Add GNOME support
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)

安装

安装 x11-wm/awesome:

root #emerge --ask x11-wm/awesome

配置

启动

要启动 awesome,请参阅启动 X 服务或使用命令 startx

要在 elogind 支持下使用 startx,设置 elogind 并创建如下文件:

文件 ~/.xinitrc
exec dbus-launch --sh-syntax --exit-with-session awesome

配置文件

Awesome的默认配置文件位于 ~/.config/awesome/rc.lua. 如果该文件不存在,那么你需要创建一个。awesome安装好带有一个默认的配置文件位于 /etc/xdg/awesome/rc.lua. 将该文件复制到用户的主目录中。

第一步,创建目录 awesome/ :

user $mkdir -p ~/.config/awesome/

接着,复制配置文件 rc.lua :

user $cp /etc/xdg/awesome/rc.lua ~/.config/awesome/rc.lua

如果 x11-terms/xterm 没有安装, 要么安装它,要么将默认的终端模拟器改为系统中其它可用的终端。如下,将系统默认终端改为konsole, 该终端在软件包 kde-apps/konsole中.

文件 ~/.config/awesome/rc.lua
-- This is used later as the default terminal and editor to run.
terminal = "konsole"

作好更改后,检查配置文件是否有错误是非常有用的:

user $awesome -k
✔ Configuration file syntax OK

通过软件包media-gfx/feh 添加壁纸支持:

root #emerge --ask media-gfx/feh

例如,要用awsetbg 设置壁纸,编辑~/.config/awesome/theme/theme.lua

文件 ~/.config/awesome/theme/theme.lua使用awsetbg设置指定的背景
theme.wallpaper_cmd = { "awsetbg -f .config/awesome/themes/awesome-wallpaper.png" }

或者简单地设置主题的壁纸:

文件 ~/.config/awesome/theme/theme.luaSetting a specific background using the wallpaper property
theme.wallpaper = ".config/awesome/themes/awesome-wallpaper.png"

标签

awesome中, 标签指定了虚拟桌面——每个虚拟桌面运行一个或多个应用程序——的名字。可以给每个标签分配自定义的符号:

文件 ~/.config/awesome/rc.lua
-- {{{ Tags
tags = {}
for s = 1, screen.count() do
    tags[s] = awful.tag({ "➊", "➋", "➌", "➍" }, s, layouts[1])
end
-- }}}

菜单

下面是一个定制的 awesome菜单的例子:

文件 ~/.config/awesome/rc.lua
-- {{{ Menu
myawesomemenu = {
   { "manual", terminal .. " -e man awesome" },
   { "edit config", editor_cmd .. " " .. awesome.conffile },
   { "reload", awesome.restart },
   { "quit", awesome.quit },
   { "reboot", "reboot" },
   { "shutdown", "shutdown" }
}
 
appsmenu = {
   { "urxvt", "urxvt" },
   { "sakura", "sakura" },
   { "ncmpcpp", terminal .. " -e ncmpcpp" },
   { "luakit", "luakit" },
   { "uzbl", "uzbl-browser" },
   { "firefox", "firefox" },
   { "chromium", "chromium" },
   { "thunar", "thunar" },
   { "ranger", terminal .. " -e ranger" },
   { "gvim", "gvim" },
   { "leafpad", "leafpad" },
   { "htop", terminal .. " -e htop" },
   { "sysmonitor", "gnome-system-monitor" }
}
 
gamesmenu = {
   { "warsow", "warsow" },
   { "nexuiz", "nexuiz" },
   { "xonotic", "xonotic" },
   { "openarena", "openarena" },
   { "alienarena", "alienarena" },
   { "teeworlds", "teeworlds" },
   { "frozen-bubble", "frozen-bubble" },
   { "warzone2100", "warzone2100" },
   { "wesnoth", "wesnoth" },
   { "supertuxkart", "supertuxkart" },
   { "xmoto" , "xmoto" },
   { "flightgear", "flightgear" },
   { "snes9x" , "snes9x" }
}
 
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu },
                                    { "apps", appsmenu },
				    { "games", gamesmenu },
                                    { "terminal", terminal },
				    { "web browser", browser },
				    { "text editor", geditor }
                                  }
                        })
 
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
                                     menu = mymainmenu })
-- }}}

日期

下面是一个定制日期格式的例子,使用的是%d.%m %H:%M格式。第二个选项,60,指定多少秒更新一次。

文件 ~/.config/awesome/rc.lua创建文本时钟小部件
-- {{{ Wibox
-- Create a text-clock widget
mytextclock = wibox.widget.textclock(" %d.%m %H:%M ", 60)
-- }}}
附注
更多关于格式的选项的信息可以执行 date --help

音量控制

media-sound/volumeicon 可用来用于自动处理音量键,并且通过托盘图标显示音量。

root #emerge --ask media-sound/volumeicon

~/.xinitrc中设置自动启动volumeicon

文件 ~/.xinitrc当启动 X 时在后台加载 volumeicon
volumeicon &
exec [...]

另外,一个更轻量的方法是直接在awesome中配置音量键:

文件 ~/.config/awesome/rc.lua音量键
awful.key({ }, "XF86AudioLowerVolume", function () awful.util.spawn("amixer -q sset Master 2dB-") end)
awful.key({ }, "XF86AudioRaiseVolume", function () awful.util.spawn("amixer -q sset Master 2dB+") end)

MPD 多媒体键

安装 media-sound/mpcMPD 添加多媒体键绑定:

root #emerge --ask media-sound/mpc

然后更新 awesome配置,给多媒体键分配合适的命令:

文件 ~/.config/awesome/rc.lua音量键绑定
awful.key({ }, "XF86AudioNext",function () awful.util.spawn( "mpc next" ) end),
awful.key({ }, "XF86AudioPrev",function () awful.util.spawn( "mpc prev" ) end),
awful.key({ }, "XF86AudioPlay",function () awful.util.spawn( "mpc play" ) end),
awful.key({ }, "XF86AudioStop",function () awful.util.spawn( "mpc pause" ) end),

清除窗口间隙

窗口之间的间隙是可见的,终端窗口之间最明显。可以通过在awful.rules.rules像这样插入size_hints_honor = false 来移除:

文件 ~/.config/awesome/rc.lua设置 size_hints_honor 属性
awful.rules.rules = {
    { rule = { },
      properties = { size_hints_honor = false, -- Remove gaps
                     border_width = beautiful.border_width,
                     border_color = beautiful.border_normal,
      ...

使用 Xephyr 调试配置

Xephyr 是一个非常有用的调试新配置文件的工具,它会在一个客户端窗口中创建一个X服务器的实例:

user $Xephyr -ac -nolisten tcp -br -noreset -screen 800x600 :1

这将打开一个800x600的窗口。在其中打开终端,执行下面的命令运行 awesome:

user $DISPLAY=:1.0 awesome

这将在窗口中运行 awesome。

快捷键

这些是最有用的默认的快捷键:

  • mod4+mouse1 = 使用鼠标移动客户端
  • mod4+mouse2 = 使用鼠标缩放客户端
  • mod4+enter = 打开终端
  • mod4+r = 运行命令
  • mod4+shift+c = kill
  • mod4+m = 最大化
  • mod4+n = 最小化
  • mod4+ctrl+n = 回复最小化的客户端
  • mod4+f = 全屏
  • mod4+tab = 切换到前一个客户端
  • mod4+ctrl+space = float
  • mod4+j = 高亮左侧客户端
  • mod4+k = 高亮左侧客户端
  • mod4+shift+j = 移动右侧客户端
  • mod4+shift+k = 移动右侧客户端
  • mod4+l = 调整平铺客户端的大小
  • mod4+h = 调整平铺客户端的大小
  • mod4+left / right = 切换标签
  • mod4+1-9 = 切换标签
  • mod4+shift+1-9 = 发送客户点到标签

定制键的绑定,例如 Alt+Tab,可以增强awesome的使用体验。例如,把Alt+Tab绑定到切换至前一个窗口:

文件 ~/.config/awesome/rc.luaAlt-TAB 键绑定
-- {{{ Key bindings
globalkeys = awful.util.table.join(
...
    -- alt + tab
    awful.key({ "Mod1", }, "Tab",
        function ()
            awful.client.focus.history.previous()
            if client.focus then
                client.focus:raise()
            end
        end),
-- }}}

外部资源