From 510ef8e178929cf5e0c7fd5a5120fecf5f1b79f2 Mon Sep 17 00:00:00 2001 From: delta Date: Tue, 5 Mar 2024 14:48:59 +0100 Subject: idk anymore --- .../awesome/ui/statusbar/panel/widgets/battery.lua | 70 ++++++++ .../ui/statusbar/panel/widgets/calendar.lua | 155 +++++++++++++++++ .../ui/statusbar/panel/widgets/displays.lua | 36 ++-- .../ui/statusbar/panel/widgets/imagebox.lua | 144 +++++++++------- .../ui/statusbar/panel/widgets/linegraph.lua | 154 ----------------- .../awesome/ui/statusbar/panel/widgets/music.lua | 187 ++++++--------------- .../ui/statusbar/panel/widgets/power_menu.lua | 36 ++-- .../awesome/ui/statusbar/panel/widgets/wifi.lua | 18 +- 8 files changed, 405 insertions(+), 395 deletions(-) create mode 100644 .config/awesome/ui/statusbar/panel/widgets/battery.lua delete mode 100644 .config/awesome/ui/statusbar/panel/widgets/linegraph.lua (limited to '.config/awesome/ui/statusbar/panel/widgets') diff --git a/.config/awesome/ui/statusbar/panel/widgets/battery.lua b/.config/awesome/ui/statusbar/panel/widgets/battery.lua new file mode 100644 index 0000000..52685b7 --- /dev/null +++ b/.config/awesome/ui/statusbar/panel/widgets/battery.lua @@ -0,0 +1,70 @@ +local gears = require "gears" +local lit = require "lib.lit" +local qbezier = require "quarrel.bezier" +local qui = require "quarrel.ui" +local wibox = require "wibox" + +local widget = wibox.widget { + widget = wibox.container.constraint, + height = 120, + width = 120, + strategy = "exact", + { + widget = lit.widget.linechart, + -- max_value = 30, + -- step_width = 10, + -- scale = true, + -- stack = false, + -- forced_height = 30, + -- step_hook = curvaceous + -- values = { 1, 10, 100 }, + fill = true, + fill_color = "#00ff00", + -- fill_border = true, + fill_border_color = "#ff0000", + draw_bg = function(cr, width, _, min, max, transform) + cr:set_line_width(1) + local min_abs = math.abs(min) + local dash_pattern = { 6, 4 } + local rendered_zero, zero_overlap = false, false + for i = 0, 4 do + local temp = ((min_abs + max) * (i / 4)) - min_abs + rendered_zero = rendered_zero or temp == 0 + if rendered_zero and not zero_overlap and min < 0 then + cr:set_source_rgba(gears.color.parse_color "#0000ff") + zero_overlap = true + else + cr:set_dash(dash_pattern, 1, 0) + cr:set_source_rgba(gears.color.parse_color "#ff0000ff") + end + local y = transform(temp) + cr:move_to(0, y) + cr:line_to(width, y) + cr:stroke() + cr:set_dash({}, 0, 0) + end + + if not rendered_zero then + cr:set_source_rgba(gears.color.parse_color "#0000ff") + local h_0 = transform(0) + cr:move_to(0, h_0) + cr:line_to(width, h_0) + cr:stroke() + end + end, + }, +} + +-- for _ = 1, 100 do +-- widget.widget:add_value(math.random(0, 30)) +-- end + +-- require "gears.timer" { +-- autostart = true, +-- timeout = 0.2, +-- callback = function () +-- widget.widget:add_value(math.random(0, 30)) +-- end +-- } + +return widget diff --git a/.config/awesome/ui/statusbar/panel/widgets/calendar.lua b/.config/awesome/ui/statusbar/panel/widgets/calendar.lua index 8b13789..8933543 100644 --- a/.config/awesome/ui/statusbar/panel/widgets/calendar.lua +++ b/.config/awesome/ui/statusbar/panel/widgets/calendar.lua @@ -1 +1,156 @@ +local awful = require "awful" +local phosphor = require "assets.phosphor" +local qbind = require "quarrel.bind" +local qmarkup = require "quarrel.markup" +local qui = require "quarrel.ui" +local qvars = require "quarrel.vars" +local wibox = require "wibox" +local weekday_map = { 7, 1, 2, 3, 4, 5, 6 } + +local calendar = wibox.widget(qui.styled { + widget = wibox.container.background, + { + widget = wibox.container.margin, + margins = qvars.big_padding, + { + { + { + widget = wibox.container.place, + qui.icon { + icon = phosphor.caret_left_bold, + }, + }, + { + widget = wibox.container.place, + { + widget = wibox.widget.textbox, + text = "January 2024", + }, + }, + { + widget = wibox.container.place, + qui.icon { + icon = phosphor.caret_right_bold, + }, + }, + layout = wibox.layout.align.horizontal, + expand = "outside", + }, + { + layout = wibox.layout.grid, + forced_num_rows = 7, + forced_num_cols = 7, + spacing = qvars.padding, + id = "grid", + }, + layout = wibox.layout.fixed.vertical, + spacing = qvars.big_padding, + }, + }, +}) + +-- Logic heavily inspired by https://github.com/Sinomor/dotfiles/blob/e409f9a84bf40daf1e39c0179ec749232ed827c9/home/.config/awesome/ui/control/moment/calendar.lua#L134-L173 +function calendar:compute_grid(year, month) + local calendar_table = { {}, {}, {}, {}, {}, {} } + local current = os.date("*t", os.time()) + local first_day = os.date("*t", os.time { year = year, month = month, day = 1 }) + local last_day = os.date("*t", os.time { year = year, month = month + 1, day = 0 }) + + local days = last_day.day + + local prev_days = os.date("*t", os.time { year = year, month = month, day = 0 }) + local prev_offset = weekday_map[first_day.wday] - 1 + local prev_month = month - 1 == -1 and 12 or month - 1 + local prev_year = prev_month == 12 and year - 1 or year + + if prev_offset ~= -1 then + for offset = prev_offset, 1, -1 do + local day = prev_days.day - offset + 1 + table.insert( + calendar_table[1], + { day, day == current.day and prev_month == current.month and prev_year == current.year, false } + ) + end + end + + do + local row = 1 + local weekday = weekday_map[first_day.wday] + for day = 1, days do + table.insert( + calendar_table[row], + { day, day == current.day and month == current.month and year == current.year, true } + ) + if weekday == 7 then + row = row + 1 + weekday = 1 + else + weekday = weekday + 1 + end + end + + local next_month = month + 1 == 13 and 1 or month + 1 + local next_year = next_month == 1 and year + 1 or year + for day = 1, 42 - prev_offset - days do + table.insert( + calendar_table[row], + { day, day == current.day and next_month + 1 == current.month and next_year == current.year, false } + ) + if weekday == 7 then + row = row + 1 + weekday = 1 + else + weekday = weekday + 1 + end + end + end + + for i, row in ipairs(calendar_table) do + for j, col in ipairs(row) do + local widget = self:get_children_by_id("grid")[1]:get_widgets_at(i + 1, j)[1] + widget.widget.widget.text = col[1] + if col[2] then + widget.bg = qvars.colors.yellow + widget.fg = qvars.colors.bg + else + widget.bg = qvars.colors.bg + widget.fg = col[3] and qvars.colors.fg or qvars.colors.dim.fg + end + end + end +end + +local cells = {} +local function cell(content) + local widget = wibox.widget { + widget = wibox.container.background, + shape = qvars.shape, + { + widget = wibox.container.place, + forced_height = qvars.char_height * 1.5, + forced_width = qvars.char_height * 1.5, + { + widget = wibox.widget.textbox, + markup = content, + }, + }, + } + table.insert(cells, widget) +end + +cell "Mo" +cell "Tu" +cell "We" +cell "Th" +cell "Fr" +cell(qmarkup("Sa", { bold = true })) +cell(qmarkup("Su", { bold = true })) + +for _ = 1, 42 do + cell() +end +calendar:get_children_by_id("grid")[1]:add(table.unpack(cells)) +calendar:compute_grid(2024, 1) + +return calendar diff --git a/.config/awesome/ui/statusbar/panel/widgets/displays.lua b/.config/awesome/ui/statusbar/panel/widgets/displays.lua index de15bd5..b52c986 100644 --- a/.config/awesome/ui/statusbar/panel/widgets/displays.lua +++ b/.config/awesome/ui/statusbar/panel/widgets/displays.lua @@ -1,3 +1,5 @@ +local backlight = require "services.backlight" +local battery = require "services.battery" local phosphor = require "assets.phosphor" local qmath = require "quarrel.math" local qui = require "quarrel.ui" @@ -23,23 +25,29 @@ local function create_display(icon, color) forced_width = qvars.element_size * 4, { widget = wibox.container.place, - qui.icon(icon, color, { id = "icon" }) + qui.icon { + icon = icon, + color = color, + widget = { + id = "icon", + }, + }, }, - id = "indicator" + id = "indicator", }, { widget = wibox.container.place, { widget = wibox.widget.textbox, text = "0%", - id = "text" - } + id = "text", + }, }, layout = wibox.layout.fixed.vertical, - spacing = qvars.big_padding - } - } - } + spacing = qvars.big_padding, + }, + }, + }, }) end @@ -58,23 +66,23 @@ awesome.connect_signal("services::audio::icon", function(icon, color) end) local d_battery = create_display(phosphor.battery_vertical_warning_fill, qvars.colors.red) -awesome.connect_signal("services::battery", function(capacity) - d_battery:get_children_by_id("indicator")[1].value = capacity - d_battery:get_children_by_id("text")[1].text = capacity .. "%" +battery:connect_signal("level", function(_, level) + d_battery:get_children_by_id("indicator")[1].value = level + d_battery:get_children_by_id("text")[1].text = level .. "%" end) -awesome.connect_signal("services::battery::icon", function(icon, color) +battery:connect_signal("icon", function(_, icon, color) d_battery:get_children_by_id("indicator")[1].color = color d_battery:get_children_by_id("icon")[1].image = icon d_battery:get_children_by_id("icon")[1].stylesheet = qui.recolor(color) end) local d_brightness = create_display(phosphor.sun_fill, qvars.colors.fg) -awesome.connect_signal("services::brightness", function(brightness) +backlight:connect_signal("value", function(_, brightness) brightness = math.floor(qmath.translate_range(brightness, 0, 255, 0, 100)) d_brightness:get_children_by_id("indicator")[1].value = brightness d_brightness:get_children_by_id("text")[1].text = brightness .. "%" end) -awesome.connect_signal("services::brightness::icon", function(icon, color) +backlight:connect_signal("icon", function(_, icon, color) d_brightness:get_children_by_id("icon")[1].image = icon d_brightness:get_children_by_id("icon")[1].stylesheet = qui.recolor(color) end) diff --git a/.config/awesome/ui/statusbar/panel/widgets/imagebox.lua b/.config/awesome/ui/statusbar/panel/widgets/imagebox.lua index 8c6e8a5..5caadc5 100644 --- a/.config/awesome/ui/statusbar/panel/widgets/imagebox.lua +++ b/.config/awesome/ui/statusbar/panel/widgets/imagebox.lua @@ -24,13 +24,13 @@ -- @supermodule wibox.widget.base --------------------------------------------------------------------------- -local lgi = require("lgi") +local lgi = require "lgi" local cairo = lgi.cairo -local base = require("wibox.widget.base") -local surface = require("gears.surface") -local gtable = require("gears.table") -local gdebug = require("gears.debug") +local base = require "wibox.widget.base" +local gdebug = require "gears.debug" +local gtable = require "gears.table" +local surface = require "gears.surface" local setmetatable = setmetatable local type = type local math = math @@ -40,7 +40,9 @@ local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility -- Safe load for optional Rsvg module local Rsvg = nil do - local success, err = pcall(function() Rsvg = lgi.Rsvg end) + local success, err = pcall(function() + Rsvg = lgi.Rsvg + end) if not success then gdebug.print_warning(debug.traceback("Could not load Rsvg: " .. tostring(err))) end @@ -48,14 +50,16 @@ end local imagebox = { mt = {} } -local rsvg_handle_cache = setmetatable({}, { __mode = 'k' }) +local rsvg_handle_cache = setmetatable({}, { __mode = "k" }) ---Load rsvg handle form image file -- @tparam string file Path to svg file. -- @return Rsvg handle -- @treturn table A table where cached data can be stored. local function load_rsvg_handle(file) - if not Rsvg then return end + if not Rsvg then + return + end local cache = (rsvg_handle_cache[file] or {})["handle"] @@ -65,7 +69,7 @@ local function load_rsvg_handle(file) local handle, err - if file:match("<[?]?xml") or file:match(" 0 and surf.height > 0 - if not is_surf_valid then return false end + if not is_surf_valid then + return false + end ib._private.default = { width = surf.width, height = surf.height } ib._private.handle = nil @@ -93,7 +99,9 @@ end local function set_handle(ib, handle, cache) local dim = handle:get_dimensions() local is_handle_valid = dim.width > 0 and dim.height > 0 - if not is_handle_valid then return false end + if not is_handle_valid then + return false + end ib._private.default = { width = dim.width, height = dim.height } ib._private.handle = handle @@ -124,18 +132,15 @@ end -- It's necessary because a single RSVG handle can be used by -- many imageboxes. So DPI and Stylesheet need to be set each time. local function update_dpi(self, ctx) - if not self._private.handle then return end + if not self._private.handle then + return + end - local dpi = self._private.auto_dpi and - ctx.dpi or - self._private.dpi or - nil + local dpi = self._private.auto_dpi and ctx.dpi or self._private.dpi or nil - local need_dpi = dpi and - self._private.last_dpi ~= dpi + local need_dpi = dpi and self._private.last_dpi ~= dpi - local need_style = self._private.handle.set_stylesheet and - self._private.stylesheet + local need_style = self._private.handle.set_stylesheet and self._private.stylesheet local old_size = self._private.default and self._private.default.width @@ -163,14 +168,16 @@ local function update_dpi(self, ctx) -- This can happen in the constructor when `dpi` is set after `image`. if old_size and old_size ~= self._private.default.width then - self:emit_signal("widget::redraw_needed") - self:emit_signal("widget::layout_changed") + self:emit_signal "widget::redraw_needed" + self:emit_signal "widget::layout_changed" end end -- Draw an imagebox with the given cairo context in the given geometry. function imagebox:draw(ctx, cr, width, height) - if width == 0 or height == 0 or not self._private.default then return end + if width == 0 or height == 0 or not self._private.default then + return + end -- For valign = "top" and halign = "left" local translate = { @@ -186,15 +193,15 @@ function imagebox:draw(ctx, cr, width, height) -- That's for the "fit" policy. local aspects = { w = width / w, - h = height / h + h = height / h, } local policy = { w = self._private.horizontal_fit_policy or "auto", - h = self._private.vertical_fit_policy or "auto" + h = self._private.vertical_fit_policy or "auto", } - for _, aspect in ipairs {"w", "h"} do + for _, aspect in ipairs { "w", "h" } do if self._private.upscale == false and (w < width and h < height) then aspects[aspect] = 1 elseif self._private.downscale == false and (w >= width and h >= height) then @@ -209,15 +216,15 @@ function imagebox:draw(ctx, cr, width, height) end if self._private.halign == "center" then - translate.x = math.floor((width - w*aspects.w)/2) + translate.x = math.floor((width - w * aspects.w) / 2) elseif self._private.halign == "right" then - translate.x = math.floor(width - (w*aspects.w)) + translate.x = math.floor(width - (w * aspects.w)) end if self._private.valign == "center" then - translate.y = math.floor((height - h*aspects.h)/2) + translate.y = math.floor((height - h * aspects.h) / 2) elseif self._private.valign == "bottom" then - translate.y = math.floor(height - (h*aspects.h)) + translate.y = math.floor(height - (h * aspects.h)) end cr:translate(translate.x, translate.y) @@ -226,25 +233,25 @@ function imagebox:draw(ctx, cr, width, height) local threshold, max_factor = self._private.max_scaling_factor, math.max(aspects.w, aspects.h) if threshold and threshold > 0 and threshold < max_factor then - aspects.w = (aspects.w*threshold)/max_factor - aspects.h = (aspects.h*threshold)/max_factor + aspects.w = (aspects.w * threshold) / max_factor + aspects.h = (aspects.h * threshold) / max_factor end -- Set the clip if self._private.clip_shape then - cr:clip(self._private.clip_shape(cr, w*aspects.w, h*aspects.h, unpack(self._private.clip_args))) + cr:clip(self._private.clip_shape(cr, w * aspects.w, h * aspects.h, unpack(self._private.clip_args))) end cr:scale(aspects.w, aspects.h) else if self._private.halign == "center" then - translate.x = math.floor((width - w)/2) + translate.x = math.floor((width - w) / 2) elseif self._private.halign == "right" then translate.x = math.floor(width - w) end if self._private.valign == "center" then - translate.y = math.floor((height - h)/2) + translate.y = math.floor((height - h) / 2) elseif self._private.valign == "bottom" then translate.y = math.floor(height - h) end @@ -274,7 +281,9 @@ end -- Fit the imagebox into the given geometry function imagebox:fit(ctx, width, height) - if not self._private.default then return 0, 0 end + if not self._private.default then + return 0, 0 + end update_dpi(self, ctx) @@ -349,11 +358,13 @@ function imagebox:set_image(image) self._private.default = nil end - if not setup_succeed then return false end + if not setup_succeed then + return false + end - self:emit_signal("widget::redraw_needed") - self:emit_signal("widget::layout_changed") - self:emit_signal("property::image") + self:emit_signal "widget::redraw_needed" + self:emit_signal "widget::layout_changed" + self:emit_signal "property::image" return true end @@ -383,8 +394,8 @@ end -- @see clip_shape function imagebox:set_clip_shape(clip_shape, ...) self._private.clip_shape = clip_shape - self._private.clip_args = {...} - self:emit_signal("widget::redraw_needed") + self._private.clip_args = { ... } + self:emit_signal "widget::redraw_needed" self:emit_signal("property::clip_shape", clip_shape) end @@ -468,14 +479,14 @@ end -- @propemits true false -- @see dpi -for _, prop in ipairs {"stylesheet", "dpi", "auto_dpi"} do +for _, prop in ipairs { "stylesheet", "dpi", "auto_dpi" } do imagebox["set_" .. prop] = function(self, value) -- It will be set in :fit and :draw. The handle is shared -- by multiple imagebox, so it cannot be set just once. self._private[prop] = value - self:emit_signal("widget::redraw_needed") - self:emit_signal("widget::layout_changed") + self:emit_signal "widget::redraw_needed" + self:emit_signal "widget::layout_changed" self:emit_signal("property::" .. prop) end end @@ -490,12 +501,12 @@ function imagebox:set_resize(allowed) self:emit_signal("property::upscale", allowed) end - self:emit_signal("widget::redraw_needed") - self:emit_signal("widget::layout_changed") + self:emit_signal "widget::redraw_needed" + self:emit_signal "widget::layout_changed" self:emit_signal("property::resize", allowed) end -for _, prop in ipairs {"downscale", "upscale" } do +for _, prop in ipairs { "downscale", "upscale" } do imagebox["set_" .. prop] = function(self, allowed) self._private[prop] = allowed @@ -504,9 +515,9 @@ for _, prop in ipairs {"downscale", "upscale" } do self:emit_signal("property::resize", self._private.resize) end - self:emit_signal("widget::redraw_needed") - self:emit_signal("widget::layout_changed") - self:emit_signal("property::"..prop, allowed) + self:emit_signal "widget::redraw_needed" + self:emit_signal "widget::layout_changed" + self:emit_signal("property::" .. prop, allowed) end end @@ -542,7 +553,6 @@ end -- @see horizontal_fit_policy -- @see resize - --- The vertical alignment. -- -- @DOC_wibox_widget_imagebox_valign_EXAMPLE@ @@ -627,30 +637,34 @@ end -- @see max_scaling_factor local defaults = { - halign = "left", - valign = "top", + halign = "left", + valign = "top", horizontal_fit_policy = "auto", - vertical_fit_policy = "auto", - max_scaling_factor = 0, - scaling_quality = "good" + vertical_fit_policy = "auto", + max_scaling_factor = 0, + scaling_quality = "good", } local function get_default(prop, value) - if value == nil then return defaults[prop] end + if value == nil then + return defaults[prop] + end return value end for prop in pairs(defaults) do - imagebox["set_"..prop] = function(self, value) - if value == self._private[prop] then return end + imagebox["set_" .. prop] = function(self, value) + if value == self._private[prop] then + return + end self._private[prop] = get_default(prop, value) - self:emit_signal("widget::redraw_needed") - self:emit_signal("property::"..prop, self._private[prop]) + self:emit_signal "widget::redraw_needed" + self:emit_signal("property::" .. prop, self._private[prop]) end - imagebox["get_"..prop] = function(self) + imagebox["get_" .. prop] = function(self) if self._private[prop] == nil then return defaults[prop] end @@ -678,7 +692,7 @@ end -- @treturn wibox.widget.imagebox A new `wibox.widget.imagebox` widget instance. -- @constructorfct wibox.widget.imagebox local function new(image, resize_allowed, clip_shape, ...) - local ret = base.make_widget(nil, nil, {enable_properties = true}) + local ret = base.make_widget(nil, nil, { enable_properties = true }) gtable.crush(ret, imagebox, true) ret._private.resize = true @@ -692,7 +706,7 @@ local function new(image, resize_allowed, clip_shape, ...) end ret._private.clip_shape = clip_shape - ret._private.clip_args = {...} + ret._private.clip_args = { ... } return ret end diff --git a/.config/awesome/ui/statusbar/panel/widgets/linegraph.lua b/.config/awesome/ui/statusbar/panel/widgets/linegraph.lua deleted file mode 100644 index 9a42632..0000000 --- a/.config/awesome/ui/statusbar/panel/widgets/linegraph.lua +++ /dev/null @@ -1,154 +0,0 @@ -local gcolor = require "gears.color" -local gtable = require "gears.table" -local wibox = require "wibox" - -local linegraph = { mt = {} } - -function linegraph:fit(_, width, height) - if #self._private.values < 2 then - return 0, 0 - end - return width, height -end - -function linegraph:draw(_, cr, width, height) - if #self._private.values < 2 then - return - end - local line_width = self._private.line_width - local values = self._private.values - - local max, min = self._private.max or 0, self._private.min or 0 - if not (self._private.max and self._private.min) then - for _, value in ipairs(values) do - if not self._private.max then - max = max < value and value or max - end - if not self._private.min then - min = min > value and value or min - end - end - end - - local usable_height = height - line_width - local min_abs = math.abs(min) - local h_factor = usable_height / (min_abs + max) - - local function transform(value) - return usable_height - math.floor((value + min_abs) * h_factor) + line_width / 2 - end - - local graph_values = {} - for i = 1, #values, math.ceil(#values / width) do - table.insert(graph_values, transform(values[i])) - end - - if self._private.draw_bg then - cr:save() - self._private.draw_bg(cr, width, height, min, max, transform) - cr:restore() - end - - cr:set_line_width(line_width) - cr:set_source(gcolor(self.color)) - cr:move_to(line_width / 2, graph_values[1]) - for i = 2, #graph_values do - cr:line_to((width - line_width / 2) / (#graph_values - 1) * (i - 1), graph_values[i]) - end - - if self._private.fill then - cr:line_to(width - line_width / 2, transform(min)) - cr:line_to(line_width / 2, transform(min)) - cr:line_to(line_width / 2, graph_values[1]) - cr:stroke_preserve() - cr:set_source(gcolor(self.fill_color)) - cr:fill() - else - cr:stroke() - end -end - -function linegraph:set_values(values) - self._private.values = values - self:emit_signal "widget::redraw_needed" -end - -function linegraph:get_values() - return self._private.values -end - -function linegraph:set_draw_bg(draw_bg) - self._private.draw_bg = draw_bg - self:emit_signal "widget::redraw_needed" -end - -function linegraph:get_draw_bg() - return self._private.draw_bg -end - -function linegraph:set_max(max) - self._private.max = max - self:emit_signal "widget::redraw_needed" -end - -function linegraph:get_max() - return self._private.max -end - -function linegraph:set_min(min) - self._private.max = min - self:emit_signal "widget::redraw_needed" -end - -function linegraph:get_min() - return self._private.min -end - -function linegraph:set_line_width(line_width) - self._private.line_width = line_width - self:emit_signal "widget::redraw_needed" -end - -function linegraph:set_color(color) - self._private.color = color - self:emit_signal "widget::redraw_needed" -end - -function linegraph:get_color() - return self._private.color -end - -function linegraph:set_fill_color(fill_color) - self._private.fill_color = fill_color - self:emit_signal "widget::redraw_needed" -end - -function linegraph:get_fill_color() - return self._private.fill_color -end - -function linegraph:set_fill(fill) - self._private.fill = fill - self:emit_signal "widget::redraw_needed" -end - -function linegraph:get_fill() - return self._private.fill -end - -local function new() - local ret = wibox.widget.base.make_widget(nil, nil, { enable_properties = true }) - gtable.crush(ret, linegraph, true) - - ret.line_width = 1 - ret.color = "#ffffff" - ret.fill_color = "#000000" - - return ret -end - -function linegraph.mt:__call() - return new() -end - -return setmetatable(linegraph, linegraph.mt) diff --git a/.config/awesome/ui/statusbar/panel/widgets/music.lua b/.config/awesome/ui/statusbar/panel/widgets/music.lua index 3eedb55..eea7335 100644 --- a/.config/awesome/ui/statusbar/panel/widgets/music.lua +++ b/.config/awesome/ui/statusbar/panel/widgets/music.lua @@ -1,28 +1,10 @@ -local cairo = require "lgi".cairo -local gcolor = require "gears.color" -local gsurface = require "gears.surface" -local imagebox = require "ui.statusbar.panel.widgets.imagebox" -local phosphor = require "assets.phosphor" -local playerctl = require "services.playerctl" local qnative = require "quarrel.native" local qui = require "quarrel.ui" local qvars = require "quarrel.vars" local wibox = require "wibox" -local default_cover = phosphor.vinyl_record_fill local default_text = "Nothing playing" -local function faded_cover(cover) - local surface = gsurface(cover) - local w,h = gsurface.get_size(surface) - local cr = cairo.Context(surface) - local pattern = gcolor(qvars.colors.bg .. "aa") - cr:rectangle(0, 0, w, h) - cr:set_source(pattern) - cr:fill_preserve() - return surface -end - local w_title = wibox.widget { widget = wibox.widget.textbox, text = "Nothing playing", @@ -33,20 +15,8 @@ local w_artist = wibox.widget { fg = qvars.colors.dim.fg, { widget = wibox.widget.textbox, - text = "" - } -} - -local w_cover = wibox.widget { - widget = imagebox, - image = default_cover, - stylesheet = qui.recolor(qvars.colors.bright.black), - forced_height = qvars.char_height * 6 + qvars.big_padding * 2, - forced_width = qvars.expanded_bar_size - qvars.big_padding, - horizontal_fit_policy = "cover", - vertical_fit_policy = "cover", - valign = "center", - halign = "center" + text = "", + }, } local w_progress_bar = wibox.widget { @@ -54,99 +24,21 @@ local w_progress_bar = wibox.widget { max_value = 0, value = 0, forced_height = qvars.char_height / 2, - forced_width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2) - (qvars.char_height / 1.25 + qvars.padding) * 3, + forced_width = qvars.expanded_bar_size + - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2) + - (qvars.char_height / 1.25 + qvars.padding) * 3, color = qvars.colors.yellow, background_color = qvars.colors.black, shape = qvars.shape, } -local w_play_pause = qui.toggle { - widget = { - forced_height = qvars.char_height / 1.25, - forced_width = qvars.char_height / 1.25 - }, - off = phosphor.play_fill, - on = phosphor.pause_fill, - manual = true, - press = function() - playerctl:play_pause() - end -} - -local w_skip_forward = qui.button { - widget = { - forced_height = qvars.char_height / 1.25, - forced_width = qvars.char_height / 1.25 - }, - image = phosphor.skip_forward_fill, - press = function() - playerctl:next() - end -} - -local w_skip_back = qui.button { - widget = { - forced_height = qvars.char_height / 1.25, - forced_width = qvars.char_height / 1.25 - }, - image = phosphor.skip_back_fill, - press = function() - playerctl:previous() - end -} - local music = wibox.widget(qui.styled { widget = wibox.container.background, { + widget = wibox.container.margin, + margins = qvars.big_padding, { - widget = wibox.container.background, - bg = qvars.colors.black - }, - w_cover, - { - widget = wibox.container.margin, - margins = qvars.big_padding, { - { - { - widget = wibox.container.background, - bg = qvars.colors.bg, - shape = qvars.shape, - { - widget = wibox.container.margin, - margins = qvars.padding, - { - { - widget = wibox.container.constraint, - width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2), - height = qvars.char_height, - { - widget = wibox.container.scroll.horizontal, - speed = 50, - step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, - w_title - } - }, - { - widget = wibox.container.constraint, - width = qvars.expanded_bar_size - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2), - height = qvars.char_height, - { - widget = wibox.container.scroll.horizontal, - speed = 50, - step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, - w_artist - } - }, - layout = wibox.layout.fixed.vertical - } - } - }, - nil, - nil, - layout = wibox.layout.align.horizontal - }, - nil, { widget = wibox.container.background, bg = qvars.colors.bg, @@ -155,29 +47,53 @@ local music = wibox.widget(qui.styled { widget = wibox.container.margin, margins = qvars.padding, { - w_play_pause, - w_skip_back, { - widget = wibox.container.place, - w_progress_bar + widget = wibox.container.constraint, + width = qvars.expanded_bar_size + - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2), + height = qvars.char_height, + { + widget = wibox.container.scroll.horizontal, + speed = 50, + step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, + w_title, + }, }, - w_skip_forward, - layout = wibox.layout.fixed.horizontal, - spacing = qvars.padding - } - } + { + widget = wibox.container.constraint, + width = qvars.expanded_bar_size + - (qvars.big_padding + qvars.big_padding * 2 + qvars.padding * 2), + height = qvars.char_height, + { + widget = wibox.container.scroll.horizontal, + speed = 50, + step_function = wibox.container.scroll.step_functions.waiting_nonlinear_back_and_forth, + w_artist, + }, + }, + layout = wibox.layout.fixed.vertical, + }, + }, }, - layout = wibox.layout.align.vertical - } + nil, + nil, + layout = wibox.layout.align.horizontal, + }, + nil, + { + widget = wibox.container.background, + bg = qvars.colors.bg, + shape = qvars.shape, + w_progress_bar, + }, + layout = wibox.layout.align.vertical, }, - layout = wibox.layout.stack - } + }, }) awesome.connect_signal("services::playerctl::metadata", function(title, artist, album_path) - w_title.text = title ~= "" and qnative.decode_html(title) or default_text - w_artist.widget.text = qnative.decode_html(artist) - w_cover.image = faded_cover(album_path) + w_title.text = title ~= "" and qnative.util.decode_html(title) or default_text + w_artist.widget.text = qnative.util.decode_html(artist) end) awesome.connect_signal("services::playerctl::position", function(position, length) @@ -186,15 +102,10 @@ awesome.connect_signal("services::playerctl::position", function(position, lengt end) awesome.connect_signal("services::playerctl::no_players", function() - w_title = default_text - w_artist = "" - w_cover.image = default_cover + w_title.text = default_text + w_artist.text = "" w_progress_bar.value = 0 w_progress_bar.max_value = 0 end) -awesome.connect_signal("services::playerctl::playback_status", function(playing) - w_play_pause:silent_press(playing) -end) - return music diff --git a/.config/awesome/ui/statusbar/panel/widgets/power_menu.lua b/.config/awesome/ui/statusbar/panel/widgets/power_menu.lua index cf0de28..feea829 100644 --- a/.config/awesome/ui/statusbar/panel/widgets/power_menu.lua +++ b/.config/awesome/ui/statusbar/panel/widgets/power_menu.lua @@ -4,7 +4,7 @@ local qui = require "quarrel.ui" local qvars = require "quarrel.vars" local wibox = require "wibox" -local power_menu = wibox.widget { +return wibox.widget { qui.styled { widget = wibox.container.background, bg = qvars.colors.black, @@ -15,12 +15,12 @@ local power_menu = wibox.widget { qbind:new { triggers = qvars.btns.left, press = function() - q.debug("from 1") + q.debug "from 1" end, - hidden = true - } - } - } + hidden = true, + }, + }, + }, }, qui.styled { widget = wibox.container.background, @@ -32,12 +32,12 @@ local power_menu = wibox.widget { qbind:new { triggers = qvars.btns.left, press = function() - q.debug("from 2") + q.debug "from 2" end, - hidden = true - } - } - } + hidden = true, + }, + }, + }, }, qui.styled { widget = wibox.container.background, @@ -49,14 +49,12 @@ local power_menu = wibox.widget { qbind:new { triggers = qvars.btns.left, press = function() - q.debug("from 3") + q.debug "from 3" end, - hidden = true - } - } - } + hidden = true, + }, + }, + }, }, - layout = wibox.layout.flex.horizontal + layout = wibox.layout.flex.horizontal, } - -return power_menu diff --git a/.config/awesome/ui/statusbar/panel/widgets/wifi.lua b/.config/awesome/ui/statusbar/panel/widgets/wifi.lua index 579474e..ad2234f 100644 --- a/.config/awesome/ui/statusbar/panel/widgets/wifi.lua +++ b/.config/awesome/ui/statusbar/panel/widgets/wifi.lua @@ -1,7 +1,9 @@ +local lgi = require "lgi" local phosphor = require "assets.phosphor" local qui = require "quarrel.ui" local qvars = require "quarrel.vars" local wibox = require "wibox" +local glib = lgi.GLib local wifi = wibox.widget(qui.styled { widget = wibox.container.background, @@ -13,17 +15,23 @@ local wifi = wibox.widget(qui.styled { widget = wibox.container.place, valign = "center", halign = "center", - qui.icon(phosphor.wifi_x_fill, qvars.colors.red, { id = "icon" }) + qui.icon { + icon = phosphor.wifi_x_fill, + color = qvars.colors.red, + widget = { + id = "icon", + }, + }, }, { widget = wibox.widget.textbox, text = "Disconnected", - id = "essid" + id = "essid", }, layout = wibox.layout.fixed.horizontal, - spacing = qvars.padding - } - } + spacing = qvars.padding, + }, + }, }) awesome.connect_signal("services::wifi", function(essid, _, connected) -- cgit v1.2.3