Update to last version of awesome

This commit is contained in:
Thomas Forgione 2017-01-21 17:37:50 +01:00
parent 0fb3428db7
commit 4fdc19c55c
No known key found for this signature in database
GPG Key ID: 2B5C8A9986271A42
2 changed files with 364 additions and 323 deletions

View File

@ -1,19 +1,18 @@
-- 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")
-- Theme handling library -- Theme handling library
local beautiful = require("beautiful") local beautiful = require("beautiful")
local vicious = require('vicious')
-- Notification library -- Notification library
naughty = require("naughty") local naughty = require("naughty")
local menubar = require("menubar") local menubar = require("menubar")
local vicious = require("vicious") local hotkeys_popup = require("awful.hotkeys_popup").widget
local options = require("options")
-- Custom imports
local options = require("options")
home = os.getenv('HOME') home = os.getenv('HOME')
os.execute('xset m 16/1 0') os.execute('xset m 16/1 0')
@ -49,7 +48,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
@ -59,37 +58,6 @@ end
-- Themes define colours, icons, font and wallpapers. -- Themes define colours, icons, font and wallpapers.
beautiful.init("~/.config/awesome/themes/default/theme.lua") beautiful.init("~/.config/awesome/themes/default/theme.lua")
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
function change_wallpaper(path, extension)
path = home .. '/Pictures/Wallpapers/' .. path
-- if not file_exists(path) then
-- return
-- end
theme.wallpaper = path
if beautiful.wallpaper then
if screen.count() == 2 and file_exists(path..'-16-9.'..extension) and file_exists(path..'-4-3.'..extension) then
gears.wallpaper.maximized(path .. '-16-9.' .. extension, 1, true)
gears.wallpaper.maximized(path .. '-4-3.' .. extension, 2, true)
elseif file_exists(path..'-16-9.'..extension) then
for s = 1, screen.count() do
gears.wallpaper.maximized(path .. '-16-9.' .. extension, s, true)
end
end
end
end
-- Widgets
local volume = require("volume")
local battery = require("battery")
local calendar = require("calendar")
-- 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 = options.terminal terminal = options.terminal
editor = os.getenv("EDITOR") or "nano" editor = os.getenv("EDITOR") or "nano"
@ -103,8 +71,7 @@ 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.tile.left, awful.layout.suit.tile.left,
awful.layout.suit.tile, awful.layout.suit.tile,
awful.layout.suit.tile.bottom, awful.layout.suit.tile.bottom,
@ -116,36 +83,37 @@ local layouts =
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.floating awful.layout.suit.corner.nw,
-- awful.layout.suit.corner.ne,
-- awful.layout.suit.corner.sw,
-- awful.layout.suit.corner.se,
awful.layout.suit.floating,
} }
-- }}} -- }}}
-- {{{ 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
change_wallpaper('arch2', 'png')
-- }}}
-- {{{ 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, 0 }, s, layouts[1])
end 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}
} }
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
@ -160,24 +128,30 @@ 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
-- Create a textclock widget mykeyboardlayout = awful.widget.keyboardlayout()
-- {{{ Wibar
-- 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
end),
awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
) )
mytasklist = {}
mytasklist.buttons = awful.util.table.join( 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
@ -185,8 +159,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
@ -194,225 +168,263 @@ 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))
-- Creation de quelques widgets local battery = require('battery')
delimiter = wibox.widget.textbox(" | ") local volume = require('volume')
local calendar = require('calendar')
local delimiter = wibox.widget.textbox(" | ")
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", "6", "7", "8", "9", "0" }, s, awful.layout.layouts[1])
for s = 1, screen.count() do
-- 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 },
s.mytasklist, -- Middle widget
right_layout:add(delimiter) { -- Right widgets
right_layout:add(volume_widget) layout = wibox.layout.fixed.horizontal,
right_layout:add(delimiter) delimiter,
right_layout:add(battery_widget) volume_widget,
right_layout:add(delimiter) delimiter,
right_layout:add(textclock_widget) battery_widget,
right_layout:add(mylayoutbox[s]) delimiter,
mykeyboardlayout,
-- Now bring it all together (with the tasklist in the middle) wibox.widget.systray(),
local layout = wibox.layout.align.horizontal() textclock_widget,
layout:set_left(left_layout) s.mylayoutbox,
layout:set_middle(mytasklist[s]) },
layout:set_right(right_layout) }
end)
mywibox[s]:set_widget(layout)
end
-- }}} -- }}}
-- {{{ Mouse bindings -- {{{ Mouse bindings
-- root.buttons(awful.util.table.join( root.buttons(awful.util.table.join(
-- awful.button({ }, 3, function () mymainmenu:toggle() end), awful.button({ }, 3, function () mymainmenu:toggle() end),
-- awful.button({ }, 4, awful.tag.viewnext), awful.button({ }, 4, awful.tag.viewnext),
-- awful.button({ }, 5, awful.tag.viewprev) awful.button({ }, 5, awful.tag.viewprev)
-- )) ))
-- }}} -- }}}
-- {{{ Key bindings -- {{{ Key bindings
globalkeys = awful.util.table.join( globalkeys = awful.util.table.join(
awful.key({ modkey, }, "Left", awful.tag.viewprev ), awful.key({ modkey, }, "s", hotkeys_popup.show_help,
awful.key({ modkey, }, "Right", awful.tag.viewnext ), {description="show help", group="awesome"}),
awful.key({ modkey, }, "Escape", awful.tag.history.restore), awful.key({ modkey, }, "Left", awful.tag.viewprev,
{description = "view previous", group = "tag"}),
awful.key({ modkey, }, "Right", awful.tag.viewnext,
{description = "view next", group = "tag"}),
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"}),
-- modkey + Tab gets the next client 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 client.focus:raise() end if client.focus then
end), client.focus:raise()
end
-- modkey + Tab gets the previous focused client end,
-- awful.key({ modkey, }, "Tab", {description = "go back", group = "client"}),
-- function ()
-- awful.client.focus.history.previous()
-- if client.focus then
-- client.focus:raise()
-- end
-- end),
-- 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"}),
awful.key({ }, "XF86PowerOff", function()
_,_,return_code = os.execute('ask-for-stop&');
end),
-- Volume keys
awful.key({ }, "XF86AudioRaiseVolume",
function ()
-- Custom shortcuts
awful.key({ }, "XF86AudioRaiseVolume", function()
awful.util.spawn("amixer set Master 3%+", false) awful.util.spawn("amixer set Master 3%+", false)
update_volume() update_volume()
end, {description = "increase the volume by 3%", group="custom"}),
end), awful.key({ }, "XF86AudioLowerVolume", function()
awful.key({ }, "XF86AudioLowerVolume",
function ()
awful.util.spawn("amixer set Master 3%-", false) awful.util.spawn("amixer set Master 3%-", false)
update_volume() update_volume()
end), end, {description = "decrease the volume by 3%", group="custom"}),
awful.key({ }, "XF86AudioMute", awful.key({ }, "XF86AudioMute", function()
function ()
-- end
awful.util.spawn("amixer set Master toggle", false) awful.util.spawn("amixer set Master toggle", false)
update_volume() update_volume()
end), end, {description = "mute sound", group="custom"}),
awful.key({ }, "XF86MonBrightnessDown", function () awful.key({ }, "XF86MonBrightnessDown", function ()
awful.util.spawn("xbacklight -dec 5") end), awful.util.spawn("xbacklight -dec 5")
awful.key({ }, "XF86MonBrightnessUp", function () end, {description = "decrease brightness", group="custom"}),
awful.util.spawn("xbacklight -inc 5") end),
awful.key({ }, "XF86MonBrightnessUp", function ()
awful.util.spawn("xbacklight -inc 5")
end, {description = "increase brightness", group="custom"}),
-- Print screen keys
awful.key({ }, "Print", function () awful.key({ }, "Print", function ()
os.execute('gnome-screenshot -fp "`echo -n ' .. home .. '"/Pictures/Captures/Capture du " && date "+%Y-%m-%d %H:%M:%S"`.png"') os.execute('gnome-screenshot -fp "`echo -n ' .. home .. '"/Pictures/Captures/Capture du " && date "+%Y-%m-%d %H:%M:%S"`.png"')
end), end, {description = "capture the screen", group="custom"}),
-- Chromium awful.key({modkey}, "a", function ()
awful.key({ }, "XF86HomePage", function () os.execute('$BROWSER &') end), os.execute(options.browser .. '&')
awful.key({ modkey}, "a", function () os.execute(options.browser .. '&') naughty.notify({title = options.browser .. " starting..."})
naughty.notify({ end, {description="start the web browser", group="custom"}),
title = options.browser .. " starting...",
text = awesome.startup_errors })
end
),
awful.key({modkey, "Shift"}, "Tab", function() os.execute('xdotool key Caps_Lock') end) awful.key({modkey, "Shift"}, "Tab", function()
os.execute('xdotool key Caps_Lock')
end, {description="switch the caps lock", group="custom"})
) )
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" }, "t", function(c) c.sticky = not c.sticky end), c:raise()
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), end,
awful.key({ modkey, }, "o", awful.client.movetoscreen ), {description = "toggle fullscreen", group = "client"}),
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end), 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, }, "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 ,
awful.key({modkey, }, "F2", function () awful.screen.focus(1) end), {description = "maximize", group = "client"})
awful.key({modkey, }, "F1", function () awful.screen.focus(2) end) )
)
-- Bind all key numbers to tags. -- Bind all key numbers to tags.
-- Be careful: we use keycodes to make it works on any keyboard layout. -- Be careful: we use keycodes to make it works on any keyboard layout.
@ -422,43 +434,48 @@ for i = 1, 10 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 and tags[client.focus.screen][i] then if client.focus then
awful.client.movetotag(tags[client.focus.screen][i]) local tag = client.focus.screen.tags[i]
local screen = mouse.screen if tag then
if tags[screen][i] then client.focus:move_to_tag(tag)
awful.tag.viewonly(tags[screen][i]) tag:view_only()
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,
end {description = "toggle focused client on tag #" .. i, group = "tag"})
)
end
clientbuttons = awful.util.table.join( clientbuttons = awful.util.table.join(
awful.button({ }, 1, function (c) client.focus = c; c:raise() end), awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
@ -479,45 +496,66 @@ 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,
} }, screen = awful.screen.preferred,
{ rule = { class = "MPlayer" }, placement = awful.placement.no_overlap+awful.placement.no_offscreen
properties = { floating = true } }, }
{ rule = { class = "pinentry" }, },
properties = { floating = true } },
{ rule = { class = "gimp" }, -- Floating clients.
properties = { floating = true } }, { rule_any = {
-- Set Firefox to always map on tags number 2 of screen 1. 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 = false }
},
-- 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
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, -- Set the windows at the slave,
-- i.e. put it at the end of others instead of setting it master. -- i.e. put it at the end of others instead of setting it master.
-- awful.client.setslave(c) -- if not awesome.startup then awful.client.setslave(c) end
-- Put windows in a smart way, only if they does not set an initial position. if awesome.startup and
if not c.size_hints.user_position and not c.size_hints.program_position then not c.size_hints.user_position
awful.placement.no_overlap(c) and not c.size_hints.program_position then
-- Prevent clients from being unreachable after screen count changes.
awful.placement.no_offscreen(c) awful.placement.no_offscreen(c)
end end
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()
@ -532,38 +570,40 @@ client.connect_signal("manage", function (c, startup)
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)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus 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) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}} -- }}}
os.execute('resetusb&')

View File

@ -2,7 +2,7 @@
-- Default awesome theme -- -- Default awesome theme --
--------------------------- ---------------------------
theme = {} local theme = {}
theme.font = "sans 8" theme.font = "sans 8"
@ -17,6 +17,7 @@ theme.fg_focus = "#ffffff"
theme.fg_urgent = "#ffffff" theme.fg_urgent = "#ffffff"
theme.fg_minimize = "#ffffff" theme.fg_minimize = "#ffffff"
theme.useless_gap = 0
theme.border_width = 1 theme.border_width = 1
theme.border_normal = "#39404b" theme.border_normal = "#39404b"
theme.border_focus = "#6d7a8d" theme.border_focus = "#6d7a8d"