Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #14 from gdott9/master

Modified getpos to work with multiple screens
  • Loading branch information...
commit 62ea299b377bfc55d6f84de448a64dddc5ecd479 2 parents 1de8b87 + 6c771d9
@bioe007 authored
Showing with 44 additions and 29 deletions.
  1. +44 −29 init.lua
View
73 init.lua
@@ -820,41 +820,53 @@ function getpos(pos, scr_arg)
end
if #existing > 0 then
- -- if making another of an existing tag, return the end of
- -- the list the optional 2nd argument decides if we return
- -- only
- if scr_arg ~= nil then
+ -- if there is no selected tag on current screen, look for the first one
+ if not selected then
for _, tag in pairs(existing) do
- if tag.screen == scr_arg then return tag end
+ if tag.screen == scr then return tag end
end
- -- no tag with a position and scr_arg match found, clear
- -- v and allow the subseqeunt conditions to be evaluated
- v = nil
- else
- v = (selected and
- existing[awful.util.cycle(#existing, selected + 1)]) or
- existing[1]
+
+ -- no tag found, loop through the other tags
+ selected = #existing
end
+ -- look for the next unselected tag
+ i = selected
+ repeat
+ i = awful.util.cycle(#existing, i + 1)
+ tag = existing[i]
+
+ if (scr_arg == nil or tag.screen == scr_arg) and not tag.selected then return tag end
+ until i == selected
+
+ -- if the screen is not specified or
+ -- if a selected tag exists on the specified screen
+ -- return the selected tag
+ if scr_arg == nil or existing[selected].screen == scr then return existing[selected] end
+
+ -- if scr_arg ~= nil and no tag exists on this screen, continue
end
- if not v then
- -- search for preconf with 'pos' and create it
- for i, j in pairs(config.tags) do
- if j.position == pos then
- v = add({name = i,
- position = pos,
- noswitch = not switch})
- end
+
+ local screens = {}
+ for s = 1, capi.screen.count() do table.insert(screens, s) end
+
+ -- search for preconf with 'pos' on current screen and create it
+ for i, j in pairs(config.tags) do
+ local tag_scr = j.screen or screens
+ if type(tag_scr) ~= 'table' then tag_scr = {tag_scr} end
+
+ if j.position == pos and awful.util.table.hasitem(tag_scr, scr) then
+ return add({name = i,
+ position = pos,
+ noswitch = not switch})
end
end
- if not v then
- -- not existing, not preconfigured
- v = add({position = pos,
- rename = pos .. ':',
- no_selectall = true,
- noswitch = not switch})
- end
- return v
+
+ -- not existing, not preconfigured
+ return add({position = pos,
+ rename = pos .. ':',
+ no_selectall = true,
+ noswitch = not switch})
end
--init : search shifty.config.tags for initial set of
@@ -862,8 +874,11 @@ end
function init()
local numscr = capi.screen.count()
+ local screens = {}
+ for s = 1, capi.screen.count() do table.insert(screens, s) end
+
for i, j in pairs(config.tags) do
- local scr = j.screen or {1}
+ local scr = j.screen or screens
if type(scr) ~= 'table' then
scr = {scr}
end
Please sign in to comment.
Something went wrong with that request. Please try again.