From ed0c911d527d31322ecbac8eca0d357d4da42b77 Mon Sep 17 00:00:00 2001 From: Klesh Wong Date: Thu, 5 May 2022 03:03:52 +0800 Subject: [PATCH] feat: use a/s/d/f as tag switching key --- gui/awesome/rc.lua | 74 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 61 insertions(+), 13 deletions(-) diff --git a/gui/awesome/rc.lua b/gui/awesome/rc.lua index ac12e61..c110e0e 100644 --- a/gui/awesome/rc.lua +++ b/gui/awesome/rc.lua @@ -208,8 +208,8 @@ awful.screen.connect_for_each_screen(function(s) set_wallpaper(s) -- Each screen has its own tag table. - awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) - --awful.tag({"𝟭", "𝟮", "𝟯", "𝟰", "𝟱", "𝟲", "𝟳", "𝟴", "𝟵"}, s, awful.layout.layouts[1]) + --awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) + awful.tag({" ", " ", " ", " " }, s, awful.layout.layouts[1]) -- Create a promptbox for each screen s.mypromptbox = awful.widget.prompt() @@ -351,8 +351,8 @@ globalkeys = gears.table.join( { description = 'toggle play', group = 'hotkeys'} ), awful.key({}, 'F1', function () awful.spawn.with_shell("flameshot gui") end, { description = 'toggle mute', group = 'hotkeys'} ), - awful.key({ modkey, }, "s", hotkeys_popup.show_help, - {description = "show help", group="awesome"}), + --awful.key({ modkey, }, "s", hotkeys_popup.show_help, + --{description = "show help", group="awesome"}), awful.key({ modkey, }, "Left", awful.tag.viewprev, {description = "view previous", group = "tag"}), awful.key({ modkey, }, "Right", awful.tag.viewnext, @@ -469,17 +469,17 @@ globalkeys = gears.table.join( {description = "bookmark", group = "launcher"}), -- Dict.sh - awful.key({ modkey }, "d", function() awful.spawn.with_shell('D_SELECTOR= d "$(xsel -o)"') end, + awful.key({ modkey }, "t", function() awful.spawn.with_shell('D_SELECTOR= d "$(xsel -o)"') end, {description = "dict.sh", group = "launcher"}) ) clientkeys = gears.table.join( - awful.key({ modkey, }, "f", - function (c) - c.fullscreen = not c.fullscreen - c:raise() - end, - {description = "toggle fullscreen", group = "client"}), + --awful.key({ modkey, }, "f", + --function (c) + --c.fullscreen = not c.fullscreen + --c:raise() + --end, + --{description = "toggle fullscreen", group = "client"}), awful.key({ modkey }, "q", function (c) c:kill() end, {description = "close", group = "client"}), awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle , @@ -488,8 +488,8 @@ clientkeys = gears.table.join( {description = "move to master", group = "client"}), awful.key({ modkey, }, "o", function (c) c:move_to_screen() end, {description = "move to screen", group = "client"}), - awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, - {description = "toggle keep on top", group = "client"}), + --awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, + --{description = "toggle keep on top", group = "client"}), awful.key({ modkey, }, "n", function (c) -- The client currently has the input focus, so it cannot be @@ -567,6 +567,54 @@ for i = 1, 9 do ) end +--- Bind a,s,d,f to tag 1,2,3,4 +for i, key in pairs({"a", "s", "d", "f"}) do + globalkeys = gears.table.join(globalkeys, + -- View tag only. + awful.key({ modkey }, key, + 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"}), + -- Toggle tag display. + awful.key({ modkey, "Control" }, key, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + {description = "toggle tag #" .. i, group = "tag"}), + -- Move client to tag. + awful.key({ modkey, "Shift" }, key, + 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"}), + -- Toggle tag on focused client. + awful.key({ modkey, "Control", "Shift" }, key, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, + {description = "toggle focused client on tag #" .. i, group = "tag"}) + ) +end + clientbuttons = gears.table.join( awful.button({ }, 1, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true})