3 -- some stuff below will eventually go to a separate file, and configuration
4 -- will remain here similar to the split between the wmii+ruby wmiirc
7 -- for now I just want to get the feel of how things will work in lua
13 io
.stderr
:write (str
.. "\n")
17 my_log("wmii: loading wmii.lua")
18 package
.path
= './.wmii-3.5/?.lua;' .. package
.path
21 my_log("wmii: wmii.lua loaded")
23 -- this is the base configuration
25 xterm
= 'x-terminal-emulator'
27 my_log("wmii: setting confg")
31 font
= '-windows-proggytiny-medium-r-normal--10-80-96-96-c-60-iso8859-1',
32 focuscolors
= '#FFFFaa #007700 #88ff88',
33 normcolors
= '#888888 #222222 #333333',
37 my_log("wmii: config set")
39 wmii
.write ("/colrules", "/.*/ -> 58+42")
40 wmii
.write ("/tagrules", "/XMMS.*/ -> ~\n"
41 .. "/MPlayer.*/ -> ~\n"
47 local key_handlers
= {
48 ["*"] = function (key
)
52 -- execution and actions
53 ["Mod1-Return"] = function (key
)
54 my_log (" executing: " .. config
.xterm
)
55 os
.execute (config
.xterm
.. " &")
57 ["Mod1-a"] = function (key
)
58 my_log (" Mod1-a: " .. key
)
59 -- for now just restart us
61 my_log ("*****************************************************\n"
62 .. "******** HACK!!! Just restart wmiirc for now ********\n"
63 .. "*****************************************************\n")
64 posix
.exec ("lua", os
.getenv("home") .. ".wmii-3.5/wmiirc")
67 ["Mod1-p"] = function (key
)
68 my_log (" Mod1-p: " .. key
)
71 -- HJKL active selection
72 ["Mod1-h"] = function (key
)
73 wmii
.write ("/tag/sel/ctl", "select left")
75 ["Mod1-l"] = function (key
)
76 wmii
.write ("/tag/sel/ctl", "select right")
78 ["Mod1-j"] = function (key
)
79 wmii
.write ("/tag/sel/ctl", "select down")
81 ["Mod1-k"] = function (key
)
82 wmii
.write ("/tag/sel/ctl", "select up")
86 ["Mod1-Shift-h"] = function (key
)
87 my_log (" Mod1-Shift-h: " .. key
)
88 wmii
.write ("/tag/sel/ctl", "send sel left")
90 ["Mod1-Shift-l"] = function (key
)
91 wmii
.write ("/tag/sel/ctl", "send sel right")
93 ["Mod1-Shift-j"] = function (key
)
94 wmii
.write ("/tag/sel/ctl", "send sel down")
96 ["Mod1-Shift-k"] = function (key
)
97 wmii
.write ("/tag/sel/ctl", "send sel up")
101 ["Mod1-space"] = function (key
)
102 wmii
.write ("/tag/sel/ctl", "select toggle")
104 ["Mod1-Shift-space"] = function (key
)
105 wmii
.write ("/tag/sel/ctl", "send sel toggle")
109 ["Mod4-#"] = function (key
, num
)
110 my_log (" Mod4-#: " .. tostring(num
))
111 wmii
.write ("/ctl", "view " .. tostring(num
))
113 ["Mod4-Shift-#"] = function (key
, num
)
114 my_log (" Mod4-Shift-#: " .. tostring(num
))
115 wmii
.write ("/client/sel/tags", tostring(num
))
121 ["Mod1-Control-t"] = function (key
)
122 my_log (" Mod1-Control-t: " .. key
)
124 ["Mod1-d"] = function (key
)
125 my_log (" Mod1-d: " .. key
)
127 ["Mod1-s"] = function (key
)
128 my_log (" Mod1-s: " .. key
)
130 ["Mod1-m"] = function (key
)
131 my_log (" Mod1-m: " .. key
)
133 ["Mod1-t"] = function (key
)
134 my_log (" Mod1-t: " .. key
)
136 ["Mod1-Shift-c"] = function (key
)
137 my_log (" Mod1-Shift-c: " .. key
)
139 ["Mod1-Shift-t"] = function (key
)
140 my_log (" Mod1-Shift-t: " .. key
)
144 -- update the /keys wmii file with the list of all handlers
149 for x
,y
in pairs(key_handlers
) do
151 local i
= x
:find("#")
164 local all_keys
= table.concat(t
, "\n")
165 my_log ("setting /keys to...\n" .. all_keys
.. "\n");
166 wmii
.write ("/keys", all_keys
)
172 local ev_handlers
= {
173 ["*"] = function (ev
, arg
)
174 my_log ("ev: " .. ev
.. " - " .. arg
)
177 ClientMouseDown
= function (ev
, arg
)
178 my_log ("ClientMouseDown: " .. arg
)
181 CreateTag
= function (ev
, arg
)
182 my_log ("CreateTag: " .. arg
)
185 DestroyTag
= function (ev
, arg
)
186 my_log ("DestroyTag: " .. arg
)
189 FocusTag
= function (ev
, arg
)
190 my_log ("FocusTag: " .. arg
)
193 Key
= function (ev
, arg
)
194 my_log ("Key: " .. arg
)
196 -- can we find an exact match?
197 local fn
= key_handlers
[arg
]
199 local key
= arg
:gsub("-%d+", "-#")
200 -- can we find a match with a # wild card for the number
201 fn
= key_handlers
[key
]
203 -- convert the trailing number to a number
204 num
= tonumber(arg
:match("-(%d+)"))
206 -- everything else failed, try default match
207 fn
= key_handlers
["*"]
215 LeftBarClick
= function (ev
, arg
)
216 my_log ("LeftBarClick: " .. arg
)
219 NotUrgentTag
= function (ev
, arg
)
220 my_log ("NotUrgentTag: " .. arg
)
223 Start
= function (ev
, arg
)
224 my_log ("Start: " .. arg
)
227 UnfocusTag
= function (ev
, arg
)
228 my_log ("UnfocusTag: " .. arg
)
231 UrgentTag
= function (ev
, arg
)
232 my_log ("UrgentTag: " .. arg
)
244 my_log("wmii: starting event loop")
246 for ev
, arg
in wmii
.ievents() do
248 local fn
= ev_handlers
[ev
] or ev_handlers
["*"]
253 my_log("wmii: event loop exited")