]> git.rmz.io Git - dotfiles.git/blob - awesome/bindings.lua
ae2ebafd055ef7036ec50b2063b03f5578e184db
[dotfiles.git] / awesome / bindings.lua
1 local hotkeys_popup = require("awful.hotkeys_popup").widget
2 local utils = require("utils")
3
4 -- Default modkey.
5 modkey = "Mod4"
6 altkey = "Mod1"
7
8 -- Mouse bindings {{{1
9 root.buttons(gears.table.join(
10 awful.button({ }, 3, function () mymainmenu:toggle() end)
11 ))
12
13 -- Global Keys {{{1
14 globalkeys = gears.table.join(globalkeys,
15 awful.key({ modkey, }, "s", hotkeys_popup.show_help,
16 {description="show help", group="awesome"}),
17 awful.key({ modkey, }, "Left", awful.tag.viewprev,
18 {description = "view previous", group = "tag"}),
19 awful.key({ modkey, }, "Down", awful.tag.viewprev,
20 {description = "view previous", group = "tag"}),
21 awful.key({ modkey, }, "Right", awful.tag.viewnext,
22 {description = "view next", group = "tag"}),
23 awful.key({ modkey, }, "Up", awful.tag.viewnext,
24 {description = "view next", group = "tag"}),
25 awful.key({ modkey, }, "Escape", awful.tag.history.restore,
26 {description = "go back", group = "tag"}),
27
28 awful.key({ modkey, }, "k",
29 function ()
30 awful.client.focus.byidx( 1)
31 end,
32 {description = "focus next by index", group = "client"}
33 ),
34 awful.key({ modkey, }, "j",
35 function ()
36 awful.client.focus.byidx(-1)
37 end,
38 {description = "focus previous by index", group = "client"}
39 ),
40 awful.key({ modkey, }, "w", function () mymainmenu:show({ coords = { x = 0, y = 0}}) end,
41 {description = "show main menu", group = "awesome"}),
42
43 -- Layout manipulation
44 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( 1) end,
45 {description = "swap with next client by index", group = "client"}),
46 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( -1) end,
47 {description = "swap with previous client by index", group = "client"}),
48 awful.key({ modkey, }, "#49", function () awful.screen.focus_relative( 1) end, -- that's the key left of 1 (chronos)
49 {description = "focus the next screen", group = "screen"}),
50 awful.key({ modkey, }, "=", function () awful.screen.focus_relative( 1) end, -- that's the key left of 1 (kinesis)
51 {description = "focus the next screen", group = "screen"}),
52 awful.key({ modkey, "Control" }, "Right", function () awful.screen.focus_relative(-1) end,
53 {description = "focus the next screen", group = "screen"}),
54 awful.key({ modkey, "Control" }, "Left", function () awful.screen.focus_relative(-1) end,
55 {description = "focus the previous screen", group = "screen"}),
56 awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
57 {description = "jump to urgent client", group = "client"}),
58 awful.key({ modkey, }, "Tab",
59 function ()
60 awful.client.focus.history.previous()
61 if client.focus then
62 client.focus:raise()
63 end
64 end,
65 {description = "go back", group = "client"}),
66
67 -- Standard program
68 awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
69 {description = "open a terminal", group = "launcher"}),
70 awful.key({ modkey, "Control" }, "r", awesome.restart,
71 {description = "reload awesome", group = "awesome"}),
72
73 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
74 {description = "increase master width factor", group = "layout"}),
75 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
76 {description = "decrease master width factor", group = "layout"}),
77 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
78 {description = "increase the number of master clients", group = "layout"}),
79 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
80 {description = "decrease the number of master clients", group = "layout"}),
81 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
82 {description = "increase the number of columns", group = "layout"}),
83 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
84 {description = "decrease the number of columns", group = "layout"}),
85 -- resize slave
86 awful.key({ modkey, "Control" }, "j", function () awful.client.incwfact( 0.05) end,
87 {description = "increase focused client window factor", group = "layout"}),
88 awful.key({ modkey, "Control" }, "k", function () awful.client.incwfact(-0.05) end,
89 {description = "decrease focused client window factor", group = "layout"}),
90
91 -- switch between layouts
92 awful.key({ modkey, }, "]", function () awful.layout.inc( 1) end,
93 {description = "select next", group = "layout"}),
94 awful.key({ modkey, }, "[", function () awful.layout.inc(-1) end,
95 {description = "select previous", group = "layout"}),
96
97 awful.key({ modkey, "Control" }, "n",
98 function ()
99 local c = awful.client.restore()
100 -- Focus restored client
101 if c then
102 client.focus = c
103 c:raise()
104 end
105 end,
106 {description = "restore minimized", group = "client"}),
107
108 -- Prompt
109 awful.key({ modkey }, "space", function () awful.screen.focused().mypromptbox:run() end,
110 {description = "run prompt", group = "launcher"}),
111
112 awful.key({ modkey }, "x",
113 function ()
114 awful.prompt.run {
115 prompt = "Run Lua code: ",
116 textbox = awful.screen.focused().mypromptbox.widget,
117 exe_callback = awful.util.eval,
118 history_path = gears.filesystem.get_cache_dir() .. "/history_eval"
119 }
120 end,
121 {description = "lua execute prompt", group = "awesome"}),
122
123 -- Applications {{{2
124 -- Ksnapshot
125 awful.key({ }, "F13", function () awful.spawn("ksnapshot") end),
126 awful.key({ }, "Print", function () awful.spawn("ksnapshot") end),
127 -- ranger
128 awful.key({ modkey }, "r", function () utils.spawn_terminal("ranger") end),
129 -- Volume
130 awful.key({ }, "XF86AudioMute", function () awful.spawn("pulsemixer --toggle-mute") end,
131 {description = "toggle mute", group = "volume"}),
132 awful.key({ }, "XF86AudioLowerVolume", function () awful.spawn("pulsemixer --change-volume -5") end,
133 {description = "decrease volume", group = "volume"}),
134 awful.key({ }, "XF86AudioRaiseVolume", function () awful.spawn("pulsemixer --change-volume +5") end,
135 {description = "increase volume", group = "volume"}),
136 awful.key({ modkey }, "F10", function () awful.spawn("pulsemixer --toggle-mute") end,
137 {description = "toggle mute", group = "volume"}),
138 awful.key({ modkey }, "F11", function () awful.spawn("pulsemixer --change-volume -5") end,
139 {description = "decrease volume", group = "volume"}),
140 awful.key({ modkey }, "F12", function () awful.spawn("pulsemixer --change-volume +5") end,
141 {description = "increase volume", group = "volume"}),
142 -- Lock
143 awful.key({ modkey, "Control" }, "Escape", function () awful.spawn("i3lock -c 000000") end),
144 -- VimWiki
145 awful.key({ modkey }, "i", function ()
146 utils.spawn_terminal("vim -c 'call vimwiki#base#goto_index(v:count1)'", { instance = "vimwiki"})
147 end),
148 -- clipboard
149 -- requires a little sleep before simulating shift+Insert, otherwise I
150 -- believe the focus is still on awful and not the current window
151 awful.key({ modkey }, "\\", function () awful.spawn('xdotool sleep 0.2 key --clearmodifiers shift+Insert') end,
152 {description = "paste primary selection", group = "awesome"})
153 )
154
155 -- Client keys {{{1
156 clientkeys = gears.table.join(
157 awful.key({ modkey, }, "f",
158 function (c)
159 c.fullscreen = not c.fullscreen
160 c:raise()
161 end,
162 {description = "toggle fullscreen", group = "client"}),
163 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
164 {description = "close", group = "client"}),
165 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
166 {description = "toggle floating", group = "client"}),
167 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
168 {description = "move to master", group = "client"}),
169 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
170 {description = "toggle keep on top", group = "client"}),
171 awful.key({ modkey, }, "b", function (c) c.below = not c.below end,
172 {description = "toggle keep below", group = "client"}),
173 awful.key({ modkey, }, "n",
174 function (c)
175 -- The client currently has the input focus, so it cannot be
176 -- minimized, since minimized clients can't have the focus.
177 c.minimized = true
178 end ,
179 {description = "minimize", group = "client"}),
180 awful.key({ modkey, }, "m",
181 function (c)
182 c.maximized = not c.maximized
183 c:raise()
184 end ,
185 {description = "maximize", group = "client"}),
186
187 -- Move client to screen
188 awful.key({ modkey, "Shift" }, "#94", function (c) c:move_to_screen() end,
189 {description = "move to screen", group = "client"}),
190 awful.key({ modkey, "Shift" }, "#49", function (c) c:move_to_screen() end,
191 {description = "move to screen", group = "client"}),
192 awful.key({ modkey, "Shift" }, "=", function (c) c:move_to_screen() end,
193 {description = "move to screen", group = "client"})
194 )
195
196 -- Tags {{{1
197 -- Bind all key numbers to tags.
198 -- Be careful: we use keycodes to make it works on any keyboard layout.
199 -- This should map on the top row of your keyboard, usually 1 to 9.
200 for i = 1, 9 do
201 globalkeys = gears.table.join(globalkeys,
202 -- View tag only.
203 awful.key({ modkey }, "#" .. i + 9,
204 function ()
205 local screen = awful.screen.focused()
206 local tag = screen.tags[i]
207 if tag then
208 if tag.selected then
209 awful.tag.history.restore(screen)
210 else
211 tag:view_only()
212 end
213 end
214 end,
215 {description = "view tag #"..i, group = "tag"}),
216 -- Toggle tag display.
217 awful.key({ modkey, "Control" }, "#" .. i + 9,
218 function ()
219 local screen = awful.screen.focused()
220 local tag = screen.tags[i]
221 if tag then
222 awful.tag.viewtoggle(tag)
223 end
224 end,
225 {description = "toggle tag #" .. i, group = "tag"}),
226 -- Move client to tag.
227 awful.key({ modkey, "Shift" }, "#" .. i + 9,
228 function ()
229 if client.focus then
230 local tag = client.focus.screen.tags[i]
231 if tag then
232 client.focus:move_to_tag(tag)
233 end
234 end
235 end,
236 {description = "move focused client to tag #"..i, group = "tag"}),
237 -- Toggle tag on focused client.
238 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
239 function ()
240 if client.focus then
241 local tag = client.focus.screen.tags[i]
242 if tag then
243 client.focus:toggle_tag(tag)
244 end
245 end
246 end,
247 {description = "toggle focused client on tag #" .. i, group = "tag"})
248 )
249 end
250
251 -- Client Buttons {{{1
252 clientbuttons = gears.table.join(
253 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
254 awful.button({ modkey }, 1, awful.mouse.client.move),
255 awful.button({ modkey }, 3, awful.mouse.client.resize))