author | Fabien Ninoles <fabien@tzone.org> |
Sat, 20 Jun 2015 20:32:45 -0400 | |
changeset 13 | e9e2f624cd99 |
parent 12 | ffc02bf394cb |
child 14 | 6348b9f842b2 |
permissions | -rw-r--r-- |
11 | 1 |
local debug = require("debug") |
7 | 2 |
-- |
3 |
-- Standard awesome library |
|
11 | 4 |
local awful = require("awful") |
5 |
awful.autofocus = require("awful.autofocus") |
|
6 |
local wibox = require("wibox") |
|
7 | 7 |
-- Theme handling library |
11 | 8 |
local beautiful = require("beautiful") |
7 | 9 |
-- Notification library |
11 | 10 |
local naughty = require("naughty") |
7 | 11 |
-- shifty - dynamic tagging library |
11 | 12 |
local shifty = require("shifty") |
7 | 13 |
-- Revelation |
11 | 14 |
local revelation = require("revelation") |
7 | 15 |
-- vicious widgets |
16 |
local vicious = require("vicious") |
|
17 |
local wicked = require("wicked") |
|
18 |
-- Load Debian menu entries |
|
19 |
require("debian.menu") |
|
20 |
||
21 |
-- require("keychains") |
|
22 |
||
11 | 23 |
local my = require("my") |
7 | 24 |
|
25 |
-- {{{ Error handling |
|
26 |
-- Check if awesome encountered an error during startup and fell back to |
|
27 |
-- another config (This code will only ever execute for the fallback config) |
|
28 |
if awesome.startup_errors then |
|
29 |
naughty.notify({ preset = naughty.config.presets.critical, |
|
30 |
title = "Oops, there were errors during startup!", |
|
31 |
text = awesome.startup_errors }) |
|
32 |
end |
|
33 |
||
34 |
-- Handle runtime errors after startup |
|
35 |
do |
|
11 | 36 |
awesome.connect_signal("debug::error", my.notify_error) |
12 | 37 |
awesome.connect_signal("debug::deprecation", my.notify_error) |
38 |
awesome.connect_signal("debug::index::miss", |
|
39 |
function (obj, key) |
|
40 |
my.notify_error("Invalid key " .. key .. " on object") |
|
41 |
end) |
|
42 |
awesome.connect_signal("debug::newindex::miss", |
|
43 |
function (obj, key, value) |
|
44 |
my.notify_error("Trying to set key " .. key .. " on object") |
|
45 |
end) |
|
7 | 46 |
end |
47 |
-- }}} |
|
48 |
||
49 |
-- Variable definitions |
|
50 |
-- Themes define colours, icons, and wallpapers |
|
51 |
-- The default is a dark theme |
|
52 |
-- theme_path = "/usr/share/awesome/themes/default/theme.lua" |
|
53 |
-- Uncommment this for a lighter theme |
|
13
e9e2f624cd99
Add themes and wallpapers menus.
Fabien Ninoles <fabien@tzone.org>
parents:
12
diff
changeset
|
54 |
theme_path = awful.util.getdir("config") .. "/current_theme/theme.lua" |
7 | 55 |
|
56 |
-- This is used later as the default terminal and editor to run. |
|
57 |
terminal = "x-terminal-emulator" |
|
8 | 58 |
-- terminal = "terminology" |
7 | 59 |
editor = os.getenv("EDITOR") or "editor" |
60 |
editor_cmd = terminal .. " -e " .. editor |
|
61 |
browser = "iceweasel" |
|
62 |
mail = "icedove" |
|
63 |
musicplayer = "ario" |
|
64 |
monitor = "gnome-system-monitor" |
|
65 |
filemanager = "pcmanfm" |
|
66 |
lookup = "pcmanfm -f" |
|
67 |
calculator = "galculator" |
|
8 | 68 |
-- Logout method |
69 |
-- logout = awesome.quit |
|
70 |
logout = my.mkspawn("obsession-logout") |
|
7 | 71 |
|
72 |
-- Default modkey. |
|
73 |
-- Usually, Mod4 is the key with a logo between Control and Alt. |
|
74 |
-- If you do not like this or do not have such a key, I suggest you to remap |
|
75 |
-- Mod4 to another key using xmodmap or other tools. However, you can use |
|
76 |
-- another modifier like Mod1, but it may interact with others. |
|
77 |
modkey = "Mod4" |
|
78 |
||
13
e9e2f624cd99
Add themes and wallpapers menus.
Fabien Ninoles <fabien@tzone.org>
parents:
12
diff
changeset
|
79 |
wallpaper = awful.util.getdir("config") .. "/default" |
e9e2f624cd99
Add themes and wallpapers menus.
Fabien Ninoles <fabien@tzone.org>
parents:
12
diff
changeset
|
80 |
wallpaper_cmd = "fbsetbg -a " .. wallpaper |
7 | 81 |
|
82 |
-- Actually load theme |
|
83 |
beautiful.init(theme_path) |
|
13
e9e2f624cd99
Add themes and wallpapers menus.
Fabien Ninoles <fabien@tzone.org>
parents:
12
diff
changeset
|
84 |
beautiful.wallpaper_cmd = { wallpaper_cmd } |
7 | 85 |
awful.util.spawn_with_shell("pgrep unagi || unagi &") |
86 |
||
87 |
||
88 |
-- Table of layouts to cover with awful.layout.inc, order matters. |
|
89 |
layouts = |
|
90 |
{ |
|
91 |
awful.layout.suit.tile, |
|
92 |
awful.layout.suit.tile.left, |
|
93 |
awful.layout.suit.tile.bottom, |
|
94 |
awful.layout.suit.tile.top, |
|
95 |
awful.layout.suit.fair, |
|
96 |
awful.layout.suit.fair.horizontal, |
|
97 |
awful.layout.suit.max, |
|
11 | 98 |
-- awful.layout.suit.max.fullscreen, |
7 | 99 |
awful.layout.suit.magnifier, |
100 |
awful.layout.suit.floating |
|
101 |
} |
|
102 |
||
103 |
-- Define if we want to use titlebar on all applications. |
|
104 |
use_titlebar = true |
|
105 |
||
8 | 106 |
-- Remove the focus follow mouse install by shifty. |
11 | 107 |
-- shifty.config.sloppy = false |
8 | 108 |
|
7 | 109 |
-- Shifty configured tags. |
110 |
shifty.config.tags = { |
|
111 |
w1 = { |
|
112 |
layout = awful.layout.suit.tile, |
|
113 |
mwfact = 0.60, |
|
114 |
exclusive = false, |
|
115 |
position = 1, |
|
116 |
init = true, |
|
117 |
screen = 1, |
|
118 |
slave = true, |
|
119 |
}, |
|
120 |
web = { |
|
121 |
layout = awful.layout.suit.tile.bottom, |
|
122 |
mwfact = 0.65, |
|
123 |
exclusive = true, |
|
124 |
max_clients = 1, |
|
8 | 125 |
position = 2, |
7 | 126 |
spawn = browser, |
127 |
}, |
|
128 |
mail = { |
|
129 |
layout = awful.layout.suit.tile, |
|
130 |
mwfact = 0.55, |
|
131 |
exclusive = false, |
|
8 | 132 |
position = 3, |
7 | 133 |
spawn = mail, |
134 |
slave = true |
|
135 |
}, |
|
8 | 136 |
steam = { |
137 |
layout = awful.layout.suit.float, |
|
138 |
mwfact = 0.65, |
|
139 |
exclusive = true, |
|
140 |
spawn = "steam", |
|
141 |
position = 4, |
|
142 |
}, |
|
7 | 143 |
media = { |
144 |
layout = awful.layout.suit.float, |
|
145 |
exclusive = false, |
|
8 | 146 |
position = 5, |
7 | 147 |
spawn = musicplayer |
148 |
}, |
|
149 |
office = { |
|
150 |
layout = awful.layout.suit.tile, |
|
8 | 151 |
position = 6, |
7 | 152 |
}, |
11 | 153 |
OZoNE = { |
154 |
layout = awful.layout.suit.max, |
|
155 |
position = 7, |
|
156 |
spawn = terminal .. " -e ssh o" |
|
157 |
} |
|
7 | 158 |
} |
159 |
||
160 |
-- SHIFTY: application matching rules |
|
161 |
-- order here matters, early rules will be applied first |
|
162 |
shifty.config.apps = { |
|
163 |
{ |
|
164 |
match = { |
|
165 |
"Navigator", |
|
166 |
"Vimperator", |
|
167 |
"Gran Paradiso", |
|
168 |
}, |
|
169 |
float = false, |
|
170 |
tag = "web", |
|
171 |
}, |
|
172 |
{ |
|
173 |
match = { |
|
174 |
"Shredder.*", |
|
175 |
"Thunderbird", |
|
176 |
"Icedove", |
|
177 |
"mutt", |
|
178 |
}, |
|
179 |
tag = "mail", |
|
180 |
}, |
|
181 |
{ |
|
182 |
match = { |
|
183 |
"pcmanfm", |
|
184 |
}, |
|
185 |
slave = true |
|
186 |
}, |
|
187 |
{ |
|
188 |
match = { |
|
189 |
"OpenOffice.*", |
|
190 |
"Abiword", |
|
191 |
"Gnumeric", |
|
192 |
}, |
|
193 |
tag = "office", |
|
194 |
}, |
|
195 |
{ |
|
196 |
match = { |
|
197 |
"Mplayer.*", |
|
198 |
"Mirage", |
|
199 |
"gimp", |
|
200 |
"gtkpod", |
|
201 |
"Ufraw", |
|
202 |
"easytag", |
|
203 |
"Ario", |
|
204 |
}, |
|
205 |
tag = "media", |
|
206 |
nopopup = true, |
|
207 |
}, |
|
208 |
{ |
|
209 |
match = { |
|
210 |
"MPlayer", |
|
211 |
"Gnuplot", |
|
212 |
"galculator", |
|
213 |
"speedcrunch" |
|
214 |
}, |
|
215 |
float = true, |
|
216 |
}, |
|
217 |
{ |
|
218 |
match = { "emacs" }, |
|
219 |
tag = "emacs" |
|
220 |
}, |
|
221 |
{ |
|
222 |
match = { |
|
223 |
terminal, |
|
224 |
}, |
|
225 |
honorsizehints = false, |
|
226 |
slave = true, |
|
227 |
}, |
|
228 |
{ |
|
229 |
match = { "Steam" }, |
|
230 |
tag = "steam", |
|
231 |
}, |
|
232 |
{ |
|
8 | 233 |
match = { "kupfer.py" }, |
234 |
slave = true, |
|
235 |
}, |
|
236 |
{ |
|
7 | 237 |
match = {""}, |
238 |
buttons = awful.util.table.join( |
|
239 |
awful.button({}, 1, function (c) client.focus = c; c:raise() end), |
|
240 |
awful.button({modkey}, 1, function(c) |
|
241 |
client.focus = c |
|
242 |
c:raise() |
|
243 |
awful.mouse.client.move(c) |
|
8 | 244 |
-- awful.mouse.client.dragtotag.border(c) |
245 |
-- awful.mouse.client.dragtotag.widget(c) |
|
7 | 246 |
end), |
247 |
awful.button({modkey}, 3, awful.mouse.client.resize) |
|
248 |
) |
|
249 |
}, |
|
250 |
} |
|
251 |
||
252 |
-- SHIFTY: default tag creation rules |
|
253 |
-- parameter description |
|
254 |
-- * floatBars : if floating clients should always have a titlebar |
|
255 |
-- * guess_name : should shifty try and guess tag names when creating |
|
256 |
-- new (unconfigured) tags? |
|
257 |
-- * guess_position: as above, but for position parameter |
|
258 |
-- * run : function to exec when shifty creates a new tag |
|
259 |
-- * all other parameters (e.g. layout, mwfact) follow awesome's tag API |
|
260 |
shifty.config.defaults = { |
|
8 | 261 |
layout = awful.layout.suit.tile, |
7 | 262 |
ncol = 1, |
263 |
mwfact = 0.60, |
|
264 |
floatBars = true, |
|
265 |
guess_name = true, |
|
266 |
guess_position = true, |
|
267 |
} |
|
268 |
||
269 |
-- Wibox |
|
270 |
-- Create a textbox widget |
|
11 | 271 |
mytextclock = awful.widget.textclock() |
7 | 272 |
|
273 |
-- Create a laucher widget and a main menu |
|
274 |
myawesomemenu = { |
|
275 |
{"manual", terminal .. " -e man awesome"}, |
|
276 |
{"edit config", |
|
277 |
editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua"}, |
|
13
e9e2f624cd99
Add themes and wallpapers menus.
Fabien Ninoles <fabien@tzone.org>
parents:
12
diff
changeset
|
278 |
{"themes", my.theme_menu()}, |
e9e2f624cd99
Add themes and wallpapers menus.
Fabien Ninoles <fabien@tzone.org>
parents:
12
diff
changeset
|
279 |
{"wallpapers", my.wallpaper_menu()}, |
7 | 280 |
{"restart", awesome.restart}, |
281 |
{"quit", my.quit} |
|
282 |
} |
|
283 |
||
284 |
mymainmenu = awful.menu( |
|
285 |
{ |
|
286 |
items = { |
|
287 |
{"awesome", myawesomemenu, beautiful.awesome_icon}, |
|
288 |
{ "Debian", debian.menu.Debian_menu.Debian }, |
|
289 |
{"open terminal", terminal}} |
|
290 |
}) |
|
291 |
||
11 | 292 |
mylauncher = awful.widget.launcher({image = beautiful.awesome_icon, |
7 | 293 |
menu = mymainmenu}) |
294 |
||
295 |
-- Create a systray |
|
11 | 296 |
mysystray = wibox.widget.systray({align = "right"}) |
7 | 297 |
|
298 |
-- Create a wibox for each screen and add it |
|
299 |
mywibox = {} |
|
300 |
mypromptbox = {} |
|
301 |
mylayoutbox = {} |
|
302 |
mytaglist = {} |
|
303 |
mytaglist.buttons = awful.util.table.join( |
|
304 |
awful.button({}, 1, awful.tag.viewonly), |
|
305 |
awful.button({modkey}, 1, awful.client.movetotag), |
|
306 |
awful.button({}, 3, function(tag) tag.selected = not tag.selected end), |
|
307 |
awful.button({modkey}, 3, awful.client.toggletag), |
|
308 |
awful.button({}, 4, awful.tag.viewnext), |
|
309 |
awful.button({}, 5, awful.tag.viewprev) |
|
310 |
) |
|
311 |
||
312 |
mytasklist = {} |
|
313 |
mytasklist.buttons = awful.util.table.join( |
|
314 |
awful.button({}, 1, function(c) |
|
315 |
if not c:isvisible() then |
|
316 |
awful.tag.viewonly(c:tags()[1]) |
|
317 |
end |
|
318 |
client.focus = c |
|
319 |
c:raise() |
|
320 |
end), |
|
321 |
awful.button({modkey}, 3, my.show_clients), |
|
322 |
awful.button({}, 3, function(c) |
|
323 |
c.minimized = not c.minimized |
|
324 |
end), |
|
325 |
awful.button({}, 4, function() |
|
326 |
awful.client.focus.byidx(1) |
|
327 |
if client.focus then client.focus:raise() end |
|
328 |
end), |
|
329 |
awful.button({}, 5, function() |
|
330 |
awful.client.focus.byidx(-1) |
|
331 |
if client.focus then client.focus:raise() end |
|
332 |
end)) |
|
333 |
||
334 |
local mycpuwidget = my.widgets.decorated(my.widgets.cpu(), my.mkspawn(monitor)) |
|
335 |
local mymemwidget = my.widgets.decorated(my.widgets.mem(), my.mkspawn(monitor)) |
|
336 |
local mynetwidget = my.widgets.decorated(my.widgets.net("eth1"), my.mkspawn(monitor)) |
|
337 |
-- local mynetupwidget = my.decorated_monitor_widget(make_netwidget("eth1", "up")) |
|
338 |
-- local mynetdownwidget = my.decorated_monitor_widget(make_netwidget("eth1", "down")) |
|
339 |
local myktwidget = my.widgets.mode() |
|
340 |
||
341 |
for s = 1, screen.count() do |
|
13
e9e2f624cd99
Add themes and wallpapers menus.
Fabien Ninoles <fabien@tzone.org>
parents:
12
diff
changeset
|
342 |
awful.util.spawn(wallpaper_cmd, false, s) |
7 | 343 |
|
344 |
-- status box |
|
345 |
||
346 |
-- Create a promptbox for each screen |
|
11 | 347 |
mypromptbox[s] = awful.widget.prompt() |
7 | 348 |
-- Create an imagebox widget which will contains an icon indicating which |
349 |
-- layout we're using. We need one layoutbox per screen. |
|
350 |
mylayoutbox[s] = awful.widget.layoutbox(s) |
|
351 |
mylayoutbox[s]:buttons(awful.util.table.join( |
|
352 |
awful.button({}, 1, function() awful.layout.inc(layouts, 1) end), |
|
353 |
awful.button({}, 3, function() awful.layout.inc(layouts, -1) end), |
|
354 |
awful.button({}, 4, function() awful.layout.inc(layouts, 1) end), |
|
355 |
awful.button({}, 5, function() awful.layout.inc(layouts, -1) end))) |
|
356 |
-- Create a taglist widget |
|
11 | 357 |
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons) |
7 | 358 |
|
359 |
-- Create a tasklist widget |
|
11 | 360 |
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons) |
7 | 361 |
|
362 |
-- Create the wibox |
|
363 |
mywibox[s] = awful.wibox({position = "top", screen = s}) |
|
364 |
-- Add widgets to the wibox - order matters |
|
11 | 365 |
local left_layout = wibox.layout.fixed.horizontal() |
366 |
left_layout:add(myktwidget) |
|
367 |
left_layout:add(mylauncher) |
|
368 |
if s == 1 then |
|
369 |
left_layout:add(mycpuwidget) |
|
370 |
left_layout:add(mymemwidget) |
|
371 |
end |
|
372 |
left_layout:add(mytaglist[s]) |
|
373 |
left_layout:add(mypromptbox[s]) |
|
374 |
||
375 |
local right_layout = wibox.layout.fixed.horizontal() |
|
12 | 376 |
if (s == 1) then right_layout:add(mynetwidget) end |
377 |
if (s == 1) then right_layout:add(mysystray) end |
|
378 |
right_layout:add(mytextclock) |
|
11 | 379 |
right_layout:add(mylayoutbox[s]) |
380 |
||
381 |
local layout = wibox.layout.align.horizontal() |
|
382 |
layout:set_left(left_layout) |
|
383 |
layout:set_middle(mytasklist[s]) |
|
384 |
layout:set_right(right_layout) |
|
385 |
mywibox[s]:set_widget(layout) |
|
7 | 386 |
end |
387 |
||
388 |
-- SHIFTY: initialize shifty |
|
389 |
-- the assignment of shifty.taglist must always be after its actually |
|
390 |
-- initialized with awful.widget.taglist.new() |
|
391 |
shifty.taglist = mytaglist |
|
392 |
shifty.init() |
|
393 |
||
394 |
-- Mouse bindings |
|
395 |
root.buttons(awful.util.table.join( |
|
396 |
awful.button({}, 3, function() mymainmenu:toggle() end), |
|
397 |
awful.button({}, 4, awful.tag.viewnext), |
|
398 |
awful.button({}, 5, awful.tag.viewprev) |
|
399 |
)) |
|
400 |
||
401 |
-- key tables |
|
402 |
||
403 |
local tagkeys = { |
|
404 |
-- Shifty: keybindings specific to shifty |
|
405 |
my.make_key("n", "Send to Next Tag", shifty.send_next), -- client to next tag |
|
406 |
my.make_key("a", "Add tag", my.mkinteractive(shifty.add)), -- create a new tag |
|
407 |
my.make_key("r", "Rename tag", my.mkinteractive(shifty.rename)), -- rename a tag |
|
408 |
my.make_key("d", "Delete tag", shifty.del), |
|
409 |
my.make_key("Shift+A", "Add tag (no popup)", -- nopopup new tag |
|
410 |
my.mkinteractive(function() shifty.add({nopopup = true}) end)), |
|
411 |
my.make_key("Up", "View prev", |
|
412 |
function () awful.tag.viewprev(); return true; end), |
|
413 |
my.make_key("Down", "View next", |
|
414 |
function () awful.tag.viewnext(); return true; end), |
|
11 | 415 |
-- my.make_key("Shift+Up", "Move tag right", |
416 |
-- function() |
|
417 |
-- local t = awful.tag.selected() |
|
418 |
-- local s = awful.util.cycle(screen.count(), t.screen + 1) |
|
419 |
-- awful.tag.history.restore() |
|
420 |
-- t = shifty.tagtoscr(s, t) |
|
421 |
-- awful.tag.viewonly(t) |
|
422 |
-- return true |
|
423 |
-- end), |
|
424 |
-- my.make_key("Shift+Down", "Move tag left", |
|
425 |
-- function() |
|
426 |
-- local t = awful.tag.selected() |
|
427 |
-- local s = screen.count() + t.screen - 1 |
|
428 |
-- s = awful.util.cycle(screen.count(), s) |
|
429 |
-- awful.tag.history.restore() |
|
430 |
-- t = shifty.tagtoscr(s, t) |
|
431 |
-- awful.tag.viewonly(t) |
|
432 |
-- return true |
|
433 |
-- end), |
|
7 | 434 |
} |
435 |
||
436 |
local awesome_keys = { |
|
437 |
my.make_key("m", "Menu", my.mkinteractive(function () |
|
438 |
mymainmenu:show({keygrabber=true}) |
|
439 |
return true |
|
440 |
end)), |
|
441 |
-- my.make_key("k", "Kill all clients", |
|
442 |
-- function () |
|
443 |
-- for client. |
|
444 |
-- my.kill_all(function (c) |
|
445 |
my.make_key("r", "Restart", awesome.restart), |
|
8 | 446 |
my.make_key("q", "Quit", logout), |
7 | 447 |
my.make_key("t", "Terminal", my.mkspawn(terminal)), |
8 | 448 |
my.make_key("f", "Toggle sloppy mouse", my.sloppy_toggle) |
7 | 449 |
} |
450 |
||
451 |
local layout_keys = { |
|
452 |
my.make_key("Right", "Focus right", |
|
453 |
function () awful.client.focus.bydirection("right"); return true end), |
|
454 |
my.make_key("Left", "Focus left", |
|
455 |
function () awful.client.focus.bydirection("left"); return true end), |
|
456 |
my.make_key("Up", "Focus up", |
|
457 |
function () awful.client.focus.bydirection("up"); return true end), |
|
458 |
my.make_key("Down", "Focus down", |
|
459 |
function () awful.client.focus.bydirection("down"); return true end), |
|
460 |
my.make_key("Shift+Right", "Move right", |
|
461 |
function () awful.client.swap.bydirection("right"); return true end), |
|
462 |
my.make_key("Shift+Left", "Move left", |
|
463 |
function () awful.client.swap.bydirection("left"); return true end), |
|
464 |
my.make_key("Shift+Up", "Move up", |
|
465 |
function () awful.client.swap.bydirection("up"); return true end), |
|
466 |
my.make_key("Shift+Down", "Move down", |
|
467 |
function () awful.client.swap.bydirection("down"); return true end), |
|
468 |
-- my.make_key("Right", "Focus next", |
|
469 |
-- function () awful.client.focus.byidx(1); return true end), |
|
470 |
-- my.make_key("Left", "Focus prev", |
|
471 |
-- function () awful.client.focus.byidx(-1); return true end), |
|
472 |
-- my.make_key("Shift+Right", "Move next", |
|
473 |
-- function() awful.client.swap.byidx(1); return true end), |
|
474 |
-- my.make_key("Shift+Left", "Move previous", |
|
475 |
-- function() awful.client.swap.byidx(-1); return true end), |
|
476 |
-- my.make_key("Shift+Right", "Move next", |
|
477 |
-- function() awful.screen.focus(1); return true end), |
|
478 |
-- my.make_key("Shift+Left", "Move previous", |
|
479 |
-- function() awful.screen.focus(-1); return true end), |
|
480 |
my.make_key("c", "Master grow", |
|
481 |
function() awful.tag.incmwfact(0.05); return true end), |
|
482 |
my.make_key("z", "Master shrink", |
|
483 |
function() awful.tag.incmwfact(-0.05); return true end), |
|
484 |
my.make_key("Shift+c", "Add master windows", |
|
485 |
function() awful.tag.incnmaster(1); return true end), |
|
486 |
my.make_key("Shift+z", "Remove master windows", |
|
487 |
function() awful.tag.incnmaster(-1); return true end), |
|
488 |
my.make_key("Control+c", "Add column", |
|
489 |
function() awful.tag.incncol(1); return true end), |
|
490 |
my.make_key("Control+z", "Remove column", |
|
491 |
function() awful.tag.incncol(-1); return true end), |
|
492 |
my.make_key("Space", "Next layout", |
|
493 |
function() awful.layout.inc(layouts, 1); return true end), |
|
494 |
my.make_key("Shift+_", "Previous layout", |
|
495 |
function() awful.layout.inc(layouts, -1) ; return true end), |
|
496 |
} |
|
497 |
||
498 |
media_keys = { |
|
499 |
-- media keys |
|
500 |
my.make_key("XF86HomePage", "Browser", my.mkspawn(browser)), |
|
501 |
my.make_key("XF86Mail", "Mail", my.mkspawn(mail)), |
|
502 |
my.make_key("XF86Search", "Search file...", my.mkspawn(lookup)), |
|
503 |
my.make_key("XF86Explorer", "File Manager", my.mkspawn(filemanager)), |
|
504 |
my.make_key("XF86Calculator", "Calculator", my.mkspawn(calculator)), |
|
505 |
my.make_key("XF86Tools", "Music", my.mkspawn(musicplayer)), |
|
506 |
my.make_key("XF86AudioPrev", "Previous song", my.mkspawn("mpc prev")), |
|
507 |
my.make_key("XF86AudioNext", "Next song", my.mkspawn("mpc next")), |
|
508 |
my.make_key("XF86AudioPlay", "Play song", my.mkspawn("mpc toggle")), |
|
509 |
my.make_key("XF86AudioMute", "Mute", my.mkspawn("pulseaudio-ctl mute")), |
|
510 |
my.make_key("XF86AudioLowerVolume", "Volume down", my.mkspawn("pulseaudio-ctl down")), |
|
511 |
my.make_key("XF86AudioRaiseVolume", "Volume up", my.mkspawn("pulseaudio-ctl up")), |
|
512 |
my.make_key("XF86Eject", "Eject", my.mkspawn("eject")), |
|
513 |
} |
|
514 |
||
515 |
global_table = { |
|
516 |
my.make_key("Escape", "Restore History", awful.tag.history.restore), |
|
517 |
my.make_key("e", "Revel windows", revelation), |
|
518 |
my.make_key("c", "Previous tag", awful.tag.viewprev), |
|
519 |
my.make_key("z", "Next tag", awful.tag.viewnext), |
|
520 |
my.make_key("Right", "Right client", my.make_focus_bydirection("right")), |
|
521 |
my.make_key("Left", "Left client", my.make_focus_bydirection("left")), |
|
522 |
my.make_key("Up", "Up client", my.make_focus_bydirection("up")), |
|
523 |
my.make_key("Down", "Down client", my.make_focus_bydirection("down")), |
|
524 |
my.make_key("u", "Jump to urgent", awful.client.urgent.jumpto), |
|
525 |
my.make_key("Tab", "Previous client", |
|
526 |
function() |
|
527 |
awful.client.focus.history.previous() |
|
528 |
if client.focus then |
|
529 |
client.focus:raise() |
|
530 |
end |
|
531 |
end), |
|
532 |
||
533 |
-- Prompt |
|
534 |
my.make_key("F2", "Run...", function() |
|
535 |
awful.prompt.run({prompt = "Run: "}, |
|
536 |
mypromptbox[mouse.screen].widget, |
|
537 |
awful.util.spawn, awful.completion.shell, |
|
538 |
awful.util.getdir("cache") .. "/history") |
|
539 |
end), |
|
540 |
||
541 |
my.make_key("F3", "Eval...", function() |
|
542 |
awful.prompt.run({prompt = "Run Lua code: "}, |
|
543 |
mypromptbox[mouse.screen].widget, |
|
544 |
awful.util.eval, nil, |
|
545 |
awful.util.getdir("cache") .. "/history_eval") |
|
546 |
end), |
|
547 |
||
548 |
-- modal key binding |
|
549 |
my.make_key("a", "Main mode", my.make_kt(awesome_keys, "awesome") ), |
|
550 |
my.make_key("t", "Tag mode...", my.make_kt(tagkeys, "tag") ), |
|
551 |
my.make_key("l", "layout mode...", my.make_kt(layout_keys, "layout") ), |
|
552 |
} |
|
553 |
||
554 |
client_keytable = { |
|
555 |
my.make_key("F4", "Kill client", |
|
556 |
function(c) c:kill() end), |
|
557 |
my.make_key("k", "Kill client", |
|
558 |
function(c) c:kill() end), |
|
559 |
my.make_key("f", "Toggle fullscreen", |
|
560 |
function(c) c.fullscreen = not c.fullscreen end), |
|
561 |
my.make_key("space", "Toggle floating", |
|
562 |
awful.client.floating.toggle), |
|
563 |
my.make_key("m", "Toggle maximize", |
|
564 |
function(c) |
|
565 |
c.maximized_horizontal = not c.maximized_horizontal |
|
566 |
c.maximized_vertical = not c.maximized_vertical |
|
567 |
end), |
|
568 |
my.make_key("h", "Toggle minimized", |
|
569 |
function (c) |
|
570 |
c.minimized = not c.minimized |
|
571 |
end), |
|
572 |
my.make_key("Return", "Swap master", |
|
573 |
function(c) |
|
574 |
c:swap(awful.client.getmaster()) |
|
575 |
end), |
|
576 |
my.make_key("o", "Move to screen", awful.client.movetoscreen), |
|
577 |
} |
|
578 |
||
579 |
-- Key bindings |
|
580 |
globalkeys = awful.util.table.join( |
|
581 |
awful.key({modkey}, "F1", function () my.show_kt(global_table, "Global binding") end), |
|
582 |
my.make_globalkeys({modkey}, global_table), |
|
583 |
my.make_globalkeys({}, media_keys), |
|
584 |
-- forcing restart of mpd. |
|
585 |
-- it sometime have difficulty to connect to pulse |
|
586 |
awful.key({modkey}, "F6", function () |
|
587 |
awful.util.spawn("pkill -9 mpd") |
|
588 |
awful.util.spawn("mpd") |
|
589 |
end) |
|
590 |
) |
|
591 |
||
592 |
||
593 |
-- Client awful tagging: this is useful to tag some clients and then do stuff |
|
594 |
-- like move to tag on them |
|
595 |
clientkeys = awful.util.table.join( |
|
596 |
awful.key({modkey, "Shift"}, "F1", |
|
597 |
function () my.show_kt(client_keytable, "Client binding") end), |
|
598 |
my.make_globalkeys({modkey}, client_keytable), |
|
599 |
awful.key({modkey, "Shift"}, "r", function(c) c:redraw() end), |
|
600 |
awful.key({modkey, "Shift"}, "t", awful.client.togglemarked)) |
|
601 |
||
602 |
||
603 |
-- SHIFTY: assign client keys to shifty for use in |
|
604 |
-- match() function(manage hook) |
|
605 |
shifty.config.clientkeys = clientkeys |
|
606 |
shifty.config.modkey = modkey |
|
607 |
||
608 |
-- Compute the maximum number of digit we need, limited to 10 |
|
609 |
local number_row = { |
|
610 |
'"', '<', '>', '(', ')', |
|
611 |
'@', '+', '-', '/', '*' |
|
612 |
} |
|
613 |
||
614 |
for i = 1, (shifty.config.maxtags or #number_row) do |
|
615 |
local k = number_row[i-1] |
|
616 |
globalkeys = awful.util.table.join( |
|
617 |
globalkeys, |
|
618 |
awful.key({modkey}, k, function() |
|
8 | 619 |
local t = awful.tag.viewonly(shifty.getpos(i-1)) |
7 | 620 |
end), |
621 |
awful.key({modkey, "Control"}, k, function() |
|
8 | 622 |
local t = shifty.getpos(i-1) |
7 | 623 |
t.selected = not t.selected |
624 |
end), |
|
625 |
awful.key({modkey, "Control", "Shift"}, k, function() |
|
626 |
if client.focus then |
|
8 | 627 |
awful.client.toggletag(shifty.getpos(i-1)) |
7 | 628 |
end |
629 |
end), |
|
630 |
-- move clients to other tags |
|
631 |
awful.key({modkey, "Shift"}, k, function() |
|
632 |
if client.focus then |
|
8 | 633 |
t = shifty.getpos(i-1) |
7 | 634 |
awful.client.movetotag(t) |
635 |
awful.tag.viewonly(t) |
|
636 |
end |
|
637 |
end)) |
|
638 |
end |
|
639 |
||
640 |
-- Set keys |
|
641 |
-- mympdwidget:append_global_keys() |
|
642 |
-- keychains.init(globalkeys,{}) |
|
643 |
root.keys(globalkeys) |
|
644 |
||
645 |
-- local function kt2kc(kt) |
|
646 |
-- t = {} |
|
647 |
-- for _,k in ipairs(kt) do |
|
648 |
-- t[k.key] = { func = k.func, info = key.desc } |
|
649 |
-- end |
|
650 |
-- return t |
|
651 |
-- end |
|
652 |
-- keychains.add({modkey}, "w", "Awesome", nil, kt2kc(awesome_keys)) |
|
653 |
-- keychains.start(5) |
|
654 |
||
655 |
-- Hook function to execute when focusing a client. |
|
11 | 656 |
client.connect_signal("focus", |
7 | 657 |
function(c) |
658 |
if not awful.client.ismarked(c) then |
|
659 |
c.border_color = beautiful.border_focus |
|
660 |
c.opacity = 1.0 |
|
661 |
end |
|
662 |
end) |
|
663 |
||
664 |
-- Hook function to execute when unfocusing a client. |
|
11 | 665 |
client.connect_signal("unfocus", function(c) |
7 | 666 |
if not awful.client.ismarked(c) then |
667 |
c.border_color = beautiful.border_normal |
|
668 |
c.opacity = 0.8 |
|
669 |
end |
|
670 |
end) |
|
671 |
||
8 | 672 |
my.sloppy_install(0.5) |