1 -- Standard awesome library
3 require("awful.autofocus")
5 -- Widget and layout library
7 -- Theme handling library
9 -- Notification library
12 -- {{{ Variable definitions
13 -- Themes define colours, icons, and wallpapers
14 beautiful
.init("@AWESOME_THEMES_PATH@/default/theme.lua")
16 -- This is used later as the default terminal and editor to run.
18 editor
= os
.getenv("EDITOR") or "nano"
19 editor_cmd
= terminal
.. " -e " .. editor
22 -- Usually, Mod4 is the key with a logo between Control and Alt.
23 -- If you do not like this or do not have such a key,
24 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
25 -- However, you can use another modifier like Mod1, but it may interact with others.
28 -- Table of layouts to cover with awful.layout.inc, order matters.
31 awful
.layout
.suit
.floating
,
32 awful
.layout
.suit
.tile
,
33 awful
.layout
.suit
.tile
.left
,
34 awful
.layout
.suit
.tile
.bottom
,
35 awful
.layout
.suit
.tile
.top
,
36 awful
.layout
.suit
.fair
,
37 awful
.layout
.suit
.fair
.horizontal
,
38 awful
.layout
.suit
.spiral
,
39 awful
.layout
.suit
.spiral
.dwindle
,
40 awful
.layout
.suit
.max,
41 awful
.layout
.suit
.max.fullscreen
,
42 awful
.layout
.suit
.magnifier
47 -- Define a tag table which hold all screen tags.
49 for s
= 1, screen
.count() do
50 -- Each screen has its own tag table.
51 tags
[s
] = awful
.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s
, layouts
[1])
56 -- Create a laucher widget and a main menu
58 { "manual", terminal
.. " -e man awesome" },
59 { "edit config", editor_cmd
.. " " .. awesome
.conffile
},
60 { "restart", awesome
.restart
},
61 { "quit", awesome
.quit
}
64 mymainmenu
= awful
.menu({ items
= { { "awesome", myawesomemenu
, beautiful
.awesome_icon
},
65 { "open terminal", terminal
}
69 mylauncher
= awful
.widget
.launcher({ image
= beautiful
.awesome_icon
,
74 -- Create a textclock widget
75 mytextclock
= awful
.widget
.textclock()
77 -- Create a wibox for each screen and add it
82 mytaglist
.buttons
= awful
.util
.table.join(
83 awful
.button({ }, 1, awful
.tag.viewonly
),
84 awful
.button({ modkey
}, 1, awful
.client
.movetotag
),
85 awful
.button({ }, 3, awful
.tag.viewtoggle
),
86 awful
.button({ modkey
}, 3, awful
.client
.toggletag
),
87 awful
.button({ }, 4, awful
.tag.viewnext
),
88 awful
.button({ }, 5, awful
.tag.viewprev
)
91 mytasklist
.buttons
= awful
.util
.table.join(
92 awful
.button({ }, 1, function (c
)
93 if c
== client
.focus
then
96 if not c
:isvisible() then
97 awful
.tag.viewonly(c
:tags()[1])
99 -- This will also un-minimize
100 -- the client, if needed
105 awful
.button({ }, 3, function ()
110 instance
= awful
.menu
.clients({ width
=250 })
113 awful
.button({ }, 4, function ()
114 awful
.client
.focus
.byidx(1)
115 if client
.focus
then client
.focus
:raise() end
117 awful
.button({ }, 5, function ()
118 awful
.client
.focus
.byidx(-1)
119 if client
.focus
then client
.focus
:raise() end
122 for s
= 1, screen
.count() do
123 -- Create a promptbox for each screen
124 mypromptbox
[s
] = awful
.widget
.prompt()
125 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
126 -- We need one layoutbox per screen.
127 mylayoutbox
[s
] = awful
.widget
.layoutbox(s
)
128 mylayoutbox
[s
]:buttons(awful
.util
.table.join(
129 awful
.button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
130 awful
.button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
131 awful
.button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
132 awful
.button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end)))
133 -- Create a taglist widget
134 mytaglist
[s
] = awful
.widget
.taglist(s
, awful
.widget
.taglist
.filter
.all
, mytaglist
.buttons
)
136 -- Create a tasklist widget
137 mytasklist
[s
] = awful
.widget
.tasklist(s
, awful
.widget
.tasklist
.filter
.currenttags
, mytasklist
.buttons
)
140 mywibox
[s
] = awful
.wibox({ position
= "top", screen
= s
})
142 -- Widgets that are aligned to the left
143 local left_layout
= wibox
.layout
.fixed
.horizontal()
144 left_layout
:add(mylauncher
)
145 left_layout
:add(mytaglist
[s
])
146 left_layout
:add(mypromptbox
[s
])
148 -- Widgets that are aligned to the right
149 local right_layout
= wibox
.layout
.fixed
.horizontal()
150 if s
== 1 then right_layout
:add(wibox
.widget
.systray()) end
151 right_layout
:add(mytextclock
)
152 right_layout
:add(mylayoutbox
[s
])
154 -- Now bring it all together (with the tasklist in the middle)
155 local layout
= wibox
.layout
.align
.horizontal()
156 layout
:set_left(left_layout
)
157 layout
:set_middle(mytasklist
[s
])
158 layout
:set_right(right_layout
)
160 mywibox
[s
]:set_widget(layout
)
164 -- {{{ Mouse bindings
165 root
.buttons(awful
.util
.table.join(
166 awful
.button({ }, 3, function () mymainmenu
:toggle() end),
167 awful
.button({ }, 4, awful
.tag.viewnext
),
168 awful
.button({ }, 5, awful
.tag.viewprev
)
173 globalkeys
= awful
.util
.table.join(
174 awful
.key({ modkey
, }, "Left", awful
.tag.viewprev
),
175 awful
.key({ modkey
, }, "Right", awful
.tag.viewnext
),
176 awful
.key({ modkey
, }, "Escape", awful
.tag.history
.restore
),
178 awful
.key({ modkey
, }, "j",
180 awful
.client
.focus
.byidx( 1)
181 if client
.focus
then client
.focus
:raise() end
183 awful
.key({ modkey
, }, "k",
185 awful
.client
.focus
.byidx(-1)
186 if client
.focus
then client
.focus
:raise() end
188 awful
.key({ modkey
, }, "w", function () mymainmenu
:show({keygrabber
=true}) end),
190 -- Layout manipulation
191 awful
.key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx( 1) end),
192 awful
.key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx( -1) end),
193 awful
.key({ modkey
, "Control" }, "j", function () awful
.screen
.focus_relative( 1) end),
194 awful
.key({ modkey
, "Control" }, "k", function () awful
.screen
.focus_relative(-1) end),
195 awful
.key({ modkey
, }, "u", awful
.client
.urgent
.jumpto
),
196 awful
.key({ modkey
, }, "Tab",
198 awful
.client
.focus
.history
.previous()
205 awful
.key({ modkey
, }, "Return", function () awful
.util
.spawn(terminal
) end),
206 awful
.key({ modkey
, "Control" }, "r", awesome
.restart
),
207 awful
.key({ modkey
, "Shift" }, "q", awesome
.quit
),
209 awful
.key({ modkey
, }, "l", function () awful
.tag.incmwfact( 0.05) end),
210 awful
.key({ modkey
, }, "h", function () awful
.tag.incmwfact(-0.05) end),
211 awful
.key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster( 1) end),
212 awful
.key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end),
213 awful
.key({ modkey
, "Control" }, "h", function () awful
.tag.incncol( 1) end),
214 awful
.key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end),
215 awful
.key({ modkey
, }, "space", function () awful
.layout
.inc(layouts
, 1) end),
216 awful
.key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end),
218 awful
.key({ modkey
, "Control" }, "n", awful
.client
.restore
),
221 awful
.key({ modkey
}, "r", function () mypromptbox
[mouse
.screen
]:run() end),
223 awful
.key({ modkey
}, "x",
225 awful
.prompt
.run({ prompt
= "Run Lua code: " },
226 mypromptbox
[mouse
.screen
].widget
,
227 awful
.util
.eval
, nil,
228 awful
.util
.getdir("cache") .. "/history_eval")
232 clientkeys
= awful
.util
.table.join(
233 awful
.key({ modkey
, }, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end),
234 awful
.key({ modkey
, "Shift" }, "c", function (c
) c
:kill() end),
235 awful
.key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
),
236 awful
.key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end),
237 awful
.key({ modkey
, }, "o", awful
.client
.movetoscreen
),
238 awful
.key({ modkey
, }, "t", function (c
) c
.ontop
= not c
.ontop
end),
239 awful
.key({ modkey
, }, "n",
241 -- The client currently has the input focus, so it cannot be
242 -- minimized, since minimized clients can't have the focus.
245 awful
.key({ modkey
, }, "m",
247 c
.maximized_horizontal
= not c
.maximized_horizontal
248 c
.maximized_vertical
= not c
.maximized_vertical
252 -- Compute the maximum number of digit we need, limited to 9
254 for s
= 1, screen
.count() do
255 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
258 -- Bind all key numbers to tags.
259 -- Be careful: we use keycodes to make it works on any keyboard layout.
260 -- This should map on the top row of your keyboard, usually 1 to 9.
261 for i
= 1, keynumber
do
262 globalkeys
= awful
.util
.table.join(globalkeys
,
263 awful
.key({ modkey
}, "#" .. i
+ 9,
265 local screen
= mouse
.screen
266 if tags
[screen
][i
] then
267 awful
.tag.viewonly(tags
[screen
][i
])
270 awful
.key({ modkey
, "Control" }, "#" .. i
+ 9,
272 local screen
= mouse
.screen
273 if tags
[screen
][i
] then
274 awful
.tag.viewtoggle(tags
[screen
][i
])
277 awful
.key({ modkey
, "Shift" }, "#" .. i
+ 9,
279 if client
.focus
and tags
[client
.focus
.screen
][i
] then
280 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
283 awful
.key({ modkey
, "Control", "Shift" }, "#" .. i
+ 9,
285 if client
.focus
and tags
[client
.focus
.screen
][i
] then
286 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
291 clientbuttons
= awful
.util
.table.join(
292 awful
.button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
293 awful
.button({ modkey
}, 1, awful
.mouse
.client
.move
),
294 awful
.button({ modkey
}, 3, awful
.mouse
.client
.resize
))
297 root
.keys(globalkeys
)
301 awful
.rules
.rules
= {
302 -- All clients will match this rule.
304 properties
= { border_width
= beautiful
.border_width
,
305 border_color
= beautiful
.border_normal
,
308 buttons
= clientbuttons
} },
309 { rule
= { class
= "MPlayer" },
310 properties
= { floating
= true } },
311 { rule
= { class
= "pinentry" },
312 properties
= { floating
= true } },
313 { rule
= { class
= "gimp" },
314 properties
= { floating
= true } },
315 -- Set Firefox to always map on tags number 2 of screen 1.
316 -- { rule = { class = "Firefox" },
317 -- properties = { tag = tags[1][2] } },
322 -- Signal function to execute when a new client appears.
323 client
.connect_signal("manage", function (c
, startup
)
324 -- Enable sloppy focus
325 c
:connect_signal("mouse::enter", function(c
)
326 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
327 and awful
.client
.focus
.filter(c
) then
333 -- Set the windows at the slave,
334 -- i.e. put it at the end of others instead of setting it master.
335 -- awful.client.setslave(c)
337 -- Put windows in a smart way, only if they does not set an initial position.
338 if not c
.size_hints
.user_position
and not c
.size_hints
.program_position
then
339 awful
.placement
.no_overlap(c
)
340 awful
.placement
.no_offscreen(c
)
345 client
.connect_signal("focus", function(c
) c
.border_color
= beautiful
.border_focus
end)
346 client
.connect_signal("unfocus", function(c
) c
.border_color
= beautiful
.border_normal
end)