[DEV] update awesome config

This commit is contained in:
Edouard DUPIN 2017-03-02 09:29:12 +01:00
parent 7f7ef06cf7
commit 104499f033

View File

@ -1,7 +1,6 @@
-- Standard awesome library -- Standard awesome library
local gears = require("gears") local gears = require("gears")
local awful = require("awful") local awful = require("awful")
awful.rules = require("awful.rules")
require("awful.autofocus") require("awful.autofocus")
-- Widget and layout library -- Widget and layout library
local wibox = require("wibox") local wibox = require("wibox")
@ -10,6 +9,7 @@ local beautiful = require("beautiful")
-- Notification library -- Notification library
local naughty = require("naughty") local naughty = require("naughty")
local menubar = require("menubar") local menubar = require("menubar")
local hotkeys_popup = require("awful.hotkeys_popup").widget
-- {{{ Error handling -- {{{ Error handling
-- Check if awesome encountered an error during startup and fell back to -- Check if awesome encountered an error during startup and fell back to
@ -30,7 +30,7 @@ do
naughty.notify({ preset = naughty.config.presets.critical, naughty.notify({ preset = naughty.config.presets.critical,
title = "Oops, an error happened!", title = "Oops, an error happened!",
text = err }) text = tostring(err) })
in_error = false in_error = false
end) end)
end end
@ -38,11 +38,11 @@ end
-- {{{ Variable definitions -- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers. -- Themes define colours, icons, font and wallpapers.
--beautiful.init("/usr/share/awesome/themes/zenburn/theme.lua") beautiful.init(awful.util.get_themes_dir() .. "default/theme.lua")
beautiful.init("~/.config/awesome/theme/theme.lua")
-- This is used later as the default terminal and editor to run. -- This is used later as the default terminal and editor to run.
terminal = "terminator" terminal = "terminator"
-- terminal = "roxterm"
editor = os.getenv("EDITOR") or "edn" editor = os.getenv("EDITOR") or "edn"
editor_cmd = terminal .. " -e " .. editor editor_cmd = terminal .. " -e " .. editor
@ -54,51 +54,51 @@ editor_cmd = terminal .. " -e " .. editor
modkey = "Mod4" modkey = "Mod4"
-- Table of layouts to cover with awful.layout.inc, order matters. -- Table of layouts to cover with awful.layout.inc, order matters.
local layouts = awful.layout.layouts = {
{
awful.layout.suit.floating, awful.layout.suit.floating,
--awful.layout.suit.tile, -- awful.layout.suit.tile,
awful.layout.suit.tile.left, awful.layout.suit.tile.left,
--awful.layout.suit.tile.bottom, -- awful.layout.suit.tile.bottom,
--awful.layout.suit.tile.top, -- awful.layout.suit.tile.top,
--awful.layout.suit.fair, -- awful.layout.suit.fair,
--awful.layout.suit.fair.horizontal, -- awful.layout.suit.fair.horizontal,
--awful.layout.suit.spiral, -- awful.layout.suit.spiral,
--awful.layout.suit.spiral.dwindle, -- awful.layout.suit.spiral.dwindle,
awful.layout.suit.max, awful.layout.suit.max,
--awful.layout.suit.max.fullscreen, -- awful.layout.suit.max.fullscreen,
--awful.layout.suit.magnifier -- awful.layout.suit.magnifier,
-- awful.layout.suit.corner.nw,
-- awful.layout.suit.corner.ne,
-- awful.layout.suit.corner.sw,
-- awful.layout.suit.corner.se,
} }
-- }}} -- }}}
-- {{{ Wallpaper -- {{{ Helper functions
if beautiful.wallpaper then local function client_menu_toggle_fn()
for s = 1, screen.count() do local instance = nil
gears.wallpaper.maximized(beautiful.wallpaper, s, true)
return function ()
if instance and instance.wibox.visible then
instance:hide()
instance = nil
else
instance = awful.menu.clients({ theme = { width = 250 } })
end
end end
end end
-- }}} -- }}}
-- {{{ 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[10])
tags[s] = awful.tag({ 1, 2, 3, 4, 5}, s, layouts[3])
end
-- }}}
-- {{{ Menu -- {{{ Menu
-- Create a laucher widget and a main menu -- Create a launcher widget and a main menu
myawesomemenu = { myawesomemenu = {
{ "hotkeys", function() return false, hotkeys_popup.show_help end},
{ "manual", terminal .. " -e man awesome" }, { "manual", terminal .. " -e man awesome" },
{ "edit config", editor_cmd .. " " .. awesome.conffile }, { "edit config", editor_cmd .. " " .. awesome.conffile },
{ "restart", awesome.restart }, { "restart", awesome.restart },
{ "quit", awesome.quit } { "quit", function() awesome.quit() end}
} }
-- import external generic application menu:
xdg_menu = require("archmenu") xdg_menu = require("archmenu")
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
@ -119,25 +119,32 @@ mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
menubar.utils.terminal = terminal -- Set the terminal for applications that require it menubar.utils.terminal = terminal -- Set the terminal for applications that require it
-- }}} -- }}}
-- {{{ Wibox -- Keyboard map indicator and switcher
mykeyboardlayout = awful.widget.keyboardlayout()
-- {{{ Wibar
-- Create a textclock widget -- Create a textclock widget
mytextclock = awful.widget.textclock() mytextclock = wibox.widget.textclock()
-- Create a wibox for each screen and add it -- Create a wibox for each screen and add it
mywibox = {} local taglist_buttons = awful.util.table.join(
mypromptbox = {} awful.button({ }, 1, function(t) t:view_only() end),
mylayoutbox = {} awful.button({ modkey }, 1, function(t)
mytaglist = {} if client.focus then
mytaglist.buttons = awful.util.table.join( client.focus:move_to_tag(t)
awful.button({ }, 1, awful.tag.viewonly), end
awful.button({ modkey }, 1, awful.client.movetotag), end),
awful.button({ }, 3, awful.tag.viewtoggle), awful.button({ }, 3, awful.tag.viewtoggle),
awful.button({ modkey }, 3, awful.client.toggletag), awful.button({ modkey }, 3, function(t)
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end), if client.focus then
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end) client.focus:toggle_tag(t)
) end
mytasklist = {} end),
mytasklist.buttons = awful.util.table.join( awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
)
local tasklist_buttons = awful.util.table.join(
awful.button({ }, 1, function (c) awful.button({ }, 1, function (c)
if c == client.focus then if c == client.focus then
c.minimized = true c.minimized = true
@ -145,8 +152,8 @@ mytasklist.buttons = awful.util.table.join(
-- Without this, the following -- Without this, the following
-- :isvisible() makes no sense -- :isvisible() makes no sense
c.minimized = false c.minimized = false
if not c:isvisible() then if not c:isvisible() and c.first_tag then
awful.tag.viewonly(c:tags()[1]) c.first_tag:view_only()
end end
-- This will also un-minimize -- This will also un-minimize
-- the client, if needed -- the client, if needed
@ -154,65 +161,74 @@ mytasklist.buttons = awful.util.table.join(
c:raise() c:raise()
end end
end), end),
awful.button({ }, 3, function () awful.button({ }, 3, client_menu_toggle_fn()),
if instance then
instance:hide()
instance = nil
else
instance = awful.menu.clients({
theme = { width = 250 }
})
end
end),
awful.button({ }, 4, function () awful.button({ }, 4, function ()
awful.client.focus.byidx(1) awful.client.focus.byidx(1)
if client.focus then client.focus:raise() end
end), end),
awful.button({ }, 5, function () awful.button({ }, 5, function ()
awful.client.focus.byidx(-1) awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end
end)) end))
for s = 1, screen.count() do local function set_wallpaper(s)
-- Wallpaper
if beautiful.wallpaper then
local wallpaper = beautiful.wallpaper
-- If wallpaper is a function, call it with the screen
if type(wallpaper) == "function" then
wallpaper = wallpaper(s)
end
gears.wallpaper.maximized(wallpaper, s, true)
end
end
-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
screen.connect_signal("property::geometry", set_wallpaper)
awful.screen.connect_for_each_screen(function(s)
-- Wallpaper
set_wallpaper(s)
-- Each screen has its own tag table.
awful.tag({ "1", "2", "3", "4", "5"}, s, awful.layout.layouts[1])
-- Create a promptbox for each screen -- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt() s.mypromptbox = awful.widget.prompt()
-- Create an imagebox widget which will contains an icon indicating which layout we're using. -- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen. -- We need one layoutbox per screen.
mylayoutbox[s] = awful.widget.layoutbox(s) s.mylayoutbox = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(awful.util.table.join( s.mylayoutbox:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 1, function () awful.layout.inc( 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), awful.button({ }, 3, function () awful.layout.inc(-1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 4, function () awful.layout.inc( 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) awful.button({ }, 5, function () awful.layout.inc(-1) end)))
-- Create a taglist widget -- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons) s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
-- Create a tasklist widget -- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons) s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
-- Create the wibox -- Create the wibox
mywibox[s] = awful.wibox({ position = "top", screen = s }) s.mywibox = awful.wibar({ position = "top", screen = s })
-- Widgets that are aligned to the left -- Add widgets to the wibox
local left_layout = wibox.layout.fixed.horizontal() s.mywibox:setup {
left_layout:add(mylauncher) layout = wibox.layout.align.horizontal,
left_layout:add(mytaglist[s]) { -- Left widgets
left_layout:add(mypromptbox[s]) layout = wibox.layout.fixed.horizontal,
mylauncher,
-- Widgets that are aligned to the right s.mytaglist,
local right_layout = wibox.layout.fixed.horizontal() s.mypromptbox,
if s == 1 then right_layout:add(wibox.widget.systray()) end },
right_layout:add(mytextclock) s.mytasklist, -- Middle widget
right_layout:add(mylayoutbox[s]) { -- Right widgets
layout = wibox.layout.fixed.horizontal,
-- Now bring it all together (with the tasklist in the middle) mykeyboardlayout,
local layout = wibox.layout.align.horizontal() wibox.widget.systray(),
layout:set_left(left_layout) mytextclock,
layout:set_middle(mytasklist[s]) s.mylayoutbox,
layout:set_right(right_layout) },
}
mywibox[s]:set_widget(layout) end)
end
-- }}} -- }}}
-- {{{ Mouse bindings -- {{{ Mouse bindings
@ -225,98 +241,159 @@ root.buttons(awful.util.table.join(
-- {{{ Key bindings -- {{{ Key bindings
globalkeys = awful.util.table.join( globalkeys = awful.util.table.join(
awful.key({ modkey, }, "z", function () awful.util.spawn("xlock") end), awful.key({ modkey, }, "z",
function ()
awful.util.spawn("xlock")
end,
{description="Lock the screen", group="awesome"}
),
awful.key({ modkey, }, "Left", awful.key({ modkey, }, "Left",
function () function ()
-- TODO : Do the first ID better ... -- TODO : Do the first ID better ...
if awful.tag.selected().name ~= "1" then if awful.tag.selected().name ~= "1" then
awful.tag.viewprev() awful.tag.viewprev()
end end
end), end,
{description="Move to the previous view (LEFT)", group="tag"}
),
awful.key({ modkey, }, "Right", awful.key({ modkey, }, "Right",
function () function ()
-- TODO : Do the last ID better ... -- TODO : Do the last ID better ...
if awful.tag.selected().name ~= "5" then if awful.tag.selected().name ~= "5" then
awful.tag.viewnext() awful.tag.viewnext()
end end
end), end,
awful.key({ modkey, }, "Escape", awful.tag.history.restore), {description="Move to the naxt view (RIGHT)", group="tag"}
),
awful.key({ modkey, }, "s",
hotkeys_popup.show_help,
{description="show help", group="awesome"}
),
awful.key({ modkey, }, "Escape", awful.tag.history.restore,
{description = "go back", group = "tag"}),
awful.key({ modkey, }, "j", awful.key({ modkey, }, "j",
function () function ()
awful.client.focus.byidx( 1) awful.client.focus.byidx( 1)
if client.focus then client.focus:raise() end end,
end), {description = "focus next by index", group = "client"}
),
awful.key({ modkey, }, "k", awful.key({ modkey, }, "k",
function () function ()
awful.client.focus.byidx(-1) awful.client.focus.byidx(-1)
if client.focus then client.focus:raise() end end,
end), {description = "focus previous by index", group = "client"}
awful.key({ modkey, }, "w", function () mymainmenu:show() end), ),
awful.key({ modkey, }, "w", function () mymainmenu:show() end,
{description = "show main menu", group = "awesome"}),
-- Layout manipulation -- Layout manipulation
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), {description = "swap with next client by index", group = "client"}),
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end), awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end), {description = "swap with previous client by index", group = "client"}),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto), awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
{description = "focus the next screen", group = "screen"}),
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
{description = "focus the previous screen", group = "screen"}),
awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
{description = "jump to urgent client", group = "client"}),
awful.key({ modkey, }, "Tab", awful.key({ modkey, }, "Tab",
function () function ()
awful.client.focus.byidx( 1) awful.client.focus.history.previous()
if client.focus then if client.focus then
client.focus:raise() client.focus:raise()
end end
end), end,
{description = "go back", group = "client"}),
-- Standard program -- Standard program
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end), awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
awful.key({ modkey, "Control" }, "r", awesome.restart), {description = "open a terminal", group = "launcher"}),
awful.key({ modkey, "Shift" }, "q", awesome.quit), awful.key({ modkey, "Control" }, "r", awesome.restart,
{description = "reload awesome", group = "awesome"}),
awful.key({ modkey, "Shift" }, "q", awesome.quit,
{description = "quit awesome", group = "awesome"}),
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), {description = "increase master width factor", group = "layout"}),
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), {description = "decrease master width factor", group = "layout"}),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), {description = "increase the number of master clients", group = "layout"}),
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end), {description = "decrease the number of master clients", group = "layout"}),
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
{description = "increase the number of columns", group = "layout"}),
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
{description = "decrease the number of columns", group = "layout"}),
awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
{description = "select next", group = "layout"}),
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
{description = "select previous", group = "layout"}),
awful.key({ modkey, "Control" }, "n", awful.client.restore), awful.key({ modkey, "Control" }, "n",
function ()
local c = awful.client.restore()
-- Focus restored client
if c then
client.focus = c
c:raise()
end
end,
{description = "restore minimized", group = "client"}),
-- Prompt -- Prompt
awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end), awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
{description = "run prompt", group = "launcher"}),
awful.key({ modkey }, "x", awful.key({ modkey }, "x",
function () function ()
awful.prompt.run({ prompt = "Run Lua code: " }, awful.prompt.run {
mypromptbox[mouse.screen].widget, prompt = "Run Lua code: ",
awful.util.eval, nil, textbox = awful.screen.focused().mypromptbox.widget,
awful.util.getdir("cache") .. "/history_eval") exe_callback = awful.util.eval,
end), history_path = awful.util.get_cache_dir() .. "/history_eval"
}
end,
{description = "lua execute prompt", group = "awesome"}),
-- Menubar -- Menubar
awful.key({ modkey }, "p", function() menubar.show() end) awful.key({ modkey }, "p", function() menubar.show() end,
{description = "show the menubar", group = "launcher"})
) )
clientkeys = awful.util.table.join( clientkeys = awful.util.table.join(
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), awful.key({ modkey, }, "f",
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end), function (c)
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), c.fullscreen = not c.fullscreen
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), c:raise()
awful.key({ modkey, }, "o", awful.client.movetoscreen ), end,
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end), {description = "toggle fullscreen", group = "client"}),
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
{description = "close", group = "client"}),
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
{description = "toggle floating", group = "client"}),
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
{description = "move to master", group = "client"}),
awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
{description = "move to screen", group = "client"}),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
{description = "toggle keep on top", group = "client"}),
awful.key({ modkey, }, "y", function (c) awful.titlebar.toggle(c) end,
{description = "toggle titlebar", group = "client"}),
awful.key({ modkey, }, "n", awful.key({ modkey, }, "n",
function (c) function (c)
-- The client currently has the input focus, so it cannot be -- The client currently has the input focus, so it cannot be
-- minimized, since minimized clients can't have the focus. -- minimized, since minimized clients can't have the focus.
c.minimized = true c.minimized = true
end), end ,
{description = "minimize", group = "client"}),
awful.key({ modkey, }, "m", awful.key({ modkey, }, "m",
function (c) function (c)
c.maximized_horizontal = not c.maximized_horizontal c.maximized = not c.maximized
c.maximized_vertical = not c.maximized_vertical c:raise()
end) end ,
{description = "maximize", group = "client"})
) )
-- Bind all key numbers to tags. -- Bind all key numbers to tags.
@ -327,41 +404,46 @@ for i = 1, 9 do
-- View tag only. -- View tag only.
awful.key({ modkey }, "#" .. i + 9, awful.key({ modkey }, "#" .. i + 9,
function () function ()
local screen = mouse.screen local screen = awful.screen.focused()
local tag = awful.tag.gettags(screen)[i] local tag = screen.tags[i]
if tag then if tag then
awful.tag.viewonly(tag) tag:view_only()
end end
end), end,
-- Toggle tag. {description = "view tag #"..i, group = "tag"}),
-- Toggle tag display.
awful.key({ modkey, "Control" }, "#" .. i + 9, awful.key({ modkey, "Control" }, "#" .. i + 9,
function () function ()
local screen = mouse.screen local screen = awful.screen.focused()
local tag = awful.tag.gettags(screen)[i] local tag = screen.tags[i]
if tag then if tag then
awful.tag.viewtoggle(tag) awful.tag.viewtoggle(tag)
end end
end), end,
{description = "toggle tag #" .. i, group = "tag"}),
-- Move client to tag. -- Move client to tag.
awful.key({ modkey, "Shift" }, "#" .. i + 9, awful.key({ modkey, "Shift" }, "#" .. i + 9,
function () function ()
if client.focus then if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i] local tag = client.focus.screen.tags[i]
if tag then if tag then
awful.client.movetotag(tag) client.focus:move_to_tag(tag)
end end
end end
end), end,
-- Toggle tag. {description = "move focused client to tag #"..i, group = "tag"}),
-- Toggle tag on focused client.
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function () function ()
if client.focus then if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i] local tag = client.focus.screen.tags[i]
if tag then if tag then
awful.client.toggletag(tag) client.focus:toggle_tag(tag)
end end
end end
end)) end,
{description = "toggle focused client on tag #" .. i, group = "tag"})
)
end end
clientbuttons = awful.util.table.join( clientbuttons = awful.util.table.join(
@ -383,85 +465,114 @@ awful.rules.rules = {
focus = awful.client.focus.filter, focus = awful.client.focus.filter,
raise = true, raise = true,
keys = clientkeys, keys = clientkeys,
buttons = clientbuttons } }, buttons = clientbuttons,
{ rule = { class = "MPlayer" }, screen = awful.screen.preferred,
properties = { floating = true } }, placement = awful.placement.no_overlap+awful.placement.no_offscreen
{ rule = { class = "pinentry" }, }
properties = { floating = true } }, },
{ rule = { class = "gimp" },
properties = { floating = true } }, -- Floating clients.
-- Set Firefox to always map on tags number 2 of screen 1. { rule_any = {
instance = {
"DTA", -- Firefox addon DownThemAll.
"copyq", -- Includes session name in class.
},
class = {
"Arandr",
"Gpick",
"Kruler",
"MessageWin", -- kalarm.
"Sxiv",
"Wpa_gui",
"pinentry",
"veromix",
"xtightvncviewer"},
name = {
"Event Tester", -- xev.
},
role = {
"AlarmWindow", -- Thunderbird's calendar.
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
}
}, properties = { floating = true }},
-- Add titlebars to normal clients and dialogs
{ rule_any = {type = { "normal", "dialog" }
}, properties = { titlebars_enabled = true }
},
-- Set Firefox to always map on the tag named "2" on screen 1.
-- { rule = { class = "Firefox" }, -- { rule = { class = "Firefox" },
-- properties = { tag = tags[1][2] } }, -- properties = { screen = 1, tag = "2" } },
} }
-- }}} -- }}}
-- {{{ Signals -- {{{ Signals
-- Signal function to execute when a new client appears. -- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c, startup) client.connect_signal("manage", function (c)
-- Enable sloppy focus -- Set the windows at the slave,
c:connect_signal("mouse::enter", function(c) -- i.e. put it at the end of others instead of setting it master.
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier -- if not awesome.startup then awful.client.setslave(c) end
and awful.client.focus.filter(c) then
client.focus = c
end
end)
if not startup then if awesome.startup and
-- Set the windows at the slave, not c.size_hints.user_position
-- i.e. put it at the end of others instead of setting it master. and not c.size_hints.program_position then
-- awful.client.setslave(c) -- Prevent clients from being unreachable after screen count changes.
awful.placement.no_offscreen(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
end end
if not awesome.startup then
awful.titlebar.show(c)
end
end)
local titlebars_enabled = false -- Add a titlebar if titlebars_enabled is set to true in the rules.
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then client.connect_signal("request::titlebars", function(c)
-- buttons for the titlebar -- buttons for the titlebar
local buttons = awful.util.table.join( local buttons = awful.util.table.join(
awful.button({ }, 1, function() awful.button({ }, 1, function()
client.focus = c client.focus = c
c:raise() c:raise()
awful.mouse.client.move(c) awful.mouse.client.move(c)
end), end),
awful.button({ }, 3, function() awful.button({ }, 3, function()
client.focus = c client.focus = c
c:raise() c:raise()
awful.mouse.client.resize(c) awful.mouse.client.resize(c)
end) end)
) )
-- Widgets that are aligned to the left awful.titlebar(c) : setup {
local left_layout = wibox.layout.fixed.horizontal() { -- Left
left_layout:add(awful.titlebar.widget.iconwidget(c)) awful.titlebar.widget.iconwidget(c),
left_layout:buttons(buttons) buttons = buttons,
layout = wibox.layout.fixed.horizontal
},
{ -- Middle
{ -- Title
align = "center",
widget = awful.titlebar.widget.titlewidget(c)
},
buttons = buttons,
layout = wibox.layout.flex.horizontal
},
{ -- Right
awful.titlebar.widget.floatingbutton (c),
awful.titlebar.widget.maximizedbutton(c),
awful.titlebar.widget.stickybutton (c),
awful.titlebar.widget.ontopbutton (c),
awful.titlebar.widget.closebutton (c),
layout = wibox.layout.fixed.horizontal()
},
layout = wibox.layout.align.horizontal
}
end)
-- Widgets that are aligned to the right -- Enable sloppy focus, so that focus follows mouse.
local right_layout = wibox.layout.fixed.horizontal() client.connect_signal("mouse::enter", function(c)
right_layout:add(awful.titlebar.widget.floatingbutton(c)) if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
right_layout:add(awful.titlebar.widget.maximizedbutton(c)) and awful.client.focus.filter(c) then
right_layout:add(awful.titlebar.widget.stickybutton(c)) client.focus = c
right_layout:add(awful.titlebar.widget.ontopbutton(c))
right_layout:add(awful.titlebar.widget.closebutton(c))
-- The title goes in the middle
local middle_layout = wibox.layout.flex.horizontal()
local title = awful.titlebar.widget.titlewidget(c)
title:set_align("center")
middle_layout:add(title)
middle_layout:buttons(buttons)
-- Now bring it all together
local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout)
layout:set_right(right_layout)
layout:set_middle(middle_layout)
awful.titlebar(c):set_widget(layout)
end end
end) end)