chore: remove unused variables
This commit is contained in:
parent
9b80e81c47
commit
fcd5bd1109
18
colors.lua
18
colors.lua
|
@ -6,12 +6,13 @@ local floor = math.floor
|
|||
local max = math.max
|
||||
local min = math.min
|
||||
local random = math.random
|
||||
local gcolor = require("gears.color")
|
||||
local gcolor = require "gears.color"
|
||||
local parse_color = gcolor.parse_color
|
||||
|
||||
-- Returns a value that is clipped to interval edges if it falls outside the interval
|
||||
local function clip(num, min_num, max_num) return
|
||||
max(min(num, max_num), min_num) end
|
||||
local function clip(num, min_num, max_num)
|
||||
return max(min(num, max_num), min_num)
|
||||
end
|
||||
|
||||
-- Converts the given hex color to normalized rgba
|
||||
local function hex2rgb(color)
|
||||
|
@ -60,8 +61,12 @@ end
|
|||
local function hsv2hex(H, S, V)
|
||||
S = S / 100
|
||||
V = V / 100
|
||||
if H > 360 then H = 360 end
|
||||
if H < 0 then H = 0 end
|
||||
if H > 360 then
|
||||
H = 360
|
||||
end
|
||||
if H < 0 then
|
||||
H = 0
|
||||
end
|
||||
local C = V * S
|
||||
local X = C * (1 - math.abs(((H / 60) % 2) - 1))
|
||||
local m = V - C
|
||||
|
@ -87,7 +92,8 @@ end
|
|||
local function relative_luminance(color)
|
||||
local r, g, b = hex2rgb(color)
|
||||
local function from_sRGB(u)
|
||||
return u <= 0.0031308 and 25 * u / 323 or ((200 * u + 11) / 211) ^ (12 / 5)
|
||||
return u <= 0.0031308 and 25 * u / 323
|
||||
or ((200 * u + 11) / 211) ^ (12 / 5)
|
||||
end
|
||||
return 0.2126 * from_sRGB(r) + 0.7152 * from_sRGB(g) + 0.0722 * from_sRGB(b)
|
||||
end
|
||||
|
|
13
init.lua
13
init.lua
|
@ -9,11 +9,7 @@ Author: mu-tex
|
|||
License: MIT
|
||||
Repository: https://github.com/mut-ex/awesome-wm-nice
|
||||
]]
|
||||
-- ============================================================
|
||||
-- local ret, helpers = pcall(require, "helpers")
|
||||
-- local debug = ret and helpers.debug or function() end
|
||||
-- => Awesome WM
|
||||
-- ============================================================
|
||||
|
||||
local awful = require "awful"
|
||||
local atooltip = awful.tooltip
|
||||
local abutton = awful.button
|
||||
|
@ -44,7 +40,6 @@ local gtimer_weak_start_new = gtimer.weak_start_new
|
|||
local math = math
|
||||
local max = math.max
|
||||
local abs = math.abs
|
||||
local rad = math.rad
|
||||
local floor = math.floor
|
||||
local pairs = pairs
|
||||
local ipairs = ipairs
|
||||
|
@ -54,7 +49,6 @@ local ipairs = ipairs
|
|||
-- => LGI
|
||||
-- ============================================================
|
||||
local lgi = require "lgi"
|
||||
local cairo = lgi.cairo
|
||||
local gdk = lgi.require("Gdk", "3.0")
|
||||
local get_default_root_window = gdk.get_default_root_window
|
||||
local pixbuf_get_from_surface = gdk.pixbuf_get_from_surface
|
||||
|
@ -415,7 +409,6 @@ local function create_titlebar_button(c, name, button_callback, property)
|
|||
end
|
||||
|
||||
local function get_titlebar_mouse_bindings(c)
|
||||
local client_color = c._nice_base_color
|
||||
local shade_enabled = _private.win_shade_enabled
|
||||
-- Add functionality for double click to (un)maximize, and single click and hold to move
|
||||
local clicks = 0
|
||||
|
@ -458,7 +451,6 @@ local function get_titlebar_mouse_bindings(c)
|
|||
set_color_rule(c, c._nice_base_color)
|
||||
_private.add_window_decorations(c)
|
||||
end)
|
||||
local picked_color
|
||||
add_item("Manually Pick Color", function()
|
||||
_G.mousegrabber.run(function(m)
|
||||
if m.buttons[1] then
|
||||
|
@ -932,7 +924,7 @@ local function validate_mb_bindings()
|
|||
local mb_specified = { false, false, false, false, false }
|
||||
local mb
|
||||
local mb_conflict_test
|
||||
for i, action_mb in ipairs(action_mbs) do
|
||||
for _, action_mb in ipairs(action_mbs) do
|
||||
mb = _private[action_mb]
|
||||
if mb then
|
||||
assert(mb >= 1 and mb <= 5, "Invalid mouse button specified!")
|
||||
|
@ -948,7 +940,6 @@ local function validate_mb_bindings()
|
|||
)
|
||||
)
|
||||
end
|
||||
else
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
74
shapes.lua
74
shapes.lua
|
@ -2,15 +2,12 @@
|
|||
-- Provides utility functions for handling cairo shapes and geometry
|
||||
-- ============================================================
|
||||
--
|
||||
local lgi = require("lgi")
|
||||
local colors = require("awesome-wm-nice.colors")
|
||||
local lgi = require "lgi"
|
||||
local colors = require "awesome-wm-nice.colors"
|
||||
local hex2rgb = colors.hex2rgb
|
||||
local darken = colors.darken
|
||||
local cairo = lgi.cairo
|
||||
local math = math
|
||||
local rad = math.rad
|
||||
local floor = math.floor
|
||||
local min = math.min
|
||||
|
||||
-- Returns a shape function for a rounded rectangle with independently configurable corner radii
|
||||
local function rounded_rect(args)
|
||||
|
@ -47,7 +44,13 @@ local function circle_filled(color, size)
|
|||
end
|
||||
|
||||
-- Returns a vertical gradient pattern going from cololr_1 -> color_2
|
||||
local function duotone_gradient_vertical(color_1, color_2, height, offset_1, offset_2)
|
||||
local function duotone_gradient_vertical(
|
||||
color_1,
|
||||
color_2,
|
||||
height,
|
||||
offset_1,
|
||||
offset_2
|
||||
)
|
||||
local fill_pattern = cairo.Pattern.create_linear(0, 0, 0, height)
|
||||
local r, g, b, a
|
||||
r, g, b, a = hex2rgb(color_1)
|
||||
|
@ -65,7 +68,7 @@ local function duotone_gradient_horizontal(color, width)
|
|||
fill_pattern:add_color_stop_rgba(0, r, g, b, a)
|
||||
r, g, b, a = hex2rgb(color)
|
||||
fill_pattern:add_color_stop_rgba(0.5, r, g, b, a)
|
||||
r, g, b, a = hex2rgb("#00000000")
|
||||
r, g, b, a = hex2rgb "#00000000"
|
||||
fill_pattern:add_color_stop_rgba(0.6, r, g, b, a)
|
||||
r, g, b, a = hex2rgb(color)
|
||||
fill_pattern:add_color_stop_rgba(0.7, r, g, b, a)
|
||||
|
@ -82,16 +85,16 @@ local function flip(surface, axis)
|
|||
local cr = cairo.Context.create(flipped)
|
||||
local source_pattern = cairo.Pattern.create_for_surface(surface)
|
||||
if axis == "horizontal" then
|
||||
source_pattern.matrix = cairo.Matrix({ xx = -1, yy = 1, x0 = width })
|
||||
source_pattern.matrix = cairo.Matrix { xx = -1, yy = 1, x0 = width }
|
||||
elseif axis == "vertical" then
|
||||
source_pattern.matrix = cairo.Matrix({ xx = 1, yy = -1, y0 = height })
|
||||
source_pattern.matrix = cairo.Matrix { xx = 1, yy = -1, y0 = height }
|
||||
elseif axis == "both" then
|
||||
source_pattern.matrix = cairo.Matrix({
|
||||
source_pattern.matrix = cairo.Matrix {
|
||||
xx = -1,
|
||||
yy = -1,
|
||||
x0 = width,
|
||||
y0 = height,
|
||||
})
|
||||
}
|
||||
end
|
||||
cr.source = source_pattern
|
||||
cr:rectangle(0, 0, width, height)
|
||||
|
@ -110,7 +113,13 @@ local function create_corner_top_left(args)
|
|||
local radius_offset = 1 -- To soften the corner
|
||||
cr:move_to(0, height)
|
||||
cr:line_to(0, radius - radius_offset)
|
||||
cr:arc(radius + radius_offset, radius + radius_offset, radius, rad(180), rad(270))
|
||||
cr:arc(
|
||||
radius + radius_offset,
|
||||
radius + radius_offset,
|
||||
radius,
|
||||
rad(180),
|
||||
rad(270)
|
||||
)
|
||||
cr:line_to(radius, height)
|
||||
cr:close_path()
|
||||
cr.source = args.background_source
|
||||
|
@ -124,35 +133,40 @@ local function create_corner_top_left(args)
|
|||
cr:new_sub_path()
|
||||
cr:move_to(offset_x, height)
|
||||
cr:line_to(offset_x, arc_radius + offset_y)
|
||||
cr:arc(arc_radius + offset_x, arc_radius + offset_y, arc_radius, rad(180), rad(270))
|
||||
cr:arc(
|
||||
arc_radius + offset_x,
|
||||
arc_radius + offset_y,
|
||||
arc_radius,
|
||||
rad(180),
|
||||
rad(270)
|
||||
)
|
||||
cr.source = nargs.source
|
||||
cr.line_width = nargs.width
|
||||
cr.antialias = cairo.Antialias.BEST
|
||||
cr:stroke()
|
||||
end
|
||||
-- Outer dark stroke
|
||||
add_stroke({
|
||||
add_stroke {
|
||||
offset_x = args.stroke_offset_outer,
|
||||
offset_y = args.stroke_offset_outer,
|
||||
radius = radius + 0.5,
|
||||
source = args.stroke_source_outer,
|
||||
width = args.stroke_width_outer,
|
||||
})
|
||||
}
|
||||
-- Inner light stroke
|
||||
add_stroke({
|
||||
add_stroke {
|
||||
offset_x = args.stroke_offset_inner,
|
||||
offset_y = args.stroke_offset_inner,
|
||||
radius = radius,
|
||||
width = args.stroke_width_inner,
|
||||
source = args.stroke_source_inner,
|
||||
})
|
||||
}
|
||||
|
||||
return surface
|
||||
end
|
||||
|
||||
-- Draws the middle of the titlebar
|
||||
local function create_edge_top_middle(args)
|
||||
local client_color = args.color
|
||||
local height = args.height
|
||||
local width = args.width
|
||||
local surface = cairo.ImageSurface.create("ARGB32", width, height)
|
||||
|
@ -171,9 +185,17 @@ local function create_edge_top_middle(args)
|
|||
cr:stroke()
|
||||
end
|
||||
-- Inner light stroke
|
||||
add_stroke(args.stroke_width_inner, args.stroke_offset_inner, args.stroke_color_inner)
|
||||
add_stroke(
|
||||
args.stroke_width_inner,
|
||||
args.stroke_offset_inner,
|
||||
args.stroke_color_inner
|
||||
)
|
||||
-- Outer dark stroke
|
||||
add_stroke(args.stroke_width_outer, args.stroke_offset_outer, args.stroke_color_outer)
|
||||
add_stroke(
|
||||
args.stroke_width_outer,
|
||||
args.stroke_offset_outer,
|
||||
args.stroke_color_outer
|
||||
)
|
||||
|
||||
return surface
|
||||
end
|
||||
|
@ -207,7 +229,11 @@ end
|
|||
|
||||
local function set_font(cr, font)
|
||||
cr:set_font_size(font.size)
|
||||
cr:select_font_face(font.font or "Inter", font.italic and 1 or 0, font.bold and 1 or 0)
|
||||
cr:select_font_face(
|
||||
font.font or "Inter",
|
||||
font.italic and 1 or 0,
|
||||
font.bold and 1 or 0
|
||||
)
|
||||
end
|
||||
|
||||
local function text_label(args)
|
||||
|
@ -217,7 +243,11 @@ local function text_label(args)
|
|||
local text = args.text
|
||||
local kern = args.font.kerning or 0
|
||||
local ext = cr:text_extents(text)
|
||||
surface = cairo.ImageSurface.create("ARGB32", ext.width + string.len(text) * kern, ext.height)
|
||||
surface = cairo.ImageSurface.create(
|
||||
"ARGB32",
|
||||
ext.width + string.len(text) * kern,
|
||||
ext.height
|
||||
)
|
||||
cr = cairo.Context.create(surface)
|
||||
set_font(cr, args.font)
|
||||
cr:move_to(0, ext.height)
|
||||
|
|
22
table.lua
22
table.lua
|
@ -1,12 +1,17 @@
|
|||
--[[
|
||||
Courtesy of: http://lua-users.org/wiki/SaveTableToFile
|
||||
]] local function exportstring(s) return string.format("%q", s) end
|
||||
]]
|
||||
local function exportstring(s)
|
||||
return string.format("%q", s)
|
||||
end
|
||||
|
||||
-- The Save Function
|
||||
local function save(tbl, filename)
|
||||
local charS, charE = " ", "\n"
|
||||
local file, err = io.open(filename, "wb")
|
||||
if err then return err end
|
||||
if err then
|
||||
return err
|
||||
end
|
||||
|
||||
-- Initialize variables for save procedure
|
||||
local tables, lookup = { tbl }, { [tbl] = 1 }
|
||||
|
@ -36,8 +41,7 @@ local function save(tbl, filename)
|
|||
|
||||
for i, v in pairs(t) do
|
||||
-- escape handled values
|
||||
if (not thandled[i]) then
|
||||
|
||||
if not thandled[i] then
|
||||
local str = ""
|
||||
local stype = type(i)
|
||||
-- handle index
|
||||
|
@ -72,19 +76,23 @@ local function save(tbl, filename)
|
|||
end
|
||||
file:write("}," .. charE)
|
||||
end
|
||||
file:write("}")
|
||||
file:write "}"
|
||||
file:close()
|
||||
end
|
||||
|
||||
-- The Load Function
|
||||
local function load(sfile)
|
||||
local ftables, err = loadfile(sfile)
|
||||
if err then return _, err end
|
||||
if err then
|
||||
return nil, err
|
||||
end
|
||||
local tables = ftables()
|
||||
for idx = 1, #tables do
|
||||
local tolinki = {}
|
||||
for i, v in pairs(tables[idx]) do
|
||||
if type(v) == "table" then tables[idx][i] = tables[v[1]] end
|
||||
if type(v) == "table" then
|
||||
tables[idx][i] = tables[v[1]]
|
||||
end
|
||||
if type(i) == "table" and tables[i[1]] then
|
||||
table.insert(tolinki, { i, tables[i[1]] })
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue