首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

有趣的 Ion 窗口管理器程序清单(1)

有趣的 Ion 窗口管理器程序清单(1)

以下是我的 ion.lua 配置文件。Lua 是一门非常复杂的语言,但是您会立刻就明白“--”表示的是注释的开始。
清单 1. ion.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--
-- Ion main configuration file
--
-- Modules.
load_module("query")
load_module("menu")
load_module("ionws")
load_module("floatws")
load_module("dock")
-- Set default modifier. Alt should usually be mapped to Mod1 on
-- XFree86-based systems. The flying window keys are probably Mod3
-- or Mod4; see the output of 'xmodmap'.
DEFAULT_MOD = "Mod1+"
-- Maximum delay between clicks in milliseconds to be considered a
-- double click.
--set_dblclick_delay(250)
-- For keyboard resize, time (in milliseconds) to wait after latest
-- key press before automatically leaving resize mode (and doing
-- the resize in case of non-opaque move).
--set_resize_delay(1500)
-- Opaque resize?
enable_opaque_resize(true)
-- Movement commands warp the pointer to frames instead of just
-- changing focus. Enabled by default.
enable_warp(true)
-- Kludges to make apps behave better.
include("kludges")
-- Make some bindings.
include("tzz-ion-bindings")
-- Define some menus (menu module required to actually use them)
include("ion-menus")
-- How to shorten window titles when the full title doesn't fit in
-- the available space? The first-defined matching rule that succeeds
-- in making the title short enough is used.
add_shortenrule("(.*) - Mozilla(<[0-9]+>)", "$1$2$|$1$<...$2")
add_shortenrule("(.*) - Mozilla", "$1$|$1$<...")
add_shortenrule("XMMS - (.*)", "$1$|...$>$1")
add_shortenrule("[^:]+: (.*)(<[0-9]+>)", "$1$2$|$1$<...$2")
add_shortenrule("[^:]+: (.*)", "$1$|$1$<...")
add_shortenrule("(.*)(<[0-9]+>)", "$1$2$|$1$<...$2")
add_shortenrule("(.*)", "$1$|$1$<...")
-- List of directories to look for manuals in the F1 man page query.
query_man_    "/usr/man",
    "/usr/share/man",
    "/usr/X11R6/man",
    "/usr/local/man"
}




lua 已经出现了大约十年,但它到现在还没有广为人知。它不同于我所了解的其他任何脚本语言,并且我也不是惟一发现它有些难用的 Ion 用户。据说一旦您习惯了使用它,您将获益匪浅。
如果您用清单 1 中的设置与 Ion 2 所附带的默认的 ion.lua 进行比较,您将发现,它们没有太多的不同。我的 ion.lua 主要用来加载已经定制的后继 Lua 文件,稍后您将看到这一点。
我的 draw.lua 文件控制的是 Ion 2 中的绘制选项,它们完全是从 Ion 附带的默认 look-clean.lua 中复制而来,所以在这里没有对它们进行讨论。look-clean.lua 文件有很好的注释,所以,如果您想定制 Ion 的颜色和外观,应该去通读该文件。我在 draw.lua 文件中所做的惟一修改是将帧标题的字体变得更大,因为不管在哪里,我都喜欢大字体(为了让眼睛得到休息,您应该使用所能使用的最大字体)。
全局键绑定位于 tzz-ion-bindings.lua 中。如果您键盘上的具体符号的位置与我的不同,那么您应该重新分配它们。例如,我分配给工作台 0 到 6 的键,在数字键区上,这些数字构成了 3/4 个圆。您可以使用 xev 程序来找出用于重新映射的键的名称。
记住,DEFAULT_MOD 是 Mod1,即普通的 Linux(和大部分 UNIX)系统中的 Alt 键。Alt 键也称为 Meta 键,不过,在 Emacs 中,您当然可以通过 Esc 键来访问 Meta,(而在 Solaris 中,Meta 键看起来像是一颗钻石,Alt 键就只是 Alt 键)。如果您能理解最后一句话,那么您就会赞同我的观点!
清单 2. tzz-ion-bindings.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
-- Load a library to create common queries.
include("querylib")
-- Load a library to create menu display callbacks.
include("menulib")
global_bindings{
-- use the keys *around* the numbers on the keypad to switch
-- to workspaces 0 through 6
    kpress("KP_Divide", function(s) s:switch_nth(0) end),
    kpress("KP_Multiply", function(s) s:switch_nth(1) end),
    kpress("KP_Subtract", function(s) s:switch_nth(2) end),
    kpress("KP_Add", function(s) s:switch_nth(3) end),
    kpress("KP_Enter", function(s) s:switch_nth(4) end),
    kpress("KP_Decimal", function(s) s:switch_nth(5) end),
    kpress("KP_0", function(s) s:switch_nth(6) end),
-- convenient Ion control functionality
    kpress(DEFAULT_MOD..KEYF11, querylib.query_restart),
    kpress(DEFAULT_MOD..KEYF12, querylib.query_exit),
-- sometimes I need to "walk" through workspaces, instead
-- of switching to specific ones
    kpress(DEFAULT_MOD.."Shift+Left", WScreen.switch_prev),
    kpress(DEFAULT_MOD.."Shift+Right", WScreen.switch_next),
-- these are assigned with xmodmap to keys on my Logitech keyboard
    kpress("XF86Mail", make_exec_fn("emacs -name gnus -f gnus")),
    kpress("XF86Standby", make_exec_fn("xlock -mode matrix")),
    kpress("XF86AudioMute", make_exec_fn("aumix.sh")),
    kpress("XF86AudioRaiseVolume", make_exec_fn("/usr/bin/aumix -v+3")),
    kpress("XF86AudioLowerVolume", make_exec_fn("/usr/bin/aumix -v-3")),
    kpress("Shift+XF86AudioRaiseVolume", make_exec_fn("/usr/bin/aumix -v+1")),
    kpress("Shift+XF86AudioLowerVolume", make_exec_fn("/usr/bin/aumix -v-1")),
    kpress("XF86AudioPlay", make_exec_fn("xmms --play")),
    kpress("XF86AudioStop", make_exec_fn("xmms --pause")),
    kpress("XF86AudioPrev", make_exec_fn("xmms --rew")),
    kpress("XF86AudioNext", make_exec_fn("xmms --fwd")),
-- I run a lot of terminals, so this is a way to make sure that no
-- matter what X resources are loaded, I get a consistent look to my
-- terminals.
    kpress("XF86PowerOff", make_exec_fn("Eterm -f yellow --shade 100
    --term-name xterm --double-buffer -L 500000 --font
    -misc-fixed-bold-r-normal--14-130-75-75-c-70-iso10646-1")),
    kpress("Mod1+XF86PowerOff", make_exec_fn("xterm -bg black
    -fg yellow -fn -misc-fixed-bold-r-normal--14-130-75-75-c-70-iso10646-1
    -cr blue -geometry 80x50 -name term")),
-- essential programs for me
    kpress("XF86Start", make_exec_fn("emacs")),
    kpress("XF86Search", make_exec_fn("mozilla")),
-- miscellaneous menus
    kpress("Print", make_bigmenu_fn("mainmenu")),
    mpress("Button2", make_pmenu_fn("windowlist")),
    mpress("Button3", make_pmenu_fn("mainmenu")),
}
mplex_bindings{
    kpress_waitrel(DEFAULT_MOD.."Return",
                   make_mplex_clientwin_fn(WClientWin.toggle_fullscreen)),
-- Alt+W is short and sweet, yet hard to press accidentally
    kpress_waitrel(DEFAULT_MOD.."W", WMPlex.close_sub_or_self),
}
genframe_bindings{
    -- Tag an object
    kpress(DEFAULT_MOD.."Shift+A", WGenFrame.attach_tagged),
    -- Tag viewed object
    kpress(DEFAULT_MOD.."T", make_mplex_sub_fn(WRegion.toggle_tag)),
-- 6 and 4 on the keypad go back and forth between tabs.
-- this is very essential to my setup.  I couldn't use Ion without
-- these key bindings.
    kpress("KP_6", WGenFrame.switch_next),
    kpress("KP_4", WGenFrame.switch_prev),
-- miscellaneous frame-oriented bindings
    kpress(DEFAULT_MOD.."A", querylib.query_attachclient),
    kpress(DEFAULT_MOD.."G", querylib.query_gotoclient),
    kpress(DEFAULT_MOD.."F3", querylib.query_exec),
    kpress(DEFAULT_MOD.."F4", querylib.query_ssh),
    kpress(DEFAULT_MOD.."F5", querylib.query_editfile),
    kpress(DEFAULT_MOD.."F6", querylib.query_runfile),
    kpress(DEFAULT_MOD.."F7", querylib.query_lua),
    kpress(DEFAULT_MOD.."F9", querylib.query_workspace),
    kpress(DEFAULT_MOD.."M", make_menu_fn("ctxmenu")),
    mpress("Button3", make_pmenu_fn("ctxmenu"),"tab"),
}




最后是我的 Ion 平铺工作台绑定。当然,这些也是面向数字键区的。
返回列表