1
0
Fork 0
mirror of https://github.com/lcpz/awesome-copycats.git synced 2024-12-23 03:32:30 +00:00

porting to 3.5.1

This commit is contained in:
luke bonham 2013-04-02 14:32:47 +02:00
parent 0e09b138f5
commit e1a09a1ff9

View file

@ -8,15 +8,15 @@
-- Required Libraries -- Required Libraries
gears = require("gears") local gears = require("gears")
awful = require("awful") local awful = require("awful")
awful.rules = require("awful.rules") awful.rules = require("awful.rules")
awful.autofocus = require("awful.autofocus") awful.autofocus = require("awful.autofocus")
wibox = require("wibox") local wibox = require("wibox")
beautiful = require("beautiful") local beautiful = require("beautiful")
naughty = require("naughty") local naughty = require("naughty")
vicious = require("vicious") local vicious = require("vicious")
scratch = require("scratch") local scratch = require("scratch")
-- Run once function -- Run once function
@ -53,7 +53,7 @@ end
-- Handle runtime errors after startup -- Handle runtime errors after startup
do do
in_error = false local in_error = false
awesome.connect_signal("debug::error", function (err) awesome.connect_signal("debug::error", function (err)
-- Make sure we don't go into an endless error loop -- Make sure we don't go into an endless error loop
if in_error then return end if in_error then return end
@ -62,7 +62,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 = err })
in_error = false local in_error = false
end) end)
end end
@ -595,26 +595,24 @@ mytasklist.buttons = awful.util.table.join(
end)) end))
for s = 1, screen.count() do for s = 1, screen.count() do
-- Create a promptbox for each screen -- Create a promptbox for each screen
mypromptbox[s] = awful.widget.prompt() mypromptbox[s] = awful.widget.prompt()
-- 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) mylayoutbox[s] = awful.widget.layoutbox(s)
mylayoutbox[s]:buttons(awful.util.table.join( mylayoutbox[s]:buttons(awful.util.table.join(
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
-- Create a taglist widget -- Create a taglist widget
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons) mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
-- Create a tasklist widget -- Create a tasklist widget
mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons) mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
-- Create the upper wibox -- Create the wibox
mywibox[s] = awful.wibox({ position = "top", screen = s, height = 18 }) mywibox[s] = awful.wibox({ position = "top", screen = s })
-- Widgets that are aligned to the upper left -- Widgets that are aligned to the upper left
local left_layout = wibox.layout.fixed.horizontal() local left_layout = wibox.layout.fixed.horizontal()
@ -649,6 +647,7 @@ for s = 1, screen.count() do
layout:set_left(left_layout) layout:set_left(left_layout)
layout:set_middle(mytasklist[s]) layout:set_middle(mytasklist[s])
layout:set_right(right_layout) layout:set_right(right_layout)
mywibox[s]:set_widget(layout) mywibox[s]:set_widget(layout)
end end
@ -811,42 +810,39 @@ clientkeys = awful.util.table.join(
c.maximized_vertical = not c.maximized_vertical c.maximized_vertical = not c.maximized_vertical
end) end)
) )
-- Compute the maximum number of digit we need, limited to 9
keynumber = 0
for s = 1, screen.count() do
keynumber = math.min(9, math.max(#tags[s], keynumber));
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.
-- This should map on the top row of your keyboard, usually 1 to 9. -- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, keynumber do for i = 1, 9 do
globalkeys = awful.util.table.join(globalkeys, globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, "#" .. i + 9, awful.key({ modkey }, "#" .. i + 9,
function () function ()
screen = mouse.screen local screen = mouse.screen
if tags[screen][i] then local tag = awful.tag.gettags(screen)[i]
awful.tag.viewonly(tags[screen][i]) if tags then
awful.tag.viewonly(tags)
end end
end), end),
awful.key({ modkey, "Control" }, "#" .. i + 9, awful.key({ modkey, "Control" }, "#" .. i + 9,
function () function ()
screen = mouse.screen local screen = mouse.screen
if tags[screen][i] then local tag = awful.tag.gettags(screen)[i]
awful.tag.viewtoggle(tags[screen][i]) if tags then
end awful.tag.viewtoggle(tags)
end
end), end),
awful.key({ modkey, "Shift" }, "#" .. i + 9, awful.key({ modkey, "Shift" }, "#" .. i + 9,
function () function ()
if client.focus and tags[client.focus.screen][i] then local tag = awful.tag.gettags(client.focus.screen)[i]
awful.client.movetotag(tags[client.focus.screen][i]) if client.focus and tag then
awful.client.movetotag(tag)
end end
end), end),
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function () function ()
if client.focus and tags[client.focus.screen][i] then local tag = awful.tag.gettags(client.focus.screen)[i]
awful.client.toggletag(tags[client.focus.screen][i]) if client.focus and tag then
awful.client.movetotag(tag)
end end
end)) end))
end end
@ -867,7 +863,7 @@ awful.rules.rules = {
{ rule = { }, { rule = { },
properties = { border_width = beautiful.border_width, properties = { border_width = beautiful.border_width,
border_color = beautiful.border_normal, border_color = beautiful.border_normal,
focus = true, focus = awful.client.focus.filter,
keys = clientkeys, keys = clientkeys,
buttons = clientbuttons, buttons = clientbuttons,
size_hints_honor = false size_hints_honor = false
@ -941,22 +937,8 @@ client.connect_signal("manage", function (c, startup)
local titlebars_enabled = false local titlebars_enabled = false
if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then if titlebars_enabled and (c.type == "normal" or c.type == "dialog") then
-- Widgets that are aligned to the left -- buttons for the titlebar
local left_layout = wibox.layout.fixed.horizontal() local buttons = awful.util.table.join(
left_layout:add(awful.titlebar.widget.iconwidget(c))
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
right_layout:add(awful.titlebar.widget.floatingbutton(c))
right_layout:add(awful.titlebar.widget.maximizedbutton(c))
right_layout:add(awful.titlebar.widget.stickybutton(c))
right_layout:add(awful.titlebar.widget.ontopbutton(c))
right_layout:add(awful.titlebar.widget.closebutton(c))
right_layout:add(awful.titlebar.widget.closebutton(c))
-- The title goes in the middle
local title = awful.titlebar.widget.titlewidget(c)
title:buttons(awful.util.table.join(
awful.button({ }, 1, function() awful.button({ }, 1, function()
client.focus = c client.focus = c
c:raise() c:raise()
@ -967,13 +949,33 @@ client.connect_signal("manage", function (c, startup)
c:raise() c:raise()
awful.mouse.client.resize(c) awful.mouse.client.resize(c)
end) end)
)) )
-- Widgets that are aligned to the left
local left_layout = wibox.layout.fixed.horizontal()
left_layout:add(awful.titlebar.widget.iconwidget(c))
left_layout:buttons(buttons)
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
right_layout:add(awful.titlebar.widget.floatingbutton(c))
right_layout:add(awful.titlebar.widget.maximizedbutton(c))
right_layout:add(awful.titlebar.widget.stickybutton(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 -- Now bring it all together
local layout = wibox.layout.align.horizontal() local layout = wibox.layout.align.horizontal()
layout:set_left(left_layout) layout:set_left(left_layout)
layout:set_right(right_layout) layout:set_right(right_layout)
layout:set_middle(title) layout:set_middle(middle_layout)
awful.titlebar(c):set_widget(layout) awful.titlebar(c):set_widget(layout)
end end