add: woowak's wibar

This commit is contained in:
ChocolateBread799 2022-03-24 18:35:02 +09:00 committed by rxyhn
parent fa977898bd
commit eebead35c7

View file

@ -10,256 +10,252 @@ local beautiful = require("beautiful")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
-- Rubato
local rubato = require("module.rubato")
-- Helpers
local helpers = require("helpers")
-- Get screen geometry
local screen_width = awful.screen.focused().geometry.width
local screen_height = awful.screen.focused().geometry.height
-- Bar
--------
local function boxed_widget(widget)
local boxed = wibox.widget{
{
widget,
top = dpi(8),
bottom = dpi(5),
widget = wibox.container.margin
},
bg = beautiful.xcolor0,
shape = helpers.rrect(dpi(4)),
widget = wibox.container.background
}
return boxed
end
-- Helpers
-------------
local function boxed_widget2(widget)
local boxed = wibox.widget{
{
widget,
top = dpi(4),
bottom = dpi(4),
left = dpi(2),
right = dpi(2),
widget = wibox.container.margin
},
bg = beautiful.lighter_bg,
shape = helpers.rrect(dpi(4)),
widget = wibox.container.background
}
return boxed
end
local wrap_widget = function(w)
local wrap_widget = function(widget)
return {
w,
left = dpi(3),
right = dpi(3),
widget,
margins = dpi(6),
widget = wibox.container.margin
}
end
local wrap_widget2 = function(w)
return {
w,
left = dpi(2),
right = dpi(2),
widget = wibox.container.margin
}
end
screen.connect_signal("request::desktop_decoration", function(s)
-- Launcher
-------------
-- Launcher
local awesome_icon = wibox.widget {
local awesome_icon = wibox.widget {
{
widget = wibox.widget.imagebox,
image = beautiful.awesome_logo,
resize = true
},
margins = dpi(4),
widget = wibox.container.margin
}
helpers.add_hover_cursor(awesome_icon, "hand2")
-- Battery
-------------
local charge_icon = wibox.widget{
bg = beautiful.xcolor8,
widget = wibox.container.background,
visible = false
}
local batt = wibox.widget{
charge_icon,
color = {beautiful.xcolor2},
bg = beautiful.xcolor8 .. "88",
value = 50,
min_value = 0,
max_value = 100,
thickness = dpi(4),
padding = dpi(2),
-- rounded_edge = true,
start_angle = math.pi * 3 / 2,
widget = wibox.container.arcchart
}
awesome.connect_signal("signal::battery", function(value)
local fill_color = beautiful.xcolor2
if value >= 11 and value <= 30 then
fill_color = beautiful.xcolor3
elseif value <= 10 then
fill_color = beautiful.xcolor1
end
batt.colors = {fill_color}
batt.value = value
end)
awesome.connect_signal("signal::charger", function(state)
if state then
charge_icon.visible = true
else
charge_icon.visible = false
end
end)
-- Time
----------
local hour = wibox.widget{
font = beautiful.font_name .. "bold 14",
format = "%H",
align = "center",
valign = "center",
widget = wibox.widget.textclock
}
local min = wibox.widget{
font = beautiful.font_name .. "bold 14",
format = "%M",
align = "center",
valign = "center",
widget = wibox.widget.textclock
}
local clock = wibox.widget{
{
{
{
widget = wibox.widget.imagebox,
image = beautiful.awesome_logo,
resize = true
},
margins = dpi(4),
widget = wibox.container.margin
hour,
min,
spacing = dpi(5),
layout = wibox.layout.fixed.vertical
},
shape = helpers.rrect(beautiful.border_radius / 2),
bg = beautiful.wibar_bg,
widget = wibox.container.background
}
top = dpi(5),
bottom = dpi(5),
widget = wibox.container.margin
},
bg = beautiful.lighter_bg,
shape = helpers.rrect(beautiful.bar_radius),
widget = wibox.container.background
}
awesome_icon:buttons(gears.table.join(
awful.button({}, 1, function ()
awful.spawn(launcher)
end)
))
awesome_icon:connect_signal("mouse::enter", function()
awesome_icon.bg = beautiful.lighter_bg
end)
-- Stats
-----------
awesome_icon:connect_signal("mouse::leave", function()
awesome_icon.bg = beautiful.transparent
end)
-- Tasklist
local tasklist_buttons = gears.table.join(
awful.button({}, 1, function(c)
if c == client.focus then
c.minimized = true
else
c:emit_signal("request::activate", "tasklist", {raise = true})
end
end), awful.button({}, 3, function()
awful.menu.client_list({theme = {width = 250}})
end), awful.button({}, 4, function() awful.client.focus.byidx(1) end),
awful.button({}, 5, function()
awful.client.focus.byidx(-1)
end))
-- Battery
local charge_icon = wibox.widget{
bg = beautiful.xcolor8,
widget = wibox.container.background,
visible = false
}
local batt = wibox.widget{
charge_icon,
color = {beautiful.xcolor2},
bg = beautiful.xcolor8 .. "88",
value = 50,
min_value = 0,
max_value = 100,
thickness = dpi(4),
padding = dpi(2),
-- rounded_edge = true,
start_angle = math.pi * 3 / 2,
widget = wibox.container.arcchart
}
awesome.connect_signal("signal::battery", function(value)
local fill_color = beautiful.xcolor2
if value >= 11 and value <= 30 then
fill_color = beautiful.xcolor3
elseif value <= 10 then
fill_color = beautiful.xcolor1
end
batt.colors = {fill_color}
batt.value = value
end)
awesome.connect_signal("signal::charger", function(state)
if state then
charge_icon.visible = true
else
charge_icon.visible = false
end
end)
-- Time
local time_hour = wibox.widget{
font = beautiful.font_name .. "bold 12",
format = "%H",
align = "center",
valign = "center",
widget = wibox.widget.textclock
}
local time_min = wibox.widget{
font = beautiful.font_name .. "bold 12",
format = "%M",
align = "center",
valign = "center",
widget = wibox.widget.textclock
}
local time = wibox.widget{
time_hour,
time_min,
local stats = wibox.widget{
{
wrap_widget(batt),
clock,
spacing = dpi(5),
layout = wibox.layout.fixed.vertical
}
},
bg = beautiful.xcolor0,
shape = helpers.rrect(beautiful.bar_radius),
widget = wibox.container.background
}
local stats_container = wibox.widget{
wrap_widget2(batt),
boxed_widget2(time),
spacing = dpi(10),
layout = wibox.layout.fixed.vertical
}
stats:connect_signal("mouse::enter", function()
stats.bg = beautiful.xcolor8
stats_tooltip_show()
end)
stats_container:connect_signal("mouse::enter", function()
cal_tooltip_show()
end)
stats:connect_signal("mouse::leave", function()
stats.bg = beautiful.xcolor0
stats_tooltip_hide()
end)
stats_container:connect_signal("mouse::leave", function()
cal_tooltip_hide()
end)
-- Notification center
local notifs = wibox.widget{
markup = "",
font = beautiful.font_name .. "16",
align = "center",
valign = "center",
widget = wibox.widget.textbox
}
-- Notification center
-------------------------
local notifs = wibox.widget{
markup = helpers.colorize_text("", beautiful.xcolor3),
font = beautiful.font_name .. "18",
align = "center",
valign = "center",
widget = wibox.widget.textbox
}
notifs:connect_signal("mouse::enter", function()
notifs.markup = helpers.colorize_text(notifs.text, beautiful.xcolor3 .. 55)
end)
notifs:connect_signal("mouse::leave", function()
notifs.markup = helpers.colorize_text(notifs.text, beautiful.xcolor3)
end)
notifs:buttons(gears.table.join(
awful.button({}, 1, function()
notifs_toggle()
end)
))
notifs:buttons(gears.table.join(
awful.button({}, 1, function()
notifs_toggle()
end)
))
helpers.add_hover_cursor(notifs, "hand2")
-- Setup wibar
-----------------
screen.connect_signal("request::desktop_decoration", function(s)
-- Create a promptbox for each screen
s.mypromptbox = awful.widget.prompt()
-- Create layoutbox widget
-- Layoutbox
local layoutbox_buttons = gears.table.join(
-- Left click
awful.button({}, 1, function (c)
awful.layout.inc(1)
end),
-- Right click
awful.button({}, 3, function (c)
awful.layout.inc(-1)
end),
-- Scrolling
awful.button({}, 4, function ()
awful.layout.inc(-1)
end),
awful.button({}, 5, function ()
awful.layout.inc(1)
end)
)
s.mylayoutbox = awful.widget.layoutbox(s)
s.mylayoutbox:buttons(layoutbox_buttons)
local layoutbox = wibox.widget{
s.mylayoutbox,
right = dpi(9),
left = dpi(9),
top = dpi(6),
bottom = dpi(6),
margins = {bottom = dpi(7), left = dpi(8), right = dpi(8)},
widget = wibox.container.margin
}
layoutbox:buttons(gears.table.join(
awful.button({}, 1, function ()
awful.layout.inc(1)
end)
))
helpers.add_hover_cursor(layoutbox, "hand2")
-- Create the wibox
s.mywibox = wibox({
-- position = beautiful.wibar_position,
-- Create the wibar
s.mywibar = awful.wibar({
position = "left",
screen = s,
type = "dock",
width = dpi(50),
height = awful.screen.focused().geometry.height - dpi(50),
bg = "#0000000",
ontop = true,
x = 0,
y = 0,
width = beautiful.wibar_width,
height = screen_height,
visible = true
})
s.mywibox:struts{left = beautiful.wibar_width}
awesome_icon:buttons(gears.table.join(
awful.button({}, 1, function ()
dashboard_toggle()
end)
))
-- Remove wibar on full screen
local function remove_wibar(c)
if c.fullscreen or c.maximized then
c.screen.mywibox.visible = false
c.screen.mywibar.visible = false
else
c.screen.mywibox.visible = true
c.screen.mywibar.visible = true
end
end
-- Remove wibar on full screen
local function add_wibar(c)
if c.fullscreen or c.maximized then
c.screen.mywibox.visible = true
c.screen.mywibar.visible = true
end
end
@ -267,121 +263,46 @@ screen.connect_signal("request::desktop_decoration", function(s)
client.connect_signal("request::unmanage", add_wibar)
-- Create the taglist widget
-- Create the taglist widget
s.mytaglist = require("ui.widgets.pacman_taglist")(s)
-- Create a tasklist widget
s.mytasklist = awful.widget.tasklist {
screen = s,
filter = awful.widget.tasklist.filter.currenttags,
buttons = tasklist_buttons,
bg = beautiful.wibar_bg,
style = {
bg = beautiful.xcolor0,
shape = helpers.rrect(beautiful.border_radius / 2)
},
layout = {spacing = dpi(10), layout = wibox.layout.fixed.vertical},
widget_template = {
{
awful.widget.clienticon,
margins = dpi(8),
layout = wibox.container.margin
},
id = "background_role",
widget = wibox.container.background,
create_callback = function(self, c, index, clients)
self:connect_signal('mouse::enter', function()
self.bg_temp = self.bg
self.bg = beautiful.xcolor0
awesome.emit_signal("bling::task_preview::visibility", s,
true, c)
end)
self:connect_signal('mouse::leave', function()
self.bg = self.bg_temp
awesome.emit_signal("bling::task_preview::visibility", s,
false, c)
end)
end
}
local taglist = wibox.widget{
s.mytaglist,
shape = beautiful.taglist_shape_focus,
bg = beautiful.xcolor0,
widget = wibox.container.background
}
-- Add widgets to the wibox
s.mywibox.widget = wibox.widget {
-- Add widgets to wibar
s.mywibar:setup {
{
layout = wibox.layout.align.vertical,
expand = "none",
{
layout = wibox.layout.fixed.vertical,
helpers.horizontal_pad(4),
-- function to add padding
{
{
awesome_icon,
margins = dpi(3),
widget = wibox.container.margin
},
margins = 3,
widget = wibox.container.margin
layout = wibox.layout.align.vertical,
expand = "none",
{ -- left
awesome_icon,
taglist,
spacing = dpi(10),
layout = wibox.layout.fixed.vertical
},
wrap_widget({
s.mytasklist,
left = dpi(2),
right = dpi(2),
widget = wibox.container.margin
}),
s.mypromptbox
-- middle
nil,
{ -- right
stats,
notifs,
layoutbox,
spacing = dpi(8),
layout = wibox.layout.fixed.vertical
}
},
{
boxed_widget({
wrap_widget({
s.mytaglist,
top = dpi(30),
bottom = dpi(30),
widget = wibox.container.margin
}),
widget = wibox.container.constraint
}),
left = dpi(5),
right = dpi(5),
margins = dpi(8),
widget = wibox.container.margin
},
{
{
{
{
boxed_widget({
wrap_widget({
stats_container,
spacing = dpi(10),
layout = wibox.layout.fixed.vertical
}),
left = dpi(2),
right = dpi(2),
widget = wibox.container.margin
}),
bottom = dpi(12),
widget = wibox.container.margin
},
boxed_widget({
notifs,
layoutbox,
spacing = dpi(3),
layout = wibox.layout.fixed.vertical
}),
helpers.horizontal_pad(4),
layout = wibox.layout.fixed.vertical
},
bottom = dpi(10),
widget = wibox.container.margin
},
left = dpi(5),
right = dpi(5),
widget = wibox.container.margin
}
},
widget = wibox.container.background,
bg = beautiful.wibar_bg
}
end)
bg = beautiful.darker_bg,
shape = helpers.rrect(beautiful.bar_radius),
widget = wibox.container.background
}
-- EOF ------------------------------------------------------------------------
-- wibar position
s.mywibar.x = dpi(25)
end)