Add tag moving
It is no longer required to require() collision at the bottom of rc.lua It is now possible to set the default behavior when swapping clients across screens
This commit is contained in:
parent
c47e2d5bca
commit
c2ed907171
|
@ -22,7 +22,7 @@ First, clone the repository
|
|||
|
||||
Now, open ~/.config/awesome/rc.lua (or copy /etc/xdg/awesome/rc.lua to
|
||||
~/.config/awesome/rc.lua fist if you never modified your Awesome config before)
|
||||
and add this line at the **end** of rc.lua:
|
||||
and add this line somewhere in your `rc.lua`:
|
||||
|
||||
```lua
|
||||
require("collision")()
|
||||
|
@ -87,3 +87,10 @@ This can be used:
|
|||
|
||||
Of course, if the `Vim` keys are used, any other shortcut binded to them have to
|
||||
be removed from rc.lua.
|
||||
|
||||
# Settings
|
||||
|
||||
```lua
|
||||
-- Swap clients across screen instead of adding them to the other tag
|
||||
collision.settings.swap_across_screen = true
|
||||
```
|
||||
|
|
11
focus.lua
11
focus.lua
|
@ -5,11 +5,13 @@ local setmetatable = setmetatable
|
|||
local ipairs = ipairs
|
||||
local util = require( "awful.util" )
|
||||
local client = require( "awful.client" )
|
||||
local tag = require( "awful.tag" )
|
||||
local alayout = require( "awful.layout" )
|
||||
local wibox = require( "wibox" )
|
||||
local cairo = require( "lgi" ).cairo
|
||||
local beautiful = require( "beautiful" )
|
||||
local color = require( "gears.color" )
|
||||
local col_utils = require( "collision.util" )
|
||||
|
||||
local module = {}
|
||||
local wiboxes,delta = nil,100
|
||||
|
@ -142,8 +144,15 @@ local function bydirection(dir, c, swap,max)
|
|||
capi.client.focus = cltbl[((not cltbl[target] and #cltbl == 1) and 1 or target)]
|
||||
capi.client.focus:raise()
|
||||
else
|
||||
local other = cltbl[((not cltbl[target] and #cltbl == 1) and 1 or target)]
|
||||
if other.screen == c.screen or col_utils.settings.swap_across_screen then
|
||||
--BUG swap doesn't work if the screen is not the same
|
||||
c:swap(cltbl[((not cltbl[target] and #cltbl == 1) and 1 or target)])
|
||||
c:swap(other)
|
||||
else
|
||||
local t = tag.selected(other.screen) --TODO get index
|
||||
c.screen = other.screen
|
||||
c:tags({t})
|
||||
end
|
||||
end
|
||||
display_wiboxes(cltbl,geomtbl,float,swap,c)
|
||||
end
|
||||
|
|
21
init.lua
21
init.lua
|
@ -2,11 +2,14 @@ local capi = {root=root,client=client,mouse=mouse,
|
|||
screen = screen, keygrabber = keygrabber}
|
||||
local util = require( "awful.util" )
|
||||
local awful = require( "awful" )
|
||||
local glib = require( "lgi" ).GLib
|
||||
local col_utils = require( "collision.util" )
|
||||
local module = {
|
||||
_focus = require( "collision.focus" ),
|
||||
_resize = require( "collision.resize"),
|
||||
_max = require( "collision.max" ),
|
||||
_screen = require( "collision.screen"),
|
||||
settings= col_utils.settings ,
|
||||
}
|
||||
|
||||
local current_mode = "focus"
|
||||
|
@ -109,11 +112,11 @@ function module.resize(direction,c,max)
|
|||
module._resize.display(c)
|
||||
end
|
||||
|
||||
function module.tag(direction,c,max)
|
||||
function module.tag(direction,swap,max)
|
||||
current_mode = "tag"
|
||||
local c = c or capi.client.focus
|
||||
module._max.display_tags((c) and c.screen or capi.mouse.screen,direction)
|
||||
start_loop(false,max)
|
||||
local c = capi.client.focus
|
||||
module._max.display_tags((c) and c.screen or capi.mouse.screen,direction,c,true,max)
|
||||
start_loop(swap,max)
|
||||
end
|
||||
|
||||
function module.screen(direction)
|
||||
|
@ -127,20 +130,24 @@ local function new(k)
|
|||
keys = k or keys
|
||||
local aw = {}
|
||||
|
||||
-- This have to be executer after rc.lua
|
||||
glib.idle_add(glib.PRIORITY_DEFAULT_IDLE, function()
|
||||
for k,v in pairs(keys) do
|
||||
for _,key_nane in ipairs(v) do
|
||||
aw[#aw+1] = awful.key({ "Mod4", }, key_nane, function () module.focus (k ) end)
|
||||
aw[#aw+1] = awful.key({ "Mod4", "Mod1" }, key_nane, function () module.resize(k ) end)
|
||||
aw[#aw+1] = awful.key({ "Mod4", "Shift" }, key_nane, function () module.move (k ) end)
|
||||
aw[#aw+1] = awful.key({ "Mod4", "Shift", "Control" }, key_nane, function () module.move (k,nil,true) end)
|
||||
aw[#aw+1] = awful.key({ "Mod4", "Control" }, key_nane, function () module.focus (k,nil,true) end)
|
||||
aw[#aw+1] = awful.key({ "Mod4", "Shift", "Control" }, key_nane, function () module.move (k,nil ,true) end)
|
||||
aw[#aw+1] = awful.key({ "Mod4", "Control" }, key_nane, function () module.focus (k,nil ,true) end)
|
||||
aw[#aw+1] = awful.key({ "Mod4", "Mod1" , "Control" }, key_nane, function () module.screen(k ) end)
|
||||
if k == "left" or k =="right" then -- Conflict with my text editor, so I say no
|
||||
aw[#aw+1] = awful.key({ "Mod1", "Control" }, key_nane, function () module.tag (k,nil,true) end)
|
||||
aw[#aw+1] = awful.key({ "Mod1", "Control" }, key_nane, function () module.tag (k,nil ,true) end)
|
||||
aw[#aw+1] = awful.key({ "Mod1", "Shift", "Control" }, key_nane, function () module.tag (k,true,true) end)
|
||||
end
|
||||
end
|
||||
end
|
||||
capi.root.keys(awful.util.table.join(capi.root.keys(),unpack(aw)))
|
||||
end)
|
||||
end
|
||||
|
||||
return setmetatable(module, { __call = function(_, ...) return new(...) end })
|
||||
|
|
32
max.lua
32
max.lua
|
@ -1,4 +1,4 @@
|
|||
local capi = {screen=screen,client=client}
|
||||
local capi = {screen=screen,client=client,mouse=mouse}
|
||||
local wibox = require("wibox")
|
||||
local awful = require("awful")
|
||||
local cairo = require( "lgi" ).cairo
|
||||
|
@ -243,26 +243,32 @@ local function tag_icon(t,width,height)
|
|||
return img
|
||||
end
|
||||
|
||||
local tmp_screen = nil
|
||||
function module.display_tags(s,direction)
|
||||
if not w then
|
||||
init()
|
||||
end
|
||||
tmp_screen = s
|
||||
if direction then
|
||||
local function change_tag(s,direction,is_swap)
|
||||
local s = capi.client.focus and capi.client.focus.screen or capi.mouse.screen
|
||||
if not is_swap then
|
||||
awful.tag[direction == "left" and "viewprev" or "viewnext"](s)
|
||||
else
|
||||
-- Move the tag
|
||||
local t = awful.tag.selected(s)
|
||||
local cur_idx,count = awful.tag.getidx(t),#awful.tag.gettags(s)
|
||||
cur_idx = cur_idx + (direction == "left" and -1 or 1)
|
||||
cur_idx = cur_idx == 0 and count or cur_idx > count and 1 or cur_idx
|
||||
awful.tag.move(cur_idx,t)
|
||||
end
|
||||
local tags = awful.tag.gettags(s)
|
||||
local fk = awful.util.table.hasitem(tags,awful.tag.selected(s))
|
||||
draw_shape(s,tags,fk,tag_icon,capi.screen[s].workarea.y + 15,20)
|
||||
end
|
||||
|
||||
function module.display_tags(s,direction,c,is_swap,is_max)
|
||||
if not w then
|
||||
init()
|
||||
end
|
||||
change_tag(s,direction,is_swap)
|
||||
end
|
||||
|
||||
function module.change_tag(mod,key,event,direction,is_swap,is_max)
|
||||
local s = tmp_screen or capi.client.focus.screen
|
||||
awful.tag[direction == "left" and "viewprev" or "viewnext"](s)
|
||||
local tags = awful.tag.gettags(s)
|
||||
local fk = awful.util.table.hasitem(tags,awful.tag.selected(s))
|
||||
draw_shape(s,tags,fk,tag_icon,capi.screen[s].workarea.y + 15,20)
|
||||
change_tag(s,direction,is_swap)
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue