]> git.rmz.io Git - dotfiles.git/blob - awesome/bindings.lua
vim: do not set pastetoggle in nvim
[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" }, "=",
53 function ()
54 -- swap tags in screens
55 local c = client.focus
56 local this_screen = awful.screen.focused();
57 -- TODO: only works with two screens
58 local next_screen = this_screen:get_next_in_direction("right") or this_screen:get_next_in_direction("left")
59 local this_screen_tag = this_screen.selected_tag;
60 local next_screen_tag = next_screen.selected_tag;
61
62 this_screen_tag:swap(next_screen_tag)
63
64 this_screen_tag:view_only()
65 next_screen_tag:view_only()
66
67 awful.screen.focus(this_screen)
68 c:jump_to(true)
69 end,
70 {description = "swap screens", group = "screen"}),
71 awful.key({ modkey, "Control" }, "Right", function () awful.screen.focus_relative(-1) end,
72 {description = "focus the next screen", group = "screen"}),
73 awful.key({ modkey, "Control" }, "Left", function () awful.screen.focus_relative(-1) end,
74 {description = "focus the previous screen", group = "screen"}),
75 awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
76 {description = "jump to urgent client", group = "client"}),
77 awful.key({ modkey, }, "Tab",
78 function ()
79 awful.client.focus.history.previous()
80 if client.focus then
81 client.focus:raise()
82 end
83 end,
84 {description = "go back", group = "client"}),
85
86 -- Standard program
87 awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
88 {description = "open a terminal", group = "launcher"}),
89 awful.key({ modkey, "Control" }, "r", awesome.restart,
90 {description = "reload awesome", group = "awesome"}),
91
92 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
93 {description = "increase master width factor", group = "layout"}),
94 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
95 {description = "decrease master width factor", group = "layout"}),
96 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
97 {description = "increase the number of master clients", group = "layout"}),
98 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
99 {description = "decrease the number of master clients", group = "layout"}),
100 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
101 {description = "increase the number of columns", group = "layout"}),
102 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
103 {description = "decrease the number of columns", group = "layout"}),
104 -- resize slave
105 awful.key({ modkey, "Control" }, "j", function () awful.client.incwfact( 0.05) end,
106 {description = "increase focused client window factor", group = "layout"}),
107 awful.key({ modkey, "Control" }, "k", function () awful.client.incwfact(-0.05) end,
108 {description = "decrease focused client window factor", group = "layout"}),
109
110 -- switch between layouts
111 awful.key({ modkey, }, "]", function () awful.layout.inc( 1) end,
112 {description = "select next", group = "layout"}),
113 awful.key({ modkey, }, "[", function () awful.layout.inc(-1) end,
114 {description = "select previous", group = "layout"}),
115
116 awful.key({ modkey, "Control" }, "n",
117 function ()
118 local c = awful.client.restore()
119 -- Focus restored client
120 if c then
121 client.focus = c
122 c:raise()
123 end
124 end,
125 {description = "restore minimized", group = "client"}),
126
127 -- Prompt
128 awful.key({ modkey }, "space", function () awful.screen.focused().mypromptbox:run() end,
129 {description = "run prompt", group = "launcher"}),
130
131 awful.key({ modkey }, "x",
132 function ()
133 awful.prompt.run {
134 prompt = "Run Lua code: ",
135 textbox = awful.screen.focused().mypromptbox.widget,
136 exe_callback = awful.util.eval,
137 history_path = gears.filesystem.get_cache_dir() .. "/history_eval"
138 }
139 end,
140 {description = "lua execute prompt", group = "awesome"}),
141
142 -- Applications {{{2
143 -- Ksnapshot
144 awful.key({ }, "F13", function () awful.spawn("ksnapshot") end),
145 awful.key({ }, "Print", function () awful.spawn("ksnapshot") end),
146 -- ranger
147 awful.key({ modkey }, "r", function () utils.spawn_terminal("ranger") end),
148 -- Volume
149 awful.key({ }, "XF86AudioMute", function () awful.spawn("pulsemixer --toggle-mute") end,
150 {description = "toggle mute", group = "volume"}),
151 awful.key({ }, "XF86AudioLowerVolume", function () awful.spawn("pulsemixer --change-volume -5") end,
152 {description = "decrease volume", group = "volume"}),
153 awful.key({ }, "XF86AudioRaiseVolume", function () awful.spawn("pulsemixer --change-volume +5") end,
154 {description = "increase volume", group = "volume"}),
155 awful.key({ modkey }, "F10", function () awful.spawn("pulsemixer --toggle-mute") end,
156 {description = "toggle mute", group = "volume"}),
157 awful.key({ modkey }, "F11", function () awful.spawn("pulsemixer --change-volume -5") end,
158 {description = "decrease volume", group = "volume"}),
159 awful.key({ modkey }, "F12", function () awful.spawn("pulsemixer --change-volume +5") end,
160 {description = "increase volume", group = "volume"}),
161 -- Lock
162 awful.key({ modkey, "Control" }, "Escape", function () awful.spawn("i3lock -c 000000") end),
163 -- VimWiki
164 awful.key({ modkey }, "i", function ()
165 utils.spawn_terminal("vim -c 'call vimwiki#base#goto_index(v:count1)'", { instance = "vimwiki"})
166 end),
167 -- clipboard
168 -- requires a little sleep before simulating shift+Insert, otherwise I
169 -- believe the focus is still on awful and not the current window
170 awful.key({ modkey }, "\\", function () awful.spawn('xdotool sleep 0.2 key --clearmodifiers shift+Insert') end,
171 {description = "paste primary selection", group = "awesome"}),
172 -- utf8 picker
173 -- TODO: the mapping is similar to kitty's <C-S-u>, but worth changing maybe?
174 awful.key({ modkey, "Shift"}, "u", function () awful.spawn('rofimoji') end,
175 { description = "select utf8 character", group = "awesome"})
176 )
177
178 -- Client keys {{{1
179 clientkeys = gears.table.join(
180 awful.key({ modkey, }, "f",
181 function (c)
182 c.fullscreen = not c.fullscreen
183 c:raise()
184 end,
185 {description = "toggle fullscreen", group = "client"}),
186 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
187 {description = "close", group = "client"}),
188 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
189 {description = "toggle floating", group = "client"}),
190 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
191 {description = "move to master", group = "client"}),
192 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
193 {description = "toggle keep on top", group = "client"}),
194 awful.key({ modkey, }, "b", function (c) c.below = not c.below end,
195 {description = "toggle keep below", group = "client"}),
196 awful.key({ modkey, }, "n",
197 function (c)
198 -- The client currently has the input focus, so it cannot be
199 -- minimized, since minimized clients can't have the focus.
200 c.minimized = true
201 end ,
202 {description = "minimize", group = "client"}),
203 awful.key({ modkey, }, "m",
204 function (c)
205 c.maximized = not c.maximized
206 c:raise()
207 end ,
208 {description = "maximize", group = "client"}),
209
210 -- Move client to screen
211 awful.key({ modkey, "Shift" }, "#94", function (c) c:move_to_screen() end,
212 {description = "move to screen", group = "client"}),
213 awful.key({ modkey, "Shift" }, "#49", function (c) c:move_to_screen() end,
214 {description = "move to screen", group = "client"}),
215 awful.key({ modkey, "Shift" }, "=", function (c) c:move_to_screen() end,
216 {description = "move to screen", group = "client"})
217 )
218
219 -- Tags {{{1
220 -- Bind all key numbers to tags.
221 -- Be careful: we use keycodes to make it works on any keyboard layout.
222 -- This should map on the top row of your keyboard, usually 1 to 9.
223 for i = 1, 9 do
224 globalkeys = gears.table.join(globalkeys,
225 -- View tag only.
226 awful.key({ modkey }, "#" .. i + 9,
227 function ()
228 local screen = awful.screen.focused()
229 local tag = screen.tags[i]
230 if tag then
231 if tag.selected then
232 awful.tag.history.restore(screen)
233 else
234 tag:view_only()
235 end
236 end
237 end,
238 {description = "view tag #"..i, group = "tag"}),
239 -- Toggle tag display.
240 awful.key({ modkey, "Control" }, "#" .. i + 9,
241 function ()
242 local screen = awful.screen.focused()
243 local tag = screen.tags[i]
244 if tag then
245 awful.tag.viewtoggle(tag)
246 end
247 end,
248 {description = "toggle tag #" .. i, group = "tag"}),
249 -- Move client to tag.
250 awful.key({ modkey, "Shift" }, "#" .. i + 9,
251 function ()
252 if client.focus then
253 local tag = client.focus.screen.tags[i]
254 if tag then
255 client.focus:move_to_tag(tag)
256 end
257 end
258 end,
259 {description = "move focused client to tag #"..i, group = "tag"}),
260 -- Toggle tag on focused client.
261 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
262 function ()
263 if client.focus then
264 local tag = client.focus.screen.tags[i]
265 if tag then
266 client.focus:toggle_tag(tag)
267 end
268 end
269 end,
270 {description = "toggle focused client on tag #" .. i, group = "tag"})
271 )
272 end
273
274 -- Client Buttons {{{1
275 clientbuttons = gears.table.join(
276 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
277 awful.button({ modkey }, 1, awful.mouse.client.move),
278 awful.button({ modkey }, 3, awful.mouse.client.resize))