2022-08-31 12:20:58 +00:00
-- This file is part of Reno desktop.
--
-- Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
--
-- Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
2022-07-12 21:26:11 +00:00
-- Module that adds default keybindings
local awful = require ( " awful " )
local gears = require ( " gears " )
2022-09-07 17:43:25 +00:00
local ask = require ( " asckey " )
2022-07-12 21:26:11 +00:00
global.modkey = global.modkey or " Mod4 "
2022-09-04 10:25:18 +00:00
2022-09-16 18:42:50 +00:00
ask.set_keymap ( config.keys )
2022-09-07 17:43:25 +00:00
local custom_keys = ask.custom_binds ( )
local k = ask.k
2022-09-04 10:25:18 +00:00
2022-07-12 21:26:11 +00:00
local keys = gears.table . join (
2023-05-06 08:56:25 +00:00
k ( ' :root.tag_next ' ,
awful.tag . viewnext ,
{ description = " switch to next tag " , group = " client " } ) ,
k ( ' :root.tag_prev ' ,
awful.tag . viewprev ,
{ description = " switch to previous tag " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( ' :root.client_next ' ,
2022-07-12 21:26:11 +00:00
function ( )
awful.client . focus.byidx ( 1 )
end ,
{ description = " switch to next client " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :root.client_previous " ,
2022-07-12 21:26:11 +00:00
function ( )
awful.client . focus.byidx ( - 1 )
end ,
{ description = " switch to previous client " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :root.screen_next " ,
2022-07-12 21:26:11 +00:00
function ( )
awful.screen . focus_relative ( 1 )
end ,
{ description = " switch to next screen " , group = " screen " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :root.screen_previous " ,
2022-07-12 21:26:11 +00:00
function ( )
awful.screen . focus_relative ( - 1 )
end ,
{ description = " switch to previous screen " , group = " screen " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :root.client_swap " ,
2022-07-12 21:26:11 +00:00
function ( )
awful.client . focus.history . previous ( )
if client.focus then
client.focus : raise ( )
end
end ,
{ description = " go back " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :root.spawn_terminal " ,
2022-07-12 21:26:11 +00:00
function ( )
awful.spawn ( global.terminal )
end ,
2022-09-04 10:25:18 +00:00
{ description = " open terminal " , group = " launcher " } ) ,
k ( " :root.spawn_browser " ,
2022-07-12 21:26:11 +00:00
function ( )
awful.spawn ( global.browser )
end ,
2022-09-04 10:25:18 +00:00
{ description = " open browser " , group = " launcher " } ) ,
2022-12-10 22:28:22 +00:00
k ( " :root.toggle_titlebars " ,
function ( c )
awesome.emit_signal ( " titlebar::toggle " )
end ,
{ description = " (un)hide all titlebars " , group = " client " } ) ,
2023-05-06 08:56:25 +00:00
k ( " :layout.increase_master " ,
function ( ) awful.tag . incmwfact ( 0.05 ) end ,
{ description = " increase master width factor " , group = " layout " } ) ,
k ( " :layout.decrease_master " ,
function ( ) awful.tag . incmwfact ( - 0.05 ) end ,
{ description = " decrease master width factor " , group = " layout " } ) ,
k ( " :layout.increase_master_count " ,
function ( ) awful.tag . incnmaster ( 1 , nil , true ) end ,
{ description = " increase the number of master clients " , group = " layout " } ) ,
k ( " :layout.decrease_master_count " ,
function ( ) awful.tag . incnmaster ( - 1 , nil , true ) end ,
{ description = " decrease the number of master clients " , group = " layout " } ) ,
k ( " :layout.increase_column_count " ,
function ( ) awful.tag . incncol ( 1 , nil , true ) end ,
{ description = " increase the number of columns " , group = " layout " } ) ,
k ( " :layout.decrease_column_count " ,
function ( ) awful.tag . incncol ( - 1 , nil , true ) end ,
{ description = " decrease the number of columns " , group = " layout " } ) ,
k ( " :layout.next_layout " ,
function ( ) awful.layout . inc ( 1 ) end ,
{ description = " next layout " , group = " layout " } ) ,
k ( " :layout.prev_layout " ,
function ( ) awful.layout . inc ( - 1 ) end ,
{ description = " previous layout " , group = " layout " } ) ,
k ( " :layout.swap_next_client " ,
function ( ) awful.client . swap.byidx ( 1 ) end ,
{ description = " swap with next client by index " , group = " client " } ) ,
k ( " :layout.swap_next_client " ,
function ( ) awful.client . swap.byidx ( - 1 ) end ,
{ description = " swap with previous client by index " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
table.unpack ( custom_keys ) )
2022-07-12 21:26:11 +00:00
root.keys ( keys )
2022-08-11 19:34:25 +00:00
local buttons = gears.table . join (
awful.button ( { } , 3 , function ( ) end ) ,
awful.button ( { } , 4 , awful.tag . viewnext ) ,
awful.button ( { } , 5 , awful.tag . viewprev )
)
root.buttons ( buttons )
2022-07-12 21:26:11 +00:00
local clientkeys = gears.table . join (
2022-09-04 10:25:18 +00:00
k ( " :client.kill " ,
2022-07-12 21:26:11 +00:00
function ( c )
c : kill ( )
end ,
{ description = " close client " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :client.cycle_screen " ,
2022-07-12 21:26:11 +00:00
function ( c )
c : move_to_screen ( )
end ,
{ description = " move to screen " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :client.ontop " ,
2022-07-12 21:26:11 +00:00
function ( c )
c.ontop = not c.ontop
end ,
{ description = " toggle ontop " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :client.below " ,
2022-07-12 21:26:11 +00:00
function ( c )
c.below = not c.below
end ,
{ description = " toggle below " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :client.fullscreen " ,
2022-07-12 21:26:11 +00:00
function ( c )
c.fullscreen = not c.fullscreen
c : raise ( )
end ,
{ description = " toggle fullscreen " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :client.minimize " ,
2022-07-12 21:26:11 +00:00
function ( c )
c.minimized = true
end ,
{ description = " minimize " , group = " client " } ) ,
2022-09-04 10:25:18 +00:00
k ( " :client.maximize " ,
2022-07-12 21:26:11 +00:00
function ( c )
c.maximized = not c.maximized
c : raise ( )
end ,
2022-09-16 18:42:50 +00:00
{ description = " (un)maximize " , group = " client " } ) ,
k ( " :client.pin " ,
function ( c )
c.sticky = not c.sticky
end ,
{ description = " (un)pin " , group = " client " } ) ,
k ( " :client.toggle_titlebars " ,
function ( c )
2022-12-10 22:28:22 +00:00
c : emit_signal ( " titlebar::toggle " )
2022-09-16 18:42:50 +00:00
end ,
2023-05-06 08:56:25 +00:00
{ description = " (un)hide titlebars " , group = " client " } ) ,
k ( " :client.swap_to_master " ,
function ( c )
c : swap ( awful.client . getmaster ( ) )
end ,
{ description = " swap with master " , group = " client " } ) ,
k ( " :client.move_to_screen " ,
function ( c )
c : move_to_screen ( )
end ,
{ description = " move to screen " , group = " client " } ) )
2022-07-12 21:26:11 +00:00
awful.rules . rules [ 1 ] . properties.keys = clientkeys
local clientbuttons = gears.table . join (
awful.button ( { } , 1 , function ( c )
c : emit_signal ( " request::activate " , " mouse_click " , { raise = true } )
end ) ,
awful.button ( { global.modkey } , 1 , function ( c )
c : emit_signal ( " request::activate " , " mouse_click " , { raise = true } )
awful.mouse . client.move ( c )
end ) ,
awful.button ( { global.modkey } , 3 , function ( c )
c : emit_signal ( " request::activate " , " mouse_click " , { raise = true } )
awful.mouse . client.resize ( c )
2023-05-06 08:56:25 +00:00
end )
)
2022-07-12 21:26:11 +00:00
awful.rules . rules [ 1 ] . properties.buttons = clientbuttons