This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
awesome/zh-cn
Warning: Display title "awesome/zh-cn" overrides earlier display title "Awesome".
awesome 是 一个高度可定制的用于X的下一代动态窗口管理器。 它主要定位于顶级用户、开发者、每天都要与计算任务打交道的人以及那些想要很好的控制他们图形界面环境的人。它使用Lua编程语言进行扩展。
安装
USE 标志
USE flags for x11-wm/awesome 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
配置
启动
通过一个 display manager 或者输入 startx来启动 awesome.
使用 startx启用 ConsoleKit 支持, 设置 ConsoleKit 创建如下文件:
~/.xinitrc
exec ck-launch-session 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.lua
Setting a specific background using the wallpaper propertytheme.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 的时候后台启动 volumeiconvolumeicon & exec ck-launch-session dbus-launch awesome
另外,一个更轻量的方法是直接在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/mpc 给 MPD 添加多媒体键绑定:
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
Setting size_hints_honor propertyawful.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.lua
Alt-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),) -- }}}
外部资源
- awesome wiki 上的用户配置文件