Merge branch 'master' of https://github.com/copycat-killer/lain
This commit is contained in:
commit
466c48d20a
4 changed files with 141 additions and 19 deletions
123
layout/centerworkd.lua
Normal file
123
layout/centerworkd.lua
Normal file
|
@ -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
|
|
@ -15,12 +15,15 @@ local naughty = require("naughty")
|
||||||
local io = { popen = io.popen }
|
local io = { popen = io.popen }
|
||||||
local os = { date = os.date }
|
local os = { date = os.date }
|
||||||
local mouse = mouse
|
local mouse = mouse
|
||||||
|
local string = { format = string.format,
|
||||||
|
sub = string.sub,
|
||||||
|
gsub = string.gsub }
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
|
||||||
-- Calendar notification
|
-- Calendar notification
|
||||||
-- lain.widgets.calendar
|
-- lain.widgets.cal
|
||||||
local calendar = {}
|
local calendar = {}
|
||||||
local cal_notification = nil
|
local cal_notification = nil
|
||||||
|
|
||||||
|
@ -34,12 +37,12 @@ end
|
||||||
function calendar:show(t_out, inc_offset, scr)
|
function calendar:show(t_out, inc_offset, scr)
|
||||||
calendar:hide()
|
calendar:hide()
|
||||||
|
|
||||||
local offs = inc_offset or 0
|
|
||||||
local tims = t_out or 0
|
|
||||||
local f, c_text
|
local f, c_text
|
||||||
|
local offs = inc_offset or 0
|
||||||
|
local tims = t_out or 0
|
||||||
local today = tonumber(os.date('%d'))
|
local today = tonumber(os.date('%d'))
|
||||||
local init_t = calendar.cal .. ' ' .. calendar.post_cal .. ' ' ..
|
local init_t = string.format("%s %s | sed -e 's/[\b]\\{3\\}//g'",
|
||||||
' | sed -r -e "s/_\\x08//g" | sed -r -e "s/(^| )('
|
calendar.cal, calendar.post_cal)
|
||||||
|
|
||||||
calendar.offset = calendar.offset + offs
|
calendar.offset = calendar.offset + offs
|
||||||
|
|
||||||
|
@ -49,12 +52,8 @@ function calendar:show(t_out, inc_offset, scr)
|
||||||
calendar.notify_icon = calendar.icons .. today .. ".png"
|
calendar.notify_icon = calendar.icons .. today .. ".png"
|
||||||
|
|
||||||
-- bg and fg inverted to highlight today
|
-- bg and fg inverted to highlight today
|
||||||
f = io.popen( init_t .. today ..
|
f = io.popen(string.format("%s -e '0,/%d/ s/%d/<b><span foreground=\"%s\" background=\"%s\">%d<\\/span><\\/b>/'",
|
||||||
')($| )/\\1<b><span foreground=\\"'
|
init_t, today, today, calendar.bg, calendar.fg, today))
|
||||||
.. calendar.bg ..
|
|
||||||
'\\" background=\\"'
|
|
||||||
.. calendar.fg ..
|
|
||||||
'\\">\\2<\\/span><\\/b>\\3/"' )
|
|
||||||
|
|
||||||
else -- no current month showing, no day to highlight
|
else -- no current month showing, no day to highlight
|
||||||
local month = tonumber(os.date('%m'))
|
local month = tonumber(os.date('%m'))
|
||||||
|
@ -78,11 +77,10 @@ function calendar:show(t_out, inc_offset, scr)
|
||||||
|
|
||||||
calendar.notify_icon = nil
|
calendar.notify_icon = nil
|
||||||
|
|
||||||
f = io.popen(calendar.cal .. ' ' .. month .. ' ' .. year .. ' ' ..
|
f = io.popen(string.format('%s %s %s %s', calendar.cal, month, year, calendar.post_cal))
|
||||||
calendar.post_cal)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
c_text = "<tt><span font='" .. calendar.font .. " "
|
c_text = " <tt><span font='" .. calendar.font .. " "
|
||||||
.. calendar.font_size .. "'><b>"
|
.. calendar.font_size .. "'><b>"
|
||||||
.. f:read() .. "</b>\n\n"
|
.. f:read() .. "</b>\n\n"
|
||||||
.. f:read() .. "\n"
|
.. f:read() .. "\n"
|
||||||
|
|
|
@ -23,17 +23,18 @@ local function worker(args)
|
||||||
local args = args or {}
|
local args = args or {}
|
||||||
local timeout = args.timeout or 5
|
local timeout = args.timeout or 5
|
||||||
local settings = args.settings or function() end
|
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 | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p'")
|
||||||
pulseaudio.cmd = args.cmd or string.format("pacmd list-sinks | grep -e 'index: %d' -e 'volume: front' -e 'muted'", pulseaudio.sink)
|
|
||||||
pulseaudio.widget = wibox.widget.textbox('')
|
pulseaudio.widget = wibox.widget.textbox('')
|
||||||
|
|
||||||
function pulseaudio.update()
|
function pulseaudio.update()
|
||||||
|
if scallback then pulseaudio.cmd = scallback() end
|
||||||
local s = read_pipe(pulseaudio.cmd)
|
local s = read_pipe(pulseaudio.cmd)
|
||||||
|
|
||||||
volume_now = {}
|
volume_now = {}
|
||||||
volume_now.left = tonumber(string.match(s, "left.-(%d+)%%"))
|
volume_now.left = tonumber(string.match(s, ":.-(%d+)%%"))
|
||||||
volume_now.right = tonumber(string.match(s, "right.-(%d+)%%"))
|
volume_now.right = tonumber(string.match(s, ":.-(%d+)%%"))
|
||||||
volume_now.muted = string.match(s, "muted: (%S+)")
|
volume_now.muted = string.match(s, "muted: (%S+)")
|
||||||
|
|
||||||
widget = pulseaudio.widget
|
widget = pulseaudio.widget
|
||||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
||||||
Subproject commit dcce6dd58791c7c1d2e2e3f046b4da0d5b9700a7
|
Subproject commit 685529e0a67fbbbc7b1b01e965a064d06e953baf
|
Loading…
Add table
Reference in a new issue