Compare commits
No commits in common. "079bef1e528ea324534b34a368aa779a1a2ebf43" and "0f0e56174d8668b60e248504ec7343bc22fcbfba" have entirely different histories.
079bef1e52
...
0f0e56174d
|
@ -4,7 +4,7 @@ local function make(tagger)
|
|||
-- Create tag tagindicators
|
||||
-- We're using flex.vertical and flex.horizontal layouts because the grid
|
||||
-- layout doesn't expand things properly.
|
||||
widget.tagindicators = {} -- NOTE THE `s`, THIS IS A DIFFERENT VARIABLE
|
||||
widget.tagindicators = {}
|
||||
widget.tagindicator = wibox.widget {
|
||||
homogeneous = true,
|
||||
spacing = beautiful.dpi(2),
|
||||
|
|
|
@ -1,20 +1,52 @@
|
|||
local backlight = req_rel(..., "util")
|
||||
local widget = {}
|
||||
local dotgrid = require("widgets.dotgrid")
|
||||
|
||||
widget.dots = dotgrid:new();
|
||||
widget.dots.on_color = {0.18, 0.88, 1}
|
||||
widget.dots.off_color = {0.1, 0.44, 0.5}
|
||||
widget.dots.spacing = beautiful.dpi(2)
|
||||
|
||||
widget.icon = wibox.widget {
|
||||
id = "icon",
|
||||
image = beautiful.icons.brightness.i,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox,
|
||||
}
|
||||
|
||||
widget.arc = wibox.widget {
|
||||
{
|
||||
widget.icon,
|
||||
top = beautiful.dpi(1),
|
||||
bottom = beautiful.dpi(1),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
max_value = 100,
|
||||
thickness = beautiful.dpi(4),
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
--forced_height = beautiful.dpi(16),
|
||||
--forced_width = beautiful.dpi(16),
|
||||
colors = {"#27D4CC", "#00446B"},
|
||||
bg = "#FFFFFF30",
|
||||
paddings = beautiful.dpi(2),
|
||||
widget = wibox.container.arcchart
|
||||
}
|
||||
|
||||
|
||||
widget.widget = wibox.widget {
|
||||
{
|
||||
widget.dots,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
left = beautiful.dpi(2),
|
||||
right = beautiful.dpi(2),
|
||||
layout = wibox.container.margin,
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{ -- Main indicator. Can be replaced with widget.arc
|
||||
widget.arc,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
{ -- Left space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
@ -45,8 +77,18 @@ widget.widget:connect_signal("button::press",
|
|||
|
||||
awesome.connect_signal("module::backlight:update",
|
||||
function(value)
|
||||
widget.dots.value = value
|
||||
widget.dots:emit_signal("widget::redraw_needed")
|
||||
widget.arc.value = value
|
||||
|
||||
if value >= 90 then widget.icon.image = beautiful.icons.brightness.i
|
||||
elseif value >= 80 then widget.icon.image = beautiful.icons.brightness.h
|
||||
elseif value >= 70 then widget.icon.image = beautiful.icons.brightness.g
|
||||
elseif value >= 60 then widget.icon.image = beautiful.icons.brightness.f
|
||||
elseif value >= 50 then widget.icon.image = beautiful.icons.brightness.e
|
||||
elseif value >= 40 then widget.icon.image = beautiful.icons.brightness.d
|
||||
elseif value >= 30 then widget.icon.image = beautiful.icons.brightness.c
|
||||
elseif value >= 20 then widget.icon.image = beautiful.icons.brightness.b
|
||||
elseif value <= 10 then widget.icon.image = beautiful.icons.brightness.a end
|
||||
|
||||
end
|
||||
)
|
||||
|
||||
|
|
|
@ -1,133 +0,0 @@
|
|||
local volume = req_rel(..., "util")
|
||||
local widget = {}
|
||||
|
||||
|
||||
widget.icon = wibox.widget {
|
||||
resize = true,
|
||||
image = beautiful.icons.volume.mute,
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
widget.arc = wibox.widget {
|
||||
{
|
||||
widget.icon,
|
||||
top = beautiful.dpi(1),
|
||||
bottom = beautiful.dpi(1),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
max_value = 1,
|
||||
thickness = beautiful.dpi(4),
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
--forced_height = beautiful.dpi(16),
|
||||
--forced_width = beautiful.dpi(16),
|
||||
colors = {"#27D4CC", "#00446B"},
|
||||
bg = "#FFFFFF30",
|
||||
paddings = beautiful.dpi(2),
|
||||
rounded_edge = true,
|
||||
widget = wibox.container.arcchart
|
||||
}
|
||||
|
||||
widget.bar = wibox.widget {
|
||||
max_value = 100,
|
||||
value = 0,
|
||||
--forced_height = 20,
|
||||
forced_width = beautiful.dpi(50),
|
||||
paddings = 0,
|
||||
border_width = 0,
|
||||
color = {
|
||||
type = "linear",
|
||||
from = {0, 0}, to = {beautiful.dpi(50), 0},
|
||||
stops = { { 0, "#27D4CC" }, { 1, "#00446B" }}
|
||||
},
|
||||
background_color = "#FFFFFF30",
|
||||
widget = wibox.widget.progressbar,
|
||||
shape = gears.shape.rounded_bar,
|
||||
}
|
||||
|
||||
|
||||
widget.widget = wibox.widget {
|
||||
{
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{
|
||||
widget.arc,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
{ -- Left space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
||||
widget.widget:connect_signal("mouse::enter", function(result)
|
||||
widget.widget.bg = beautiful.color.bar.hover_bg
|
||||
awesome.emit_signal("module::volume:popup_show_stay")
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("mouse::leave", function(result)
|
||||
widget.widget.bg = beautiful.color.transparent
|
||||
awesome.emit_signal("module::volume:popup_show")
|
||||
end)
|
||||
|
||||
widget.widget:connect_signal("button::press",
|
||||
function(_, _, _, button, mods)
|
||||
|
||||
-- Left-click
|
||||
if (button == 1) then
|
||||
volume.toggle_mute()
|
||||
|
||||
-- Scroll up
|
||||
elseif (button == 4) then
|
||||
volume.volume_up(config.volume.scroll_step)
|
||||
|
||||
-- Scroll down
|
||||
elseif (button == 5) then
|
||||
volume.volume_down(config.volume.scroll_step)
|
||||
end
|
||||
awesome.emit_signal("module::volume:popup_show_stay")
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal("module::volume:update",
|
||||
function(status)
|
||||
if (status.value == false) then
|
||||
widget.icon.image = beautiful.icons.volume.error
|
||||
widget.arc.value = 100;
|
||||
widget.bar.value = 100;
|
||||
return
|
||||
end
|
||||
|
||||
widget.arc.value = status.value / 100;
|
||||
widget.bar.value = status.value;
|
||||
|
||||
|
||||
if (status.mute) then
|
||||
-- Set muted icon
|
||||
widget.icon.image = beautiful.icons.volume.mute
|
||||
else
|
||||
-- Set icon by value
|
||||
if status.value > 70 then
|
||||
widget.icon.image = beautiful.icons.volume.high
|
||||
elseif status.value > 40 then
|
||||
widget.icon.image = beautiful.icons.volume.medium
|
||||
elseif status.value > 0 then
|
||||
widget.icon.image = beautiful.icons.volume.low
|
||||
elseif status.value == 0 then
|
||||
widget.icon.image = beautiful.icons.volume.off
|
||||
end
|
||||
end
|
||||
|
||||
w.update();
|
||||
end
|
||||
)
|
||||
|
||||
return widget
|
|
@ -1,20 +1,69 @@
|
|||
local volume = req_rel(..., "util")
|
||||
local widget = {}
|
||||
local dotgrid = require("widgets.dotgrid")
|
||||
|
||||
widget.dots = dotgrid:new();
|
||||
widget.dots.on_color = {1, 0, 0}
|
||||
widget.dots.off_color = {0.5, 0, 0}
|
||||
widget.dots.spacing = beautiful.dpi(2)
|
||||
|
||||
widget.icon = wibox.widget {
|
||||
resize = true,
|
||||
image = beautiful.icons.volume.mute,
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
widget.arc = wibox.widget {
|
||||
{
|
||||
widget.icon,
|
||||
top = beautiful.dpi(1),
|
||||
bottom = beautiful.dpi(1),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
max_value = 1,
|
||||
thickness = beautiful.dpi(4),
|
||||
start_angle = 4.71238898, -- 2pi*3/4
|
||||
--forced_height = beautiful.dpi(16),
|
||||
--forced_width = beautiful.dpi(16),
|
||||
colors = {"#27D4CC", "#00446B"},
|
||||
bg = "#FFFFFF30",
|
||||
paddings = beautiful.dpi(2),
|
||||
rounded_edge = true,
|
||||
widget = wibox.container.arcchart
|
||||
}
|
||||
|
||||
widget.bar = wibox.widget {
|
||||
max_value = 100,
|
||||
value = 0,
|
||||
--forced_height = 20,
|
||||
forced_width = beautiful.dpi(50),
|
||||
paddings = 0,
|
||||
border_width = 0,
|
||||
color = {
|
||||
type = "linear",
|
||||
from = {0, 0}, to = {beautiful.dpi(50), 0},
|
||||
stops = { { 0, "#27D4CC" }, { 1, "#00446B" }}
|
||||
},
|
||||
background_color = "#FFFFFF30",
|
||||
widget = wibox.widget.progressbar,
|
||||
shape = gears.shape.rounded_bar,
|
||||
}
|
||||
|
||||
|
||||
widget.widget = wibox.widget {
|
||||
{
|
||||
widget.dots,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
left = beautiful.dpi(2),
|
||||
right = beautiful.dpi(2),
|
||||
layout = wibox.container.margin,
|
||||
{ -- Right space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
{
|
||||
widget.arc,
|
||||
top = beautiful.dpi(2),
|
||||
bottom = beautiful.dpi(2),
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
{ -- Left space
|
||||
widget = wibox.widget.separator,
|
||||
color = beautiful.color.transparent,
|
||||
forced_width = beautiful.dpi(3)
|
||||
},
|
||||
layout = wibox.layout.align.horizontal,
|
||||
},
|
||||
layout = wibox.container.background,
|
||||
}
|
||||
|
@ -51,21 +100,31 @@ widget.widget:connect_signal("button::press",
|
|||
awesome.connect_signal("module::volume:update",
|
||||
function(status)
|
||||
if (status.value == false) then
|
||||
widget.dots.value = 100
|
||||
widget.icon.image = beautiful.icons.volume.error
|
||||
widget.arc.value = 100;
|
||||
widget.bar.value = 100;
|
||||
return
|
||||
end
|
||||
|
||||
widget.dots.value = status.value
|
||||
widget.arc.value = status.value / 100;
|
||||
widget.bar.value = status.value;
|
||||
|
||||
|
||||
if (status.mute) then
|
||||
widget.dots.on_color = {0.7, 0.7, 0.7}
|
||||
widget.dots.off_color = {0.3, 0.3, 0.3}
|
||||
-- Set muted icon
|
||||
widget.icon.image = beautiful.icons.volume.mute
|
||||
else
|
||||
widget.dots.on_color = {0, 1, 0}
|
||||
widget.dots.off_color = {0, 0.5, 0}
|
||||
-- Set icon by value
|
||||
if status.value > 70 then
|
||||
widget.icon.image = beautiful.icons.volume.high
|
||||
elseif status.value > 40 then
|
||||
widget.icon.image = beautiful.icons.volume.medium
|
||||
elseif status.value > 0 then
|
||||
widget.icon.image = beautiful.icons.volume.low
|
||||
elseif status.value == 0 then
|
||||
widget.icon.image = beautiful.icons.volume.off
|
||||
end
|
||||
end
|
||||
|
||||
widget.dots:emit_signal("widget::redraw_needed")
|
||||
end
|
||||
)
|
||||
|
||||
|
|
|
@ -1,137 +0,0 @@
|
|||
local dotgrid = {}
|
||||
|
||||
function dotgrid:shuffle(tbl)
|
||||
for i = #tbl, 2, -1 do
|
||||
local j = math.random(i)
|
||||
tbl[i], tbl[j] = tbl[j], tbl[i]
|
||||
end
|
||||
return tbl
|
||||
end
|
||||
|
||||
function dotgrid:new()
|
||||
local dots = wibox.widget.base.make_widget();
|
||||
|
||||
dots.on_color = {1, 0, 0}
|
||||
dots.off_color = {0.5, 0, 0}
|
||||
dots.value = 0
|
||||
dots.max = 100
|
||||
dots.rows = 5
|
||||
dots.cols = 5
|
||||
dots.spacing = 2
|
||||
|
||||
dots.map = {}
|
||||
local idx
|
||||
for i=1, dots.rows*dots.cols do
|
||||
dots.map[i] = false;
|
||||
end
|
||||
--dots.map = dotgrid:shuffle(dots.map)
|
||||
|
||||
|
||||
function dots:fit(context, width, height)
|
||||
local m = math.min(width, height)
|
||||
return m, m
|
||||
end
|
||||
|
||||
function dots:draw(context, cr, width, height)
|
||||
local col_size = (height - self.spacing * (self.rows-1)) // self.rows
|
||||
local row_size = (width - self.spacing * (self.cols-1)) // self.cols
|
||||
|
||||
-- Compute rounding offsets for better centering
|
||||
local xoffset = (
|
||||
width - (
|
||||
(col_size * self.cols) +
|
||||
(self.spacing * (self.cols - 1))
|
||||
)
|
||||
) // 2
|
||||
|
||||
local yoffset = (
|
||||
height - (
|
||||
(row_size * self.rows) +
|
||||
(self.spacing * (self.rows - 1))
|
||||
)
|
||||
) // 2
|
||||
|
||||
-- How many dots should be on
|
||||
local on = math.floor((self.value / self.max) * (self.rows * self.cols))
|
||||
|
||||
-- How many dote are currently on
|
||||
local current_value = 0
|
||||
for i=1, dots.rows*dots.cols do
|
||||
if dots.map[i] then
|
||||
current_value = current_value + 1
|
||||
end
|
||||
end
|
||||
|
||||
local change, remove
|
||||
if current_value ~= on then
|
||||
change = on - current_value
|
||||
remove = change < 0
|
||||
change = math.abs(change)
|
||||
|
||||
local flip
|
||||
for i=1, change do
|
||||
if remove then
|
||||
-- Flip the nth on dot
|
||||
flip = math.random(1, current_value)
|
||||
for i=1, dots.rows*dots.cols do
|
||||
if dots.map[i] then
|
||||
if flip == 1 then
|
||||
dots.map[i] = false
|
||||
break
|
||||
else
|
||||
flip = flip - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
current_value = current_value - 1
|
||||
else
|
||||
-- Flip the nth off dot
|
||||
flip = math.random(1, dots.rows*dots.cols - current_value)
|
||||
for i=1, dots.rows*dots.cols do
|
||||
if not dots.map[i] then
|
||||
if flip == 1 then
|
||||
dots.map[i] = true
|
||||
break
|
||||
else
|
||||
flip = flip - 1
|
||||
end
|
||||
end
|
||||
end
|
||||
current_value = current_value + 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
for r=1, self.rows do
|
||||
for c=1, self.cols do
|
||||
idx = c + ((r-1)*self.cols)
|
||||
|
||||
--idx_mapped = self.map[idx] - 1
|
||||
--r_mapped = (idx_mapped % self.rows) + 1
|
||||
--c_mapped = (idx_mapped // self.cols) + 1
|
||||
|
||||
cr:new_path();
|
||||
if self.map[idx] then
|
||||
cr:set_source_rgb(self.on_color[1], self.on_color[2], self.on_color[3])
|
||||
else
|
||||
cr:set_source_rgb(self.off_color[1], self.off_color[2], self.off_color[3])
|
||||
end
|
||||
|
||||
cr:rectangle(
|
||||
(c-1) * (col_size + self.spacing) + xoffset,
|
||||
(r-1) * (row_size + self.spacing) + yoffset,
|
||||
col_size,
|
||||
row_size
|
||||
)
|
||||
cr:fill()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
return dots
|
||||
end
|
||||
|
||||
return dotgrid
|
Loading…
Reference in New Issue