Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.85 KB | None | 0 0
  1. -- {{{ Signals
  2. -- Signal function to execute when a new client appears.
  3. client.connect_signal("manage", function (c, startup)
  4.     -- Enable sloppy focus
  5.     c:connect_signal("mouse::enter", function(c)
  6.         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
  7.             and awful.client.focus.filter(c) then
  8.             client.focus = c
  9.         end
  10.     end)
  11.  
  12.     if not startup then
  13.         -- Set the windows at the slave,
  14.         -- i.e. put it at the end of others instead of setting it master.
  15.         -- awful.client.setslave(c)
  16.  
  17.         -- Put windows in a smart way, only if they does not set an initial position.
  18.         if not c.size_hints.user_position and not c.size_hints.program_position then
  19.             awful.placement.no_overlap(c)    
  20.             awful.placement.no_offscreen(c)
  21.         end
  22.     end
  23.     -- You can skip this part if you don't want to have titlebars  
  24.     local titlebars_enabled = false
  25.     if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
  26.         -- buttons for the titlebar
  27.         local buttons = awful.util.table.join(
  28.                 awful.button({ }, 1, function()
  29.                     client.focus = c
  30.                     c:raise()
  31.                     awful.mouse.client.move(c)
  32.                 end),
  33.                 awful.button({ }, 3, function()
  34.                     client.focus = c
  35.                     c:raise()
  36.                     awful.mouse.client.resize(c)
  37.                 end)
  38.                 )
  39.  
  40.         -- Widgets that are aligned to the left
  41.         local left_layout = wibox.layout.fixed.horizontal()
  42.         left_layout:add(awful.titlebar.widget.iconwidget(c))
  43.         left_layout:buttons(buttons)
  44.  
  45.         -- Widgets that are aligned to the right
  46.         local right_layout = wibox.layout.fixed.horizontal()
  47.         right_layout:add(awful.titlebar.widget.floatingbutton(c))
  48.         right_layout:add(awful.titlebar.widget.maximizedbutton(c))
  49.         right_layout:add(awful.titlebar.widget.stickybutton(c))
  50.         right_layout:add(awful.titlebar.widget.ontopbutton(c))
  51.         right_layout:add(awful.titlebar.widget.closebutton(c))
  52.  
  53.         -- The title goes in the middle
  54.         local middle_layout = wibox.layout.flex.horizontal()
  55.         local title = awful.titlebar.widget.titlewidget(c)
  56.         title:set_align("center")
  57.         middle_layout:add(title)
  58.         middle_layout:buttons(buttons)
  59.  
  60.         -- Now bring it all together
  61.         local layout = wibox.layout.align.horizontal()
  62.         layout:set_left(left_layout)
  63.         layout:set_right(right_layout)
  64.         layout:set_middle(middle_layout)
  65.  
  66.         awful.titlebar(c):set_widget(layout)
  67.     end
  68. end)
  69.  
  70. client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
  71. client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
  72. -- }}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement