Add new notification-center module with various widgets, add rubato animations and other fixes and improvements
This commit is contained in:
@@ -17,10 +17,10 @@ BACKLIGHT_SEPS = 0
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"pkexec xfpm-power-backlight-helper --get-max-brightness",
|
||||
function(stdout)
|
||||
BACKLIGHT_MAX_BRIGHTNESS = tonumber(stdout)
|
||||
BACKLIGHT_SEPS = BACKLIGHT_MAX_BRIGHTNESS / 100
|
||||
BACKLIGHT_SEPS = math.floor(BACKLIGHT_SEPS)
|
||||
end
|
||||
BACKLIGHT_MAX_BRIGHTNESS = tonumber(stdout)
|
||||
BACKLIGHT_SEPS = BACKLIGHT_MAX_BRIGHTNESS / 100
|
||||
BACKLIGHT_SEPS = math.floor(BACKLIGHT_SEPS)
|
||||
end
|
||||
)
|
||||
|
||||
return function(s)
|
||||
@@ -112,60 +112,61 @@ return function(s)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:connect_signal(
|
||||
"property::value",
|
||||
function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"pkexec xfpm-power-backlight-helper --get-brightness",
|
||||
function(stdout)
|
||||
local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(tostring(brightness_value) .. "%")
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"pkexec xfpm-power-backlight-helper --get-brightness",
|
||||
function(stdout)
|
||||
local brightness_value = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.label_value_layout.value:set_text(tostring(brightness_value) .. "%")
|
||||
|
||||
awesome.emit_signal(
|
||||
"widget::brightness:update",
|
||||
brightness_value
|
||||
awesome.emit_signal(
|
||||
"widget::brightness:update",
|
||||
brightness_value
|
||||
)
|
||||
|
||||
if awful.screen.focused().show_brightness_osd then
|
||||
awesome.emit_signal(
|
||||
"module::brightness_osd:show",
|
||||
true
|
||||
)
|
||||
end
|
||||
|
||||
local icon = icondir .. "brightness"
|
||||
if brightness_value >= 0 and brightness_value < 34 then
|
||||
icon = icon .. "-low"
|
||||
elseif brightness_value >= 34 and brightness_value < 67 then
|
||||
icon = icon .. "-medium"
|
||||
elseif brightness_value >= 67 then
|
||||
icon = icon .. "-high"
|
||||
end
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg")
|
||||
awesome.emit_signal("update::backlight_widget", brightness_value, icon .. ".svg")
|
||||
end
|
||||
)
|
||||
|
||||
if awful.screen.focused().show_brightness_osd then
|
||||
awesome.emit_signal(
|
||||
"module::brightness_osd:show",
|
||||
true
|
||||
)
|
||||
end
|
||||
|
||||
local icon = icondir .. "brightness"
|
||||
if brightness_value >= 0 and brightness_value < 34 then
|
||||
icon = icon .. "-low"
|
||||
elseif brightness_value >= 34 and brightness_value < 67 then
|
||||
icon = icon .. "-medium"
|
||||
elseif brightness_value >= 67 then
|
||||
icon = icon .. "-high"
|
||||
end
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.icon_margin1.icon_margin2.icon:set_image(icon .. ".svg")
|
||||
end
|
||||
)
|
||||
end
|
||||
)
|
||||
|
||||
local update_slider = function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
[[ pkexec xfpm-power-backlight-helper --get-brightness ]],
|
||||
function(stdout)
|
||||
stdout = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(stdout)
|
||||
end
|
||||
stdout = math.floor((tonumber(stdout) - 1) / (BACKLIGHT_MAX_BRIGHTNESS - 1) * 100)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(stdout)
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
awesome.connect_signal(
|
||||
"module::brightness_slider:update",
|
||||
function()
|
||||
update_slider()
|
||||
end
|
||||
update_slider()
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"widget::brightness:update",
|
||||
function(value)
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(tonumber(value))
|
||||
end
|
||||
brightness_osd_widget.container.osd_layout.icon_slider_layout.slider_layout.brightness_slider:set_value(tonumber(value))
|
||||
end
|
||||
)
|
||||
|
||||
update_slider()
|
||||
@@ -199,36 +200,36 @@ return function(s)
|
||||
awesome.connect_signal(
|
||||
"widget::brightness_osd:rerun",
|
||||
function()
|
||||
if hide_brightness_osd.started then
|
||||
hide_brightness_osd:again()
|
||||
else
|
||||
hide_brightness_osd:start()
|
||||
if hide_brightness_osd.started then
|
||||
hide_brightness_osd:again()
|
||||
else
|
||||
hide_brightness_osd:start()
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"module::brightness_osd:show",
|
||||
function()
|
||||
if s == mouse.screen then
|
||||
brightness_container.visible = true
|
||||
if s == mouse.screen then
|
||||
brightness_container.visible = true
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
brightness_container:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
brightness_container.visible = true
|
||||
hide_brightness_osd:stop()
|
||||
end
|
||||
brightness_container.visible = true
|
||||
hide_brightness_osd:stop()
|
||||
end
|
||||
)
|
||||
|
||||
brightness_container:connect_signal(
|
||||
"mouse::leave",
|
||||
function()
|
||||
brightness_container.visible = true
|
||||
hide_brightness_osd:again()
|
||||
end
|
||||
brightness_container.visible = true
|
||||
hide_brightness_osd:again()
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
122
awesome/src/modules/crylia_bar/center_bar.lua
Normal file
122
awesome/src/modules/crylia_bar/center_bar.lua
Normal file
@@ -0,0 +1,122 @@
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
|
||||
return function(s, widgets)
|
||||
|
||||
local top_center = awful.popup {
|
||||
screen = s,
|
||||
widget = wibox.container.background,
|
||||
ontop = false,
|
||||
bg = color["Grey900"],
|
||||
visible = true,
|
||||
maximum_width = dpi(500),
|
||||
placement = function(c) awful.placement.top(c, { margins = dpi(10) }) end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
|
||||
top_center:struts {
|
||||
top = 55
|
||||
}
|
||||
|
||||
local function prepare_widgets(widgets)
|
||||
local layout = {
|
||||
forced_height = 45,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
for i, widget in pairs(widgets) do
|
||||
if i == 1 then
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(6),
|
||||
right = dpi(6),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
elseif i == #widgets then
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(3),
|
||||
right = dpi(6),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
else
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(3),
|
||||
right = dpi(3),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
end
|
||||
end
|
||||
return layout
|
||||
end
|
||||
|
||||
top_center:setup {
|
||||
nil,
|
||||
prepare_widgets(widgets),
|
||||
nil,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
|
||||
client.connect_signal(
|
||||
"manage",
|
||||
function(c)
|
||||
if #s.selected_tag:clients() < 1 then
|
||||
top_center.visible = false
|
||||
else
|
||||
top_center.visible = true
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
client.connect_signal(
|
||||
"unmanage",
|
||||
function(c)
|
||||
if #s.selected_tag:clients() < 1 then
|
||||
top_center.visible = false
|
||||
else
|
||||
top_center.visible = true
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
client.connect_signal(
|
||||
"tag::switched",
|
||||
function(c)
|
||||
if #s.selected_tag:clients() < 1 then
|
||||
top_center.visible = false
|
||||
else
|
||||
top_center.visible = true
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"refresh",
|
||||
function(c)
|
||||
if #s.selected_tag:clients() < 1 then
|
||||
top_center.visible = false
|
||||
else
|
||||
top_center.visible = true
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
313
awesome/src/modules/crylia_bar/dock.lua
Normal file
313
awesome/src/modules/crylia_bar/dock.lua
Normal file
@@ -0,0 +1,313 @@
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
|
||||
return function(screen, programs)
|
||||
|
||||
local function create_dock_element(class, program, name, user_icon, is_steam, size)
|
||||
if program == nil or class == nil then
|
||||
return
|
||||
end
|
||||
is_steam = is_steam or false
|
||||
user_icon = user_icon or nil
|
||||
local dock_element = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
resize = true,
|
||||
forced_width = size,
|
||||
forced_height = size,
|
||||
image = user_icon or Get_icon(user_vars.icon_theme, nil, program, class, is_steam),
|
||||
widget = wibox.widget.imagebox,
|
||||
id = "icon",
|
||||
},
|
||||
margins = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
id = "margin"
|
||||
},
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 10)
|
||||
end,
|
||||
bg = color["Grey900"],
|
||||
widget = wibox.container.background,
|
||||
id = "background"
|
||||
},
|
||||
top = dpi(5),
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
for _, c in ipairs(client.get()) do
|
||||
if string.lower(c.class):match(program) and c == client.focus then
|
||||
dock_element.background.bg = color["Grey800"]
|
||||
end
|
||||
end
|
||||
|
||||
Hover_signal(dock_element.background, color["Grey800"], color["White"])
|
||||
|
||||
dock_element:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
if is_steam then
|
||||
awful.spawn("steam steam://rungameid/" .. program)
|
||||
else
|
||||
awful.spawn(program)
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
awful.tooltip {
|
||||
objects = { dock_element },
|
||||
text = name,
|
||||
mode = "outside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
return dock_element
|
||||
end
|
||||
|
||||
local dock = awful.popup {
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
bg = color["Grey900"],
|
||||
visible = true,
|
||||
screen = screen,
|
||||
type = "dock",
|
||||
height = user_vars.dock_icon_size + 10,
|
||||
placement = function(c) awful.placement.bottom(c, { margins = dpi(10) }) end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 15)
|
||||
end
|
||||
}
|
||||
|
||||
local fakedock = awful.popup {
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
bg = '#00000000',
|
||||
visible = true,
|
||||
screen = screen,
|
||||
type = "dock",
|
||||
id = "fakedock",
|
||||
height = dpi(10),
|
||||
placement = function(c) awful.placement.bottom(c, { margins = dpi(0) }) end,
|
||||
}
|
||||
|
||||
local function get_dock_elements(pr)
|
||||
local dock_elements = { layout = wibox.layout.fixed.horizontal }
|
||||
|
||||
for i, p in ipairs(pr) do
|
||||
dock_elements[i] = create_dock_element(p[1], p[2], p[3], p[4], p[5], user_vars.dock_icon_size)
|
||||
end
|
||||
|
||||
return dock_elements
|
||||
end
|
||||
|
||||
local dock_elements = get_dock_elements(programs)
|
||||
|
||||
local function get_fake_elements(amount)
|
||||
local fake_elements = { layout = wibox.layout.fixed.horizontal }
|
||||
|
||||
for i = 0, amount, 1 do
|
||||
fake_elements[i] = wibox.widget {
|
||||
bg = '00000000',
|
||||
forced_width = user_vars.dock_icon_size + dpi(20),
|
||||
forced_height = dpi(10),
|
||||
id = "fake",
|
||||
widget = wibox.container.background
|
||||
}
|
||||
end
|
||||
return fake_elements
|
||||
end
|
||||
|
||||
local function create_incicator_widget(prog)
|
||||
local container = { layout = wibox.layout.flex.horizontal }
|
||||
local clients = client.get()
|
||||
for index, pr in ipairs(prog) do
|
||||
local indicators = { layout = wibox.layout.flex.horizontal, spacing = dpi(5) }
|
||||
local col = color["Grey600"]
|
||||
for i, c in ipairs(clients) do
|
||||
if string.lower(c.class or c.name):match(string.lower(pr[1]) or string.lower(pr[2])) then
|
||||
if c == client.focus then
|
||||
col = color["YellowA200"]
|
||||
elseif c.urgent then
|
||||
col = color["RedA200"]
|
||||
elseif c.maximized then
|
||||
col = color["GreenA200"]
|
||||
elseif c.minimized then
|
||||
col = color["BlueA200"]
|
||||
elseif c.fullscreen then
|
||||
col = color["PinkA200"]
|
||||
else
|
||||
col = color["Grey600"]
|
||||
end
|
||||
indicators[i] = wibox.widget {
|
||||
widget = wibox.container.background,
|
||||
shape = gears.shape.rounded_rect,
|
||||
forced_height = dpi(3),
|
||||
bg = col,
|
||||
forced_width = dpi(5),
|
||||
}
|
||||
end
|
||||
end
|
||||
container[index] = wibox.widget {
|
||||
indicators,
|
||||
forced_height = dpi(5),
|
||||
forced_width = dpi(50),
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
}
|
||||
end
|
||||
|
||||
return wibox.widget {
|
||||
container,
|
||||
bottom = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
}
|
||||
end
|
||||
|
||||
fakedock:setup {
|
||||
get_fake_elements(#programs),
|
||||
type = 'dock',
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local function check_for_dock_hide(s)
|
||||
for _, client in ipairs(s.selected_tag:clients()) do
|
||||
if client.fullscreen then
|
||||
dock.visible = false
|
||||
fakedock.visible = false
|
||||
else
|
||||
fakedock.visible = true
|
||||
end
|
||||
end
|
||||
if #s.selected_tag:clients() < 1 then
|
||||
dock.visible = true
|
||||
return
|
||||
end
|
||||
if s == mouse.screen then
|
||||
local minimized
|
||||
for _, c in ipairs(s.selected_tag:clients()) do
|
||||
if c.minimized then
|
||||
minimized = true
|
||||
end
|
||||
if c.maximized or c.fullscreen then
|
||||
dock.visible = false
|
||||
return
|
||||
end
|
||||
if not c.minimized then
|
||||
local y = c:geometry().y
|
||||
local h = c.height
|
||||
if (y + h) >= s.geometry.height - user_vars.dock_icon_size - 35 then
|
||||
dock.visible = false
|
||||
return
|
||||
else
|
||||
dock.visible = true
|
||||
end
|
||||
end
|
||||
end
|
||||
if minimized then
|
||||
dock.visible = true
|
||||
end
|
||||
else
|
||||
dock.visible = false
|
||||
end
|
||||
end
|
||||
|
||||
local dock_intelligent_hide = gears.timer {
|
||||
timeout = 1,
|
||||
autostart = true,
|
||||
call_now = true,
|
||||
callback = function()
|
||||
check_for_dock_hide(screen)
|
||||
end
|
||||
}
|
||||
|
||||
fakedock:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
for _, c in ipairs(screen.clients) do
|
||||
if not c.fullscreen then
|
||||
dock_intelligent_hide:stop()
|
||||
dock.visible = true
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
client.connect_signal(
|
||||
"manage",
|
||||
function()
|
||||
check_for_dock_hide(screen)
|
||||
dock:setup {
|
||||
dock_elements,
|
||||
create_incicator_widget(programs),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
client.connect_signal(
|
||||
"property::minimized",
|
||||
function()
|
||||
check_for_dock_hide(screen)
|
||||
dock:setup {
|
||||
dock_elements,
|
||||
create_incicator_widget(programs),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
client.connect_signal(
|
||||
"unmanage",
|
||||
function()
|
||||
check_for_dock_hide(screen)
|
||||
dock:setup {
|
||||
dock_elements,
|
||||
create_incicator_widget(programs),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
client.connect_signal(
|
||||
"focus",
|
||||
function()
|
||||
check_for_dock_hide(screen)
|
||||
dock:setup {
|
||||
dock_elements,
|
||||
create_incicator_widget(programs),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
end
|
||||
)
|
||||
|
||||
dock:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
dock_intelligent_hide:stop()
|
||||
end
|
||||
)
|
||||
|
||||
dock:connect_signal(
|
||||
"mouse::leave",
|
||||
function()
|
||||
dock_intelligent_hide:again()
|
||||
end
|
||||
)
|
||||
|
||||
dock:setup {
|
||||
get_dock_elements(programs),
|
||||
create_incicator_widget(programs),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
end
|
||||
52
awesome/src/modules/crylia_bar/init.lua
Normal file
52
awesome/src/modules/crylia_bar/init.lua
Normal file
@@ -0,0 +1,52 @@
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
|
||||
return function(s)
|
||||
|
||||
-- Every Widget
|
||||
--[[
|
||||
If you are going to use a widget on a single screen only, put it inside the s.index == X where X is the screen number.
|
||||
This will lead to better performance and prevent widgets to be loaded but not used
|
||||
--]]
|
||||
s.audio = require("src.widgets.audio")(s)
|
||||
s.date = require("src.widgets.date")()
|
||||
s.clock = require("src.widgets.clock")()
|
||||
s.layoutlist = require("src.widgets.layout_list")()
|
||||
s.powerbutton = require("src.widgets.power")()
|
||||
s.kblayout = require("src.widgets.kblayout")(s)
|
||||
s.taglist = require("src.widgets.taglist")(s)
|
||||
s.tasklist = require("src.widgets.tasklist")(s)
|
||||
-- s.battery = require("src.widgets.battery")()
|
||||
-- s.bluetooth = require("src.widgets.bluetooth")()
|
||||
-- s.cpu_freq = require("src.widgets.cpu_info")("freq", "average")
|
||||
-- s.systray = require("src.widgets.systray")(s)
|
||||
-- s.cpu_usage = require("src.widgets.cpu_info")("usage")
|
||||
-- s.cpu_temp = require("src.widgets.cpu_info")("temp")
|
||||
-- s.gpu_usage = require("src.widgets.gpu_info")("usage")
|
||||
-- s.gpu_temp = require("src.widgets.gpu_info")("temp")
|
||||
-- s.network = require("src.widgets.network")()
|
||||
-- s.ram_info = require("src.widgets.ram_info")()
|
||||
|
||||
if s.index == 1 then
|
||||
s.systray = require("src.widgets.systray")(s)
|
||||
s.cpu_usage = require("src.widgets.cpu_info")("usage")
|
||||
s.cpu_temp = require("src.widgets.cpu_info")("temp")
|
||||
s.gpu_usage = require("src.widgets.gpu_info")("usage")
|
||||
s.gpu_temp = require("src.widgets.gpu_info")("temp")
|
||||
|
||||
require("src.modules.crylia_bar.left_bar")(s, { s.layoutlist, s.systray, s.taglist })
|
||||
require("src.modules.crylia_bar.center_bar")(s, { s.tasklist })
|
||||
require("src.modules.crylia_bar.right_bar")(s, { s.gpu_usage, s.gpu_temp, s.cpu_usage, s.cpu_temp, s.audio, s.kblayout, s.date, s.clock, s.powerbutton })
|
||||
require("src.modules.crylia_bar.dock")(s, user_vars.dock_programs)
|
||||
end
|
||||
|
||||
if s.index == 2 then
|
||||
s.network = require("src.widgets.network")()
|
||||
s.ram_info = require("src.widgets.ram_info")()
|
||||
|
||||
require("src.modules.crylia_bar.left_bar")(s, { s.layoutlist, s.taglist })
|
||||
require("src.modules.crylia_bar.center_bar")(s, { s.tasklist })
|
||||
require("src.modules.crylia_bar.right_bar")(s, { s.ram_info, s.audio, s.kblayout, s.network, s.date, s.clock, s.powerbutton })
|
||||
end
|
||||
end
|
||||
77
awesome/src/modules/crylia_bar/left_bar.lua
Normal file
77
awesome/src/modules/crylia_bar/left_bar.lua
Normal file
@@ -0,0 +1,77 @@
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
|
||||
return function(s, widgets)
|
||||
|
||||
local top_left = awful.popup {
|
||||
screen = s,
|
||||
widget = wibox.container.background,
|
||||
ontop = false,
|
||||
bg = color["Grey900"],
|
||||
visible = true,
|
||||
maximum_width = dpi(650),
|
||||
placement = function(c) awful.placement.top_left(c, { margins = dpi(10) }) end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
|
||||
top_left:struts {
|
||||
top = 55
|
||||
}
|
||||
|
||||
local function prepare_widgets(widgets)
|
||||
local layout = {
|
||||
forced_height = 45,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
for i, widget in pairs(widgets) do
|
||||
if i == 1 then
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(6),
|
||||
right = dpi(3),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
elseif i == #widgets then
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(3),
|
||||
right = dpi(6),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
else
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(3),
|
||||
right = dpi(3),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
end
|
||||
end
|
||||
return layout
|
||||
end
|
||||
|
||||
top_left:setup {
|
||||
prepare_widgets(widgets),
|
||||
nil,
|
||||
nil,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
end
|
||||
76
awesome/src/modules/crylia_bar/right_bar.lua
Normal file
76
awesome/src/modules/crylia_bar/right_bar.lua
Normal file
@@ -0,0 +1,76 @@
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
|
||||
return function(s, widgets)
|
||||
|
||||
local top_right = awful.popup {
|
||||
widget = wibox.container.background,
|
||||
ontop = false,
|
||||
bg = color["Grey900"],
|
||||
visible = true,
|
||||
screen = s,
|
||||
placement = function(c) awful.placement.top_right(c, { margins = dpi(10) }) end,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 5)
|
||||
end
|
||||
}
|
||||
|
||||
top_right:struts {
|
||||
top = 55
|
||||
}
|
||||
|
||||
local function prepare_widgets(widgets)
|
||||
local layout = {
|
||||
forced_height = 45,
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
for i, widget in pairs(widgets) do
|
||||
if i == 1 then
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(6),
|
||||
right = dpi(3),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
elseif i == #widgets then
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(3),
|
||||
right = dpi(6),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
else
|
||||
table.insert(layout,
|
||||
{
|
||||
widget,
|
||||
left = dpi(3),
|
||||
right = dpi(3),
|
||||
top = dpi(6),
|
||||
bottom = dpi(6),
|
||||
widget = wibox.container.margin
|
||||
})
|
||||
end
|
||||
end
|
||||
return layout
|
||||
end
|
||||
|
||||
top_right:setup {
|
||||
nil,
|
||||
nil,
|
||||
prepare_widgets(widgets),
|
||||
layout = wibox.layout.align.horizontal
|
||||
}
|
||||
end
|
||||
28
awesome/src/modules/init.lua
Normal file
28
awesome/src/modules/init.lua
Normal file
@@ -0,0 +1,28 @@
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- This is the statusbar, every widget, module and so on is combined to all the stuff you see on the screen --
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
|
||||
awful.screen.connect_for_each_screen(
|
||||
-- For each screen this function is called once
|
||||
-- If you want to change the modules per screen use the indices
|
||||
-- e.g. 1 would be the primary screen and 2 the secondary screen.
|
||||
function(s)
|
||||
-- Create 9 tags
|
||||
awful.layout.layouts = user_vars.layouts
|
||||
awful.tag(
|
||||
{ "1", "2", "3", "4", "5", "6", "7", "8", "9" },
|
||||
s,
|
||||
user_vars.layouts[1]
|
||||
)
|
||||
|
||||
require("src.modules.powermenu")(s)
|
||||
require("src.modules.volume_osd")(s)
|
||||
require("src.modules.brightness_osd")(s)
|
||||
require("src.modules.titlebar")
|
||||
require("src.modules.volume_controller")(s)
|
||||
require("src.modules.crylia_bar.init")(s)
|
||||
require("src.modules.notification-center.init")(s)
|
||||
end
|
||||
)
|
||||
@@ -0,0 +1,371 @@
|
||||
-------------------------------------
|
||||
-- This is the notification-center --
|
||||
-------------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/notifications/"
|
||||
|
||||
return function(s)
|
||||
|
||||
--#region Activation area
|
||||
|
||||
local activation_area = awful.popup {
|
||||
bg = '#00000000',
|
||||
widget = wibox.container.background,
|
||||
ontop = true,
|
||||
screen = s,
|
||||
type = 'dock',
|
||||
placement = function(c)
|
||||
awful.placement.top(c)
|
||||
end,
|
||||
}
|
||||
|
||||
activation_area:setup({
|
||||
widget = wibox.container.background,
|
||||
forced_height = dpi(1),
|
||||
forced_width = dpi(300),
|
||||
bg = '#00000000',
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
})
|
||||
|
||||
--#endregion
|
||||
|
||||
--#region Widgets
|
||||
local nl = require("src.modules.notification-center.notification_list").notification_list
|
||||
local music_widget = require("src.modules.notification-center.song_info")()
|
||||
local time_date = require("src.modules.notification-center.time_date")()
|
||||
local weather_widget = require("src.modules.notification-center.weather")()
|
||||
local profile_widget = require("src.modules.notification-center.profile")()
|
||||
local status_bars_widget = require("src.modules.notification-center.status_bars")()
|
||||
--#endregion
|
||||
|
||||
--#region Notification buttons
|
||||
local clear_all_widget = wibox.widget { -- Clear all button
|
||||
{
|
||||
{
|
||||
{
|
||||
text = "Clear",
|
||||
valign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "clearall"
|
||||
},
|
||||
id = "background4",
|
||||
fg = color["Grey900"],
|
||||
bg = color["Blue200"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 12)
|
||||
end,
|
||||
forced_width = dpi(80),
|
||||
forced_height = dpi(40),
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "margin3",
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "place",
|
||||
widget = wibox.container.place,
|
||||
valign = "bottom",
|
||||
halign = "right",
|
||||
}
|
||||
|
||||
local left_button = wibox.widget {
|
||||
{
|
||||
{
|
||||
widget = wibox.container.background,
|
||||
bg = color["Grey700"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end,
|
||||
forced_height = dpi(30),
|
||||
forced_width = dpi(30),
|
||||
id = "circle"
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
id = "margin"
|
||||
},
|
||||
visible = true,
|
||||
valign = "center",
|
||||
halign = "left",
|
||||
widget = wibox.container.place,
|
||||
}
|
||||
|
||||
local right_button = wibox.widget {
|
||||
{
|
||||
{
|
||||
widget = wibox.container.background,
|
||||
bg = color["Purple200"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end,
|
||||
forced_height = dpi(30),
|
||||
forced_width = dpi(30),
|
||||
id = "circle"
|
||||
},
|
||||
left = dpi(5),
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin,
|
||||
id = "margin"
|
||||
},
|
||||
valign = "center",
|
||||
halign = "right",
|
||||
visible = false,
|
||||
widget = wibox.container.place,
|
||||
}
|
||||
|
||||
local toggle_button = wibox.widget {
|
||||
{
|
||||
left_button,
|
||||
right_button,
|
||||
widget = wibox.layout.flex.horizontal
|
||||
},
|
||||
active = false,
|
||||
widget = wibox.container.background,
|
||||
bg = color["Grey900"],
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(2),
|
||||
forced_height = dpi(40),
|
||||
forced_width = dpi(80),
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(10))
|
||||
end,
|
||||
}
|
||||
|
||||
toggle_button:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
if toggle_button.active then
|
||||
left_button.visible = true
|
||||
right_button.visible = false
|
||||
toggle_button.active = not toggle_button.active
|
||||
toggle_button.border_color = color["Grey800"]
|
||||
user_vars.dnd = false
|
||||
else
|
||||
left_button.visible = false
|
||||
right_button.visible = true
|
||||
toggle_button.active = not toggle_button.active
|
||||
toggle_button.border_color = color["Purple200"]
|
||||
user_vars.dnd = true
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
local dnd = wibox.widget { -- Clear all button
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
text = "Do Not Disturb",
|
||||
valign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "clearall"
|
||||
},
|
||||
toggle_button,
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
id = "layout12"
|
||||
},
|
||||
id = "background4",
|
||||
fg = color["Pink200"],
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 12)
|
||||
end,
|
||||
forced_height = dpi(40),
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "margin3",
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "place",
|
||||
widget = wibox.container.place,
|
||||
valign = "bottom",
|
||||
halign = "right",
|
||||
}
|
||||
|
||||
-- TODO: Add rubato animation. For this the widget needs to be rewritten to use a single moving square
|
||||
local no_notification_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
resize = true,
|
||||
forced_height = dpi(200),
|
||||
forced_width = dpi(200),
|
||||
image = icondir .. "megamind.svg",
|
||||
widget = wibox.widget.imagebox,
|
||||
id = "icon"
|
||||
},
|
||||
{
|
||||
id = "txt",
|
||||
markup = "<span color='#414141' font='JetBrainsMono Nerd Font, ExtraBold 20'>No Notifications?</span>",
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
id = "lay",
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
widget = wibox.container.place
|
||||
}
|
||||
|
||||
--#endregion
|
||||
|
||||
--#region Notification center
|
||||
local notification_center = awful.popup {
|
||||
widget = wibox.container.background,
|
||||
bg = color["Grey900"],
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(4),
|
||||
placement = function(c)
|
||||
awful.placement.top(c, { margins = dpi(10) })
|
||||
end,
|
||||
ontop = true,
|
||||
screen = s,
|
||||
visible = false,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 12)
|
||||
end,
|
||||
}
|
||||
|
||||
-- TODO: Currently awesome doesn't come with a scroll container, there is a PR(#3309) and once its merged we can use it
|
||||
local function notification_center_setup()
|
||||
notification_center:setup({
|
||||
widget = notification_center,
|
||||
-- Custom widgets
|
||||
{
|
||||
time_date,
|
||||
require("src.modules.notification-center.spacingline_widget")(),
|
||||
{
|
||||
{
|
||||
weather_widget,
|
||||
{
|
||||
profile_widget,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
status_bars_widget,
|
||||
music_widget,
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
-- Notification list
|
||||
{
|
||||
{
|
||||
{
|
||||
nl,
|
||||
height = dpi(680),
|
||||
strategy = "max",
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
{
|
||||
no_notification_widget,
|
||||
strategy = "max",
|
||||
height = dpi(400),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
{
|
||||
dnd,
|
||||
nil,
|
||||
clear_all_widget,
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
id = "layout5",
|
||||
layout = wibox.layout.align.vertical
|
||||
},
|
||||
id = "margin6",
|
||||
margins = dpi(20),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "yes",
|
||||
spacing_widget = {
|
||||
{
|
||||
fg = color["Grey800"],
|
||||
bg = color["Grey800"],
|
||||
widget = wibox.container.background
|
||||
},
|
||||
top = dpi(40),
|
||||
bottom = dpi(40),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
spacing = dpi(1),
|
||||
forced_height = dpi(800),
|
||||
forced_width = dpi(1000),
|
||||
layout = wibox.layout.flex.horizontal
|
||||
})
|
||||
end
|
||||
|
||||
--#endregion
|
||||
|
||||
--#region Signals
|
||||
-- Toggle notification_center visibility when mouse is over activation_area
|
||||
activation_area:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
notification_center.visible = true
|
||||
notification_center_setup()
|
||||
end
|
||||
)
|
||||
|
||||
-- Update the notification center popup and check if there are no notifications
|
||||
awesome.connect_signal(
|
||||
"notification_center:update::needed",
|
||||
function()
|
||||
if #nl == 0 then
|
||||
math.randomseed(os.time())
|
||||
local prob = math.random(1, 10)
|
||||
|
||||
if (prob == 5) or (prob == 6) then
|
||||
no_notification_widget.lay.icon.image = icondir .. "megamind.svg"
|
||||
no_notification_widget.lay.txt.markup = "<span color='#414141' font='JetBrainsMono Nerd Font, ExtraBold 20'>No Notifications?</span>"
|
||||
else
|
||||
no_notification_widget.lay.icon.image = icondir .. "bell-outline.svg"
|
||||
no_notification_widget.lay.txt.markup = "<span color='#414141' font='JetBrainsMono Nerd Font, ExtraBold 20'>No Notification</span>"
|
||||
end
|
||||
no_notification_widget.visible = true
|
||||
else
|
||||
no_notification_widget.visible = false
|
||||
end
|
||||
notification_center_setup()
|
||||
end
|
||||
)
|
||||
|
||||
-- Hide notification_center when mouse leaves it
|
||||
notification_center:connect_signal(
|
||||
"mouse::leave",
|
||||
function()
|
||||
notification_center.visible = false
|
||||
end
|
||||
)
|
||||
|
||||
-- Clear all notifications on button press
|
||||
clear_all_widget:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
local size = #nl
|
||||
for i = 0, size do
|
||||
nl[i] = nil
|
||||
end
|
||||
awesome.emit_signal("notification_center:update::needed")
|
||||
end
|
||||
)
|
||||
|
||||
Hover_signal(clear_all_widget, color["Blue200"], color["Grey900"])
|
||||
--#endregion
|
||||
|
||||
end
|
||||
|
||||
261
awesome/src/modules/notification-center/notification_list.lua
Normal file
261
awesome/src/modules/notification-center/notification_list.lua
Normal file
@@ -0,0 +1,261 @@
|
||||
-------------------------------------
|
||||
-- This is the notification-center --
|
||||
-------------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
local naughty = require("naughty")
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/notifications/"
|
||||
|
||||
local nl = {}
|
||||
|
||||
nl.notification_list = { layout = wibox.layout.fixed.vertical, spacing = dpi(20) }
|
||||
|
||||
-- @param {table} notification
|
||||
-- @return {widget} notifications_list
|
||||
function nl.create_notification(n)
|
||||
|
||||
n.time = os.time()
|
||||
|
||||
local time_ago_text = "- ago"
|
||||
|
||||
local timer_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
text = time_ago_text,
|
||||
widget = wibox.widget.textbox,
|
||||
id = "txt"
|
||||
},
|
||||
id = "background",
|
||||
fg = color["Teal200"],
|
||||
widget = wibox.container.background
|
||||
},
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin,
|
||||
}
|
||||
|
||||
gears.timer {
|
||||
timeout = 1,
|
||||
autostart = true,
|
||||
call_now = true,
|
||||
callback = function()
|
||||
local time_ago = math.floor(os.time() - n.time)
|
||||
local timer_text = timer_widget.background.txt
|
||||
if time_ago < 5 then
|
||||
timer_text:set_text("now")
|
||||
elseif time_ago < 60 then
|
||||
timer_text:set_text(time_ago .. "s ago")
|
||||
elseif time_ago < 3600 then
|
||||
timer_text:set_text(math.floor(time_ago / 60) .. "m ago")
|
||||
elseif time_ago < 86400 then
|
||||
timer_text:set_text(math.floor(time_ago / 3600) .. "h ago")
|
||||
else
|
||||
timer_text:set_text(math.floor(time_ago / 86400) .. "d ago")
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
local close_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
font = user_vars.font.specify .. ", 10",
|
||||
text = "✕",
|
||||
align = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
start_angle = 4.71239,
|
||||
thickness = dpi(2),
|
||||
min_value = 0,
|
||||
max_value = 360,
|
||||
value = 360,
|
||||
widget = wibox.container.arcchart,
|
||||
id = "arc_chart"
|
||||
},
|
||||
id = "background",
|
||||
fg = color["Teal200"],
|
||||
widget = wibox.container.background
|
||||
},
|
||||
strategy = "exact",
|
||||
width = dpi(20),
|
||||
height = dpi(20),
|
||||
widget = wibox.container.constraint,
|
||||
id = "const"
|
||||
},
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin,
|
||||
id = "arc_margin"
|
||||
}
|
||||
|
||||
local timer_close_widget = timer_widget
|
||||
|
||||
local notification = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
image = gears.color.recolor_image(icondir .. "notification-outline.svg", color["Teal200"]),
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
right = dpi(5),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
{
|
||||
markup = n.app_name or 'System Notification',
|
||||
align = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
fg = color["Teal200"],
|
||||
widget = wibox.container.background
|
||||
},
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
nil,
|
||||
{
|
||||
timer_widget,
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
id = "arc_app_layout_2"
|
||||
},
|
||||
id = "arc_app_layout",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
id = "arc_app_bg",
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(2),
|
||||
widget = wibox.container.background
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
image = n.icon,
|
||||
resize = true,
|
||||
widget = wibox.widget.imagebox,
|
||||
clip_shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 10)
|
||||
end
|
||||
},
|
||||
width = naughty.config.defaults.icon_size,
|
||||
height = naughty.config.defaults.icon_size,
|
||||
strategy = "exact",
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
halign = "center",
|
||||
valign = "top",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "margin01",
|
||||
left = dpi(20),
|
||||
bottom = dpi(15),
|
||||
top = dpi(15),
|
||||
right = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
markup = n.title,
|
||||
widget = wibox.widget.textbox,
|
||||
align = "left"
|
||||
},
|
||||
{
|
||||
markup = n.message,
|
||||
widget = wibox.widget.textbox,
|
||||
align = "left"
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
left = dpi(10),
|
||||
bottom = dpi(10),
|
||||
top = dpi(10),
|
||||
right = dpi(20),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
id = "widget_layout",
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
id = "min_size",
|
||||
strategy = "min",
|
||||
width = dpi(100),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "max_size",
|
||||
strategy = "max",
|
||||
width = Theme.notification_max_width or dpi(500),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
pk = #nl.notification_list + 1,
|
||||
bg = color["Grey900"],
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(4),
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, 8)
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
|
||||
close_widget:connect_signal(
|
||||
"button::press",
|
||||
function(_, _, _, button)
|
||||
if button == 1 then
|
||||
for i, b in pairs(nl.notification_list) do
|
||||
if b.pk == notification.pk then
|
||||
table.remove(nl.notification_list, i)
|
||||
awesome.emit_signal("notification_center:update::needed")
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Hover_signal(close_widget.const.background, color["Grey900"], color["Teal200"])
|
||||
|
||||
notification:connect_signal(
|
||||
"mouse::enter",
|
||||
function()
|
||||
notification:get_children_by_id("arc_app_layout_2")[1]:set(1, close_widget)
|
||||
end
|
||||
)
|
||||
|
||||
notification:connect_signal(
|
||||
"mouse::leave",
|
||||
function()
|
||||
notification:get_children_by_id("arc_app_layout_2")[1]:set(1, timer_close_widget)
|
||||
end
|
||||
)
|
||||
|
||||
table.insert(nl.notification_list, notification)
|
||||
end
|
||||
|
||||
naughty.connect_signal(
|
||||
"request::display",
|
||||
function(n)
|
||||
nl.create_notification(n)
|
||||
awesome.emit_signal("notification_center:update::needed")
|
||||
end
|
||||
)
|
||||
|
||||
return nl
|
||||
207
awesome/src/modules/notification-center/profile.lua
Normal file
207
awesome/src/modules/notification-center/profile.lua
Normal file
@@ -0,0 +1,207 @@
|
||||
--------------------------------
|
||||
-- This is the profile widget --
|
||||
--------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/profile/"
|
||||
|
||||
return function()
|
||||
|
||||
local profile_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
image = gears.surface.load_uncached(awful.util.getdir("config") .. "src/assets/userpfp/crylia.png"),
|
||||
id = "icon",
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
clip_shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(12))
|
||||
end,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
strategy = "exact",
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "icon_margin",
|
||||
margins = dpi(20),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{ -- Username
|
||||
id = "username_prefix",
|
||||
image = gears.color.recolor_image(icondir .. "user.svg", color["Blue200"]),
|
||||
valign = "center",
|
||||
halign = "left",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
{ -- Username
|
||||
id = "username",
|
||||
valign = "center",
|
||||
align = "left",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "os_prefix",
|
||||
image = gears.color.recolor_image(icondir .. "laptop.svg", color["Blue200"]),
|
||||
valign = "center",
|
||||
halign = "left",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
{ -- OS
|
||||
id = "os",
|
||||
valign = "center",
|
||||
align = "left",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "kernel_prefix",
|
||||
image = gears.color.recolor_image(icondir .. "penguin.svg", color["Blue200"]),
|
||||
valign = "center",
|
||||
halign = "left",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
{ -- Kernel
|
||||
id = "kernel",
|
||||
valign = "center",
|
||||
align = "left",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
{
|
||||
{
|
||||
id = "uptime_prefix",
|
||||
image = gears.color.recolor_image(icondir .. "clock.svg", color["Blue200"]),
|
||||
valign = "center",
|
||||
halign = "left",
|
||||
resize = false,
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
{ -- Uptime
|
||||
id = "uptime",
|
||||
valign = "center",
|
||||
align = "left",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
spacing = dpi(10),
|
||||
id = "uptime_layout",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
spacing = dpi(5),
|
||||
id = "info_layout",
|
||||
layout = wibox.layout.flex.vertical
|
||||
},
|
||||
id = "text_margin",
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "text_container",
|
||||
bottom = dpi(20),
|
||||
left = dpi(20),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "text_container_wrapper",
|
||||
widget = wibox.layout.fixed.vertical
|
||||
},
|
||||
id = "wrapper",
|
||||
fg = color["Green200"],
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(4),
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "const",
|
||||
strategy = "exact",
|
||||
width = dpi(250),
|
||||
height = dpi(350),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
top = dpi(20),
|
||||
left = dpi(10),
|
||||
right = dpi(20),
|
||||
bottom = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
local function get_os_name_pretty()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"cat /etc/os-release | grep -w NAME",
|
||||
function(stdout)
|
||||
profile_widget:get_children_by_id("os")[1].text = stdout:match("\"(.+)\"")
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
-- function to get and set the kernel version
|
||||
local function get_kernel_version()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"uname -r",
|
||||
function(stdout)
|
||||
profile_widget:get_children_by_id("kernel")[1].text = stdout:match("(%d+%.%d+%.%d+)")
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
--function to get the username and hostname
|
||||
local function get_user_hostname()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"echo $USER@$(hostname)",
|
||||
function(stdout)
|
||||
profile_widget:get_children_by_id("username")[1].text = stdout:gsub("\n", "") or ""
|
||||
end
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
-- function to fetch uptime async
|
||||
local function get_uptime()
|
||||
awful.spawn.easy_async_with_shell("uptime -p", function(stdout)
|
||||
|
||||
local hours = stdout:match("(%d+) hours") or 0
|
||||
local minutes = stdout:match("(%d+) minutes") or 0
|
||||
|
||||
profile_widget:get_children_by_id("uptime")[1].text = hours .. "h, " .. minutes .. "m"
|
||||
end)
|
||||
end
|
||||
|
||||
get_os_name_pretty()
|
||||
get_kernel_version()
|
||||
get_user_hostname()
|
||||
|
||||
gears.timer {
|
||||
timeout = 60,
|
||||
autostart = true,
|
||||
call_now = true,
|
||||
callback = get_uptime
|
||||
}
|
||||
|
||||
return profile_widget
|
||||
|
||||
end
|
||||
466
awesome/src/modules/notification-center/song_info.lua
Normal file
466
awesome/src/modules/notification-center/song_info.lua
Normal file
@@ -0,0 +1,466 @@
|
||||
---------------------------
|
||||
-- This is the song-info --
|
||||
---------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
local naughty = require("naughty")
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/notifications/"
|
||||
|
||||
return function(s)
|
||||
|
||||
--#region Music control button widgets
|
||||
|
||||
local function button_hover_effect(widget, svg, color, color2)
|
||||
local mouse_enter = function()
|
||||
widget.image = gears.surface.load_uncached(gears.color.recolor_image(icondir .. svg, color2))
|
||||
local w = mouse.current_wibox
|
||||
if w then
|
||||
w.cursor = "hand1"
|
||||
end
|
||||
end
|
||||
|
||||
local mouse_leave = function()
|
||||
widget.image = gears.surface.load_uncached(gears.color.recolor_image(icondir .. svg, color))
|
||||
mouse.cursor = "left_ptr"
|
||||
local w = mouse.current_wibox
|
||||
if w then
|
||||
w.cursor = "left_ptr"
|
||||
end
|
||||
end
|
||||
|
||||
widget:disconnect_signal("mouse::enter", mouse_enter)
|
||||
widget:connect_signal("mouse::enter", mouse_enter)
|
||||
widget:disconnect_signal("mouse::leave", mouse_leave)
|
||||
widget:connect_signal("mouse::leave", mouse_leave)
|
||||
end
|
||||
|
||||
local shuffle_button = wibox.widget {
|
||||
resize = false,
|
||||
image = gears.color.recolor_image(icondir .. "shuffle.svg", color["Grey800"]),
|
||||
widget = wibox.widget.imagebox,
|
||||
}
|
||||
|
||||
local function suffle_handler()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl shuffle",
|
||||
function(stdout)
|
||||
if stdout:match("On") then
|
||||
awful.spawn.with_shell("playerctl shuffle off")
|
||||
shuffle_button.image = gears.color.recolor_image(icondir .. "shuffle.svg", color["Grey800"])
|
||||
else
|
||||
awful.spawn.with_shell("playerctl shuffle on")
|
||||
shuffle_button.image = gears.color.recolor_image(icondir .. "shuffle.svg", color["Green200"])
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
local function update_shuffle()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl shuffle",
|
||||
function(stdout)
|
||||
if stdout:match("On") then
|
||||
shuffle_button.image = gears.color.recolor_image(icondir .. "shuffle.svg", color["Green200"])
|
||||
else
|
||||
shuffle_button.image = gears.color.recolor_image(icondir .. "shuffle.svg", color["Grey800"])
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
update_shuffle()
|
||||
|
||||
local repeat_button = wibox.widget {
|
||||
resize = false,
|
||||
image = gears.color.recolor_image(icondir .. "repeat.svg", color["Grey800"]),
|
||||
widget = wibox.widget.imagebox,
|
||||
id = "imagebox"
|
||||
}
|
||||
|
||||
-- On first time load set the correct loop
|
||||
local function update_loop()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl loop",
|
||||
function(stdout)
|
||||
local loop_mode = stdout:gsub("\n", "")
|
||||
if loop_mode == "Track" then
|
||||
repeat_button.image = gears.color.recolor_image(gears.surface.load_uncached(icondir .. "repeat-once.svg"), color["Green200"])
|
||||
elseif loop_mode == "None" then
|
||||
repeat_button.image = gears.color.recolor_image(gears.surface.load_uncached(icondir .. "repeat.svg"), color["Grey800"])
|
||||
elseif loop_mode == "Playlist" then
|
||||
repeat_button.image = gears.color.recolor_image(gears.surface.load_uncached(icondir .. "repeat.svg"), color["Green200"])
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
update_loop()
|
||||
-- Activate shuffle when button is clicked
|
||||
shuffle_button:buttons(gears.table.join(
|
||||
awful.button({}, 1, suffle_handler)))
|
||||
|
||||
local prev_button = wibox.widget {
|
||||
resize = false,
|
||||
image = gears.color.recolor_image(icondir .. "skip-prev.svg", color["Teal200"]),
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
-- Activate previous song when button is clicked
|
||||
prev_button:buttons(gears.table.join(
|
||||
awful.button({}, 1, function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl previous && sleep 1",
|
||||
function()
|
||||
update_loop()
|
||||
end
|
||||
)
|
||||
end)
|
||||
))
|
||||
|
||||
local pause_play_button = wibox.widget {
|
||||
resize = false,
|
||||
image = gears.color.recolor_image(icondir .. "play-pause.svg", color["Teal200"]),
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
-- Activate play/pause when button is clicked
|
||||
pause_play_button:buttons(gears.table.join(
|
||||
awful.button({}, 1, function()
|
||||
awful.spawn.with_shell("playerctl play-pause")
|
||||
end)
|
||||
))
|
||||
|
||||
local next_button = wibox.widget {
|
||||
resize = false,
|
||||
image = gears.color.recolor_image(icondir .. "skip-next.svg", color["Teal200"]),
|
||||
widget = wibox.widget.imagebox
|
||||
}
|
||||
|
||||
-- Activate next song when button is clicked
|
||||
next_button:buttons(gears.table.join(
|
||||
awful.button({}, 1, function()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl next && sleep 1",
|
||||
function()
|
||||
update_loop()
|
||||
end
|
||||
)
|
||||
end)
|
||||
))
|
||||
|
||||
--- This function updates the repeat button svg and changes the mode on click
|
||||
local function loop_handler()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl loop",
|
||||
function(stdout)
|
||||
local loop_mode = stdout:gsub("\n", "")
|
||||
if loop_mode == "None" then
|
||||
awful.spawn.with_shell("playerctl loop playlist")
|
||||
repeat_button.image = gears.color.recolor_image(gears.surface.load_uncached(icondir .. "repeat.svg"), color["Green200"])
|
||||
elseif loop_mode == "Playlist" then
|
||||
awful.spawn.with_shell("playerctl loop track")
|
||||
repeat_button.image = gears.color.recolor_image(gears.surface.load_uncached(icondir .. "repeat-once.svg"), color["Green200"])
|
||||
elseif loop_mode == "Track" then
|
||||
awful.spawn.with_shell("playerctl loop none")
|
||||
repeat_button.image = gears.color.recolor_image(gears.surface.load_uncached(icondir .. "repeat.svg"), color["Grey800"])
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
repeat_button:buttons(gears.table.join(awful.button({}, 1, loop_handler)))
|
||||
|
||||
button_hover_effect(prev_button, "skip-prev.svg", color["Teal200"], color["Teal300"])
|
||||
button_hover_effect(pause_play_button, "play-pause.svg", color["Teal200"], color["Teal300"])
|
||||
button_hover_effect(next_button, "skip-next.svg", color["Teal200"], color["Teal300"])
|
||||
|
||||
--#endregion
|
||||
|
||||
-- Main music widget
|
||||
local music_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{ -- Album art
|
||||
{
|
||||
image = "default image",
|
||||
resize = true,
|
||||
clip_shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end,
|
||||
widget = wibox.widget.imagebox,
|
||||
id = "imagebox"
|
||||
},
|
||||
width = dpi(80),
|
||||
height = dpi(80),
|
||||
strategy = "exact",
|
||||
widget = wibox.container.constraint,
|
||||
id = "const"
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{ --Title
|
||||
halign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "textbox4"
|
||||
},
|
||||
fg = color["Pink200"],
|
||||
id = "textbox5",
|
||||
widget = wibox.container.background
|
||||
},
|
||||
strategy = "max",
|
||||
width = dpi(400),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
id = "textbox_container4",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
{ --Artist
|
||||
halign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "textbox3"
|
||||
},
|
||||
fg = color["Teal200"],
|
||||
id = "background",
|
||||
widget = wibox.container.background
|
||||
},
|
||||
strategy = "max",
|
||||
width = dpi(400),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
id = "artist_container",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
{ --Buttons
|
||||
{
|
||||
{
|
||||
shuffle_button,
|
||||
prev_button,
|
||||
pause_play_button,
|
||||
next_button,
|
||||
repeat_button,
|
||||
spacing = dpi(15),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
id = "layout5"
|
||||
},
|
||||
halign = "center",
|
||||
widget = wibox.container.place,
|
||||
id = "place2"
|
||||
},
|
||||
widget = wibox.container.margin,
|
||||
id = "margin6"
|
||||
},
|
||||
layout = wibox.layout.flex.vertical,
|
||||
id = "layout4"
|
||||
},
|
||||
fill_space = true,
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
id = "layout3"
|
||||
},
|
||||
widget = wibox.container.margin,
|
||||
id = "margin5"
|
||||
},
|
||||
{ --Song Duration
|
||||
{
|
||||
{
|
||||
{
|
||||
markup = "0:00",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "textbox2"
|
||||
},
|
||||
fg = color["Lime200"],
|
||||
widget = wibox.container.background,
|
||||
id = "background3"
|
||||
},
|
||||
right = dpi(10),
|
||||
widget = wibox.container.margin,
|
||||
id = "margin4"
|
||||
},
|
||||
{ -- Progressbar
|
||||
{
|
||||
color = color["Purple200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(5),
|
||||
shape = function(cr, width)
|
||||
gears.shape.rounded_bar(cr, width, dpi(5))
|
||||
end,
|
||||
widget = wibox.widget.progressbar,
|
||||
id = "progressbar1"
|
||||
},
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
widget = wibox.container.place,
|
||||
id = "place1"
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
text = "00:00",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "text1"
|
||||
},
|
||||
id = "background2",
|
||||
fg = color["Lime200"],
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "margin3",
|
||||
left = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
id = "layout2",
|
||||
layout = wibox.layout.align.horizontal
|
||||
},
|
||||
id = "layout1",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
id = "margin2",
|
||||
widget = wibox.container.margin,
|
||||
margins = dpi(10)
|
||||
},
|
||||
id = "background1",
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(4),
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "margin1",
|
||||
widget = wibox.container.margin,
|
||||
top = dpi(10),
|
||||
bottom = dpi(20),
|
||||
left = dpi(20),
|
||||
right = dpi(20)
|
||||
}
|
||||
|
||||
-- Used to check if the music changed and if everthing should be updated
|
||||
local trackid = ""
|
||||
local artist = ""
|
||||
local title = ""
|
||||
|
||||
-- Function to get spotify title, artist, album, album_art, length and track_id
|
||||
local function get_spotify_metadata(skip_check)
|
||||
skip_check = skip_check or false
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl metadata",
|
||||
function(stdout)
|
||||
-- Only fetch info if the track changed or if the title/artist is empty
|
||||
if skip_check or (not stdout:match(trackid)) or (not stdout:match(artist)) or (not stdout:match(title)) then
|
||||
update_loop()
|
||||
update_shuffle()
|
||||
-- Get the song title
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl metadata xesam:title",
|
||||
function(stdout2)
|
||||
local tit = stdout2:gsub("\n", "")
|
||||
title = tit
|
||||
music_widget:get_children_by_id("textbox4")[1].text = tit
|
||||
end
|
||||
)
|
||||
|
||||
-- Get the song artist
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl metadata xesam:artist",
|
||||
function(stdout2)
|
||||
local art = stdout2:gsub("\n", "")
|
||||
artist = art
|
||||
music_widget:get_children_by_id("textbox3")[1].text = art
|
||||
end
|
||||
)
|
||||
|
||||
-- Get the song album image
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl metadata mpris:artUrl",
|
||||
function(album_art)
|
||||
local url = album_art:gsub("\n", "")
|
||||
awful.spawn.easy_async_with_shell(
|
||||
-- TODO: curl does not stdout and is returns before it finished. This causes the image to sometimes not show correctly.
|
||||
-- !Find a better solution than sleep 0.1
|
||||
-- Maybe cache the image? Not sure if that would be a waste of space or not.
|
||||
"curl -s " .. url .. " -o /tmp/album_art.jpg && echo /tmp/album_art.jpg && sleep 0.5",
|
||||
function()
|
||||
music_widget:get_children_by_id("imagebox")[1].image = gears.surface.load_uncached("/tmp/album_art.jpg")
|
||||
end
|
||||
)
|
||||
end
|
||||
)
|
||||
|
||||
-- Get the length of the song
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl metadata mpris:length",
|
||||
function(stdout2)
|
||||
local length = stdout2:gsub("\n", "")
|
||||
if length ~= "" then
|
||||
local length_formated = string.format("%02d:%02d", math.floor(tonumber(length or 1) / 60000000) or 0, (math.floor(tonumber(length or 1) / 1000000) % 60) or 0)
|
||||
music_widget:get_children_by_id("progressbar1")[1].max_value = tonumber(math.floor(tonumber(length) / 1000000))
|
||||
music_widget:get_children_by_id("text1")[1].markup = string.format("<span foreground='%s' font='JetBrainsMono Nerd Font, Bold 14'>%s</span>", color["Teal200"], length_formated)
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl metadata mpris:trackid",
|
||||
function(stdout2)
|
||||
trackid = stdout2:gsub("\n", "")
|
||||
end
|
||||
)
|
||||
-- Update track id
|
||||
trackid, artist, title = stdout, music_widget:get_children_by_id("textbox3")[1].text, music_widget:get_children_by_id("textbox4")[1].text
|
||||
end
|
||||
)
|
||||
-- Always update the current song progression
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"playerctl position",
|
||||
function(stdout)
|
||||
local time = stdout:gsub("\n", "")
|
||||
if time ~= "" then
|
||||
local time_formated = string.format("%02d:%02d", math.floor(tonumber(time or "1") / 60), math.floor(tonumber(time or "1")) % 60)
|
||||
music_widget:get_children_by_id("textbox2")[1].markup = string.format("<span foreground='%s' font='JetBrainsMono Nerd Font, Bold 14'>%s</span>", color["Teal200"], time_formated)
|
||||
music_widget:get_children_by_id("progressbar1")[1].value = tonumber(time)
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
-- Call every second, if performance is bad, set the timer to a higher value
|
||||
gears.timer {
|
||||
timeout = 1,
|
||||
autostart = true,
|
||||
call_now = true,
|
||||
callback = function()
|
||||
get_spotify_metadata()
|
||||
end
|
||||
}
|
||||
|
||||
-- get_spotify_metadata() on awesome reload
|
||||
awesome.connect_signal("startup", function()
|
||||
get_spotify_metadata(true)
|
||||
end)
|
||||
|
||||
return music_widget
|
||||
end
|
||||
@@ -0,0 +1,23 @@
|
||||
------------------------------------------------
|
||||
-- This is the spacing widget under the clock --
|
||||
------------------------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local wibox = require("wibox")
|
||||
|
||||
return function()
|
||||
|
||||
return wibox.widget {
|
||||
{
|
||||
forced_height = dpi(2),
|
||||
bg = color["Grey800"],
|
||||
widget = wibox.container.background
|
||||
},
|
||||
left = dpi(80),
|
||||
right = dpi(80),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
end
|
||||
712
awesome/src/modules/notification-center/status_bars.lua
Normal file
712
awesome/src/modules/notification-center/status_bars.lua
Normal file
@@ -0,0 +1,712 @@
|
||||
------------------------------------
|
||||
-- This is the status_bars widget --
|
||||
------------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
|
||||
local rubato = require("src.lib.rubato")
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/"
|
||||
|
||||
--- Signal bars widget for the notification-center
|
||||
---@return wibox.widget
|
||||
return function()
|
||||
|
||||
---Creates a layout with bar widgets based on the given table
|
||||
---@param widget_table string{}
|
||||
---@return table @{layout}
|
||||
local function create_bar_layout(widget_table)
|
||||
local bar_layout = { layout = wibox.layout.flex.horizontal, spacing = dpi(10) }
|
||||
|
||||
for _, widget in pairs(widget_table) do
|
||||
local w
|
||||
if widget == "cpu_usage" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Blue200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 0,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
image = gears.color.recolor_image(icondir .. "cpu/cpu.svg", color["Cyan200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox,
|
||||
id = "icon1",
|
||||
},
|
||||
id = "background3",
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "cpu_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::cpu_usage_widget",
|
||||
function(cpu_usage)
|
||||
w:get_children_by_id("progressbar1")[1].value = cpu_usage
|
||||
tooltip.text = "CPU Usage: " .. cpu_usage .. "%"
|
||||
rubato_timer.target = cpu_usage
|
||||
end
|
||||
)
|
||||
elseif widget == "cpu_temp" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Blue200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
id = "icon1",
|
||||
image = gears.color.recolor_image(icondir .. "cpu/thermometer.svg", color["Cyan200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
id = "background3",
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "cpu_temp_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::cpu_temp_widget",
|
||||
function(cpu_temp, cpu_temp_icon)
|
||||
w:get_children_by_id("progressbar1")[1].value = cpu_temp
|
||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(cpu_temp_icon, color["Blue200"])
|
||||
tooltip.text = "CPU Temp: " .. cpu_temp .. "°C"
|
||||
rubato_timer.target = cpu_temp
|
||||
end
|
||||
)
|
||||
elseif widget == "ram_usage" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Red200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
image = gears.color.recolor_image(icondir .. "cpu/ram.svg", color["Red200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "ram_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::ram_widget",
|
||||
function(ram_usage)
|
||||
w:get_children_by_id("progressbar1")[1].value = ram_usage
|
||||
tooltip.text = "RAM Usage: " .. ram_usage .. "%"
|
||||
rubato_timer.target = ram_usage
|
||||
end
|
||||
)
|
||||
elseif widget == "gpu_usage" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Green200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
image = gears.color.recolor_image(icondir .. "cpu/gpu.svg", color["Green200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "gpu_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::gpu_usage_widget",
|
||||
function(gpu_usage)
|
||||
w:get_children_by_id("progressbar1")[1].value = gpu_usage
|
||||
tooltip.text = "GPU Usage: " .. gpu_usage .. "%"
|
||||
rubato_timer.target = gpu_usage
|
||||
end
|
||||
)
|
||||
elseif widget == "gpu_temp" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Green200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
id = "icon1",
|
||||
image = gears.color.recolor_image(icondir .. "cpu/gpu.svg", color["Green200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
id = "background3",
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "gpu_temp_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::gpu_temp_widget",
|
||||
function(gpu_temp, gpu_temp_icon)
|
||||
w:get_children_by_id("progressbar1")[1].value = gpu_temp
|
||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(gpu_temp_icon, color["Green200"])
|
||||
tooltip.text = "GPU Temp: " .. gpu_temp .. "°C"
|
||||
rubato_timer.target = gpu_temp
|
||||
end
|
||||
)
|
||||
elseif widget == "volume" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Yellow200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
id = "icon1",
|
||||
image = gears.color.recolor_image(icondir .. "audio/volume-high.svg", color["Yellow200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
id = "background3",
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "volume_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::volume_widget",
|
||||
function(volume, volume_icon)
|
||||
w:get_children_by_id("progressbar1")[1].value = volume
|
||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(volume_icon, color["Yellow200"])
|
||||
tooltip.text = "Volume: " .. volume .. "%"
|
||||
rubato_timer.target = volume
|
||||
end
|
||||
)
|
||||
elseif widget == "microphone" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Purple200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
id = "icon1",
|
||||
image = gears.color.recolor_image(icondir .. "audio/microphone.svg", color["Purple200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
id = "background3",
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "microphone_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::microphone_widget",
|
||||
function(microphone, microphone_icon)
|
||||
w:get_children_by_id("progressbar1")[1].value = microphone
|
||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(microphone_icon, color["Purple200"])
|
||||
tooltip.text = "Microphone: " .. microphone .. "%"
|
||||
rubato_timer.target = microphone
|
||||
end
|
||||
)
|
||||
elseif widget == "backlight" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Pink200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
id = "icon1",
|
||||
image = gears.color.recolor_image(icondir .. "brightness/brightness-high.svg", color["Pink200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
id = "background3",
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "brightness_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::backlight_widget",
|
||||
function(backlight, backlight_icon)
|
||||
w:get_children_by_id("progressbar1")[1].value = backlight
|
||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(backlight_icon, color["Pink200"])
|
||||
tooltip.text = "Backlight: " .. backlight .. "%"
|
||||
rubato_timer.target = backlight
|
||||
end
|
||||
)
|
||||
elseif widget == "battery" then
|
||||
w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{ --Bar
|
||||
color = color["Purple200"],
|
||||
background_color = color["Grey800"],
|
||||
max_value = 100,
|
||||
value = 50,
|
||||
forced_height = dpi(8),
|
||||
shape = function(cr, width, heigth)
|
||||
gears.shape.rounded_bar(cr, dpi(58), dpi(8))
|
||||
end,
|
||||
id = "progressbar1",
|
||||
widget = wibox.widget.progressbar
|
||||
},
|
||||
id = "background1",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background2",
|
||||
forced_height = dpi(58), --120 Base size - (10+10) margin - (4+4) Border - 24 Icon - 10 spacing = 58
|
||||
forced_width = dpi(24),
|
||||
direction = "east",
|
||||
widget = wibox.container.rotate
|
||||
},
|
||||
{
|
||||
{ --Icon
|
||||
id = "icon1",
|
||||
image = gears.color.recolor_image(icondir .. "battery/battery.svg", color["Purple200"]),
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
id = "background3",
|
||||
height = dpi(24),
|
||||
width = dpi(24),
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
id = "battery_layout",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
|
||||
local bar = w:get_children_by_id("progressbar1")[1]
|
||||
|
||||
local rubato_timer = rubato.timed {
|
||||
duration = 1,
|
||||
pos = bar.value,
|
||||
easing = rubato.linear,
|
||||
subscribed = function(v)
|
||||
bar.value = v
|
||||
end
|
||||
}
|
||||
|
||||
local tooltip = awful.tooltip {
|
||||
objects = { w },
|
||||
mode = "inside",
|
||||
preferred_alignments = "middle",
|
||||
margins = dpi(10)
|
||||
}
|
||||
|
||||
awesome.connect_signal(
|
||||
"update::battery_widget",
|
||||
function(battery, battery_icon)
|
||||
w:get_children_by_id("progressbar1")[1].value = battery
|
||||
w:get_children_by_id("icon1")[1].image = gears.color.recolor_image(battery_icon, color["Purple200"])
|
||||
tooltip.text = "Battery: " .. battery .. "%"
|
||||
rubato_timer.target = battery
|
||||
end
|
||||
)
|
||||
end
|
||||
table.insert(bar_layout, w)
|
||||
end
|
||||
|
||||
return bar_layout
|
||||
end
|
||||
|
||||
local signal_bars = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
create_bar_layout({ "cpu_usage", "cpu_temp", "ram_usage", "battery", "microphone", "backlight", "volume", "gpu_temp", "gpu_usage" }),
|
||||
width = dpi(480),
|
||||
strategy = "exact",
|
||||
widget = wibox.container.constraint
|
||||
},
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
magins = dpi(10),
|
||||
layout = wibox.container.margin
|
||||
},
|
||||
forced_height = dpi(120),
|
||||
forced_width = dpi(500),
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(4),
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(10))
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
top = dpi(10),
|
||||
left = dpi(20),
|
||||
right = dpi(20),
|
||||
bottom = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
return signal_bars
|
||||
|
||||
end
|
||||
65
awesome/src/modules/notification-center/time_date.lua
Normal file
65
awesome/src/modules/notification-center/time_date.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
----------------------------------
|
||||
-- This is the time_date widget --
|
||||
----------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local wibox = require("wibox")
|
||||
|
||||
return function()
|
||||
|
||||
local time_date = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{ -- Time
|
||||
{
|
||||
id = "label",
|
||||
align = "center",
|
||||
valign = "center",
|
||||
format = "<span foreground='#18FFFF' font='JetBrainsMono Nerd Font, Bold 46'><b>%H:%M</b></span>",
|
||||
widget = wibox.widget.textclock
|
||||
},
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
{ -- Date and Day
|
||||
{ -- Date
|
||||
{
|
||||
id = "label",
|
||||
align = "left",
|
||||
valign = "bottom",
|
||||
format = "<span foreground='#69F0AE' font='JetBrainsMono Nerd Font, Regular 18'><b>%e</b></span><span foreground='#18FFFF' font='JetBrainsMono Nerd Font, Regular 18'><b> %b %Y</b></span>",
|
||||
widget = wibox.widget.textclock
|
||||
},
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
{ -- Day
|
||||
{
|
||||
id = "label",
|
||||
align = "left",
|
||||
valign = "top",
|
||||
format = "<span foreground='#69F0AE' font='JetBrainsMono Nerd Font, Bold 20'><b>%A</b></span>",
|
||||
widget = wibox.widget.textclock
|
||||
},
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
layout = wibox.layout.flex.vertical
|
||||
},
|
||||
spacing = dpi(20),
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background",
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "margin",
|
||||
margins = dpi(20),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
return time_date
|
||||
|
||||
end
|
||||
219
awesome/src/modules/notification-center/weather.lua
Normal file
219
awesome/src/modules/notification-center/weather.lua
Normal file
@@ -0,0 +1,219 @@
|
||||
--------------------------------
|
||||
-- This is the weather widget --
|
||||
--------------------------------
|
||||
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local color = require("src.theme.colors")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gears = require("gears")
|
||||
local wibox = require("wibox")
|
||||
local naughty = require("naughty")
|
||||
|
||||
local json_lua = require("src.lib.json-lua.json-lua")
|
||||
|
||||
-- Icon directory path
|
||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/weather/"
|
||||
|
||||
return function()
|
||||
|
||||
local api_secrets = {
|
||||
key = user_vars.weather_secrets.key,
|
||||
city_id = user_vars.weather_secrets.city_id,
|
||||
unit = user_vars.weather_secrets.unit
|
||||
}
|
||||
|
||||
local weather_widget = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{
|
||||
{ -- Icon
|
||||
valign = "center",
|
||||
align = "center",
|
||||
resize = true,
|
||||
forced_width = dpi(64),
|
||||
forced_height = dpi(64),
|
||||
widget = wibox.widget.imagebox,
|
||||
id = "icon"
|
||||
},
|
||||
id = "place2",
|
||||
valing = "center",
|
||||
halign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
{ -- Temperature
|
||||
text = "0°C",
|
||||
valign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
font = "JetBrains Mono Bold 24",
|
||||
id = "temp"
|
||||
},
|
||||
{ -- City, Country
|
||||
text = "City, Country",
|
||||
valign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "city_country",
|
||||
},
|
||||
{
|
||||
{ -- Description
|
||||
text = "Description",
|
||||
valign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "description"
|
||||
},
|
||||
fg = color["LightBlue200"],
|
||||
widget = wibox.container.background
|
||||
},
|
||||
{ -- line
|
||||
forced_height = dpi(4),
|
||||
forced_width = dpi(10),
|
||||
bg = color["Grey800"],
|
||||
widget = wibox.container.background,
|
||||
id = "line"
|
||||
},
|
||||
{
|
||||
{ -- Speed
|
||||
{
|
||||
image = gears.color.recolor_image(icondir .. "weather-windy.svg", color["OrangeA200"]),
|
||||
resize = true,
|
||||
forced_width = dpi(24),
|
||||
forced_height = dpi(24),
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
{
|
||||
text = "",
|
||||
valign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "speed"
|
||||
},
|
||||
spacing = dpi(10),
|
||||
id = "layout3",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
id = "place4",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
{
|
||||
{ -- Humidity
|
||||
{
|
||||
forced_width = dpi(24),
|
||||
forced_height = dpi(24),
|
||||
widget = wibox.widget.imagebox,
|
||||
image = gears.color.recolor_image(icondir .. "humidity.svg", color["OrangeA200"]),
|
||||
id = "humidity_icon"
|
||||
},
|
||||
{
|
||||
text = "",
|
||||
valign = "center",
|
||||
align = "center",
|
||||
widget = wibox.widget.textbox,
|
||||
id = "humidity"
|
||||
},
|
||||
spacing = dpi(10),
|
||||
id = "layoutHum",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "lyt",
|
||||
spacing = dpi(10),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
margins = dpi(20),
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
id = "center",
|
||||
halign = "center",
|
||||
valign = "center",
|
||||
widget = wibox.container.place
|
||||
},
|
||||
id = "background",
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(4),
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(12))
|
||||
end,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
id = "margin",
|
||||
top = dpi(20),
|
||||
left = dpi(20),
|
||||
right = dpi(10),
|
||||
bottom = dpi(10),
|
||||
forced_width = dpi(250),
|
||||
widget = wibox.container.margin
|
||||
}
|
||||
|
||||
local function fetch_weather_data()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"curl -sf 'http://api.openweathermap.org/data/2.5/weather?id=" .. api_secrets.city_id .. "&units=" .. api_secrets.unit .. "&appid=" .. api_secrets.key .. "'",
|
||||
function(stdout)
|
||||
if not stdout:match('error') then
|
||||
local weather_metadata = json_lua:decode(stdout)
|
||||
if weather_metadata then
|
||||
local temp = weather_metadata.main.temp
|
||||
local humidity = weather_metadata.main.humidity
|
||||
local city = weather_metadata.name
|
||||
local country = weather_metadata.sys.country
|
||||
local weather_icon = weather_metadata.weather[1].icon
|
||||
local description = weather_metadata.weather[1].description
|
||||
local speed = weather_metadata.wind.speed
|
||||
|
||||
local icon_table = {
|
||||
["01d"] = "weather-sunny",
|
||||
["01n"] = "weather-clear-night",
|
||||
["02d"] = "weather-partly-cloudy",
|
||||
["02n"] = "weather-night-partly-cloudy",
|
||||
["03d"] = "weather-cloudy",
|
||||
["03n"] = "weather-clouds-night",
|
||||
["04d"] = "weather-cloudy",
|
||||
["04n"] = "weather-cloudy",
|
||||
["09d"] = "weather-rainy",
|
||||
["09n"] = "weather-rainy",
|
||||
["10d"] = "weather-partly-rainy",
|
||||
["10n"] = "weather-partly-rainy",
|
||||
["11d"] = "weather-pouring",
|
||||
["11n"] = "weather-pouring",
|
||||
["13d"] = "weather-snowy",
|
||||
["13n"] = "weather-snowy",
|
||||
["50d"] = "weather-fog",
|
||||
["50n"] = "weather-fog"
|
||||
}
|
||||
|
||||
weather_widget:get_children_by_id("icon")[1].image = icondir .. icon_table[weather_icon] .. ".svg"
|
||||
weather_widget:get_children_by_id("temp")[1].text = math.floor(temp + 0.5) .. "°C"
|
||||
weather_widget:get_children_by_id("city_country")[1].text = city .. ", " .. country
|
||||
weather_widget:get_children_by_id("description")[1].text = description:sub(1, 1):upper() .. description:sub(2)
|
||||
weather_widget:get_children_by_id("line")[1].bg = color["Grey800"]
|
||||
weather_widget:get_children_by_id("speed")[1].text = speed .. " m/s"
|
||||
weather_widget:get_children_by_id("humidity")[1].text = humidity .. "%"
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
fetch_weather_data()
|
||||
|
||||
gears.timer {
|
||||
timeout = 900,
|
||||
autostart = true,
|
||||
callback = function()
|
||||
fetch_weather_data()
|
||||
end
|
||||
}
|
||||
|
||||
return weather_widget
|
||||
|
||||
end
|
||||
@@ -706,10 +706,18 @@ return function(s)
|
||||
stdout = function(line)
|
||||
get_input_devices()
|
||||
get_source_devices()
|
||||
awful.spawn.with_shell("pkill pactl && pkill grep")
|
||||
end
|
||||
}
|
||||
)
|
||||
|
||||
awesome.connect_signal(
|
||||
"exit",
|
||||
function()
|
||||
awful.spawn.with_shell("pkill pactl && pkill grep")
|
||||
end
|
||||
)
|
||||
|
||||
-- Get microphone volume
|
||||
local function get_mic_volume()
|
||||
awful.spawn.easy_async_with_shell(
|
||||
@@ -834,8 +842,10 @@ return function(s)
|
||||
function(volume)
|
||||
if volume > 0 then
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "microphone.svg", color["LightBlue200"]))
|
||||
awesome.emit_signal("update::microphone_widget", tonumber(volume), icondir .. "microphone.svg")
|
||||
else
|
||||
volume_controller:get_children_by_id("mic_volume_margin")[1].mic_volume.icon:set_image(gears.color.recolor_image(icondir .. "microphone-off.svg", color["LightBlue200"]))
|
||||
awesome.emit_signal("update::microphone_widget", tonumber(volume), icondir .. "microphone-off.svg")
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user