-- Awesomewm configuration -- Standard awesome library local gears = require("gears") local awful = require("awful") awful.rules = require("awful.rules") autofocus = require("awful.autofocus") ewmh = require("awful.ewmh") -- Theme handling library local beautiful = require("beautiful") -- Notifications --local naughty = require("naughty") -- {{{ Variable definitions -- Themes define colours, icons, and wallpapers beautiful.init(awful.util.getdir("config") .. "/theme.lua") --beautiful.init("/usr/share/awesome/themes/zenburn/theme.lua") terminal = "konsole" editor = os.getenv("EDITOR") or "vim" editor_cmd = terminal .. " -e " .. editor modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. -- Look for more layouts in apidoc or standard config local layouts = { awful.layout.suit.tile, awful.layout.suit.floating, awful.layout.suit.max.fullscreen, awful.layout.suit.fair } -- }}} -- {{{ Tags -- Define a tag table which hold all screen tags. tags = {} for s = 1, screen.count() do -- Each screen has its own tag table. tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1]) end -- }}} -- {{{ Key bindings globalkeys = awful.util.table.join( awful.key({ modkey, }, "Left", function () awful.tag.viewprev() end), awful.key({ modkey, }, "Right", function () awful.tag.viewnext() end), awful.key({ modkey, }, "j", function () awful.client.focus.byidx( 1) if client.focus then client.focus:raise() end end), awful.key({ modkey, }, "k", function () awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end end), -- Layout manipulation awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end), awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end), awful.key({ modkey, }, "u", awful.client.urgent.jumpto), awful.key({ modkey, }, "Tab", function () awful.client.focus.history.previous() if client.focus then client.focus:raise() end end), -- Standard program awful.key({ modkey, "Control" }, "r", awesome.restart), awful.key({ modkey, "Shift" }, "q", awesome.quit), awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end), -- TODO Toggle between floating and tile awful.key({ modkey, }, "a", function () awful.layout.set(awful.layout.suit.tile,nil) end), awful.key({ modkey, }, "t", function () awful.layout.set(awful.layout.suit.floating,nil) end), awful.key({ modkey, "Control" }, "n", awful.client.restore) ) clientkeys = awful.util.table.join( awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), awful.key({ modkey, }, "c", function (c) c:kill() end), awful.key({ modkey, }, "x", awful.client.toggletag(awful.tag.selected(mouse.screen)) ), awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), awful.key({ modkey, }, "o", awful.client.movetoscreen ), awful.key({ modkey, }, "n", function (c) -- The client currently has the input focus, so it cannot be -- minimized, since minimized clients can't have the focus. c.minimized = true end), awful.key({ modkey, }, "m", function (c) -- No, don't maximize. Maximizing doesn't make sense here --c.maximized_horizontal = not c.maximized_horizontal --c.maximized_vertical = not c.maximized_vertical c.maximized_horizontal = false c.maximized_vertical = false end) ) -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it works on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. for i = 1, 9 do globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey }, "#" .. i + 9, function () local screen = mouse.screen local tag = awful.tag.gettags(screen)[i] if tag then awful.tag.viewonly(tag) end end), awful.key({ modkey, "Control" }, "#" .. i + 9, function () local screen = mouse.screen local tag = awful.tag.gettags(screen)[i] if tag then awful.tag.viewtoggle(tag) end end), awful.key({ modkey, "Shift" }, "#" .. i + 9, function () local tag = awful.tag.gettags(client.focus.screen)[i] if client.focus and tag then awful.client.movetotag(tag) end end), awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function () local tag = awful.tag.gettags(client.focus.screen)[i] if client.focus and tag then awful.client.toggletag(tag) end end)) end clientbuttons = awful.util.table.join( awful.button({ }, 1, function (c) client.focus = c; c:raise() end), awful.button({ modkey }, 1, awful.mouse.client.move), awful.button({ modkey }, 3, awful.mouse.client.resize)) -- Set keys root.keys(globalkeys) -- }}} -- {{{ Rules -- TODO: Cleanup awful.rules.rules = { { rule = { }, properties = { border_width = beautiful.border_width, border_color = beautiful.border_normal, focus = awful.client.focus.filter, keys = clientkeys, size_hints_honor = true, buttons = clientbuttons } }, { rule = { class = "Yakuake" }, properties = { floating = true, ontop = true, above = true,size_hints_honor = true, width=1366, maximized_horizontal = true } }, { rule = { class = "Plasma" }, properties = { floating = true,sticky=true, size_hints_honor = true } }, --{ rule = { class = "Plasma", type = "dock" }, --properties = { x = 0, y = 0, size_hints_honor = false } }, { rule_any = { class = { "Plasma-desktop", "gimp", "pinentry", "MPlayer" }, properties = { floating = true, size_hints_honor = true,maximized_horizontal = false, maximized_vertical = false } } }, { rule = { class = "krunner" }, properties = { focus = true, ontop = true, size_hints_honor = false } }, { rule = { class = "Steam" }, properties = { tag = tags[1][4] } }, { rule = { class = "Firefox" }, properties = { tag = tags[1][2] } }, -- Flashplayer { rule = { class = "Plugin-container" }, properties = { floating = true } }, { rule = { type = "desktop" }, properties = { ontop = false, above = false, below = true, border_width = 0 } } } zeroborderrule = { class = {"Plasma-desktop", "gimp", "pinentry", "MPlayer", "Yakuake", "Plasma"} } zbtable = { rule_any = zeroborderrule, properties = { border_width = 0 } } for k,v in pairs(zbtable) do awful.rules.rules[k] = v end --table.insert(awful.rules.rules, zeroborderrule) -- }}} -- {{{ Signals -- Signal function to execute when a new client appears. client.connect_signal("manage", function (c, startup) -- Enable sloppy focus c:connect_signal("mouse::enter", function(c) if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier and awful.client.focus.filter(c) then client.focus = c end end) if not startup then -- Set the windows at the slave, -- i.e. put it at the end of others instead of setting it master. -- awful.client.setslave(c) -- Put windows in a smart way, only if they does not set an initial position. if not c.size_hints.user_position and not c.size_hints.program_position then awful.placement.no_overlap(c) awful.placement.no_offscreen(c) end else -- On startup smartborders(c) end -- Move the desktop to the bottom so it doesn't get focus on tag switching -- FIXME: Doesn't work perfectly (breaks when awesome is restarted) if c.class == "Plasma" and c.type == "desktop" then c:lower() --c:unmanage() -- essentially kill it end -- Move plasmoids under the mouse (without going offscreen) and size them according to their requirements (specified in _minimum_ size hints) -- TODO: Avoid struts (probably not struts per se) if c.class == "Plasma-desktop" and c.type ~= "dock" and c.skip_taskbar then c:geometry( { width = c.size_hints.min_width, height = c.size_hints.min_height } ) awful.placement.under_mouse(c) awful.placement.no_offscreen(c) -- FIXME: This has no effect (46 is the width of the plasma panel) --c:geometry( { x = c.x + 46 } ) end -- Titlebars could go here end) client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) -- Smartborders - don't show borders for the only visible (bordered) window smartborders = function(c) if c then if awful.rules.match_any(c, zeroborderrule) then -- We've got a non-bordered window, this won't change anything c.border_width = 0 return end end for s = 1, screen.count() do local ts = 0 for _, t in ipairs(awful.tag.selectedlist(s)) do for _, cl in ipairs(t:clients()) do -- Only windows that should be bordered count here, so reset them if (not awful.rules.match_any(cl, zeroborderrule)) and cl.type ~= "dock" and cl.type ~= "desktop" then ts = ts + 1 end end end if ts < 2 then for _, t in ipairs(awful.tag.selectedlist(s)) do for _, cl in ipairs(t:clients()) do cl.border_width = 0 end end else -- Need to reset borders as we have more than one window that should be bordered for _, t in ipairs(awful.tag.selectedlist(s)) do for _, cl in ipairs(t:clients()) do if not awful.rules.match_any(cl, zeroborderrule) then cl.border_width = beautiful.border_width else cl.border_width = 0 end end end end end end client.connect_signal("tagged", smartborders) client.connect_signal("untagged", smartborders) -- For when a tag is added or removed (multiple tags) for s = 1 , screen.count() do awful.tag.attached_connect_signal(s, "property::selected", smartborders) screen[s]:connect_signal("tag::attach", smartborders) screen[s]:connect_signal("tag::detach", smartborders) end -- }}}