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
|
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)
|
~/.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
|
```lua
|
||||||
require("collision")()
|
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
|
Of course, if the `Vim` keys are used, any other shortcut binded to them have to
|
||||||
be removed from rc.lua.
|
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
|
||||||
|
```
|
||||||
|
|
27
focus.lua
27
focus.lua
|
@ -3,13 +3,15 @@ local capi = { client = client , mouse = mouse ,
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local util = require( "awful.util" )
|
local util = require( "awful.util" )
|
||||||
local client = require( "awful.client" )
|
local client = require( "awful.client" )
|
||||||
local alayout = require( "awful.layout" )
|
local tag = require( "awful.tag" )
|
||||||
local wibox = require( "wibox" )
|
local alayout = require( "awful.layout" )
|
||||||
local cairo = require( "lgi" ).cairo
|
local wibox = require( "wibox" )
|
||||||
local beautiful = require( "beautiful" )
|
local cairo = require( "lgi" ).cairo
|
||||||
local color = require( "gears.color" )
|
local beautiful = require( "beautiful" )
|
||||||
|
local color = require( "gears.color" )
|
||||||
|
local col_utils = require( "collision.util" )
|
||||||
|
|
||||||
local module = {}
|
local module = {}
|
||||||
local wiboxes,delta = nil,100
|
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 = cltbl[((not cltbl[target] and #cltbl == 1) and 1 or target)]
|
||||||
capi.client.focus:raise()
|
capi.client.focus:raise()
|
||||||
else
|
else
|
||||||
--BUG swap doesn't work if the screen is not the same
|
local other = cltbl[((not cltbl[target] and #cltbl == 1) and 1 or target)]
|
||||||
c:swap(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(other)
|
||||||
|
else
|
||||||
|
local t = tag.selected(other.screen) --TODO get index
|
||||||
|
c.screen = other.screen
|
||||||
|
c:tags({t})
|
||||||
|
end
|
||||||
end
|
end
|
||||||
display_wiboxes(cltbl,geomtbl,float,swap,c)
|
display_wiboxes(cltbl,geomtbl,float,swap,c)
|
||||||
end
|
end
|
||||||
|
|
43
init.lua
43
init.lua
|
@ -1,12 +1,15 @@
|
||||||
local capi = {root=root,client=client,mouse=mouse,
|
local capi = {root=root,client=client,mouse=mouse,
|
||||||
screen = screen, keygrabber = keygrabber}
|
screen = screen, keygrabber = keygrabber}
|
||||||
local util = require( "awful.util" )
|
local util = require( "awful.util" )
|
||||||
local awful = require( "awful" )
|
local awful = require( "awful" )
|
||||||
|
local glib = require( "lgi" ).GLib
|
||||||
|
local col_utils = require( "collision.util" )
|
||||||
local module = {
|
local module = {
|
||||||
_focus = require( "collision.focus" ),
|
_focus = require( "collision.focus" ),
|
||||||
_resize = require( "collision.resize"),
|
_resize = require( "collision.resize"),
|
||||||
_max = require( "collision.max" ),
|
_max = require( "collision.max" ),
|
||||||
_screen = require( "collision.screen"),
|
_screen = require( "collision.screen"),
|
||||||
|
settings= col_utils.settings ,
|
||||||
}
|
}
|
||||||
|
|
||||||
local current_mode = "focus"
|
local current_mode = "focus"
|
||||||
|
@ -109,11 +112,11 @@ function module.resize(direction,c,max)
|
||||||
module._resize.display(c)
|
module._resize.display(c)
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.tag(direction,c,max)
|
function module.tag(direction,swap,max)
|
||||||
current_mode = "tag"
|
current_mode = "tag"
|
||||||
local c = c or capi.client.focus
|
local c = capi.client.focus
|
||||||
module._max.display_tags((c) and c.screen or capi.mouse.screen,direction)
|
module._max.display_tags((c) and c.screen or capi.mouse.screen,direction,c,true,max)
|
||||||
start_loop(false,max)
|
start_loop(swap,max)
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.screen(direction)
|
function module.screen(direction)
|
||||||
|
@ -127,20 +130,24 @@ local function new(k)
|
||||||
keys = k or keys
|
keys = k or keys
|
||||||
local aw = {}
|
local aw = {}
|
||||||
|
|
||||||
for k,v in pairs(keys) do
|
-- This have to be executer after rc.lua
|
||||||
for _,key_nane in ipairs(v) do
|
glib.idle_add(glib.PRIORITY_DEFAULT_IDLE, function()
|
||||||
aw[#aw+1] = awful.key({ "Mod4", }, key_nane, function () module.focus (k ) end)
|
for k,v in pairs(keys) do
|
||||||
aw[#aw+1] = awful.key({ "Mod4", "Mod1" }, key_nane, function () module.resize(k ) end)
|
for _,key_nane in ipairs(v) do
|
||||||
aw[#aw+1] = awful.key({ "Mod4", "Shift" }, key_nane, function () module.move (k ) end)
|
aw[#aw+1] = awful.key({ "Mod4", }, key_nane, function () module.focus (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", "Mod1" }, key_nane, function () module.resize(k ) end)
|
||||||
aw[#aw+1] = awful.key({ "Mod4", "Control" }, key_nane, function () module.focus (k,nil,true) end)
|
aw[#aw+1] = awful.key({ "Mod4", "Shift" }, key_nane, function () module.move (k ) end)
|
||||||
aw[#aw+1] = awful.key({ "Mod4", "Mod1" , "Control" }, key_nane, function () module.screen(k ) end)
|
aw[#aw+1] = awful.key({ "Mod4", "Shift", "Control" }, key_nane, function () module.move (k,nil ,true) end)
|
||||||
if k == "left" or k =="right" then -- Conflict with my text editor, so I say no
|
aw[#aw+1] = awful.key({ "Mod4", "Control" }, key_nane, function () module.focus (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({ "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", "Shift", "Control" }, key_nane, function () module.tag (k,true,true) end)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
capi.root.keys(awful.util.table.join(capi.root.keys(),unpack(aw)))
|
||||||
capi.root.keys(awful.util.table.join(capi.root.keys(),unpack(aw)))
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(module, { __call = function(_, ...) return new(...) 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 wibox = require("wibox")
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local cairo = require( "lgi" ).cairo
|
local cairo = require( "lgi" ).cairo
|
||||||
|
@ -243,26 +243,32 @@ local function tag_icon(t,width,height)
|
||||||
return img
|
return img
|
||||||
end
|
end
|
||||||
|
|
||||||
local tmp_screen = nil
|
local function change_tag(s,direction,is_swap)
|
||||||
function module.display_tags(s,direction)
|
local s = capi.client.focus and capi.client.focus.screen or capi.mouse.screen
|
||||||
if not w then
|
if not is_swap then
|
||||||
init()
|
|
||||||
end
|
|
||||||
tmp_screen = s
|
|
||||||
if direction then
|
|
||||||
awful.tag[direction == "left" and "viewprev" or "viewnext"](s)
|
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
|
end
|
||||||
local tags = awful.tag.gettags(s)
|
local tags = awful.tag.gettags(s)
|
||||||
local fk = awful.util.table.hasitem(tags,awful.tag.selected(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)
|
draw_shape(s,tags,fk,tag_icon,capi.screen[s].workarea.y + 15,20)
|
||||||
end
|
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)
|
function module.change_tag(mod,key,event,direction,is_swap,is_max)
|
||||||
local s = tmp_screen or capi.client.focus.screen
|
change_tag(s,direction,is_swap)
|
||||||
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)
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue