Last active
March 28, 2024 05:15
-
-
Save unai-ndz/2545b83e682ea1ad8ceb192e7f2e4f16 to your computer and use it in GitHub Desktop.
keychords for awesome 4.3-git
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local awful = require('awful') | |
local escape = require('gears').string.xml_escape | |
local ss = require('module.screens') | |
local keychords_widget = require('widget.keychord_mode') | |
local table_insert = table.insert | |
local modkey = 'Mod4' | |
local actions = { | |
focus = function(tag) | |
tag:view_only() | |
end, | |
move = function(tag) | |
if client.focus then | |
client.focus:move_to_tag(tag) | |
end | |
end, | |
toogle = function(tag) | |
awful.tag.viewtoggle(tag) | |
end, | |
} | |
local action, selected_screen | |
local function run_action(self, tag) | |
tag = ss.get_screen_tag(selected_screen, tag) | |
if tag then | |
action(tag) | |
end | |
self:stop() | |
end | |
local keybindings = {} | |
for i = 1, 5 do | |
table_insert(keybindings, | |
awful.key { | |
modifiers = {}, | |
key = tostring(i), | |
group = 'Tag', | |
description = 'select tag', | |
on_press = function(self) | |
run_action(self, i) | |
end, | |
} | |
) | |
end | |
-- Bind four screens, handle non existant screens inside the keygrabber | |
awful.key.keygroups.screens = { | |
{ 1, 1 }, | |
{ 2, 2 }, | |
{ 3, 3 }, | |
{ 4, 4 }, | |
} | |
local keygrabber = awful.keygrabber { | |
stop_key = 'Escape', | |
mask_modkeys = true, | |
keybindings = keybindings, | |
stop_callback = function() | |
keychords_widget:update() | |
end | |
} | |
keygrabber.root_keybindings = { | |
awful.key { | |
keygroup = 'screens', | |
modifiers = { modkey }, | |
group = 'Tag', | |
description = escape('Chain: focus <screen>, tag'), | |
on_press = function(index) | |
if not ss.by_index[index] then | |
keygrabber:stop() | |
return | |
end | |
action = actions.focus | |
selected_screen = index | |
keychords_widget:update('focus <tag> in screen '..selected_screen) | |
end, | |
}, | |
awful.key { | |
keygroup = 'screens', | |
modifiers = { modkey, 'Shift' }, | |
group = 'Tag', | |
description = escape('Chain: move focused client to <screen>, tag'), | |
on_press = function(index) | |
if not ss.by_index[index] then | |
keygrabber:stop() | |
return | |
end | |
action = actions.move | |
selected_screen = index | |
keychords_widget:update('move <tag> in screen '..selected_screen) | |
end, | |
}, | |
awful.key { | |
keygroup = 'screens', | |
modifiers = { modkey, 'Control' }, | |
group = 'Tag', | |
description = escape('Chain: toggle <screen>, tag'), | |
on_press = function(index) | |
if not ss.by_index[index] then | |
keygrabber:stop() | |
return | |
end | |
action = actions.toggle | |
selected_screen = index | |
keychords_widget:update('toggle <tag> in screen '..selected_screen) | |
end, | |
}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local wibox = require('wibox') | |
local beautiful = require('beautiful') | |
local markup = require('util.markup') | |
local spacer = require('util.spacer') | |
local icon = wibox.widget { | |
markup = markup.fg(beautiful.fg_focus, ''), | |
font = beautiful.icon_font, | |
widget = wibox.widget.textbox, | |
} | |
local mode = wibox.widget.textbox() | |
local layout = wibox.widget { | |
icon, | |
spacer.normal, | |
mode, | |
spacer.normal, | |
visible = false, | |
layout = wibox.layout.fixed.horizontal, | |
} | |
function layout:update(mode_string) | |
if mode_string then | |
self:set_visible(true) | |
mode.text = mode_string | |
else | |
self:set_visible(false) | |
end | |
end | |
return layout |
Global just contains the desired modkey as a string. I removed it from the latest commit so it should work now.
Tried that and the global error is gone but now it complains about:
local ss = require('module.screens')
I got awesome 4.3 and that is running lua 5.3 and in /usr/share/lua/5.3/lgi/ that there is no 'screens' module
Check my first comment, module.screens, util.markup and util.spacer
are custom files very specific to my configuration and tightly integrated with it. I could provide them but you will then need to fix 20 other things that are not in your config. I recommend you to remove those requires that fail and replace the functions used in here with something specific to your config.
Oh, forgot that
thx
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried this but this line 3 in keychord.lua gives me an error; local global = require('global')
'module not found', where does that come from and how to I add it?