From a0f8b5fa6acdd1c2477fb1881dd9067956bf0ae6 Mon Sep 17 00:00:00 2001 From: delta Date: Sun, 29 Jan 2023 09:59:52 +0100 Subject: init dots --- .config/awesome/components/statusbar/battery.lua | 78 ++++++++++++++++++++ .../awesome/components/statusbar/brightness.lua | 33 +++++++++ .config/awesome/components/statusbar/clock.lua | 32 ++++++++ .config/awesome/components/statusbar/init.lua | 57 ++++++++++++++ .config/awesome/components/statusbar/taglist.lua | 86 ++++++++++++++++++++++ .config/awesome/components/statusbar/wifi.lua | 60 +++++++++++++++ 6 files changed, 346 insertions(+) create mode 100644 .config/awesome/components/statusbar/battery.lua create mode 100644 .config/awesome/components/statusbar/brightness.lua create mode 100644 .config/awesome/components/statusbar/clock.lua create mode 100644 .config/awesome/components/statusbar/init.lua create mode 100644 .config/awesome/components/statusbar/taglist.lua create mode 100644 .config/awesome/components/statusbar/wifi.lua (limited to '.config/awesome/components/statusbar') diff --git a/.config/awesome/components/statusbar/battery.lua b/.config/awesome/components/statusbar/battery.lua new file mode 100644 index 0000000..670b200 --- /dev/null +++ b/.config/awesome/components/statusbar/battery.lua @@ -0,0 +1,78 @@ +local awful = require "awful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi +local vars = require "themes.prismite.vars" +local wibox = require "wibox" + +local battery_inner = awful.widget.watch("cat /sys/class/power_supply/BAT0/capacity", 1, function(widget, stdout) + local icon = "" + local color = vars.colors.red + + 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("" .. icon .. "") + 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("" .. icon .. "") +end) + +local battery = wibox.widget { + widget = wibox.container.place, + battery_inner +} + +awful.tooltip { + objects = { battery }, + timer_function = function() + return io.popen("cat /sys/class/power_supply/BAT0/capacity"):read("*a"):sub(0, -2) .. "%" + end, + bg = vars.colors.bg, + fg = vars.colors.fg, + border_color = vars.colors.bright.black, + border_width = vars.border_width, + font = vars.font, + shape = vars.shape, + margin_leftright = dpi(6), + margin_topbottom = dpi(6) +} + +return battery diff --git a/.config/awesome/components/statusbar/brightness.lua b/.config/awesome/components/statusbar/brightness.lua new file mode 100644 index 0000000..eb37f06 --- /dev/null +++ b/.config/awesome/components/statusbar/brightness.lua @@ -0,0 +1,33 @@ +local awful = require "awful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi +local vars = require "themes.prismite.vars" +local wibox = require "wibox" + + +local brightness = wibox.widget { + widget = wibox.container.place, + { + widget = wibox.widget.textbox, + font = vars.font, + text = "" + }, +} + +awful.tooltip { + objects = { brightness }, + timer_function = function() + return math.floor(tonumber(io.popen("brightnessctl g"):read("*a"):sub(0, -2)) / 255 * 100) .. "%" + end, + timeout = 0.5, + bg = vars.colors.bg, + fg = vars.colors.fg, + border_color = vars.colors.bright.black, + border_width = vars.border_width, + font = vars.font, + shape = vars.shape, + margin_leftright = dpi(6), + margin_topbottom = dpi(6) +} + +return brightness diff --git a/.config/awesome/components/statusbar/clock.lua b/.config/awesome/components/statusbar/clock.lua new file mode 100644 index 0000000..c88ea62 --- /dev/null +++ b/.config/awesome/components/statusbar/clock.lua @@ -0,0 +1,32 @@ +local awful = require "awful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi +local vars = require "themes.prismite.vars" +local wibox = require "wibox" + + +local clock = wibox.widget { + widget = wibox.container.place, + { + format = "%H\n%M", + widget = wibox.widget.textclock, + font = vars.font + }, +} + +awful.tooltip { + objects = { clock }, + timer_function = function() + return os.date("%a %d/%m/%y") + end, + bg = vars.colors.bg, + fg = vars.colors.fg, + border_color = vars.colors.bright.black, + border_width = vars.border_width, + font = vars.font, + shape = vars.shape, + margin_leftright = dpi(6), + margin_topbottom = dpi(6) +} + +return clock diff --git a/.config/awesome/components/statusbar/init.lua b/.config/awesome/components/statusbar/init.lua new file mode 100644 index 0000000..c798669 --- /dev/null +++ b/.config/awesome/components/statusbar/init.lua @@ -0,0 +1,57 @@ +local awful = require "awful" +local beautiful = require "beautiful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi +local vars = require "themes.prismite.vars" +local wibox = require "wibox" + +local taglist = require "components.statusbar.taglist" +local clock = require "components.statusbar.clock" +local wifi = require "components.statusbar.wifi" +local battery = require "components.statusbar.battery" +local brightness = require "components.statusbar.brightness" + +screen.connect_signal("request::desktop_decoration", function(s) + local bar = awful.wibar({ + -- placement = function(d) + -- local place = awful.placement.left + awful.placement.maximize_vertically + -- return place(d, { + -- margins = beautiful.useless_gap + -- }) + -- end, + margins = dpi(4), + position = "left", + screen = s, + restrict_workarea = true, + height = s.geometry.height - (beautiful.useless_gap * 4 + vars.border_width * 2) - 2, + width = dpi(32), + border_width = vars.border_width, + border_color = vars.colors.bright.black, + shape = vars.shape, + bg = vars.colors.bg, + widget = { + { + margins = dpi(4), + widget = wibox.container.margin, + { + layout = wibox.layout.fixed.vertical, + taglist + } + }, + nil, + { + margins = dpi(4), + widget = wibox.container.margin, + { + layout = wibox.layout.fixed.vertical, + spacing = dpi(8), + brightness, + battery, + wifi, + clock + } + }, + layout = wibox.layout.align.vertical, + } + }) +end) diff --git a/.config/awesome/components/statusbar/taglist.lua b/.config/awesome/components/statusbar/taglist.lua new file mode 100644 index 0000000..8eb8d17 --- /dev/null +++ b/.config/awesome/components/statusbar/taglist.lua @@ -0,0 +1,86 @@ +local awful = require "awful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi +local vars = require "themes.prismite.vars" +local wibox = require "wibox" +local naughty = require "naughty" + +return awful.widget.taglist({ + screen = screen[1], + filter = awful.widget.taglist.filter.all, + style = { + shape = vars.shape + }, + layout = { + spacing = 8, + layout = wibox.layout.fixed.vertical + }, + widget_template = { + { + { + { + id = "text_role", + widget = wibox.widget.textbox, + }, + widget = wibox.container.place, + }, + { + widget = wibox.container.background, + bg = vars.colors.bright.black, + shape = vars.shape, + forced_height = dpi(2), + forced_width = dpi(16), + id = "indicator_role" + }, + layout = wibox.layout.fixed.vertical + }, + widget = wibox.container.place, + create_callback = function(self, tag) + local indicator = self:get_children_by_id("indicator_role")[1] + local text = self:get_children_by_id("text_role")[1] + -- naughty.notification { + -- message = "b ".. tostring(text.font) + -- } + + -- text.font = "FiraCode Nerd Font Mono SemiBold 12" + + -- naughty.notification { + -- message = "a " .. tostring(text.font) + -- } + + self:connect_signal("mouse::enter", function() + if tag.selected then return end + + indicator.bg = vars.colors.yellow + end) + + self:connect_signal("mouse::leave", function() + if tag.selected then return end + + indicator.bg = vars.colors.bright.black + end) + + if tag.selected then + indicator.bg = vars.colors.yellow + end + end, + update_callback = function(self, tag) + local indicator = self:get_children_by_id("indicator_role")[1] + + if tag.selected then + indicator.bg = vars.colors.yellow + else + indicator.bg = vars.colors.bright.black + end + end + }, + buttons = { + awful.button({ }, 1, function(t) t:view_only() end), + awful.button({ modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({ }, 3, awful.tag.viewtoggle), + } +}) diff --git a/.config/awesome/components/statusbar/wifi.lua b/.config/awesome/components/statusbar/wifi.lua new file mode 100644 index 0000000..e6431ce --- /dev/null +++ b/.config/awesome/components/statusbar/wifi.lua @@ -0,0 +1,60 @@ +local awful = require "awful" +local xresources = require "beautiful.xresources" +local dpi = xresources.apply_dpi +local vars = require "themes.prismite.vars" +local wibox = require "wibox" + +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 + + if stdout == "" then + widget:set_markup("" .. icon .. "") + 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("" .. icon .. "") +end) + +local wifi = wibox.widget { + widget = wibox.container.place, + wifi_inner +} + +awful.tooltip { + objects = { wifi }, + timer_function = function() + return io.popen("iwgetid -r"):read("*a"):sub(0, -2) + end, + bg = vars.colors.bg, + fg = vars.colors.fg, + border_color = vars.colors.bright.black, + border_width = vars.border_width, + font = vars.font, + shape = vars.shape, + margin_leftright = dpi(6), + margin_topbottom = dpi(6) +} + +return wifi -- cgit v1.2.3