]> git.rmz.io Git - dotfiles.git/blob - awesome/bindings.lua
zsh: add check_copyright to path
[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" }, "j", function () awful.client.swap.byidx( 1) end,
45 {description = "swap with next client by index", group = "client"}),
46 awful.key({ modkey, "Shift" }, "k", 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 )
149
150 -- Client keys {{{1
151 clientkeys = gears.table.join(
152 awful.key({ modkey, }, "f",
153 function (c)
154 c.fullscreen = not c.fullscreen
155 c:raise()
156 end,
157 {description = "toggle fullscreen", group = "client"}),
158 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
159 {description = "close", group = "client"}),
160 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
161 {description = "toggle floating", group = "client"}),
162 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
163 {description = "move to master", group = "client"}),
164 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
165 {description = "toggle keep on top", group = "client"}),
166 awful.key({ modkey, }, "b", function (c) c.below = not c.below end,
167 {description = "toggle keep below", group = "client"}),
168 awful.key({ modkey, }, "n",
169 function (c)
170 -- The client currently has the input focus, so it cannot be
171 -- minimized, since minimized clients can't have the focus.
172 c.minimized = true
173 end ,
174 {description = "minimize", group = "client"}),
175 awful.key({ modkey, }, "m",
176 function (c)
177 c.maximized = not c.maximized
178 c:raise()
179 end ,
180 {description = "maximize", group = "client"}),
181
182 -- Move client to screen
183 awful.key({ modkey, "Shift" }, "#94", function (c) c:move_to_screen() end,
184 {description = "move to screen", group = "client"}),
185 awful.key({ modkey, "Shift" }, "#49", function (c) c:move_to_screen() end,
186 {description = "move to screen", group = "client"}),
187 awful.key({ modkey, "Shift" }, "=", function (c) c:move_to_screen() end,
188 {description = "move to screen", group = "client"})
189 )
190
191 -- Tags {{{1
192 -- Bind all key numbers to tags.
193 -- Be careful: we use keycodes to make it works on any keyboard layout.
194 -- This should map on the top row of your keyboard, usually 1 to 9.
195 for i = 1, 9 do
196 globalkeys = gears.table.join(globalkeys,
197 -- View tag only.
198 awful.key({ modkey }, "#" .. i + 9,
199 function ()
200 local screen = awful.screen.focused()
201 local tag = screen.tags[i]
202 if tag then
203 if tag.selected then
204 awful.tag.history.restore(screen)
205 else
206 tag:view_only()
207 end
208 end
209 end,
210 {description = "view tag #"..i, group = "tag"}),
211 -- Toggle tag display.
212 awful.key({ modkey, "Control" }, "#" .. i + 9,
213 function ()
214 local screen = awful.screen.focused()
215 local tag = screen.tags[i]
216 if tag then
217 awful.tag.viewtoggle(tag)
218 end
219 end,
220 {description = "toggle tag #" .. i, group = "tag"}),
221 -- Move client to tag.
222 awful.key({ modkey, "Shift" }, "#" .. i + 9,
223 function ()
224 if client.focus then
225 local tag = client.focus.screen.tags[i]
226 if tag then
227 client.focus:move_to_tag(tag)
228 end
229 end
230 end,
231 {description = "move focused client to tag #"..i, group = "tag"}),
232 -- Toggle tag on focused client.
233 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
234 function ()
235 if client.focus then
236 local tag = client.focus.screen.tags[i]
237 if tag then
238 client.focus:toggle_tag(tag)
239 end
240 end
241 end,
242 {description = "toggle focused client on tag #" .. i, group = "tag"})
243 )
244 end
245
246 -- Client Buttons {{{1
247 clientbuttons = gears.table.join(
248 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
249 awful.button({ modkey }, 1, awful.mouse.client.move),
250 awful.button({ modkey }, 3, awful.mouse.client.resize))