local gears = require('gears') local awful = require('awful') local lain = require('lain') local hotkeys_popup = require('awful.hotkeys_popup') local globals = require('src.globals') local modkey = globals.modkey local altkey = globals.altkey local mpris = require('src.util.mpris') local volume = require('src.util.volume') local quake_terminal_name = 'QuakeTerminal' local quake = lain.util.quake({ followtag = true, overlap = true, app = 'alacritty', argname = '-t ' .. quake_terminal_name, name = quake_terminal_name, extra = '--class ' .. quake_terminal_name, vert = 'center', horiz = 'center', height = 0.6, width = 0.6 }) local function focus_bydirection(direction) awful.client.focus.global_bydirection(direction) if client.focus then client.focus:raise() end end local globalkeys = gears.table.join( ---- HOTKEYS ---- awful.key({ modkey, altkey }, 'p', function() awful.spawn('flameshot gui') end, { description = 'screenshot', group = 'hotkeys' }), awful.key({ modkey, altkey, 'Control' }, 'l', function() awful.spawn('dm-tool lock') end, { description = 'lock', group = 'hotkeys' }), awful.key({ modkey }, 's', hotkeys_popup.show_help), ---- TAG ---- -- NAVIGATION awful.key({ modkey }, 'Left', awful.tag.viewprev, { description = 'view previous', group = 'tag' }), awful.key({ modkey }, 'Right', awful.tag.viewnext, { description = 'view next', group = 'tag' }), awful.key({ altkey }, 'Left', function() lain.util.tag_view_nonempty(-1) end, { description = 'view previous nonempty', group = 'tag' }), awful.key({ altkey }, 'Right', function() lain.util.tag_view_nonempty(1) end, { description = 'view next nonempty', group = 'tag' }), -- CREATE/MOVE/DELETE awful.key({ modkey, 'Shift' }, 'n', function() lain.util.add_tag() end, { description = 'add new tag', group = 'tag' }), awful.key({ modkey, 'Shift' }, 'r', function() lain.util.rename_tag() end, { description = 'rename tag', group = 'tag' }), awful.key({ modkey, 'Shift' }, 'Left', function() lain.util.move_tag(-1) end, { description = 'move tag to the left', group = 'tag' }), awful.key({ modkey, 'Shift' }, 'Right', function() lain.util.move_tag(1) end, { description = 'move tag to the right', group = 'tag' }), awful.key({ modkey, 'Shift' }, 'd', function() lain.util.delete_tag() end, { description = 'delete tag', group = 'tag' }), ---- CLIENT ---- awful.key({ altkey }, 'j', function() awful.client.focus.byidx(1) end, { description = 'focus next by index', group = 'client' }), awful.key({ altkey }, 'k', function() awful.client.focus.byidx(-1) end, { description = 'focus previous by index', group = 'client' }), awful.key({ modkey }, 'h', function() focus_bydirection('left') end, { description = 'focus left', group = 'client' }), awful.key({ modkey }, 'j', function() focus_bydirection('down') end, { description = 'focus down', group = 'client' }), awful.key({ modkey }, 'k', function() focus_bydirection('up') end, { description = 'focus up', group = 'client' }), awful.key({ modkey }, 'l', function() focus_bydirection('right') end, { description = 'focus right', group = 'client' }), awful.key({ modkey }, 'u', awful.client.urgent.jumpto, { description = 'jump to urgent client', group = 'client' }), awful.key({ modkey, 'Control' }, 'n', function() local c = awful.client.restore() if c then c:emit_signal('request::activate', 'key.unminimize', { raise = true }) end end, { description = 'restore minimized', group = 'client' }), ---- AWESOME ---- awful.key({ modkey }, 'b', function() for s in screen do s.wibox.visible = not s.wibox.visible end end, { description = 'toggle wibox', group = 'awesome' }), awful.key({ modkey, 'Control' }, 'r', awesome.restart, { description = 'reload awesome', group = 'awesome' }), awful.key({ modkey, 'Shift', 'Control' }, 'q', awesome.quit, { description = 'quit awesome', group = 'awesome' }), ---- PROGRAMS ---- awful.key({ modkey }, 'Return', function() awful.spawn(globals.terminal) end, { description = 'open a terminal', group = 'programs' }), awful.key({ modkey, altkey }, 'Return', function() quake:toggle() end, { description = 'Dropdown terminal', group = 'programs' }), awful.key({ modkey }, 'y', function() awful.spawn('rofi -show drun -theme "' .. os.getenv('HOME') .. '/.config/awesome/rofi/launcher.rasi"') end, { description = 'show drun', group = 'launcher' }), awful.key({ modkey, 'Control', 'Shift' }, 'y', function() awful.spawn('rofi -show drun -drun-show-actions -theme "' .. os.getenv('HOME') .. '/.config/awesome/rofi/launcher.rasi"') end, { description = 'show drun actions', group = 'launcher' }), awful.key({ modkey, 'Shift' }, 'y', function() awful.spawn(os.getenv('HOME') .. '/.config/awesome/rofi/launcher_launcher.sh') end, { description = 'show rofi launcher', group = 'launcher' }), ---- LAYOUT ---- awful.key({ modkey, altkey }, 'l', function() awful.tag.incmwfact(0.05) end, { description = 'increase master width factor', group = 'layout' }), awful.key({ modkey, altkey }, 'h', function() awful.tag.incmwfact(-0.05) end, { description = 'decrease master width factor', group = 'layout' }), awful.key({ modkey, 'Shift' }, 'h', function() awful.tag.incnmaster(1, nil, true) end, { description = 'increase the number of master clients', group = 'layout' }), awful.key({ modkey, 'Shift' }, 'l', function() awful.tag.incnmaster(-1, nil, true) end, { description = 'decrease the number of master clients', group = 'layout' }), awful.key({ modkey, 'Control' }, 'h', function() awful.tag.incncol(1, nil, true) end, { description = 'increase the number of columns', group = 'layout' }), awful.key({ modkey, 'Control' }, 'l', function() awful.tag.incncol(-1, nil, true) end, { description = 'decrease the number of columns', group = 'layout' }), awful.key({ modkey }, 'space', function() awful.layout.inc(1) end, { description = 'select next', group = 'layout' }), awful.key({ modkey, 'Shift' }, 'space', function() awful.layout.inc(-1) end, { description = 'select previous', group = 'layout' }), ---- AUDIO KEYS ---- awful.key({}, "XF86AudioMute", volume.toggle_mute), awful.key({}, "XF86AudioLowerVolume", volume.vol_down), awful.key({}, "XF86AudioRaiseVolume", volume.vol_up), awful.key({ 'Control' }, "XF86AudioMute", mpris.play_pause), awful.key({ 'Control' }, "XF86AudioLowerVolume", mpris.previous), awful.key({ 'Control' }, "XF86AudioRaiseVolume", mpris.skip) ) -- Bind all key numbers to tags. for i = 1, 9 do globalkeys = gears.table.join( globalkeys, -- View tag only. awful.key({ modkey }, '#' .. i + 9, function() local screen = awful.screen.focused() local tag = screen.tags[i] if tag then tag:view_only() end end, { description = 'view tag #' .. i, group = 'tag' }), -- Move client to tag. awful.key({ modkey, 'Shift' }, '#' .. i + 9, function() if client.focus then local tag = client.focus.screen.tags[i] if tag then client.focus:move_to_tag(tag) end end end, { description = 'move focused client to tag #' .. i, group = 'tag' }) ) end return globalkeys