Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Extended application matching #10

Merged
merged 1 commit into from

3 participants

@TheMarex

I made it possible to match for specific attributes like class and instance. Now application rules as follows are possible:

{
    match = {
        class = {
            "Do",
        },
        "clock%-applet",
    },
    float = true,
    intrusive = true,
},
@masterkorp masterkorp was assigned
@bioe007
Owner

This would close issue #2

I'm in favor but need to rewrite the readme and wiki

I can probably manage that this week, unless someone else will :)

Perhaps even a message in awesome mailing list.

@bioe007 bioe007 referenced this pull request
Closed

improve matching granularity #2

@masterkorp
Collaborator

Ok, gave a look at the code. Its nice. Will test it on my setup and documente on the readme and wiki.

@masterkorp masterkorp commented on the diff
((21 lines not shown))
- end
- if a.geometry ~=nil then
- geom = {x = a.geometry[1],
- y = a.geometry[2],
- width = a.geometry[3],
- height = a.geometry[4]}
- end
- if a.float ~= nil then float = a.float end
- if a.slave ~=nil then slave = a.slave end
- if a.border_width ~= nil then
- c.border_width = a.border_width
+ local matched = false
+ -- match only class
+ if not matched and cls and a.match.class then
+ for k, w in ipairs(a.match.class) do
+ matched = cls:find(w)
@masterkorp Collaborator

I personally dont like this syntax sugar things. It s inconsistent in this library tough. So i guess it OK.

@bioe007 Owner
bioe007 added a note

You mean the colon for member functions? I would say there is a lot of other ugliness in the code...

w0w.. didn't even know we could do this commenting in lines. O.O

@masterkorp Collaborator

Yeah its pretty sweet to discuss code :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@masterkorp masterkorp merged commit 48a220f into bioe007:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 20, 2012
This page is out of date. Refresh to see the latest.
Showing with 120 additions and 67 deletions.
  1. +120 −67 init.lua
View
187 init.lua
@@ -475,80 +475,133 @@ function match(c, startup)
-- try matching client to config.apps
for i, a in ipairs(config.apps) do
if a.match then
- for k, w in ipairs(a.match) do
- if
- (cls and cls:find(w)) or
- (inst and inst:find(w)) or
- (name and name:find(w)) or
- (role and role:find(w)) or
- (typ and typ:find(w)) then
- if a.screen then target_screen = a.screen end
- if a.tag then
- if type(a.tag) == "string" then
- target_tag_names = {a.tag}
- else
- target_tag_names = a.tag
- end
- end
- if a.startup and startup then
- a = awful.util.table.join(a, a.startup)
- end
- if a.geometry ~=nil then
- geom = {x = a.geometry[1],
- y = a.geometry[2],
- width = a.geometry[3],
- height = a.geometry[4]}
- end
- if a.float ~= nil then float = a.float end
- if a.slave ~=nil then slave = a.slave end
- if a.border_width ~= nil then
- c.border_width = a.border_width
+ local matched = false
+ -- match only class
+ if not matched and cls and a.match.class then
+ for k, w in ipairs(a.match.class) do
+ matched = cls:find(w)
@masterkorp Collaborator

I personally dont like this syntax sugar things. It s inconsistent in this library tough. So i guess it OK.

@bioe007 Owner
bioe007 added a note

You mean the colon for member functions? I would say there is a lot of other ugliness in the code...

w0w.. didn't even know we could do this commenting in lines. O.O

@masterkorp Collaborator

Yeah its pretty sweet to discuss code :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if matched then
+ break
end
- if a.nopopup ~=nil then nopopup = a.nopopup end
- if a.intrusive ~=nil then
- intrusive = a.intrusive
- end
- if a.fullscreen ~=nil then
- c.fullscreen = a.fullscreen
- end
- if a.honorsizehints ~=nil then
- c.size_hints_honor = a.honorsizehints
- end
- if a.kill ~=nil then c:kill(); return end
- if a.ontop ~= nil then c.ontop = a.ontop end
- if a.above ~= nil then c.above = a.above end
- if a.below ~= nil then c.below = a.below end
- if a.buttons ~= nil then
- c:buttons(a.buttons)
- end
- if a.nofocus ~= nil then nofocus = a.nofocus end
- if a.keys ~= nil then
- keys = awful.util.table.join(keys, a.keys)
+ end
+ end
+ -- match only instance
+ if not matched and inst and a.match.instance then
+ for k, w in ipairs(a.match.instance) do
+ matched = inst:find(w)
+ if matched then
+ break
end
- if a.hidden ~= nil then c.hidden = a.hidden end
- if a.minimized ~= nil then
- c.minimized = a.minimized
+ end
+ end
+ -- match only name
+ if not matched and name and a.match.name then
+ for k, w in ipairs(a.match.name) do
+ matched = name:find(w)
+ if matched then
+ break
end
- if a.dockable ~= nil then
- awful.client.dockable.set(c, a.dockable)
+ end
+ end
+ -- match only role
+ if not matched and role and a.match.role then
+ for k, w in ipairs(a.match.role) do
+ matched = role:find(w)
+ if matched then
+ break
end
- if a.urgent ~= nil then
- c.urgent = a.urgent
+ end
+ end
+ -- match only type
+ if not matched and typ and a.match.type then
+ for k, w in ipairs(a.match.type) do
+ matched = typ:find(w)
+ if matched then
+ break
end
- if a.opacity ~= nil then
- c.opacity = a.opacity
+ end
+ end
+ -- check everything else against all attributes
+ if not matched then
+ for k, w in ipairs(a.match) do
+ matched = (cls and cls:find(w)) or
+ (inst and inst:find(w)) or
+ (name and name:find(w)) or
+ (role and role:find(w)) or
+ (typ and typ:find(w))
+ if matched then
+ break
end
- if a.run ~= nil then run = a.run end
- if a.sticky ~= nil then c.sticky = a.sticky end
- if a.wfact ~= nil then wfact = a.wfact end
- if a.struts then struts = a.struts end
- if a.skip_taskbar ~= nil then
- c.skip_taskbar = a.skip_taskbar
+ end
+ end
+ -- set attributes
+ if matched then
+ if a.screen then target_screen = a.screen end
+ if a.tag then
+ if type(a.tag) == "string" then
+ target_tag_names = {a.tag}
+ else
+ target_tag_names = a.tag
end
- if a.props then
- for kk, vv in pairs(a.props) do
- awful.client.property.set(c, kk, vv)
- end
+ end
+ if a.startup and startup then
+ a = awful.util.table.join(a, a.startup)
+ end
+ if a.geometry ~=nil then
+ geom = {x = a.geometry[1],
+ y = a.geometry[2],
+ width = a.geometry[3],
+ height = a.geometry[4]}
+ end
+ if a.float ~= nil then float = a.float end
+ if a.slave ~=nil then slave = a.slave end
+ if a.border_width ~= nil then
+ c.border_width = a.border_width
+ end
+ if a.nopopup ~=nil then nopopup = a.nopopup end
+ if a.intrusive ~=nil then
+ intrusive = a.intrusive
+ end
+ if a.fullscreen ~=nil then
+ c.fullscreen = a.fullscreen
+ end
+ if a.honorsizehints ~=nil then
+ c.size_hints_honor = a.honorsizehints
+ end
+ if a.kill ~=nil then c:kill(); return end
+ if a.ontop ~= nil then c.ontop = a.ontop end
+ if a.above ~= nil then c.above = a.above end
+ if a.below ~= nil then c.below = a.below end
+ if a.buttons ~= nil then
+ c:buttons(a.buttons)
+ end
+ if a.nofocus ~= nil then nofocus = a.nofocus end
+ if a.keys ~= nil then
+ keys = awful.util.table.join(keys, a.keys)
+ end
+ if a.hidden ~= nil then c.hidden = a.hidden end
+ if a.minimized ~= nil then
+ c.minimized = a.minimized
+ end
+ if a.dockable ~= nil then
+ awful.client.dockable.set(c, a.dockable)
+ end
+ if a.urgent ~= nil then
+ c.urgent = a.urgent
+ end
+ if a.opacity ~= nil then
+ c.opacity = a.opacity
+ end
+ if a.run ~= nil then run = a.run end
+ if a.sticky ~= nil then c.sticky = a.sticky end
+ if a.wfact ~= nil then wfact = a.wfact end
+ if a.struts then struts = a.struts end
+ if a.skip_taskbar ~= nil then
+ c.skip_taskbar = a.skip_taskbar
+ end
+ if a.props then
+ for kk, vv in pairs(a.props) do
+ awful.client.property.set(c, kk, vv)
end
end
end
Something went wrong with that request. Please try again.