From: Quan Guo Date: Mon, 29 Feb 2016 20:04:00 +0000 (+0100) Subject: Merge branch 'master' of https://github.com/copycat-killer/lain X-Git-Url: https://git.madduck.net/etc/awesome.git/commitdiff_plain/466c48d20a13a447afaec373b700a5cd2e3fa877?hp=47a00516d88c42378b487ba302835097c3138099 Merge branch 'master' of https://github.com/copycat-killer/lain --- diff --git a/layout/centerworkd.lua b/layout/centerworkd.lua new file mode 100644 index 0000000..e66a15a --- /dev/null +++ b/layout/centerworkd.lua @@ -0,0 +1,123 @@ + +--[[ + + Licensed under GNU General Public License v2 + * (c) 2016, Henrik Antonsson + * (c) 2014, projektile + * (c) 2013, Luke Bonham + * (c) 2010-2012, Peter Hofmann + + Based on centerwork.lua +--]] + +local awful = require("awful") +local beautiful = require("beautiful") +local tonumber = tonumber +local math = { floor = math.floor } + +local centerworkd = +{ + name = "centerworkd", +} + +function centerworkd.arrange(p) + -- A useless gap (like the dwm patch) can be defined with + -- beautiful.useless_gap_width . + local useless_gap = tonumber(beautiful.useless_gap_width) or 0 + + -- A global border can be defined with + -- beautiful.global_border_width + local global_border = tonumber(beautiful.global_border_width) or 0 + if global_border < 0 then global_border = 0 end + + -- Screen. + local wa = p.workarea + local cls = p.clients + + -- Borders are factored in. + wa.height = wa.height - (global_border * 2) + wa.width = wa.width - (global_border * 2) + wa.x = wa.x + global_border + wa.y = wa.y + global_border + + -- Width of main column? + local t = awful.tag.selected(p.screen) + local mwfact = awful.tag.getmwfact(t) + + if #cls > 0 + then + -- Main column, fixed width and height. + local c = cls[1] + local g = {} + local mainwid = math.floor(wa.width * mwfact) + local slavewid = wa.width - mainwid + local slaveLwid = math.floor(slavewid / 2) + local slaveRwid = slavewid - slaveLwid + local nbrLeftSlaves = math.floor(#cls / 2) + local nbrRightSlaves = math.floor((#cls - 1) / 2) + + local slaveLeftHeight = 0 + if nbrLeftSlaves > 0 then slaveLeftHeight = math.floor(wa.height / nbrLeftSlaves) end + if nbrRightSlaves > 0 then slaveRightHeight = math.floor(wa.height / nbrRightSlaves) end + + g.height = wa.height - 2*useless_gap - 2*c.border_width + g.width = mainwid - 2*c.border_width + g.x = wa.x + slaveLwid + g.y = wa.y + useless_gap + + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + c:geometry(g) + + -- Auxiliary windows. + if #cls > 1 + then + for i = 2,#cls + do + c = cls[i] + g = {} + + local rowIndex = math.floor(i/2) + + -- If i is even it should be placed on the left side + if i % 2 == 0 + then + -- left slave + g.x = wa.x + useless_gap + g.y = wa.y + useless_gap + (rowIndex-1)*slaveLeftHeight + + g.width = slaveLwid - 2*useless_gap - 2*c.border_width + + -- if last slave in left row use remaining space for that slave + if rowIndex == nbrLeftSlaves + then + g.height = wa.y + wa.height - g.y - useless_gap - 2*c.border_width + else + g.height = slaveLeftHeight - useless_gap - 2*c.border_width + end + else + -- right slave + g.x = wa.x + slaveLwid + mainwid + useless_gap + g.y = wa.y + useless_gap + (rowIndex-1)*slaveRightHeight + + g.width = slaveRwid - 2*useless_gap - 2*c.border_width + + -- if last slave in right row use remaining space for that slave + if rowIndex == nbrRightSlaves + then + g.height = wa.y + wa.height - g.y - useless_gap - 2*c.border_width + else + g.height = slaveRightHeight - useless_gap - 2*c.border_width + end + + end + + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + c:geometry(g) + end + end + end +end + +return centerworkd diff --git a/widgets/calendar.lua b/widgets/calendar.lua index 4714a54..93f171f 100644 --- a/widgets/calendar.lua +++ b/widgets/calendar.lua @@ -15,12 +15,15 @@ local naughty = require("naughty") local io = { popen = io.popen } local os = { date = os.date } local mouse = mouse +local string = { format = string.format, + sub = string.sub, + gsub = string.gsub } local tonumber = tonumber local setmetatable = setmetatable -- Calendar notification --- lain.widgets.calendar +-- lain.widgets.cal local calendar = {} local cal_notification = nil @@ -34,12 +37,12 @@ end function calendar:show(t_out, inc_offset, scr) calendar:hide() - local offs = inc_offset or 0 - local tims = t_out or 0 local f, c_text + local offs = inc_offset or 0 + local tims = t_out or 0 local today = tonumber(os.date('%d')) - local init_t = calendar.cal .. ' ' .. calendar.post_cal .. ' ' .. - ' | sed -r -e "s/_\\x08//g" | sed -r -e "s/(^| )(' + local init_t = string.format("%s %s | sed -e 's/[\b]\\{3\\}//g'", + calendar.cal, calendar.post_cal) calendar.offset = calendar.offset + offs @@ -49,12 +52,8 @@ function calendar:show(t_out, inc_offset, scr) calendar.notify_icon = calendar.icons .. today .. ".png" -- bg and fg inverted to highlight today - f = io.popen( init_t .. today .. - ')($| )/\\1\\2<\\/span><\\/b>\\3/"' ) + f = io.popen(string.format("%s -e '0,/%d/ s/%d/%d<\\/span><\\/b>/'", + init_t, today, today, calendar.bg, calendar.fg, today)) else -- no current month showing, no day to highlight local month = tonumber(os.date('%m')) @@ -78,11 +77,10 @@ function calendar:show(t_out, inc_offset, scr) calendar.notify_icon = nil - f = io.popen(calendar.cal .. ' ' .. month .. ' ' .. year .. ' ' .. - calendar.post_cal) + f = io.popen(string.format('%s %s %s %s', calendar.cal, month, year, calendar.post_cal)) end - c_text = "" .. f:read() .. "\n\n" .. f:read() .. "\n" diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index b675276..3ef26f0 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -23,17 +23,18 @@ local function worker(args) local args = args or {} local timeout = args.timeout or 5 local settings = args.settings or function() end + local scallback = args.scallback - pulseaudio.sink = args.sink or 0 -- user defined or first one - pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | grep -e 'index: %d' -e 'volume: front' -e 'muted'", pulseaudio.sink) + pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p'") pulseaudio.widget = wibox.widget.textbox('') function pulseaudio.update() + if scallback then pulseaudio.cmd = scallback() end local s = read_pipe(pulseaudio.cmd) volume_now = {} - volume_now.left = tonumber(string.match(s, "left.-(%d+)%%")) - volume_now.right = tonumber(string.match(s, "right.-(%d+)%%")) + volume_now.left = tonumber(string.match(s, ":.-(%d+)%%")) + volume_now.right = tonumber(string.match(s, ":.-(%d+)%%")) volume_now.muted = string.match(s, "muted: (%S+)") widget = pulseaudio.widget diff --git a/wiki b/wiki index dcce6dd..685529e 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit dcce6dd58791c7c1d2e2e3f046b4da0d5b9700a7 +Subproject commit 685529e0a67fbbbc7b1b01e965a064d06e953baf