]> git.rmz.io Git - dotfiles.git/blobdiff - awesome/bindings.lua
lazyvim: absorb blink config
[dotfiles.git] / awesome / bindings.lua
index 16d579af6558d36c1a1f216f6cd4429dca783c04..be64d76b6f3947343be925bccf7724b5862f66cd 100644 (file)
@@ -1,16 +1,17 @@
 local hotkeys_popup = require("awful.hotkeys_popup").widget
+local utils = require("utils")
 
 -- Default modkey.
 modkey = "Mod4"
 altkey = "Mod1"
 
 -- Mouse bindings {{{1
-root.buttons(awful.util.table.join(
+root.buttons(gears.table.join(
     awful.button({ }, 3, function () mymainmenu:toggle() end)
 ))
 
 -- Global Keys {{{1
-globalkeys = awful.util.table.join(globalkeys,
+globalkeys = gears.table.join(globalkeys,
     awful.key({ modkey,           }, "s",      hotkeys_popup.show_help,
               {description="show help", group="awesome"}),
     awful.key({ modkey,           }, "Left",   awful.tag.viewprev,
@@ -40,14 +41,33 @@ globalkeys = awful.util.table.join(globalkeys,
               {description = "show main menu", group = "awesome"}),
 
     -- Layout manipulation
-    awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end,
+    awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx(  1)    end,
               {description = "swap with next client by index", group = "client"}),
-    awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end,
+    awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx( -1)    end,
               {description = "swap with previous client by index", group = "client"}),
     awful.key({ modkey,         }, "#49",     function () awful.screen.focus_relative( 1) end, -- that's the key left of 1 (chronos)
               {description = "focus the next screen", group = "screen"}),
     awful.key({ modkey,           }, "=",     function () awful.screen.focus_relative( 1) end, -- that's the key left of 1 (kinesis)
               {description = "focus the next screen", group = "screen"}),
+    awful.key({ modkey, "Control" }, "=",
+              function ()
+                -- swap tags in screens
+                local c = client.focus
+                local this_screen = awful.screen.focused();
+                -- TODO: only works with two screens
+                local next_screen = this_screen:get_next_in_direction("right") or this_screen:get_next_in_direction("left")
+                local this_screen_tag = this_screen.selected_tag;
+                local next_screen_tag = next_screen.selected_tag;
+
+                this_screen_tag:swap(next_screen_tag)
+
+                this_screen_tag:view_only()
+                next_screen_tag:view_only()
+
+                awful.screen.focus(this_screen)
+                c:jump_to(true)
+              end,
+              {description = "swap screens", group = "screen"}),
     awful.key({ modkey, "Control" }, "Right", function () awful.screen.focus_relative(-1) end,
               {description = "focus the next screen", group = "screen"}),
     awful.key({ modkey, "Control" }, "Left",  function () awful.screen.focus_relative(-1) end,
@@ -114,7 +134,7 @@ globalkeys = awful.util.table.join(globalkeys,
                     prompt       = "Run Lua code: ",
                     textbox      = awful.screen.focused().mypromptbox.widget,
                     exe_callback = awful.util.eval,
-                    history_path = awful.util.get_cache_dir() .. "/history_eval"
+                    history_path = gears.filesystem.get_cache_dir() .. "/history_eval"
                   }
               end,
               {description = "lua execute prompt", group = "awesome"}),
@@ -124,30 +144,39 @@ globalkeys = awful.util.table.join(globalkeys,
     awful.key({        }, "F13",   function () awful.spawn("ksnapshot") end),
     awful.key({        }, "Print", function () awful.spawn("ksnapshot") end),
     -- ranger
-    awful.key({ modkey }, "r", function () awful.spawn(terminal .. " -e ranger") end),
+    awful.key({ modkey }, "r", function () utils.spawn_terminal("ranger") end),
     -- Volume
-    awful.key({        }, "XF86AudioMute",        function () awful.spawn("ponymix toggle")     end,
+    awful.key({        }, "XF86AudioMute",        function () awful.spawn("pulsemixer --toggle-mute")     end,
               {description = "toggle mute", group = "volume"}),
-    awful.key({        }, "XF86AudioLowerVolume", function () awful.spawn("ponymix decrease 5") end,
+    awful.key({        }, "XF86AudioLowerVolume", function () awful.spawn("pulsemixer --change-volume -5") end,
               {description = "decrease volume", group = "volume"}),
-    awful.key({        }, "XF86AudioRaiseVolume", function () awful.spawn("ponymix increase 5") end,
+    awful.key({        }, "XF86AudioRaiseVolume", function () awful.spawn("pulsemixer --change-volume +5") end,
               {description = "increase volume", group = "volume"}),
-    awful.key({ modkey }, "F10",                  function () awful.spawn("ponymix toggle")     end,
+    awful.key({ modkey }, "F10",                  function () awful.spawn("pulsemixer --toggle-mute")     end,
               {description = "toggle mute", group = "volume"}),
-    awful.key({ modkey }, "F11",                  function () awful.spawn("ponymix decrease 5") end,
+    awful.key({ modkey }, "F11",                  function () awful.spawn("pulsemixer --change-volume -5") end,
               {description = "decrease volume", group = "volume"}),
-    awful.key({ modkey }, "F12",                  function () awful.spawn("ponymix increase 5") end,
+    awful.key({ modkey }, "F12",                  function () awful.spawn("pulsemixer --change-volume +5") end,
               {description = "increase volume", group = "volume"}),
     -- Lock
-    awful.key({ modkey, "Control" }, "Escape", function () awful.spawn("xautolock -locknow") end),
+    awful.key({ modkey, "Control" }, "Escape", function () awful.spawn("i3lock -c 000000") end),
     -- VimWiki
     awful.key({ modkey }, "i", function ()
-        awful.spawn(terminal.." -name vimwiki -e vim -c 'call vimwiki#base#goto_index(v:count1)'")
-    end)
+        utils.spawn_terminal("vim -c 'call vimwiki#base#goto_index(v:count1)'", { instance = "vimwiki"})
+    end),
+    -- clipboard
+    -- requires a little sleep before simulating shift+Insert, otherwise I
+    -- believe the focus is still on awful and not the current window
+    awful.key({ modkey }, "\\", function () awful.spawn('xdotool sleep 0.2 key --clearmodifiers shift+Insert') end,
+              {description = "paste primary selection", group = "awesome"}),
+    -- utf8 picker
+    -- TODO: the mapping is similar to kitty's <C-S-u>, but worth changing maybe?
+    awful.key({ modkey, "Shift"}, "u", function () awful.spawn('rofimoji') end,
+              { description = "select utf8 character", group = "awesome"})
 )
 
 -- Client keys {{{1
-clientkeys = awful.util.table.join(
+clientkeys = gears.table.join(
     awful.key({ modkey,           }, "f",
         function (c)
             c.fullscreen = not c.fullscreen
@@ -192,7 +221,7 @@ clientkeys = awful.util.table.join(
 -- Be careful: we use keycodes to make it works on any keyboard layout.
 -- This should map on the top row of your keyboard, usually 1 to 9.
 for i = 1, 9 do
-    globalkeys = awful.util.table.join(globalkeys,
+    globalkeys = gears.table.join(globalkeys,
         -- View tag only.
         awful.key({ modkey }, "#" .. i + 9,
                   function ()
@@ -243,7 +272,7 @@ for i = 1, 9 do
 end
 
 -- Client Buttons {{{1
-clientbuttons = awful.util.table.join(
+clientbuttons = gears.table.join(
     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
     awful.button({ modkey }, 1, awful.mouse.client.move),
     awful.button({ modkey }, 3, awful.mouse.client.resize))