From a1438c6d7553fce62533ca9018291c4852ac5e46 Mon Sep 17 00:00:00 2001 From: Henrik Antonsson Date: Wed, 3 Feb 2016 17:49:17 +0100 Subject: [PATCH 01/12] Added dynamic centerwork layout Centerwork layout that is not restricted to 5 clients --- layout/centerworkd.lua | 123 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 layout/centerworkd.lua 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 From b07aad86215f84f5d17433f751ba246da364df2b Mon Sep 17 00:00:00 2001 From: Luke Bonham Date: Thu, 4 Feb 2016 08:15:53 +0100 Subject: [PATCH 02/12] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index dcce6dd..f1868c3 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit dcce6dd58791c7c1d2e2e3f046b4da0d5b9700a7 +Subproject commit f1868c31feab78b1898998407a597e3c06ee71ba From eb961497d3ac63279a919dc9d90156b9d03e8674 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Fri, 19 Feb 2016 14:17:44 +0100 Subject: [PATCH 03/12] pulseaudio #168 --- widgets/pulseaudio.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index b675276..17f91f3 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -25,15 +25,15 @@ local function worker(args) local settings = args.settings or function() end 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 | grep -e 'index: %d' -e 'volume:' -e 'muted'", pulseaudio.sink) pulseaudio.widget = wibox.widget.textbox('') function pulseaudio.update() 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, "left.-(%d+)%%")) or tonumber(string.match(s, "0:.-(%d+)%%")) + volume_now.right = tonumber(string.match(s, "right.-(%d+)%%")) or tonumber(string.match(s, "1:.-(%d+)%%")) volume_now.muted = string.match(s, "muted: (%S+)") widget = pulseaudio.widget From 4d664adc0132c8d110cde257227557dd7deac48b Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sun, 21 Feb 2016 14:45:46 +0100 Subject: [PATCH 04/12] pulseaudio: cmd switch from grep to sed #168 --- widgets/pulseaudio.lua | 3 ++- wiki | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index 17f91f3..589249f 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -25,7 +25,8 @@ local function worker(args) local settings = args.settings or function() end 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:' -e 'muted'", pulseaudio.sink) + pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | sed -n -e '/base volume/d' -e '/index: %d/p' -e '/volume:/p' -e '/muted:/p' | sed -n -e '/index: %d/,+2p'", + pulseaudio.sink, pulseaudio.sink) pulseaudio.widget = wibox.widget.textbox('') function pulseaudio.update() diff --git a/wiki b/wiki index f1868c3..22e0d07 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit f1868c31feab78b1898998407a597e3c06ee71ba +Subproject commit 22e0d07b582caf059aa4dd856cf213f7c027a282 From e52c38e0f9ddf1299ff4d37c838007b4ebfdeaf7 Mon Sep 17 00:00:00 2001 From: Maxim Gordeev Date: Thu, 25 Feb 2016 07:37:01 +0300 Subject: [PATCH 05/12] Add callback function for to update sink --- widgets/pulseaudio.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index 589249f..d243b8d 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -23,6 +23,7 @@ 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 or function() end pulseaudio.sink = args.sink or 0 -- user defined or first one pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | sed -n -e '/base volume/d' -e '/index: %d/p' -e '/volume:/p' -e '/muted:/p' | sed -n -e '/index: %d/,+2p'", @@ -37,6 +38,10 @@ local function worker(args) volume_now.right = tonumber(string.match(s, "right.-(%d+)%%")) or tonumber(string.match(s, "1:.-(%d+)%%")) volume_now.muted = string.match(s, "muted: (%S+)") + if scallback ~= nil then + pulseaudio.sink = scallback() + end + widget = pulseaudio.widget settings() end From 624a0c9f020fbf81d982829b6d770dfb691c86b8 Mon Sep 17 00:00:00 2001 From: Maxim Gordeev Date: Thu, 25 Feb 2016 07:54:50 +0300 Subject: [PATCH 06/12] Default value for scallback is nil --- widgets/pulseaudio.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index d243b8d..4f05779 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -23,7 +23,7 @@ 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 or function() end + local scallback = args.scallback or nil pulseaudio.sink = args.sink or 0 -- user defined or first one pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | sed -n -e '/base volume/d' -e '/index: %d/p' -e '/volume:/p' -e '/muted:/p' | sed -n -e '/index: %d/,+2p'", From 62ad74c4cd57b509fd69d85bbd7ca9e6b28496c8 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 25 Feb 2016 13:26:20 +0100 Subject: [PATCH 07/12] pulseaudio: improve scallback #169; #168 --- widgets/pulseaudio.lua | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index 4f05779..3ce98d4 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -15,6 +15,7 @@ local string = { match = string.match, local setmetatable = setmetatable +local naughty = require("naughty") -- PulseAudio volume -- lain.widgets.pulseaudio local pulseaudio = {} @@ -23,24 +24,20 @@ 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 or nil + 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 | sed -n -e '/base volume/d' -e '/index: %d/p' -e '/volume:/p' -e '/muted:/p' | sed -n -e '/index: %d/,+2p'", - pulseaudio.sink, 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() local s = read_pipe(pulseaudio.cmd) volume_now = {} - volume_now.left = tonumber(string.match(s, "left.-(%d+)%%")) or tonumber(string.match(s, "0:.-(%d+)%%")) - volume_now.right = tonumber(string.match(s, "right.-(%d+)%%")) or tonumber(string.match(s, "1:.-(%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+)") - if scallback ~= nil then - pulseaudio.sink = scallback() - end + if scallback then pulseaudio.sink = scallback() end widget = pulseaudio.widget settings() From c0d58a78fbddbce7e1722b6722534ec76b3b06fb Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 25 Feb 2016 13:41:33 +0100 Subject: [PATCH 08/12] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index 22e0d07..efecc2a 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit 22e0d07b582caf059aa4dd856cf213f7c027a282 +Subproject commit efecc2a67b4572ff47180e2e4041a6076418488e From 7121c9ab504508fce55314d59a835cfb10471569 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Thu, 25 Feb 2016 13:54:03 +0100 Subject: [PATCH 09/12] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index efecc2a..af2be48 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit efecc2a67b4572ff47180e2e4041a6076418488e +Subproject commit af2be487e3610e4f2a3cf5325c1a703a2bee6daf From e386dbb7196851dd348f71b3db601be2786c3324 Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Fri, 26 Feb 2016 11:49:44 +0100 Subject: [PATCH 10/12] #169 typos fixed --- widgets/pulseaudio.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/widgets/pulseaudio.lua b/widgets/pulseaudio.lua index 3ce98d4..3ef26f0 100644 --- a/widgets/pulseaudio.lua +++ b/widgets/pulseaudio.lua @@ -15,7 +15,6 @@ local string = { match = string.match, local setmetatable = setmetatable -local naughty = require("naughty") -- PulseAudio volume -- lain.widgets.pulseaudio local pulseaudio = {} @@ -30,6 +29,7 @@ local function worker(args) pulseaudio.widget = wibox.widget.textbox('') function pulseaudio.update() + if scallback then pulseaudio.cmd = scallback() end local s = read_pipe(pulseaudio.cmd) volume_now = {} @@ -37,8 +37,6 @@ local function worker(args) volume_now.right = tonumber(string.match(s, ":.-(%d+)%%")) volume_now.muted = string.match(s, "muted: (%S+)") - if scallback then pulseaudio.sink = scallback() end - widget = pulseaudio.widget settings() end From f7601c768102a898fdd9dc73fbacced412aa143e Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 27 Feb 2016 21:36:32 +0100 Subject: [PATCH 11/12] cal: highlight only first match of today number; #170 --- widgets/calendar.lua | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) 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" From 5e53a6e620172389f941f01ce91a00a18fafe35e Mon Sep 17 00:00:00 2001 From: copycat-killer Date: Sat, 27 Feb 2016 21:53:31 +0100 Subject: [PATCH 12/12] wiki updated --- wiki | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiki b/wiki index af2be48..685529e 160000 --- a/wiki +++ b/wiki @@ -1 +1 @@ -Subproject commit af2be487e3610e4f2a3cf5325c1a703a2bee6daf +Subproject commit 685529e0a67fbbbc7b1b01e965a064d06e953baf