Added settings.lua

This commit is contained in:
2023-01-25 20:10:58 +01:00
parent 80cc950271
commit 5cf452e053
38 changed files with 3880 additions and 3450 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -11,180 +11,200 @@
--]]
local awful = require("awful")
local sqrt = math.sqrt
local pairs = pairs
local client = client
local tonumber = tonumber
local wrequire = require("lain.helpers").wrequire
local awful = require('awful')
local sqrt = math.sqrt
local pairs = pairs
local client = client
local tonumber = tonumber
local wrequire = require('lain.helpers').wrequire
local setmetatable = setmetatable
-- Lain utilities submodule
-- lain.util
local util = { _NAME = "lain.util" }
local util = { _NAME = 'lain.util' }
-- Like awful.menu.clients, but only show clients of currently selected tags
function util.menu_clients_current_tags(menu, args)
-- List of currently selected tags.
local cls_tags = awful.screen.focused().selected_tags
-- List of currently selected tags.
local cls_tags = awful.screen.focused().selected_tags
if cls_tags == nil then return nil end
if cls_tags == nil then
return nil
end
-- Final list of menu items.
local cls_t = {}
-- Final list of menu items.
local cls_t = {}
-- For each selected tag get all clients of that tag and add them to
-- the menu. A click on a menu item will raise that client.
for i = 1,#cls_tags do
local t = cls_tags[i]
local cls = t:clients()
-- For each selected tag get all clients of that tag and add them to
-- the menu. A click on a menu item will raise that client.
for i = 1, #cls_tags do
local t = cls_tags[i]
local cls = t:clients()
for _, c in pairs(cls) do
cls_t[#cls_t + 1] = { awful.util.escape(c.name) or "",
function ()
c.minimized = false
client.focus = c
c:raise()
end,
c.icon }
end
end
for _, c in pairs(cls) do
cls_t[#cls_t + 1] = {
awful.util.escape(c.name) or '',
function()
c.minimized = false
client.focus = c
c:raise()
end,
c.icon,
}
end
end
-- No clients? Then quit.
if #cls_t <= 0 then return nil end
-- No clients? Then quit.
if #cls_t <= 0 then
return nil
end
-- menu may contain some predefined values, otherwise start with a
-- fresh menu.
if not menu then menu = {} end
-- menu may contain some predefined values, otherwise start with a
-- fresh menu.
if not menu then
menu = {}
end
-- Set the list of items and show the menu.
menu.items = cls_t
local m = awful.menu(menu)
m:show(args)
-- Set the list of items and show the menu.
menu.items = cls_t
local m = awful.menu(menu)
m:show(args)
return m
return m
end
-- Magnify a client: set it to "float" and resize it.
function util.magnify_client(c, width_f, height_f)
if c and not c.floating then
util.magnified_client = c
util.mc(c, width_f, height_f)
else
util.magnified_client = nil
c.floating = false
end
if c and not c.floating then
util.magnified_client = c
util.mc(c, width_f, height_f)
else
util.magnified_client = nil
c.floating = false
end
end
-- https://github.com/lcpz/lain/issues/195
function util.mc(c, width_f, height_f)
c = c or util.magnified_client
if not c then return end
c = c or util.magnified_client
if not c then
return
end
c.floating = true
local s = awful.screen.focused()
local mg = s.workarea
local g = {}
local mwfact = width_f or s.selected_tag.master_width_factor or 0.5
g.width = sqrt(mwfact) * mg.width
g.height = sqrt(height_f or mwfact) * mg.height
g.x = mg.x + (mg.width - g.width) / 2
g.y = mg.y + (mg.height - g.height) / 2
c.floating = true
local s = awful.screen.focused()
local mg = s.workarea
local g = {}
local mwfact = width_f or s.selected_tag.master_width_factor or 0.5
g.width = sqrt(mwfact) * mg.width
g.height = sqrt(height_f or mwfact) * mg.height
g.x = mg.x + (mg.width - g.width) / 2
g.y = mg.y + (mg.height - g.height) / 2
if c then c:geometry(g) end -- if c is still a valid object
if c then
c:geometry(g)
end -- if c is still a valid object
end
-- Non-empty tag browsing
-- direction in {-1, 1} <-> {previous, next} non-empty tag
function util.tag_view_nonempty(direction,sc)
direction = direction or 1
local s = sc or awful.screen.focused()
local tags = s.tags
local sel = s.selected_tag
function util.tag_view_nonempty(direction, sc)
direction = direction or 1
local s = sc or awful.screen.focused()
local tags = s.tags
local sel = s.selected_tag
local i = sel.index
repeat
i = i + direction
local i = sel.index
repeat
i = i + direction
-- Wrap around when we reach one of the bounds
if i > #tags then
i = i - #tags
end
if i < 1 then
i = i + #tags
end
-- Wrap around when we reach one of the bounds
if i > #tags then
i = i - #tags
end
if i < 1 then
i = i + #tags
end
local t = tags[i]
local t = tags[i]
-- Stop when we get back to where we started
if t == sel then
break
end
-- Stop when we get back to where we started
if t == sel then
break
end
-- If it's The One, view it.
if #t:clients() > 0 then
t:view_only()
return
end
until false
-- If it's The One, view it.
if #t:clients() > 0 then
t:view_only()
return
end
until false
end
-- {{{ Dynamic tagging
-- Add a new tag
function util.add_tag(layout)
awful.prompt.run {
prompt = "New tag name: ",
textbox = awful.screen.focused().mypromptbox.widget,
exe_callback = function(name)
if not name or #name == 0 then return end
awful.tag.add(name, { screen = awful.screen.focused(), layout = layout or awful.layout.suit.tile }):view_only()
end
}
awful.prompt.run({
prompt = 'New tag name: ',
textbox = awful.screen.focused().mypromptbox.widget,
exe_callback = function(name)
if not name or #name == 0 then
return
end
awful.tag
.add(name, { screen = awful.screen.focused(), layout = layout or awful.layout.suit.tile })
:view_only()
end,
})
end
-- Rename current tag
function util.rename_tag()
awful.prompt.run {
prompt = "Rename tag: ",
textbox = awful.screen.focused().mypromptbox.widget,
exe_callback = function(new_name)
if not new_name or #new_name == 0 then return end
local t = awful.screen.focused().selected_tag
if t then
t.name = new_name
end
end
}
awful.prompt.run({
prompt = 'Rename tag: ',
textbox = awful.screen.focused().mypromptbox.widget,
exe_callback = function(new_name)
if not new_name or #new_name == 0 then
return
end
local t = awful.screen.focused().selected_tag
if t then
t.name = new_name
end
end,
})
end
-- Move current tag
-- pos in {-1, 1} <-> {previous, next} tag position
function util.move_tag(pos)
local tag = awful.screen.focused().selected_tag
if tonumber(pos) <= -1 then
awful.tag.move(tag.index - 1, tag)
else
awful.tag.move(tag.index + 1, tag)
end
local tag = awful.screen.focused().selected_tag
if tonumber(pos) <= -1 then
awful.tag.move(tag.index - 1, tag)
else
awful.tag.move(tag.index + 1, tag)
end
end
-- Delete current tag
-- Any rule set on the tag shall be broken
function util.delete_tag()
local t = awful.screen.focused().selected_tag
if not t then return end
t:delete()
local t = awful.screen.focused().selected_tag
if not t then
return
end
t:delete()
end
-- }}}
-- On the fly useless gaps change
function util.useless_gaps_resize(thatmuch, s, t)
local scr = s or awful.screen.focused()
local tag = t or scr.selected_tag
tag.gap = tag.gap + tonumber(thatmuch)
awful.layout.arrange(scr)
local scr = s or awful.screen.focused()
local tag = t or scr.selected_tag
tag.gap = tag.gap + tonumber(thatmuch)
awful.layout.arrange(scr)
end
return setmetatable(util, { __index = wrequire })

View File

@@ -15,52 +15,78 @@ local setmetatable = setmetatable
local markup = { fg = {}, bg = {} }
-- Convenience tags
function markup.bold(text) return format("<b>%s</b>", text) end
function markup.italic(text) return format("<i>%s</i>", text) end
function markup.strike(text) return format("<s>%s</s>", text) end
function markup.underline(text) return format("<u>%s</u>", text) end
function markup.monospace(text) return format("<tt>%s</tt>", text) end
function markup.big(text) return format("<big>%s</big>", text) end
function markup.small(text) return format("<small>%s</small>", text) end
function markup.bold(text)
return format('<b>%s</b>', text)
end
function markup.italic(text)
return format('<i>%s</i>', text)
end
function markup.strike(text)
return format('<s>%s</s>', text)
end
function markup.underline(text)
return format('<u>%s</u>', text)
end
function markup.monospace(text)
return format('<tt>%s</tt>', text)
end
function markup.big(text)
return format('<big>%s</big>', text)
end
function markup.small(text)
return format('<small>%s</small>', text)
end
-- Set the font
function markup.font(font, text)
return format("<span font='%s'>%s</span>", font, text)
return format("<span font='%s'>%s</span>", font, text)
end
-- Set the foreground
function markup.fg.color(color, text)
return format("<span foreground='%s'>%s</span>", color, text)
return format("<span foreground='%s'>%s</span>", color, text)
end
-- Set the background
function markup.bg.color(color, text)
return format("<span background='%s'>%s</span>", color, text)
return format("<span background='%s'>%s</span>", color, text)
end
-- Set foreground and background
function markup.color(fg, bg, text)
return format("<span foreground='%s' background='%s'>%s</span>", fg, bg, text)
return format("<span foreground='%s' background='%s'>%s</span>", fg, bg, text)
end
-- Set font and foreground
function markup.fontfg(font, fg, text)
return format("<span font='%s' foreground='%s'>%s</span>", font, fg, text)
return format("<span font='%s' foreground='%s'>%s</span>", font, fg, text)
end
-- Set font and background
function markup.fontbg(font, bg, text)
return format("<span font='%s' background='%s'>%s</span>", font, bg, text)
return format("<span font='%s' background='%s'>%s</span>", font, bg, text)
end
-- Set font, foreground and background
function markup.fontcolor(font, fg, bg, text)
return format("<span font='%s' foreground='%s' background='%s'>%s</span>", font, fg, bg, text)
return format("<span font='%s' foreground='%s' background='%s'>%s</span>", font, fg, bg, text)
end
-- link markup.{fg,bg}(...) calls to markup.{fg,bg}.color(...)
setmetatable(markup.fg, { __call = function(_, ...) return markup.fg.color(...) end })
setmetatable(markup.bg, { __call = function(_, ...) return markup.bg.color(...) end })
setmetatable(markup.fg, {
__call = function(_, ...)
return markup.fg.color(...)
end,
})
setmetatable(markup.bg, {
__call = function(_, ...)
return markup.bg.color(...)
end,
})
-- link markup(...) calls to markup.fg.color(...)
return setmetatable(markup, { __call = function(_, ...) return markup.fg.color(...) end })
return setmetatable(markup, {
__call = function(_, ...)
return markup.fg.color(...)
end,
})

View File

@@ -10,28 +10,30 @@
-- Menu iterator with Naughty notifications
-- lain.util.menu_iterator
local naughty = require("naughty")
local helpers = require("lain.helpers")
local atable = require("awful.util").table
local assert = assert
local pairs = pairs
local naughty = require('naughty')
local helpers = require('lain.helpers')
local atable = require('awful.util').table
local assert = assert
local pairs = pairs
local tconcat = table.concat
local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility
local state = { cid = nil }
local function naughty_destroy_callback(reason)
local closed = naughty.notificationClosedReason
if reason == closed.expired or reason == closed.dismissedByUser then
local actions = state.index and state.menu[state.index - 1][2]
if actions then
for _,action in pairs(actions) do
-- don't try to call nil callbacks
if action then action() end
end
state.index = nil
end
end
local closed = naughty.notificationClosedReason
if reason == closed.expired or reason == closed.dismissedByUser then
local actions = state.index and state.menu[state.index - 1][2]
if actions then
for _, action in pairs(actions) do
-- don't try to call nil callbacks
if action then
action()
end
end
state.index = nil
end
end
end
-- Iterates over a menu.
@@ -41,35 +43,35 @@ end
-- * timeout: time to wait before confirming the menu selection
-- * icon: icon to display in the notification of the chosen label
local function iterate(menu, timeout, icon)
timeout = timeout or 4 -- default timeout for each menu entry
icon = icon or nil -- icon to display on the menu
timeout = timeout or 4 -- default timeout for each menu entry
icon = icon or nil -- icon to display on the menu
-- Build the list of choices
if not state.index then
state.menu = menu
state.index = 1
end
-- Build the list of choices
if not state.index then
state.menu = menu
state.index = 1
end
-- Select one and display the appropriate notification
local label
local next = state.menu[state.index]
state.index = state.index + 1
-- Select one and display the appropriate notification
local label
local next = state.menu[state.index]
state.index = state.index + 1
if not next then
label = "Cancel"
state.index = nil
else
label, _ = unpack(next)
end
if not next then
label = 'Cancel'
state.index = nil
else
label, _ = unpack(next)
end
state.cid = naughty.notify({
text = label,
icon = icon,
timeout = timeout,
screen = mouse.screen,
replaces_id = state.cid,
destroy = naughty_destroy_callback
}).id
state.cid = naughty.notify({
text = label,
icon = icon,
timeout = timeout,
screen = mouse.screen,
replaces_id = state.cid,
destroy = naughty_destroy_callback,
}).id
end
-- Generates a menu compatible with the first argument of `iterate` function and
@@ -95,50 +97,55 @@ end
-- Output:
-- * m: menu to be iterated over.
local function menu(args)
local choices = assert(args.choices or args[1])
local name = assert(args.name or args[2])
local selected_cb = args.selected_cb
local rejected_cb = args.rejected_cb
local extra_choices = args.extra_choices or {}
local choices = assert(args.choices or args[1])
local name = assert(args.name or args[2])
local selected_cb = args.selected_cb
local rejected_cb = args.rejected_cb
local extra_choices = args.extra_choices or {}
local ch_combinations = args.combination == "powerset" and helpers.powerset(choices) or helpers.trivial_partition_set(choices)
local ch_combinations = args.combination == 'powerset' and helpers.powerset(choices)
or helpers.trivial_partition_set(choices)
for _, c in pairs(extra_choices) do
ch_combinations = atable.join(ch_combinations, {{c[1]}})
end
for _, c in pairs(extra_choices) do
ch_combinations = atable.join(ch_combinations, { { c[1] } })
end
local m = {} -- the menu
local m = {} -- the menu
for _,c in pairs(ch_combinations) do
if #c > 0 then
local cbs = {}
for _, c in pairs(ch_combinations) do
if #c > 0 then
local cbs = {}
-- selected choices
for _,ch in pairs(c) do
if atable.hasitem(choices, ch) then
cbs[#cbs + 1] = selected_cb and function() selected_cb(ch) end or nil
end
end
-- selected choices
for _, ch in pairs(c) do
if atable.hasitem(choices, ch) then
cbs[#cbs + 1] = selected_cb and function()
selected_cb(ch)
end or nil
end
end
-- rejected choices
for _,ch in pairs(choices) do
if not atable.hasitem(c, ch) and atable.hasitem(choices, ch) then
cbs[#cbs + 1] = rejected_cb and function() rejected_cb(ch) end or nil
end
end
-- rejected choices
for _, ch in pairs(choices) do
if not atable.hasitem(c, ch) and atable.hasitem(choices, ch) then
cbs[#cbs + 1] = rejected_cb and function()
rejected_cb(ch)
end or nil
end
end
-- add user extra choices (like the choice "None" for example)
for _,x in pairs(extra_choices) do
if x[1] == c[1] then
cbs[#cbs + 1] = x[2]
end
end
-- add user extra choices (like the choice "None" for example)
for _, x in pairs(extra_choices) do
if x[1] == c[1] then
cbs[#cbs + 1] = x[2]
end
end
m[#m + 1] = { name .. ": " .. tconcat(c, " + "), cbs }
end
end
m[#m + 1] = { name .. ': ' .. tconcat(c, ' + '), cbs }
end
end
return m
return m
end
return { iterate = iterate, menu = menu }

View File

@@ -6,12 +6,12 @@
--]]
local awful = require("awful")
local capi = { client = client }
local math = math
local string = string
local pairs = pairs
local screen = screen
local awful = require('awful')
local capi = { client = client }
local math = math
local string = string
local pairs = pairs
local screen = screen
local setmetatable = setmetatable
-- Quake-like Dropdown application spawn
@@ -22,158 +22,182 @@ local quake = {}
-- run into problems with focus.
function quake:display()
if self.followtag then self.screen = awful.screen.focused() end
if self.followtag then
self.screen = awful.screen.focused()
end
-- First, we locate the client
local client = nil
local i = 0
for c in awful.client.iterate(function (c)
-- c.name may be changed!
return c.instance == self.name
end)
do
i = i + 1
if i == 1 then
client = c
else
-- Additional matching clients, let's remove the sticky bit
-- which may persist between awesome restarts. We don't close
-- them as they may be valuable. They will just turn into
-- normal clients.
c.sticky = false
c.ontop = false
c.above = false
end
end
-- First, we locate the client
local client = nil
local i = 0
for c in
awful.client.iterate(function(c)
-- c.name may be changed!
return c.instance == self.name
end)
do
i = i + 1
if i == 1 then
client = c
else
-- Additional matching clients, let's remove the sticky bit
-- which may persist between awesome restarts. We don't close
-- them as they may be valuable. They will just turn into
-- normal clients.
c.sticky = false
c.ontop = false
c.above = false
end
end
if not client and not self.visible then return end
if not client and not self.visible then
return
end
if not client then
-- The client does not exist, we spawn it
local cmd = string.format("%s %s %s", self.app,
string.format(self.argname, self.name), self.extra)
awful.spawn(cmd, { tag = self.screen.selected_tag })
return
end
if not client then
-- The client does not exist, we spawn it
local cmd = string.format('%s %s %s', self.app, string.format(self.argname, self.name), self.extra)
awful.spawn(cmd, { tag = self.screen.selected_tag })
return
end
-- Set geometry
client.floating = true
client.border_width = self.border
client.size_hints_honor = false
local maximized = client.maximized
local fullscreen = client.fullscreen
client:geometry(self.geometry[self.screen.index] or self:compute_size())
-- Set geometry
client.floating = true
client.border_width = self.border
client.size_hints_honor = false
local maximized = client.maximized
local fullscreen = client.fullscreen
client:geometry(self.geometry[self.screen.index] or self:compute_size())
-- Set not sticky and on top
client.sticky = false
client.ontop = true
client.above = true
client.skip_taskbar = true
-- Set not sticky and on top
client.sticky = false
client.ontop = true
client.above = true
client.skip_taskbar = true
-- Additional user settings
if self.settings then self.settings(client) end
-- Additional user settings
if self.settings then
self.settings(client)
end
-- Toggle display
if self.visible then
client.hidden = false
client.maximized = self.maximized
client.fullscreen = self.fullscreen
client:raise()
self.last_tag = self.screen.selected_tag
client:tags({self.screen.selected_tag})
capi.client.focus = client
else
self.maximized = maximized
self.fullscreen = fullscreen
client.maximized = false
client.fullscreen = false
client.hidden = true
local ctags = client:tags()
for j, _ in pairs(ctags) do
ctags[j] = nil
end
client:tags(ctags)
end
-- Toggle display
if self.visible then
client.hidden = false
client.maximized = self.maximized
client.fullscreen = self.fullscreen
client:raise()
self.last_tag = self.screen.selected_tag
client:tags({ self.screen.selected_tag })
capi.client.focus = client
else
self.maximized = maximized
self.fullscreen = fullscreen
client.maximized = false
client.fullscreen = false
client.hidden = true
local ctags = client:tags()
for j, _ in pairs(ctags) do
ctags[j] = nil
end
client:tags(ctags)
end
return client
return client
end
function quake:compute_size()
-- skip if we already have a geometry for this screen
if not self.geometry[self.screen.index] then
local geom
if not self.overlap then
geom = screen[self.screen.index].workarea
else
geom = screen[self.screen.index].geometry
end
local width, height = self.width, self.height
if width <= 1 then width = math.floor(geom.width * width) - 2 * self.border end
if height <= 1 then height = math.floor(geom.height * height) end
local x, y
if self.horiz == "left" then x = geom.x
elseif self.horiz == "right" then x = geom.width + geom.x - width
else x = geom.x + (geom.width - width)/2 end
if self.vert == "top" then y = geom.y
elseif self.vert == "bottom" then y = geom.height + geom.y - height
else y = geom.y + (geom.height - height)/2 end
self.geometry[self.screen.index] = { x = x, y = y, width = width, height = height }
end
return self.geometry[self.screen.index]
-- skip if we already have a geometry for this screen
if not self.geometry[self.screen.index] then
local geom
if not self.overlap then
geom = screen[self.screen.index].workarea
else
geom = screen[self.screen.index].geometry
end
local width, height = self.width, self.height
if width <= 1 then
width = math.floor(geom.width * width) - 2 * self.border
end
if height <= 1 then
height = math.floor(geom.height * height)
end
local x, y
if self.horiz == 'left' then
x = geom.x
elseif self.horiz == 'right' then
x = geom.width + geom.x - width
else
x = geom.x + (geom.width - width) / 2
end
if self.vert == 'top' then
y = geom.y
elseif self.vert == 'bottom' then
y = geom.height + geom.y - height
else
y = geom.y + (geom.height - height) / 2
end
self.geometry[self.screen.index] = { x = x, y = y, width = width, height = height }
end
return self.geometry[self.screen.index]
end
function quake:toggle()
if self.followtag then self.screen = awful.screen.focused() end
local current_tag = self.screen.selected_tag
if current_tag and self.last_tag ~= current_tag and self.visible then
local c=self:display()
if c then
c:move_to_tag(current_tag)
end
else
self.visible = not self.visible
self:display()
end
if self.followtag then
self.screen = awful.screen.focused()
end
local current_tag = self.screen.selected_tag
if current_tag and self.last_tag ~= current_tag and self.visible then
local c = self:display()
if c then
c:move_to_tag(current_tag)
end
else
self.visible = not self.visible
self:display()
end
end
function quake.new(conf)
conf = conf or {}
conf = conf or {}
conf.app = conf.app or "xterm" -- application to spawn
conf.name = conf.name or "QuakeDD" -- window name
conf.argname = conf.argname or "-name %s" -- how to specify window name
conf.extra = conf.extra or "" -- extra arguments
conf.border = conf.border or 1 -- client border width
conf.visible = conf.visible or false -- initially not visible
conf.followtag = conf.followtag or false -- spawn on currently focused screen
conf.overlap = conf.overlap or false -- overlap wibox
conf.screen = conf.screen or awful.screen.focused()
conf.settings = conf.settings
conf.app = conf.app or 'xterm' -- application to spawn
conf.name = conf.name or 'QuakeDD' -- window name
conf.argname = conf.argname or '-name %s' -- how to specify window name
conf.extra = conf.extra or '' -- extra arguments
conf.border = conf.border or 1 -- client border width
conf.visible = conf.visible or false -- initially not visible
conf.followtag = conf.followtag or false -- spawn on currently focused screen
conf.overlap = conf.overlap or false -- overlap wibox
conf.screen = conf.screen or awful.screen.focused()
conf.settings = conf.settings
-- If width or height <= 1 this is a proportion of the workspace
conf.height = conf.height or 0.25 -- height
conf.width = conf.width or 1 -- width
conf.vert = conf.vert or "top" -- top, bottom or center
conf.horiz = conf.horiz or "left" -- left, right or center
conf.geometry = {} -- internal use
-- If width or height <= 1 this is a proportion of the workspace
conf.height = conf.height or 0.25 -- height
conf.width = conf.width or 1 -- width
conf.vert = conf.vert or 'top' -- top, bottom or center
conf.horiz = conf.horiz or 'left' -- left, right or center
conf.geometry = {} -- internal use
conf.maximized = false
conf.fullscreen = false
conf.maximized = false
conf.fullscreen = false
local dropdown = setmetatable(conf, { __index = quake })
local dropdown = setmetatable(conf, { __index = quake })
capi.client.connect_signal("manage", function(c)
if c.instance == dropdown.name and c.screen == dropdown.screen then
dropdown:display()
end
end)
capi.client.connect_signal("unmanage", function(c)
if c.instance == dropdown.name and c.screen == dropdown.screen then
dropdown.visible = false
end
end)
capi.client.connect_signal('manage', function(c)
if c.instance == dropdown.name and c.screen == dropdown.screen then
dropdown:display()
end
end)
capi.client.connect_signal('unmanage', function(c)
if c.instance == dropdown.name and c.screen == dropdown.screen then
dropdown.visible = false
end
end)
return dropdown
return dropdown
end
return setmetatable(quake, { __call = function(_, ...) return quake.new(...) end })
return setmetatable(quake, {
__call = function(_, ...)
return quake.new(...)
end,
})

View File

@@ -6,9 +6,9 @@
--]]
local wibox = require("wibox")
local gears = require("gears")
local beautiful = require("beautiful")
local wibox = require('wibox')
local gears = require('gears')
local beautiful = require('beautiful')
-- Lain Cairo separators util submodule
-- lain.util.separators
@@ -18,99 +18,99 @@ local separators = { height = beautiful.separators_height or 0, width = beautifu
-- Right
function separators.arrow_right(col1, col2)
local widget = wibox.widget.base.make_widget()
widget.col1 = col1
widget.col2 = col2
local widget = wibox.widget.base.make_widget()
widget.col1 = col1
widget.col2 = col2
widget.fit = function(_, _, _)
return separators.width, separators.height
end
widget.fit = function(_, _, _)
return separators.width, separators.height
end
widget.update = function(_, _)
widget.col1 = col1
widget.col2 = col2
widget:emit_signal("widget::redraw_needed")
end
widget.update = function(_, _)
widget.col1 = col1
widget.col2 = col2
widget:emit_signal('widget::redraw_needed')
end
widget.draw = function(_, _, cr, width, height)
if widget.col2 ~= "alpha" then
cr:set_source_rgba(gears.color.parse_color(widget.col2))
cr:new_path()
cr:move_to(0, 0)
cr:line_to(width, height/2)
cr:line_to(width, 0)
cr:close_path()
cr:fill()
widget.draw = function(_, _, cr, width, height)
if widget.col2 ~= 'alpha' then
cr:set_source_rgba(gears.color.parse_color(widget.col2))
cr:new_path()
cr:move_to(0, 0)
cr:line_to(width, height / 2)
cr:line_to(width, 0)
cr:close_path()
cr:fill()
cr:new_path()
cr:move_to(0, height)
cr:line_to(width, height/2)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end
cr:new_path()
cr:move_to(0, height)
cr:line_to(width, height / 2)
cr:line_to(width, height)
cr:close_path()
cr:fill()
end
if widget.col1 ~= "alpha" then
cr:set_source_rgba(gears.color.parse_color(widget.col1))
cr:new_path()
cr:move_to(0, 0)
cr:line_to(width, height/2)
cr:line_to(0, height)
cr:close_path()
cr:fill()
end
end
if widget.col1 ~= 'alpha' then
cr:set_source_rgba(gears.color.parse_color(widget.col1))
cr:new_path()
cr:move_to(0, 0)
cr:line_to(width, height / 2)
cr:line_to(0, height)
cr:close_path()
cr:fill()
end
end
return widget
return widget
end
-- Left
function separators.arrow_left(col1, col2)
local widget = wibox.widget.base.make_widget()
widget.col1 = col1
widget.col2 = col2
local widget = wibox.widget.base.make_widget()
widget.col1 = col1
widget.col2 = col2
widget.fit = function(_, _, _)
return separators.width, separators.height
end
widget.fit = function(_, _, _)
return separators.width, separators.height
end
widget.update = function(c1, c2)
widget.col1 = c1
widget.col2 = c2
widget:emit_signal("widget::redraw_needed")
end
widget.update = function(c1, c2)
widget.col1 = c1
widget.col2 = c2
widget:emit_signal('widget::redraw_needed')
end
widget.draw = function(_, _, cr, width, height)
if widget.col1 ~= "alpha" then
cr:set_source_rgba(gears.color.parse_color(widget.col1))
cr:new_path()
cr:move_to(width, 0)
cr:line_to(0, height/2)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
widget.draw = function(_, _, cr, width, height)
if widget.col1 ~= 'alpha' then
cr:set_source_rgba(gears.color.parse_color(widget.col1))
cr:new_path()
cr:move_to(width, 0)
cr:line_to(0, height / 2)
cr:line_to(0, 0)
cr:close_path()
cr:fill()
cr:new_path()
cr:move_to(width, height)
cr:line_to(0, height/2)
cr:line_to(0, height)
cr:close_path()
cr:fill()
end
cr:new_path()
cr:move_to(width, height)
cr:line_to(0, height / 2)
cr:line_to(0, height)
cr:close_path()
cr:fill()
end
if widget.col2 ~= "alpha" then
cr:new_path()
cr:move_to(width, 0)
cr:line_to(0, height/2)
cr:line_to(width, height)
cr:close_path()
if widget.col2 ~= 'alpha' then
cr:new_path()
cr:move_to(width, 0)
cr:line_to(0, height / 2)
cr:line_to(width, height)
cr:close_path()
cr:set_source_rgba(gears.color.parse_color(widget.col2))
cr:fill()
end
end
cr:set_source_rgba(gears.color.parse_color(widget.col2))
cr:fill()
end
end
return widget
return widget
end
-- ]]