moved to personal fennel config for awesome and added qutebrowser

This commit is contained in:
Chris Cochrun 2020-10-13 17:35:26 -05:00
parent 403cb92b7d
commit 688748f8a6
502 changed files with 8576 additions and 9597 deletions

View file

@ -0,0 +1,65 @@
-- This returns the "Wow, such empty." message.
local wibox = require('wibox')
local dpi = require('beautiful').xresources.apply_dpi
local config_dir = require('gears').filesystem.get_configuration_dir()
local widget_icon_dir = config_dir .. 'widget/notif-center/icons/'
local empty_notifbox = wibox.widget {
{
layout = wibox.layout.fixed.vertical,
spacing = dpi(5),
{
expand = 'none',
layout = wibox.layout.align.horizontal,
nil,
{
image = widget_icon_dir .. 'empty-notification' .. '.svg',
resize = true,
forced_height = dpi(35),
forced_width = dpi(35),
widget = wibox.widget.imagebox,
},
nil
},
{
text = 'Wow, such empty.',
font = 'SF Pro Text Bold 14',
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
},
{
text = 'Come back later.',
font = 'SF Pro Text Regular 10',
align = 'center',
valign = 'center',
widget = wibox.widget.textbox
},
},
margins = dpi(20),
widget = wibox.container.margin
}
local separator_for_empty_msg = wibox.widget
{
orientation = 'vertical',
opacity = 0.0,
widget = wibox.widget.separator
}
-- Make empty_notifbox center
local centered_empty_notifbox = wibox.widget {
expand = 'none',
layout = wibox.layout.align.vertical,
separator_for_empty_msg,
empty_notifbox,
separator_for_empty_msg
}
return centered_empty_notifbox

View file

@ -0,0 +1,80 @@
local wibox = require('wibox')
local awful = require('awful')
local gears = require('gears')
local naughty = require('naughty')
local beautiful = require('beautiful')
local dpi = beautiful.xresources.apply_dpi
local config_dir = gears.filesystem.get_configuration_dir()
local widget_icon_dir = config_dir .. 'widget/notif-center/icons/'
local empty_notifbox = require('widget.notif-center.build-notifbox.empty-notifbox')
local notifbox_scroller = require('widget.notif-center.build-notifbox.notifbox-scroller')
local notif_core = {}
notif_core.remove_notifbox_empty = true
notif_core.notifbox_layout = wibox.widget {
layout = wibox.layout.fixed.vertical,
spacing = dpi(5),
empty_notifbox
}
notifbox_scroller(notif_core.notifbox_layout)
notif_core.reset_notifbox_layout = function()
notif_core.notifbox_layout:reset()
notif_core.notifbox_layout:insert(1, empty_notifbox)
notif_core.remove_notifbox_empty = true
end
local notifbox_add = function(n, notif_icon, notifbox_color)
if #notif_core.notifbox_layout.children == 1 and notif_core.remove_notifbox_empty then
notif_core.notifbox_layout:reset(notif_core.notifbox_layout)
notif_core.remove_notifbox_empty = false
end
local notifbox_box = require('widget.notif-center.build-notifbox.notifbox-builder')
notif_core.notifbox_layout:insert(
1,
notifbox_box(
n,
notif_icon,
n.title,
n.message,
n.app_name,
notifbox_color
)
)
end
local notifbox_add_expired = function(n, notif_icon, notifbox_color)
n:connect_signal(
'destroyed',
function(self, reason, keep_visble)
if reason == 1 then
notifbox_add(n, notif_icon, notifbox_color)
end
end
)
end
naughty.connect_signal(
"request::display",
function(n)
local notifbox_color = beautiful.groups_bg
if n.urgency == 'critical' then
notifbox_color = n.bg .. '66'
end
local notif_icon = n.icon or n.app_icon
if not notif_icon then
notif_icon = widget_icon_dir .. 'new-notif' .. '.svg'
end
notifbox_add_expired(n, notif_icon, notifbox_color)
end
)
return notif_core

View file

@ -0,0 +1,177 @@
local wibox = require('wibox')
local awful = require('awful')
local gears = require('gears')
local beautiful = require('beautiful')
local dpi = beautiful.xresources.apply_dpi
local builder = require('widget.notif-center.build-notifbox.notifbox-ui-elements')
local notifbox_core = require('widget.notif-center.build-notifbox')
local notifbox_layout = notifbox_core.notifbox_layout
local remove_notifbox_empty = notifbox_core.remove_notifbox_empty
local reset_notifbox_layout = notifbox_core.reset_notifbox_layout
local return_date_time = function(format)
return os.date(format)
end
local parse_to_seconds = function(time)
local hourInSec = tonumber(string.sub(time, 1, 2)) * 3600
local minInSec = tonumber(string.sub(time, 4, 5)) * 60
local getSec = tonumber(string.sub(time, 7, 8))
return (hourInSec + minInSec + getSec)
end
notifbox_box = function(notif, icon, title, message, app, bgcolor)
local time_of_pop = return_date_time('%H:%M:%S')
local exact_time = return_date_time('%I:%M %p')
local exact_date_time = return_date_time('%b %d, %I:%M %p')
local notifbox_timepop = wibox.widget {
id = 'time_pop',
markup = nil,
font = 'SF Pro Text Regular 10',
align = 'left',
valign = 'center',
visible = true,
widget = wibox.widget.textbox
}
local notifbox_dismiss = builder.notifbox_dismiss()
local time_of_popup = gears.timer {
timeout = 60,
call_now = true,
autostart = true,
callback = function()
local time_difference = nil
time_difference = parse_to_seconds(return_date_time('%H:%M:%S')) - parse_to_seconds(time_of_pop)
time_difference = tonumber(time_difference)
if time_difference < 60 then
notifbox_timepop:set_markup('now')
elseif time_difference >= 60 and time_difference < 3600 then
local time_in_minutes = math.floor(time_difference / 60)
notifbox_timepop:set_markup(time_in_minutes .. 'm ago')
elseif time_difference >= 3600 and time_difference < 86400 then
notifbox_timepop:set_markup(exact_time)
elseif time_difference >= 86400 then
notifbox_timepop:set_markup(exact_date_time)
return false
end
collectgarbage('collect')
end
}
local notifbox_template = wibox.widget {
id = 'notifbox_template',
expand = 'none',
{
{
layout = wibox.layout.fixed.vertical,
spacing = dpi(5),
{
expand = 'none',
layout = wibox.layout.align.horizontal,
{
layout = wibox.layout.fixed.horizontal,
spacing = dpi(5),
builder.notifbox_icon(icon),
builder.notifbox_appname(app),
},
nil,
{
notifbox_timepop,
notifbox_dismiss,
layout = wibox.layout.fixed.horizontal
}
},
{
layout = wibox.layout.fixed.vertical,
spacing = dpi(5),
{
builder.notifbox_title(title),
builder.notifbox_message(message),
layout = wibox.layout.fixed.vertical
},
builder.notifbox_actions(notif),
},
},
margins = dpi(10),
widget = wibox.container.margin
},
bg = bgcolor,
shape = function(cr, width, height)
gears.shape.partially_rounded_rect(cr, width, height, true, true, true, true, beautiful.groups_radius)
end,
widget = wibox.container.background,
}
-- Put the generated template to a container
local notifbox = wibox.widget {
notifbox_template,
shape = function(cr, width, height)
gears.shape.partially_rounded_rect(cr, width, height, true, true, true, true, beautiful.groups_radius)
end,
widget = wibox.container.background
}
-- Delete notification box
local notifbox_delete = function()
notifbox_layout:remove_widgets(notifbox, true)
end
-- Delete notifbox on LMB
notifbox:buttons(
awful.util.table.join(
awful.button(
{},
1,
function()
if #notifbox_layout.children == 1 then
reset_notifbox_layout()
else
notifbox_delete()
end
collectgarbage('collect')
end
)
)
)
-- Add hover, and mouse leave events
notifbox_template:connect_signal(
"mouse::enter",
function()
notifbox.bg = beautiful.groups_bg
notifbox_timepop.visible = false
notifbox_dismiss.visible = true
end
)
notifbox_template:connect_signal(
"mouse::leave",
function()
notifbox.bg = beautiful.tranparent
notifbox_timepop.visible = true
notifbox_dismiss.visible = false
end
)
collectgarbage('collect')
return notifbox
end
return notifbox_box

View file

@ -0,0 +1,33 @@
local wibox = require('wibox')
local awful = require('awful')
local naughty = require('naughty')
local find_widget_in_wibox = function(wb, widget)
local function find_widget_in_hierarchy(h, widget)
if h:get_widget() == widget then
return h
end
local result
for _, ch in ipairs(h:get_children()) do
result = result or find_widget_in_hierarchy(ch, widget)
end
return result
end
local h = wb._drawable._widget_hierarchy
return h and find_widget_in_hierarchy(h, widget)
end
local focused = awful.screen.focused()
local h = find_widget_in_wibox(focused.top_panel, focused.music)
local x, y, width, height = h:get_matrix_to_device():transform_rectangle(0, 0, h:get_size())
-- local geo = focused.mywibox:geometry()
-- x, y = x + geo.x, y + geo.y
-- print(string.format("The widget is inside of the rectangle (%d, %d, %d, %d) on the screen", x, y, width, height)
naughty.notification({message=tostring(height)})

View file

@ -0,0 +1,37 @@
local awful = require('awful')
local gears = require('gears')
local add_button_event = function(widget)
widget:buttons(
gears.table.join(
awful.button(
{},
4,
nil,
function()
if #widget.children == 1 then
return
end
widget:insert(1, widget.children[#widget.children])
widget:remove(#widget.children)
end
),
awful.button(
{},
5,
nil,
function()
if #widget.children == 1 then
return
end
widget:insert(#widget.children + 1, widget.children[1])
widget:remove(1)
end
)
)
)
end
return add_button_event

View file

@ -0,0 +1,136 @@
local wibox = require('wibox')
local beautiful = require('beautiful')
local naughty = require('naughty')
local gears = require('gears')
local dpi = beautiful.xresources.apply_dpi
local config_dir = gears.filesystem.get_configuration_dir()
local widget_icon_dir = config_dir .. 'widget/notif-center/icons/'
local clickable_container = require('widget.clickable-container')
local ui_noti_builder = {}
-- Notification icon container
ui_noti_builder.notifbox_icon = function(ico_image)
local noti_icon = wibox.widget {
{
id = 'icon',
resize = true,
forced_height = dpi(25),
forced_width = dpi(25),
widget = wibox.widget.imagebox
},
layout = wibox.layout.fixed.horizontal
}
noti_icon.icon:set_image(ico_image)
return noti_icon
end
-- Notification title container
ui_noti_builder.notifbox_title = function(title)
return wibox.widget {
markup = title,
font = 'SF Pro Text Bold 12',
align = 'left',
valign = 'center',
widget = wibox.widget.textbox
}
end
-- Notification message container
ui_noti_builder.notifbox_message = function(msg)
return wibox.widget {
markup = msg,
font = 'SF Pro Text Regular 11',
align = 'left',
valign = 'center',
widget = wibox.widget.textbox
}
end
-- Notification app name container
ui_noti_builder.notifbox_appname = function(app)
return wibox.widget {
markup = app,
font = 'SF Pro Text Bold 12',
align = 'left',
valign = 'center',
widget = wibox.widget.textbox
}
end
-- Notification actions container
ui_noti_builder.notifbox_actions = function(n)
actions_template = wibox.widget {
notification = n,
base_layout = wibox.widget {
spacing = dpi(0),
layout = wibox.layout.flex.horizontal
},
widget_template = {
{
{
{
{
id = 'text_role',
font = 'SF Pro Text Regular 10',
widget = wibox.widget.textbox
},
widget = wibox.container.place
},
widget = clickable_container
},
bg = beautiful.groups_bg,
shape = gears.shape.rounded_rect,
forced_height = 30,
widget = wibox.container.background
},
margins = 4,
widget = wibox.container.margin
},
style = { underline_normal = false, underline_selected = true },
widget = naughty.list.actions,
}
return actions_template
end
-- Notification dismiss button
ui_noti_builder.notifbox_dismiss = function()
local dismiss_imagebox = wibox.widget {
{
id = 'dismiss_icon',
image = widget_icon_dir .. 'delete.svg',
resize = true,
forced_height = dpi(5),
widget = wibox.widget.imagebox
},
layout = wibox.layout.fixed.horizontal
}
local dismiss_button = wibox.widget {
{
dismiss_imagebox,
margins = dpi(5),
widget = wibox.container.margin
},
widget = clickable_container
}
local notifbox_dismiss = wibox.widget {
dismiss_button,
visible = false,
bg = beautiful.groups_title_bg,
shape = gears.shape.circle,
widget = wibox.container.background
}
return notifbox_dismiss
end
return ui_noti_builder