From 682fdcfbe406cd1fcea88ecdf8753319161db464 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Mon, 21 Dec 2020 20:12:39 +0530 Subject: added keybindings to launch apps --- awesome/rc.lua | 85 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/awesome/rc.lua b/awesome/rc.lua index d5464384..b839c5fb 100755 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -36,11 +36,35 @@ end -- Themes define colours, icons, font and wallpapers. beautiful.init(gears.filesystem.get_configuration_dir() .. "theme.lua") --- This is used later as the default terminal and editor to run. +-- variable declarations +modkey = "Mod4" + +-- app defaults terminal = "st" +launcher = "dmenu_run" + +-- terminal apps editor = "nvim" +termFileManager = "ranger" +sysMonitor = "bashtop" +-- terminal app commands editor_cmd = terminal .. " -e " .. editor -modkey = "Mod4" +termFileManager_cmd = terminal .. " -e " .. termFileManager +sysMonitor_cmd = terminal .. " -e " .. sysMonitor + +-- gui apps +fileManager = "pcmanfm" +browser = "firefox" +emailClient = "thunderbird" + +-- system commands +screenshot = "scrot /zt/Screenshots/Screenshot-%Y-%d-%m--%T.png" +screenLock = "betterlockscreen -l -t 'pee pee poo poo'" + +-- volume commands +volumeUp = "pulseaudio-ctl up" +volumeDown = "pulseaudio-ctl down" +toggleMute = "pulseaudio-ctl mute" -- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = { @@ -62,6 +86,11 @@ awful.layout.layouts = { -- awful.layout.suit.corner.se, } + +function sh(command) + awful.spawn.with_shell(command) +end + -- Keyboard map indicator and switcher mykeyboardlayout = awful.widget.keyboardlayout() @@ -195,12 +224,39 @@ end) -- {{{ Mouse bindings root.buttons(gears.table.join( - awful.button({ }, 3, function () naughty.notify({ title = "Achtung!", text = "You're idling", timeout = 0 }) end), + awful.button({ }, 3, function() sh("nitrogen") end), awful.button({ }, 5, awful.tag.viewnext), awful.button({ }, 4, awful.tag.viewprev) )) -- }}} +-- my custom keybindings to spawn +-- apps or execute scripts and shit +myKeys = gears.table.join( + awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end), + awful.key({ modkey, }, "p", function () awful.spawn(launcher) end), + awful.key({ modkey, }, "q", function () awful.spawn(screenLock) end), + awful.key({ modkey, "Shift" }, "Return", function () awful.spawn(screenshot) end), + + -- gui apps + awful.key({ modkey, }, "i", function () awful.spawn(browser) end), + awful.key({ modkey, }, "s", function () awful.spawn(fileManager) end), + awful.key({ modkey, }, "w", function () awful.spawn("nitrogen") end), + awful.key({ modkey, }, "y", function () awful.spawn("gimp") end), + awful.key({ modkey, }, "e", function () awful.spawn(emailClient) end), + + -- terminal apps + awful.key({ modkey, }, "r", function () awful.spawn(termFileManager_cmd) end), + awful.key({ modkey, }, "a", function () awful.spawn(sysMonitor_cmd) end), + awful.key({ modkey, "Shift", }, "w", function () awful.spawn("nitrogen --restore") end), + + -- volume controls + awful.key({ "Mod1", }, "j", function () awful.spawn(volumeDown) end), + awful.key({ "Mod1", }, "k", function () awful.spawn(volumeUp) end), + awful.key({ "Mod1", }, "m", function () awful.spawn(toggleMute) end), + awful.key({ "Mod1", }, "n", function () awful.spawn("pavucontrol") end) +) + -- for window navigation with hjkl -- i.e vim movement keys vimNavKeys = gears.table.join( @@ -221,10 +277,10 @@ vimNavKeys = gears.table.join( -- for manipulating layout with hjkl -- i.e move windows with vim movement keys vimLayoutKeys = gears.table.join( - awful.key({ "Mod4", "Shift" }, "h", function () awful.client.swap.bydirection("left") end), - awful.key({ "Mod4", "Shift" }, "j", function () awful.client.swap.bydirection("down") end), - awful.key({ "Mod4", "Shift" }, "k", function () awful.client.swap.bydirection("up") end), - awful.key({ "Mod4", "Shift" }, "l", function () awful.client.swap.bydirection("right") end) + awful.key({ modkey, "Shift", }, "h", function () awful.client.swap.bydirection("left") end), + awful.key({ modkey, "Shift", }, "j", function () awful.client.swap.bydirection("down") end), + awful.key({ modkey, "Shift", }, "k", function () awful.client.swap.bydirection("up") end), + awful.key({ modkey, "Shift", }, "l", function () awful.client.swap.bydirection("right") end) ) layoutKeys = gears.table.join( @@ -244,7 +300,7 @@ multiMonitorNavKeys = gears.table.join( -- focus next screen awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end), -- focus preious screen - awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end) + awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end) ) tagKeys = gears.table.join( @@ -262,7 +318,7 @@ tagKeys = gears.table.join( -- i.e minimizing, maximizing, hiding, closing windows clientkeys = gears.table.join( -- kill client - awful.key({ modkey, "Shift", }, "c", function (c) c:kill() end), + awful.key({ "Mod1", }, "w", function (c) c:kill() end), -- toggle fulscreen awful.key({ modkey, }, "f", function (c) @@ -317,7 +373,7 @@ clientkeys = gears.table.join( end), -- move client to master - awful.key({ modkey, "Shift" }, "Return", function (c) c:swap(awful.client.getmaster()) end) + awful.key({ "Mod1", }, "Return", function (c) c:swap(awful.client.getmaster()) end) ) awesomeKeys = gears.table.join( @@ -331,13 +387,10 @@ globalkeys = gears.table.join( multiMonitorNavKeys, vimLayoutKeys, layoutKeys, - tagKeys + tagKeys, + myKeys ) - - - - -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it work on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. @@ -429,7 +482,7 @@ awful.rules.rules = { "scrcpy", }, class = { - "gimp", + "GIMP", "Sxiv", "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. "xtightvncviewer"}, -- cgit v1.2.3