diff options
author | delta <darkussdelta@gmail.com> | 2023-04-04 15:43:40 +0200 |
---|---|---|
committer | delta <darkussdelta@gmail.com> | 2023-04-04 15:43:40 +0200 |
commit | f7116d268aff3fae88d8de408e8c807295618a5c (patch) | |
tree | 6f52530d5799769e6af7c63bc5108f16f9aff742 /.config/awesome/ui/statusbar/widgets | |
parent | f0b32f45746c026d402651013b7e98315d6956a1 (diff) |
restructure and improve config
Diffstat (limited to '.config/awesome/ui/statusbar/widgets')
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/app_launcher.lua | 6 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/battery.lua | 84 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/brightness.lua | 30 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/clock.lua | 8 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/taglist.lua | 107 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/volume.lua (renamed from .config/awesome/ui/statusbar/widgets/power_menu.lua) | 0 | ||||
-rw-r--r-- | .config/awesome/ui/statusbar/widgets/wifi.lua | 64 |
7 files changed, 129 insertions, 170 deletions
diff --git a/.config/awesome/ui/statusbar/widgets/app_launcher.lua b/.config/awesome/ui/statusbar/widgets/app_launcher.lua deleted file mode 100644 index 2e1e10a..0000000 --- a/.config/awesome/ui/statusbar/widgets/app_launcher.lua +++ /dev/null @@ -1,6 +0,0 @@ -local awful = require "awful" -local wibox = require "wibox" -local vars = require "misc.vars" -local h = require "misc.helpers" - - diff --git a/.config/awesome/ui/statusbar/widgets/battery.lua b/.config/awesome/ui/statusbar/widgets/battery.lua index b041c3a..dab98ca 100644 --- a/.config/awesome/ui/statusbar/widgets/battery.lua +++ b/.config/awesome/ui/statusbar/widgets/battery.lua @@ -1,67 +1,37 @@ -local awful = require "awful" -local xresources = require "beautiful.xresources" -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local h = require "misc.helpers" +local qmath = require "quarrel.math" +local gcolor = require "gears.color" +local phosphor = require "assets.phosphor" -local battery_inner = awful.widget.watch("cat /sys/class/power_supply/BAT0/capacity", 1, function(widget, stdout) - local icon = "" - local color = vars.colors.red +local battery = wibox.widget { + widget = wibox.container.place, + valign = "center", + halign = "center", + { + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.battery_warning_vertical_fill, qvars.colors.red), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size + } +} - if io.popen("cat /sys/class/power_supply/BAT0/status"):read("*a"):sub(0, -2) == "Charging" then - icon = "" - color = vars.colors.green - widget:set_markup("<span color=\"" .. color .. "\">" .. icon .. "</span>") +awesome.connect_signal("services::battery", function(capacity, status) + if status == "Charging" then + battery.widget.image = gcolor.recolor_image(phosphor.battery_charging_vertical_fill, qvars.colors.green) return end - local percent = tonumber(stdout) - - if percent <= 5 then - icon = "" - color = vars.colors.red - elseif percent <= 10 then - icon = "" - color = vars.colors.red - elseif percent <= 20 then - icon = "" - color = vars.colors.red - elseif percent <= 30 then - icon = "" - color = vars.colors.yellow - elseif percent <= 40 then - icon = "" - color = vars.colors.yellow - elseif percent <= 50 then - icon = "" - color = vars.colors.yellow - elseif percent <= 60 then - icon = "" - color = vars.colors.yellow - elseif percent <= 70 then - icon = "" - color = vars.colors.yellow - elseif percent <= 80 then - icon = "" - color = vars.colors.green - elseif percent <= 90 then - icon = "" - color = vars.colors.green - elseif percent <= 100 then - icon = "" - color = vars.colors.green - end - - widget:set_markup("<span color=\"" .. color .. "\">" .. icon .. "</span>") -end) - -local battery = wibox.widget { - widget = wibox.container.place, - battery_inner -} + local icon_data = qmath.step_value(capacity, { + { 0, { "empty", "red" } }, + { 20, { "low", "red" } }, + { 40, { "medium", "yellow" } }, + { 60, { "high", "green" } }, + { 80, { "full", "green" } }, + { 100 } + }) -h.tooltip({ battery }, function() - return io.popen("cat /sys/class/power_supply/BAT0/capacity"):read("*a"):sub(0, -2) .. "%" + battery.widget.image = gcolor.recolor_image(phosphor["battery_vertical_" .. icon_data[1] .. "_fill"], qvars.colors[icon_data[2]]) end) return battery diff --git a/.config/awesome/ui/statusbar/widgets/brightness.lua b/.config/awesome/ui/statusbar/widgets/brightness.lua index cceba89..f8f6c17 100644 --- a/.config/awesome/ui/statusbar/widgets/brightness.lua +++ b/.config/awesome/ui/statusbar/widgets/brightness.lua @@ -1,18 +1,32 @@ -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local h = require "misc.helpers" +local qmath = require "quarrel.math" +local gcolor = require "gears.color" +local phosphor = require "assets.phosphor" local brightness = wibox.widget { widget = wibox.container.place, + valign = "center", + halign = "center", { - widget = wibox.widget.textbox, - font = vars.font, - text = "" - }, + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.moon_fill, qvars.colors.fg), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size + } } -h.tooltip({ brightness }, function() - return math.floor(tonumber(io.popen("brightnessctl g"):read("*a"):sub(0, -2)) / 255 * 100) .. "%" +awesome.connect_signal("services::brightness", function(value) + local icon_data = qmath.step_value(value, { + { 0, "cloud_moon" }, + { 51, "moon" }, + { 102, "sun_horizon" }, + { 153, "sun_dim" }, + { 204, "sun" }, + { 255 } + }) + + brightness.widget.image = gcolor.recolor_image(phosphor[icon_data .. "_fill"], qvars.colors.fg) end) return brightness diff --git a/.config/awesome/ui/statusbar/widgets/clock.lua b/.config/awesome/ui/statusbar/widgets/clock.lua index c7b3c29..77ce8ce 100644 --- a/.config/awesome/ui/statusbar/widgets/clock.lua +++ b/.config/awesome/ui/statusbar/widgets/clock.lua @@ -1,17 +1,17 @@ -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local h = require "misc.helpers" +local qui = require "quarrel.ui" local clock = wibox.widget { widget = wibox.container.place, { format = "%H\n%M", widget = wibox.widget.textclock, - font = vars.font + font = qvars.font }, } -h.tooltip({ clock }, function() +qui.tooltip({ clock }, function() return os.date("%a %d/%m/%y") end) diff --git a/.config/awesome/ui/statusbar/widgets/taglist.lua b/.config/awesome/ui/statusbar/widgets/taglist.lua index 751cbf0..89eaf2f 100644 --- a/.config/awesome/ui/statusbar/widgets/taglist.lua +++ b/.config/awesome/ui/statusbar/widgets/taglist.lua @@ -1,89 +1,82 @@ local awful = require "awful" -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local timed = require "lib.rubato".timed +local gcolor = require "gears.color" +local phosphor = require "assets.phosphor" +local qbind = require "quarrel.bind" -return awful.widget.taglist({ +return awful.widget.taglist { screen = screen[1], filter = awful.widget.taglist.filter.all, - style = { - shape = vars.shape - }, layout = { - spacing = vars.padding, + spacing = qvars.padding, layout = wibox.layout.fixed.vertical }, widget_template = { + widget = wibox.container.place, + valign = "center", + halign = "center", { - widget = wibox.container.background, - bg = vars.colors.bright.black, - shape = vars.shape, - forced_height = vars.button_size, - forced_width = vars.button_size, - id = "indicator_role" + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.circle_bold, qvars.colors.fg), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size, + icon = phosphor.dot_fill }, - widget = wibox.container.place, create_callback = function(self, tag) - local indicator = self:get_children_by_id("indicator_role")[1] - - self._anim = timed { - duration = vars.anim_duration, - intro = vars.anim_intro, - pos = indicator.height, - subscribed = function(pos) - indicator.forced_height = pos - end - } - - if tag.selected then - indicator.bg = vars.colors.yellow - self._anim.target = vars.button_size * 2 - elseif next(tag:clients()) then - indicator.bg = vars.colors.bright.black - self._anim.target = vars.button_size * 1.5 - else - self._anim.target = vars.button_size - end + -- self.widget.icon = phosphor[next(tag:clients()) and "circle_fill" or "circle_bold"] self:connect_signal("mouse::enter", function() if tag.selected then return end - indicator.bg = vars.colors.yellow + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.yellow) end) self:connect_signal("mouse::leave", function() if tag.selected then return end - if next(tag:clients()) then - indicator.bg = vars.colors.bright.black - return - end - - indicator.bg = vars.colors.bright.black + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.fg) end) + + if tag.selected then + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.yellow) + return + end + + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.fg) end, update_callback = function(self, tag) - local indicator = self:get_children_by_id("indicator_role")[1] + -- self.widget.icon = phosphor[next(tag:clients()) and "circle_fill" or "circle_bold"] if tag.selected then - indicator.bg = vars.colors.yellow - self._anim.target = vars.button_size * 2 - elseif next(tag:clients()) then - indicator.bg = vars.colors.bright.black - self._anim.target = vars.button_size * 1.5 + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.yellow) else - indicator.bg = vars.colors.bright.black - self._anim.target = vars.button_size + self.widget.image = gcolor.recolor_image(self.widget.icon, qvars.colors.fg) end end }, buttons = { - awful.button({ }, 1, function(t) t:view_only() end), - awful.button(vars.mods.M, 1, function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end), - awful.button({ }, 3, awful.tag.viewtoggle), + 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 + }, } -}) +} diff --git a/.config/awesome/ui/statusbar/widgets/power_menu.lua b/.config/awesome/ui/statusbar/widgets/volume.lua index e69de29..e69de29 100644 --- a/.config/awesome/ui/statusbar/widgets/power_menu.lua +++ b/.config/awesome/ui/statusbar/widgets/volume.lua diff --git a/.config/awesome/ui/statusbar/widgets/wifi.lua b/.config/awesome/ui/statusbar/widgets/wifi.lua index d0b7116..5f131b3 100644 --- a/.config/awesome/ui/statusbar/widgets/wifi.lua +++ b/.config/awesome/ui/statusbar/widgets/wifi.lua @@ -1,48 +1,36 @@ -local awful = require "awful" -local vars = require "misc.vars" +local qvars = require "quarrel.vars" local wibox = require "wibox" -local h = require "misc.helpers" +local qmath = require "quarrel.math" +local gcolor = require "gears.color" +local phosphor = require "assets.phosphor" -local wifi_inner = awful.widget.watch("awk 'NR==3 {printf(\"%.0f\", $3*10/7)}' /proc/net/wireless", 1, function(widget, stdout) - widget.font = "DejaVu Sans Mono wifi ramp Normal 8" - local icon = "" - local color = vars.colors.red +local wifi = wibox.widget { + widget = wibox.container.place, + valign = "center", + halign = "center", + { + widget = wibox.widget.imagebox, + image = gcolor.recolor_image(phosphor.wifi_x_fill, qvars.colors.red), + forced_width = qvars.icon_size, + forced_height = qvars.icon_size + } +} - if stdout == "" then - widget:set_markup("<span color=\"" .. color .. "\">" .. icon .. "</span>") +awesome.connect_signal("services::wifi", function(strength, connected) + if not connected then + wifi.widget.image = gcolor.recolor_image(phosphor.wifi_x_fill, qvars.colors.red) return end - local percent = tonumber(stdout) - - if percent <= 20 then - icon = "" - color = vars.colors.red - elseif percent <= 40 then - icon = "" - color = vars.colors.yellow - elseif percent <= 60 then - icon = "" - color = vars.colors.yellow - elseif percent <= 80 then - icon = "" - color = vars.colors.green - elseif percent <= 100 then - icon = "" - color = vars.colors.green - end - - - widget:set_markup("<span color=\"" .. color .. "\">" .. icon .. "</span>") -end) - -local wifi = wibox.widget { - widget = wibox.container.place, - wifi_inner -} + local icon_data = qmath.step_value(strength, { + { 0, { "none", "red" } }, + { 25, { "low", "yellow" } }, + { 50, { "medium", "yellow" } }, + { 75, { "high", "green" } }, + { 100 } + }) -h.tooltip({ wifi }, function() - return io.popen("iwgetid -r"):read("*a"):sub(0, -2) + wifi.widget.image = gcolor.recolor_image(phosphor["wifi_" .. icon_data[1] .. "_fill"], qvars.colors[icon_data[2]]) end) return wifi |