aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/components/statusbar
diff options
context:
space:
mode:
authordelta <darkussdelta@gmail.com>2023-01-29 09:59:52 +0100
committerdelta <darkussdelta@gmail.com>2023-01-29 10:02:22 +0100
commita0f8b5fa6acdd1c2477fb1881dd9067956bf0ae6 (patch)
tree04500ca0a4c97f85b1a2d875d8285effda7b57fe /.config/awesome/components/statusbar
init dots
Diffstat (limited to '.config/awesome/components/statusbar')
-rw-r--r--.config/awesome/components/statusbar/battery.lua78
-rw-r--r--.config/awesome/components/statusbar/brightness.lua33
-rw-r--r--.config/awesome/components/statusbar/clock.lua32
-rw-r--r--.config/awesome/components/statusbar/init.lua57
-rw-r--r--.config/awesome/components/statusbar/taglist.lua86
-rw-r--r--.config/awesome/components/statusbar/wifi.lua60
6 files changed, 346 insertions, 0 deletions
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("<span color=\"" .. color .. "\">" .. icon .. "</span>")
+ 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
+}
+
+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("<span color=\"" .. color .. "\">" .. icon .. "</span>")
+ 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
+}
+
+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