mirror of
https://github.com/elenapan/dotfiles.git
synced 2026-01-09 10:42:41 +08:00
Former-commit-id: 4295c806ec
Former-commit-id: c87f8e56cd2677dbb5a2a15e90f879a9fa1a1a6b
Former-commit-id: 1ad787023efcecb57853b9a5103dff461192e56d
Former-commit-id: 595bf6d1621414a7b6e7d8e9acb374ce52687596
137 lines
4.8 KiB
Lua
137 lines
4.8 KiB
Lua
local awful = require("awful")
|
|
local gears = require("gears")
|
|
local beautiful = require("beautiful")
|
|
local wibox = require("wibox")
|
|
|
|
local helpers = require("helpers")
|
|
local titlebars = {}
|
|
local pad = helpers.pad
|
|
|
|
-- Mouse buttons
|
|
titlebars.buttons = gears.table.join(
|
|
-- Left button - move
|
|
awful.button({ }, 1, function()
|
|
c = mouse.object_under_pointer()
|
|
client.focus = c
|
|
c:raise()
|
|
awful.mouse.client.move(c)
|
|
end),
|
|
-- Middle button - close
|
|
awful.button({ }, 2, function ()
|
|
window_to_kill = mouse.object_under_pointer()
|
|
window_to_kill:kill()
|
|
end),
|
|
-- Right button - resize
|
|
awful.button({ }, 3, function()
|
|
c = mouse.object_under_pointer()
|
|
client.focus = c
|
|
c:raise()
|
|
awful.mouse.client.resize(c)
|
|
end),
|
|
-- Scroll up - toggle ontop
|
|
awful.button({ }, 4, function()
|
|
c = mouse.object_under_pointer()
|
|
--c.maximized = not c.maximized
|
|
c.ontop = not c.ontop
|
|
c:raise()
|
|
end),
|
|
-- Scroll down - minimize
|
|
awful.button({ }, 5, function()
|
|
c = mouse.object_under_pointer()
|
|
c.minimized = true
|
|
end),
|
|
-- Side button up - toggle floating
|
|
awful.button({ }, 9, function()
|
|
c = mouse.object_under_pointer()
|
|
--client.focus = c
|
|
--awful.placement.centered(c,{honor_workarea=true})
|
|
c.floating = not c.floating
|
|
c:raise()
|
|
end),
|
|
-- Side button down - toggle sticky
|
|
awful.button({ }, 8, function()
|
|
c = mouse.object_under_pointer()
|
|
c.sticky = not c.sticky
|
|
end)
|
|
)
|
|
|
|
-- Disable popup tooltip on titlebar button hover
|
|
awful.titlebar.enable_tooltip = false
|
|
|
|
-- Add a titlebar
|
|
client.connect_signal("request::titlebars", function(c)
|
|
local buttons = titlebars.buttons
|
|
|
|
local title_widget
|
|
if beautiful.titlebar_title_enabled then
|
|
title_widget = awful.titlebar.widget.titlewidget(c)
|
|
title_widget:set_align(beautiful.titlebar_title_align)
|
|
else
|
|
title_widget = wibox.widget.textbox("")
|
|
end
|
|
|
|
local titlebar_item_layout
|
|
local titlebar_layout
|
|
if beautiful.titlebar_position == "left" or beautiful.titlebar_position == "right" then
|
|
titlebar_item_layout = wibox.layout.fixed.vertical
|
|
titlebar_layout = wibox.layout.align.vertical
|
|
else
|
|
titlebar_item_layout = wibox.layout.fixed.horizontal
|
|
titlebar_layout = wibox.layout.align.horizontal
|
|
end
|
|
|
|
-- Create 4 dummy titlebars around the window to imitate borders
|
|
if beautiful.titlebars_imitate_borders then
|
|
helpers.create_titlebar(c, buttons, "top", beautiful.titlebar_size)
|
|
helpers.create_titlebar(c, buttons, "bottom", beautiful.titlebar_size)
|
|
helpers.create_titlebar(c, buttons, "left", beautiful.titlebar_size)
|
|
helpers.create_titlebar(c, buttons, "right", beautiful.titlebar_size)
|
|
else -- Normal, single titlebar
|
|
awful.titlebar(c, {font = beautiful.titlebar_font, position = beautiful.titlebar_position, size = beautiful.titlebar_size}) : setup {
|
|
-- Titlebar items
|
|
{ -- Left
|
|
-- In the presence of buttons, use padding to center the title if needed.
|
|
--pad(10),
|
|
-- Clickable buttons
|
|
--awful.titlebar.widget.closebutton (c),
|
|
--awful.titlebar.widget.maximizedbutton(c),
|
|
--awful.titlebar.widget.minimizebutton (c),
|
|
--awful.titlebar.widget.ontopbutton (c),
|
|
--awful.titlebar.widget.stickybutton (c),
|
|
--awful.titlebar.widget.floatingbutton (c),
|
|
|
|
buttons = buttons,
|
|
--awful.titlebar.widget.iconwidget(c),
|
|
|
|
layout = titlebar_item_layout
|
|
},
|
|
{ -- Middle
|
|
--{ -- Title
|
|
--align = beautiful.titlebar_title_align,
|
|
--widget = title_widget
|
|
--},
|
|
title_widget,
|
|
buttons = buttons,
|
|
layout = wibox.layout.flex.horizontal
|
|
},
|
|
{ -- Right
|
|
-- Clickable buttons
|
|
--awful.titlebar.widget.floatingbutton (c),
|
|
--awful.titlebar.widget.stickybutton (c),
|
|
--awful.titlebar.widget.ontopbutton (c),
|
|
awful.titlebar.widget.minimizebutton(c),
|
|
awful.titlebar.widget.maximizedbutton(c),
|
|
awful.titlebar.widget.closebutton (c),
|
|
--buttons = buttons,
|
|
-- In the presence of buttons, use padding to center the title if needed.
|
|
--pad(10),
|
|
layout = titlebar_item_layout
|
|
--layout = wibox.layout.fixed.horizontal()
|
|
},
|
|
layout = titlebar_layout
|
|
--layout = wibox.layout.align.horizontal
|
|
}
|
|
end
|
|
end)
|
|
|
|
return titlebars
|