diff options
author | delta <darkussdelta@gmail.com> | 2024-03-05 14:48:59 +0100 |
---|---|---|
committer | delta <darkussdelta@gmail.com> | 2024-03-05 14:48:59 +0100 |
commit | 510ef8e178929cf5e0c7fd5a5120fecf5f1b79f2 (patch) | |
tree | 3582e5cd7d000335ca94f2a009f3aed57bd86919 /.config/awesome/ui/statusbar | |
parent | 95ba8030f722a616cff06c122dcfb2f63e25cf45 (diff) |
idk anymore
Diffstat (limited to '.config/awesome/ui/statusbar')
-rw-r--r-- | .config/awesome/ui/statusbar/init.lua | 75 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/init.lua | 20 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/widgets/battery.lua | 70 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/widgets/calendar.lua | 155 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/widgets/displays.lua | 36 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/widgets/imagebox.lua | 144 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/widgets/linegraph.lua | 154 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/widgets/music.lua | 187 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/widgets/power_menu.lua | 36 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/panel/widgets/wifi.lua | 18 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/clock.lua | 8 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/displays.lua | 34 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/keyboardlayout.lua | 307 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/taglist.lua | 127 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/tasklist.lua | 30 |
15 files changed, 720 insertions, 681 deletions
diff --git a/.config/awesome/ui/statusbar/init.lua b/.config/awesome/ui/statusbar/init.lua index d4f2001..77a28f7 100644 --- a/.config/awesome/ui/statusbar/init.lua +++ b/.config/awesome/ui/statusbar/init.lua @@ -1,9 +1,8 @@ local awful = require "awful" local beautiful = require "beautiful" -local gcolor = require "gears.color" local panel = require "ui.statusbar.panel" local phosphor = require "assets.phosphor" -local qbind = require "quarrel.bind" +local qstore = require "quarrel.store" local qui = require "quarrel.ui" local qvars = require "quarrel.vars" local rubato = require "lib.rubato" @@ -13,38 +12,26 @@ local clock = require "ui.statusbar.widgets.clock" local displays = require "ui.statusbar.widgets.displays" local keyboardlayout = require "ui.statusbar.widgets.keyboardlayout" local taglist = require "ui.statusbar.widgets.taglist" +local tasklist = require "ui.statusbar.widgets.tasklist" screen.connect_signal("request::desktop_decoration", function(s) - local expand_button = wibox.widget { - widget = wibox.container.place, - valign = "center", - halign = "center", - { - widget = wibox.widget.imagebox, - image = gcolor.recolor_image(phosphor.caret_right_fill, qvars.colors.fg), - forced_width = qvars.char_height, - forced_height = qvars.char_height - }, - _expanded = false - } - local bar = qui.popup { placement = function(d) - local place = awful.placement.left - return place(d, { - margins = beautiful.useless_gap * 2 + return awful.placement.left(d, { + margins = beautiful.useless_gap * 2, }) end, minimum_height = s.geometry.height - (beautiful.useless_gap * 4 + qvars.border_width * 2), widget = { { { - expand_button, - taglist, + taglist(s), layout = wibox.layout.fixed.vertical, spacing = qvars.padding * 2, + id = "top", }, nil, + -- tasklist(s), { widget = wibox.container.place, valign = "bottom", @@ -55,11 +42,16 @@ screen.connect_signal("request::desktop_decoration", function(s) displays.wifi, { widget = wibox.container.place, - keyboardlayout + { + widget = wibox.container.constraint, + height = qvars.char_height, + width = qvars.char_height, + keyboardlayout, + }, }, clock, layout = wibox.layout.fixed.vertical, - spacing = qvars.padding * 2 + spacing = qvars.padding * 2, }, }, layout = wibox.layout.align.vertical, @@ -74,23 +66,24 @@ screen.connect_signal("request::desktop_decoration", function(s) local bar_width = bar.width + qvars.border_width * 2 bar:struts { - left = bar_width + beautiful.useless_gap * 4 + left = bar_width + beautiful.useless_gap * 4, } local panel_width + local panel_toggle = { toggled = false } -- hacky but it works local timed = rubato.timed { duration = qvars.anim_duration, intro = qvars.anim_intro, pos = bar_width, subscribed = function(pos) - if pos ~= bar_width and expand_button._expanded then + if pos ~= bar_width and panel_toggle.toggled then bar.widget.widget.third = panel if panel_width == nil then panel_width = bar.widget.widget.third.width end bar.ontop = true - elseif pos == bar_width and not expand_button._expanded then + elseif pos == bar_width and not panel_toggle.toggled then bar.widget.widget.third = nil bar.ontop = false end @@ -98,25 +91,21 @@ screen.connect_signal("request::desktop_decoration", function(s) bar.shape = function(cr, _, h) qvars.shape(cr, pos, h) end - end + end, } - expand_button.buttons = { - qbind:new { - triggers = qvars.btns.left, - press = function() - if expand_button._expanded then - timed.target = bar_width - else - timed.target = bar_width + qvars.expanded_bar_size - -- timed.target = bar_width + qvars.big_padding + (qvars.big_padding * 2 + qvars.element_size * 4) * 3 + qvars.padding * 2 - end - - -- q.debug(tostring(panel_width)) - expand_button._expanded = not expand_button._expanded - end, - hidden = true - } + panel_toggle = qui.toggle { + off = phosphor.arrows_out_simple_fill, + on = phosphor.arrows_in_simple_fill, + press = function(self) + if not self.toggled then + timed.target = bar_width + else + timed.target = bar_width + qvars.expanded_bar_size + end + end, } - + + bar.widget:get_children_by_id("top")[1]:insert(1, panel_toggle) + qstore.panel_toggle = panel_toggle end) diff --git a/.config/awesome/ui/statusbar/panel/init.lua b/.config/awesome/ui/statusbar/panel/init.lua index 7685451..31c2860 100644 --- a/.config/awesome/ui/statusbar/panel/init.lua +++ b/.config/awesome/ui/statusbar/panel/init.lua @@ -1,6 +1,8 @@ local qvars = require "quarrel.vars" local wibox = require "wibox" +local battery = require "ui.statusbar.panel.widgets.battery" +local calendar = require "ui.statusbar.panel.widgets.calendar" local displays = require "ui.statusbar.panel.widgets.displays" local music = require "ui.statusbar.panel.widgets.music" local power_menu = require "ui.statusbar.panel.widgets.power_menu" @@ -9,7 +11,7 @@ local wifi = require "ui.statusbar.panel.widgets.wifi" local panel = wibox.widget { widget = wibox.container.margin, margins = { - left = qvars.big_padding + left = qvars.big_padding, }, { { @@ -24,25 +26,27 @@ local panel = wibox.widget { spacing = qvars.padding, }, wifi, - music, + -- battery, + -- music, + calendar, layout = wibox.layout.fixed.vertical, - spacing = qvars.padding - } + spacing = qvars.padding, + }, }, { widget = wibox.container.background, { widget = wibox.widget.textbox, - text = ":)" - } + text = ":)", + }, }, { widget = wibox.container.place, valign = "bottom", - power_menu + power_menu, }, layout = wibox.layout.align.vertical, - } + }, } return panel 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("<svg") then + if file:match "<[?]?xml" or file:match "<svg" then handle, err = Rsvg.Handle.new_from_data(file) else handle, err = Rsvg.Handle.new_from_file(file) @@ -81,7 +85,9 @@ end ---Apply cairo surface for given imagebox widget local function set_surface(ib, surf) local is_surf_valid = surf.width > 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,100 +24,22 @@ 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, shape = qvars.shape, @@ -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) diff --git a/.config/awesome/ui/statusbar/widgets/clock.lua b/.config/awesome/ui/statusbar/widgets/clock.lua index ff57a36..c186dc5 100644 --- a/.config/awesome/ui/statusbar/widgets/clock.lua +++ b/.config/awesome/ui/statusbar/widgets/clock.lua @@ -1,13 +1,11 @@ local qvars = require "quarrel.vars" local wibox = require "wibox" -local clock = wibox.widget { +return wibox.widget { widget = wibox.container.place, { format = "%H\n%M", widget = wibox.widget.textclock, - font = qvars.font - } + font = qvars.font, + }, } - -return clock diff --git a/.config/awesome/ui/statusbar/widgets/displays.lua b/.config/awesome/ui/statusbar/widgets/displays.lua index 44ff2c6..62e4398 100644 --- a/.config/awesome/ui/statusbar/widgets/displays.lua +++ b/.config/awesome/ui/statusbar/widgets/displays.lua @@ -1,3 +1,4 @@ +local battery = require "services.battery" local phosphor = require "assets.phosphor" local qui = require "quarrel.ui" local qvars = require "quarrel.vars" @@ -8,32 +9,35 @@ local function create_display(icon, color) widget = wibox.container.place, valign = "center", halign = "center", - qui.icon(icon, color) + qui.icon { + icon = icon, + color = color, + }, } end -local battery = create_display(phosphor.battery_vertical_warning_fill, qvars.colors.red) -awesome.connect_signal("services::battery::icon", function(icon, color) - battery.widget.image = icon - battery.widget.stylesheet = qui.recolor(color) +local d_battery = create_display(phosphor.battery_vertical_warning_fill, qvars.colors.red) +battery:connect_signal("icon", function(_, icon, color) + d_battery.widget.image = icon + d_battery.widget.stylesheet = qui.recolor(color) end) -local brightness = create_display(phosphor.moon_fill, qvars.colors.fg) +local d_brightness = create_display(phosphor.moon_fill, qvars.colors.fg) awesome.connect_signal("services::brightness::icon", function(icon, color) - brightness.widget.image = icon - brightness.widget.stylesheet = qui.recolor(color) + d_brightness.widget.image = icon + d_brightness.widget.stylesheet = qui.recolor(color) end) -local audio = create_display(phosphor.speaker_simple_slash_fill, qvars.colors.red) +local d_audio = create_display(phosphor.speaker_simple_slash_fill, qvars.colors.red) awesome.connect_signal("services::audio::icon", function(icon, color) - audio.widget.image = icon - audio.widget.stylesheet = qui.recolor(color) + d_audio.widget.image = icon + d_audio.widget.stylesheet = qui.recolor(color) end) -local wifi = create_display(phosphor.wifi_x_fill, qvars.colors.red) +local d_wifi = create_display(phosphor.wifi_x_fill, qvars.colors.red) awesome.connect_signal("services::wifi::icon", function(icon, color) - wifi.widget.image = icon - wifi.widget.stylesheet = qui.recolor(color) + d_wifi.widget.image = icon + d_wifi.widget.stylesheet = qui.recolor(color) end) -return { audio = audio, battery = battery, brightness = brightness, wifi = wifi } +return { audio = d_audio, battery = d_battery, brightness = d_brightness, wifi = d_wifi } diff --git a/.config/awesome/ui/statusbar/widgets/keyboardlayout.lua b/.config/awesome/ui/statusbar/widgets/keyboardlayout.lua index 0bbbf14..d9302ff 100644 --- a/.config/awesome/ui/statusbar/widgets/keyboardlayout.lua +++ b/.config/awesome/ui/statusbar/widgets/keyboardlayout.lua @@ -10,12 +10,12 @@ -- @supermodule wibox.widget.base --------------------------------------------------------------------------- -local capi = {awesome = awesome} +local capi = { awesome = awesome } local setmetatable = setmetatable -local textbox = require("wibox.widget.textbox") -local button = require("awful.button") -local widget_base = require("wibox.widget.base") -local gdebug = require("gears.debug") +local button = require "awful.button" +local gdebug = require "gears.debug" +local textbox = require "wibox.widget.textbox" +local widget_base = require "wibox.widget.base" --- Keyboard Layout widget. -- awful.widget.keyboardlayout @@ -24,109 +24,109 @@ local keyboardlayout = { mt = {} } -- As to the country-code-like symbols below, refer to the names of XKB's -- data files in /.../xkb/symbols/*. keyboardlayout.xkeyboard_country_code = { - ["ad"] = true, -- Andorra - ["af"] = true, -- Afganistan - ["al"] = true, -- Albania - ["am"] = true, -- Armenia - ["ara"] = true, -- Arabic - ["at"] = true, -- Austria - ["az"] = true, -- Azerbaijan - ["ba"] = true, -- Bosnia and Herzegovina - ["bd"] = true, -- Bangladesh - ["be"] = true, -- Belgium - ["bg"] = true, -- Bulgaria - ["br"] = true, -- Brazil - ["bt"] = true, -- Bhutan - ["bw"] = true, -- Botswana - ["by"] = true, -- Belarus - ["ca"] = true, -- Canada - ["cd"] = true, -- Congo - ["ch"] = true, -- Switzerland - ["cm"] = true, -- Cameroon - ["cn"] = true, -- China - ["cz"] = true, -- Czechia - ["de"] = true, -- Germany - ["dk"] = true, -- Denmark - ["ee"] = true, -- Estonia - ["epo"] = true, -- Esperanto - ["es"] = true, -- Spain - ["et"] = true, -- Ethiopia - ["eu"] = true, -- EurKey - ["fi"] = true, -- Finland - ["fo"] = true, -- Faroe Islands - ["fr"] = true, -- France - ["gb"] = true, -- United Kingdom - ["ge"] = true, -- Georgia - ["gh"] = true, -- Ghana - ["gn"] = true, -- Guinea - ["gr"] = true, -- Greece - ["hr"] = true, -- Croatia - ["hu"] = true, -- Hungary - ["ie"] = true, -- Ireland - ["il"] = true, -- Israel - ["in"] = true, -- India - ["iq"] = true, -- Iraq - ["ir"] = true, -- Iran - ["is"] = true, -- Iceland - ["it"] = true, -- Italy - ["jp"] = true, -- Japan - ["ke"] = true, -- Kenya - ["kg"] = true, -- Kyrgyzstan - ["kh"] = true, -- Cambodia - ["kr"] = true, -- Korea - ["kz"] = true, -- Kazakhstan - ["la"] = true, -- Laos + ["ad"] = true, -- Andorra + ["af"] = true, -- Afganistan + ["al"] = true, -- Albania + ["am"] = true, -- Armenia + ["ara"] = true, -- Arabic + ["at"] = true, -- Austria + ["az"] = true, -- Azerbaijan + ["ba"] = true, -- Bosnia and Herzegovina + ["bd"] = true, -- Bangladesh + ["be"] = true, -- Belgium + ["bg"] = true, -- Bulgaria + ["br"] = true, -- Brazil + ["bt"] = true, -- Bhutan + ["bw"] = true, -- Botswana + ["by"] = true, -- Belarus + ["ca"] = true, -- Canada + ["cd"] = true, -- Congo + ["ch"] = true, -- Switzerland + ["cm"] = true, -- Cameroon + ["cn"] = true, -- China + ["cz"] = true, -- Czechia + ["de"] = true, -- Germany + ["dk"] = true, -- Denmark + ["ee"] = true, -- Estonia + ["epo"] = true, -- Esperanto + ["es"] = true, -- Spain + ["et"] = true, -- Ethiopia + ["eu"] = true, -- EurKey + ["fi"] = true, -- Finland + ["fo"] = true, -- Faroe Islands + ["fr"] = true, -- France + ["gb"] = true, -- United Kingdom + ["ge"] = true, -- Georgia + ["gh"] = true, -- Ghana + ["gn"] = true, -- Guinea + ["gr"] = true, -- Greece + ["hr"] = true, -- Croatia + ["hu"] = true, -- Hungary + ["ie"] = true, -- Ireland + ["il"] = true, -- Israel + ["in"] = true, -- India + ["iq"] = true, -- Iraq + ["ir"] = true, -- Iran + ["is"] = true, -- Iceland + ["it"] = true, -- Italy + ["jp"] = true, -- Japan + ["ke"] = true, -- Kenya + ["kg"] = true, -- Kyrgyzstan + ["kh"] = true, -- Cambodia + ["kr"] = true, -- Korea + ["kz"] = true, -- Kazakhstan + ["la"] = true, -- Laos ["latam"] = true, -- Latin America ["latin"] = true, -- Latin - ["lk"] = true, -- Sri Lanka - ["lt"] = true, -- Lithuania - ["lv"] = true, -- Latvia - ["ma"] = true, -- Morocco - ["mao"] = true, -- Maori - ["me"] = true, -- Montenegro - ["mk"] = true, -- Macedonia - ["ml"] = true, -- Mali - ["mm"] = true, -- Myanmar - ["mn"] = true, -- Mongolia - ["mt"] = true, -- Malta - ["mv"] = true, -- Maldives - ["ng"] = true, -- Nigeria - ["nl"] = true, -- Netherlands - ["no"] = true, -- Norway - ["np"] = true, -- Nepal - ["ph"] = true, -- Philippines - ["pk"] = true, -- Pakistan - ["pl"] = true, -- Poland - ["pt"] = true, -- Portugal - ["ro"] = true, -- Romania - ["rs"] = true, -- Serbia - ["ru"] = true, -- Russia - ["se"] = true, -- Sweden - ["si"] = true, -- Slovenia - ["sk"] = true, -- Slovakia - ["sn"] = true, -- Senegal - ["sy"] = true, -- Syria - ["th"] = true, -- Thailand - ["tj"] = true, -- Tajikistan - ["tm"] = true, -- Turkmenistan - ["tr"] = true, -- Turkey - ["tw"] = true, -- Taiwan - ["tz"] = true, -- Tanzania - ["ua"] = true, -- Ukraine - ["us"] = true, -- USA - ["uz"] = true, -- Uzbekistan - ["vn"] = true, -- Vietnam - ["za"] = true, -- South Africa + ["lk"] = true, -- Sri Lanka + ["lt"] = true, -- Lithuania + ["lv"] = true, -- Latvia + ["ma"] = true, -- Morocco + ["mao"] = true, -- Maori + ["me"] = true, -- Montenegro + ["mk"] = true, -- Macedonia + ["ml"] = true, -- Mali + ["mm"] = true, -- Myanmar + ["mn"] = true, -- Mongolia + ["mt"] = true, -- Malta + ["mv"] = true, -- Maldives + ["ng"] = true, -- Nigeria + ["nl"] = true, -- Netherlands + ["no"] = true, -- Norway + ["np"] = true, -- Nepal + ["ph"] = true, -- Philippines + ["pk"] = true, -- Pakistan + ["pl"] = true, -- Poland + ["pt"] = true, -- Portugal + ["ro"] = true, -- Romania + ["rs"] = true, -- Serbia + ["ru"] = true, -- Russia + ["se"] = true, -- Sweden + ["si"] = true, -- Slovenia + ["sk"] = true, -- Slovakia + ["sn"] = true, -- Senegal + ["sy"] = true, -- Syria + ["th"] = true, -- Thailand + ["tj"] = true, -- Tajikistan + ["tm"] = true, -- Turkmenistan + ["tr"] = true, -- Turkey + ["tw"] = true, -- Taiwan + ["tz"] = true, -- Tanzania + ["ua"] = true, -- Ukraine + ["us"] = true, -- USA + ["uz"] = true, -- Uzbekistan + ["vn"] = true, -- Vietnam + ["za"] = true, -- South Africa } -- Callback for updating current layout. -local function update_status (self) +local function update_status(self) self._current = awesome.xkb_get_layout_group() local text = "" if #self._layout > 0 then -- Please note that the group number reported by xkb_get_layout_group -- is lower by one than the group numbers reported by xkb_get_group_names. - local name = self._layout[self._current+1] + local name = self._layout[self._current + 1] if name then text = name end @@ -155,53 +155,45 @@ function keyboardlayout.get_groups_from_group_names(group_names) -- pattern. local pattern_and_callback_pairs = { -- vendor/file(section):group_idx - ["^" .. word_pat .. "/" .. word_pat .. sec_pat .. idx_pat .. "$"] - = function(token, pattern) - local vendor, file, section, group_idx = string.match(token, pattern) - return vendor, file, section, group_idx - end, + ["^" .. word_pat .. "/" .. word_pat .. sec_pat .. idx_pat .. "$"] = function(token, pattern) + local vendor, file, section, group_idx = string.match(token, pattern) + return vendor, file, section, group_idx + end, -- vendor/file(section) - ["^" .. word_pat .. "/" .. word_pat .. sec_pat .. "$"] - = function(token, pattern) - local vendor, file, section = string.match(token, pattern) - return vendor, file, section, 1 - end, + ["^" .. word_pat .. "/" .. word_pat .. sec_pat .. "$"] = function(token, pattern) + local vendor, file, section = string.match(token, pattern) + return vendor, file, section, 1 + end, -- vendor/file:group_idx - ["^" .. word_pat .. "/" .. word_pat .. idx_pat .. "$"] - = function(token, pattern) - local vendor, file, group_idx = string.match(token, pattern) - return vendor, file, nil, group_idx - end, + ["^" .. word_pat .. "/" .. word_pat .. idx_pat .. "$"] = function(token, pattern) + local vendor, file, group_idx = string.match(token, pattern) + return vendor, file, nil, group_idx + end, -- vendor/file - ["^" .. word_pat .. "/" .. word_pat .. "$"] - = function(token, pattern) - local vendor, file = string.match(token, pattern) - return vendor, file, nil, 1 - end, + ["^" .. word_pat .. "/" .. word_pat .. "$"] = function(token, pattern) + local vendor, file = string.match(token, pattern) + return vendor, file, nil, 1 + end, -- file(section):group_idx - ["^" .. word_pat .. sec_pat .. idx_pat .. "$"] - = function(token, pattern) - local file, section, group_idx = string.match(token, pattern) - return nil, file, section, group_idx - end, + ["^" .. word_pat .. sec_pat .. idx_pat .. "$"] = function(token, pattern) + local file, section, group_idx = string.match(token, pattern) + return nil, file, section, group_idx + end, -- file(section) - ["^" .. word_pat .. sec_pat .. "$"] - = function(token, pattern) - local file, section = string.match(token, pattern) - return nil, file, section, 1 - end, + ["^" .. word_pat .. sec_pat .. "$"] = function(token, pattern) + local file, section = string.match(token, pattern) + return nil, file, section, 1 + end, -- file:group_idx - ["^" .. word_pat .. idx_pat .. "$"] - = function(token, pattern) - local file, group_idx = string.match(token, pattern) - return nil, file, nil, group_idx - end, + ["^" .. word_pat .. idx_pat .. "$"] = function(token, pattern) + local file, group_idx = string.match(token, pattern) + return nil, file, nil, group_idx + end, -- file - ["^" .. word_pat .. "$"] - = function(token, pattern) - local file = string.match(token, pattern) - return nil, file, nil, 1 - end + ["^" .. word_pat .. "$"] = function(token, pattern) + local file = string.match(token, pattern) + return nil, file, nil, 1 + end, } -- Split 'group_names' into 'tokens'. The separator is "+". @@ -229,10 +221,10 @@ function keyboardlayout.get_groups_from_group_names(group_names) section = string.gsub(section, "%(([%w-_]+)%)", "%1") end - table.insert(layout_groups, { vendor = vendor, - file = file, - section = section, - group_idx = tonumber(group_idx) }) + table.insert( + layout_groups, + { vendor = vendor, file = file, section = section, group_idx = tonumber(group_idx) } + ) break end end @@ -243,10 +235,10 @@ end -- Callback for updating list of layouts local function update_layout(self) - self._layout = {}; + self._layout = {} local layouts = keyboardlayout.get_groups_from_group_names(awesome.xkb_get_group_names()) if layouts == nil or layouts[1] == nil then - gdebug.print_error("Failed to get list of keyboard groups") + gdebug.print_error "Failed to get list of keyboard groups" return end if #layouts == 1 then @@ -270,7 +262,7 @@ end -- @treturn awful.widget.keyboardlayout A keyboard layout widget. function keyboardlayout.new() local widget = textbox() - local self = widget_base.make_widget(widget, nil, {enable_properties=true}) + local self = widget_base.make_widget(widget, nil, { enable_properties = true }) self.widget = widget @@ -288,30 +280,31 @@ function keyboardlayout.new() self.set_layout = function(group_number) if (0 > group_number) or (group_number > #self._layout) then - error("Invalid group number: " .. group_number .. - "expected number from 0 to " .. #self._layout) - return; + error("Invalid group number: " .. group_number .. "expected number from 0 to " .. #self._layout) + return end - awesome.xkb_set_layout_group(group_number); + awesome.xkb_set_layout_group(group_number) end - update_layout(self); + update_layout(self) -- callback for processing layout changes - capi.awesome.connect_signal("xkb::map_changed", - function () update_layout(self) end) - capi.awesome.connect_signal("xkb::group_changed", - function () update_status(self) end); + capi.awesome.connect_signal("xkb::map_changed", function() + update_layout(self) + end) + capi.awesome.connect_signal("xkb::group_changed", function() + update_status(self) + end) -- Mouse bindings self.buttons = { - button({ }, 1, self.next_layout) + button({}, 1, self.next_layout), } return self end -local _instance = nil; +local _instance = nil function keyboardlayout.mt:__call(...) if _instance == nil then @@ -320,8 +313,6 @@ function keyboardlayout.mt:__call(...) return _instance end - return setmetatable(keyboardlayout, keyboardlayout.mt) -- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 - diff --git a/.config/awesome/ui/statusbar/widgets/taglist.lua b/.config/awesome/ui/statusbar/widgets/taglist.lua index 1072426..df114df 100644 --- a/.config/awesome/ui/statusbar/widgets/taglist.lua +++ b/.config/awesome/ui/statusbar/widgets/taglist.lua @@ -1,75 +1,88 @@ local awful = require "awful" -local gcolor = require "gears.color" -local gdebug = require "gears.debug" local phosphor = require "assets.phosphor" local qbind = require "quarrel.bind" local qui = require "quarrel.ui" local qvars = require "quarrel.vars" local wibox = require "wibox" -return awful.widget.taglist { - screen = screen[1], - filter = awful.widget.taglist.filter.all, - layout = { - spacing = qvars.padding, - layout = wibox.layout.fixed.vertical - }, - widget_template = { - widget = wibox.container.place, - valign = "center", - halign = "center", - create_callback = function(self, tag) - self.widget = qui.icon(tag.icon) - - self:connect_signal("mouse::enter", function() - if tag.selected then return end - self.widget.stylesheet = qui.recolor(qvars.colors.yellow) - end) +return function(s) + return awful.widget.taglist { + screen = s, + filter = awful.widget.taglist.filter.all, + layout = { + spacing = qvars.padding, + layout = wibox.layout.fixed.vertical, + }, + widget_template = { + widget = wibox.container.place, + valign = "center", + halign = "center", + create_callback = function(self, tag) + self.widget = qui.icon { + icon = phosphor[next(tag:clients()) and "circle_fill" or "circle_bold"], + widget = { + forced_height = qvars.char_height / 1.5, + forced_width = qvars.char_height / 1.5, + }, + } + -- self.widget = wibox.widget { + -- + -- } - self:connect_signal("mouse::leave", function() - if tag.selected then return end - self.widget.stylesheet = qui.recolor(qvars.colors.fg) - end) + self:connect_signal("mouse::enter", function() + if tag.selected then + return + end + self.widget.stylesheet = qui.recolor(qvars.colors.yellow) + end) - if tag.selected then - self.widget.stylesheet = qui.recolor(qvars.colors.yellow) - return - end + self:connect_signal("mouse::leave", function() + if tag.selected then + return + end + self.widget.stylesheet = qui.recolor(qvars.colors.fg) + end) - self.widget.stylesheet = qui.recolor(qvars.colors.fg) - end, - update_callback = function(self, tag) - -- self.widget.icon = phosphor[next(tag:clients()) and "circle_fill" or "circle_bold"] + if tag.selected then + self.widget.stylesheet = qui.recolor(qvars.colors.yellow) + return + end - if tag.selected then - self.widget.stylesheet = qui.recolor(qvars.colors.yellow) - else self.widget.stylesheet = qui.recolor(qvars.colors.fg) - end - end - }, - buttons = { - qbind:new { - triggers = qvars.btns.left, - press = function(t) - t:view_only() end, - hidden = true - }, - qbind:new { - mods = qvars.mods.M, - triggers = qvars.btns.left, - press = function(t) - if client.focus then - client.focus:move_to_tag(t) + update_callback = function(self, tag) + self.widget.image = phosphor[next(tag:clients()) and "circle_fill" or "circle_bold"] + + if tag.selected then + self.widget.stylesheet = qui.recolor(qvars.colors.yellow) + else + self.widget.stylesheet = qui.recolor(qvars.colors.fg) end end, - hidden = true }, - qbind:new { - triggers = qvars.btns.right, - press = awful.tag.viewtoggle, - hidden = true + buttons = { + qbind:new { + triggers = qvars.btns.left, + press = function(t) + t:view_only() + end, + hidden = true, + }, + qbind:new { + mods = qvars.mods.M, + triggers = qvars.btns.left, + press = function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end, + hidden = true, + }, + qbind:new { + triggers = qvars.btns.right, + press = awful.tag.viewtoggle, + hidden = true, + }, }, } -} +end diff --git a/.config/awesome/ui/statusbar/widgets/tasklist.lua b/.config/awesome/ui/statusbar/widgets/tasklist.lua new file mode 100644 index 0000000..9656185 --- /dev/null +++ b/.config/awesome/ui/statusbar/widgets/tasklist.lua @@ -0,0 +1,30 @@ +local awful = require "awful" +local gears = require "gears" +local qvars = require "quarrel.vars" +local wibox = require "wibox" + +return function(s) + return awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + -- buttons = tasklist_buttons, + layout = { + spacing = qvars.padding, + layout = wibox.layout.flex.vertical, + }, + widget_template = { + widget = wibox.container.place, + valign = "center", + halign = "center", + -- { + -- widget = awful.widget.clienticon, + + -- } + { + widget = awful.widget.clienticon, + forced_width = qvars.char_height, + forced_height = qvars.char_height, + }, + }, + } +end |