a lot of stuff and added dbus_proxy as sub module
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -7,3 +7,6 @@
|
||||
[submodule "awesome/src/lib/color"]
|
||||
path = awesome/src/lib/color
|
||||
url = https://github.com/andOrlando/color
|
||||
[submodule "awesome/src/lib/dbus_proxy"]
|
||||
path = awesome/src/lib/dbus_proxy
|
||||
url = https://github.com/stefano-m/lua-dbus_proxy
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 292 KiB After Width: | Height: | Size: 88 KiB |
@@ -404,7 +404,7 @@ naughty.connect_signal(
|
||||
|
||||
local box = naughty.layout.box {
|
||||
notification = n,
|
||||
timeout = 3,
|
||||
timeout = 5,
|
||||
type = "notification",
|
||||
screen = screen.primary,
|
||||
shape = function(cr, width, height)
|
||||
@@ -413,6 +413,10 @@ naughty.connect_signal(
|
||||
widget_template = w_template
|
||||
}
|
||||
|
||||
awful.spawn.easy_async_with_shell(
|
||||
"paplay /usr/share/sounds/freedesktop/stereo/message.oga"
|
||||
)
|
||||
|
||||
box.buttons = {}
|
||||
n.buttons = {}
|
||||
end
|
||||
|
||||
@@ -37,26 +37,6 @@ awful.rules.rules = {
|
||||
properties = {
|
||||
titlebars_enabled = true
|
||||
}
|
||||
},
|
||||
{
|
||||
id = "games",
|
||||
rule_any = {
|
||||
class = {
|
||||
"steam_app_.%d+",
|
||||
"gta5.exe",
|
||||
},
|
||||
},
|
||||
properties = {
|
||||
tag = "9",
|
||||
switchtotag = true,
|
||||
fullscreen = true,
|
||||
screen = screen[1],
|
||||
floating = true,
|
||||
},
|
||||
focus = true,
|
||||
callback = function(c)
|
||||
awful.screen.focused()
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,15 +121,20 @@ function Hover_signal(widget, bg_override, fg_override, border_override, icon_ov
|
||||
local b_timed_border = rubato.timed { duration = 0.3, pos = math.floor(bbo) }
|
||||
|
||||
local function update_bg()
|
||||
widget:set_bg("#" .. color.utils.rgba_to_hex { r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos })
|
||||
widget:set_bg("#" ..
|
||||
color.utils.rgba_to_hex { math.min(r_timed_bg.pos, 255), math.min(g_timed_bg.pos, 255),
|
||||
math.min(b_timed_bg.pos, 255) })
|
||||
end
|
||||
|
||||
local function update_fg()
|
||||
widget:set_fg("#" .. color.utils.rgba_to_hex { r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos })
|
||||
widget:set_fg("#" .. color.utils.rgba_to_hex { math.min(r_timed_fg.pos, 255), math.min(g_timed_fg.pos, 255),
|
||||
math.min(b_timed_fg.pos, 255) })
|
||||
end
|
||||
|
||||
local function update_border()
|
||||
widget:set_border_color("#" .. color.utils.rgba_to_hex { r_timed_border.pos, g_timed_border.pos, b_timed_border.pos })
|
||||
widget:set_border_color("#" ..
|
||||
color.utils.rgba_to_hex { math.min(r_timed_border.pos, 255), math.min(g_timed_border.pos, 255),
|
||||
math.min(b_timed_border.pos, 255) })
|
||||
end
|
||||
|
||||
r_timed_bg:subscribe(update_bg)
|
||||
@@ -260,24 +265,8 @@ function Hover_signal(widget, bg_override, fg_override, border_override, icon_ov
|
||||
--widget:connect_signal("mouse::leave", mouse_leave)
|
||||
end
|
||||
|
||||
local button_press = function()
|
||||
--[[ if old_bg or bg_override then
|
||||
if bg_override then
|
||||
bg_override = bg_override .. "bb"
|
||||
end
|
||||
widget.bg = bg_override or old_bg .. "bb"
|
||||
end
|
||||
if fg_override or old_fg then
|
||||
if fg_override then
|
||||
fg_override = fg_override .. "bb"
|
||||
end
|
||||
widget.fg = fg_override or old_fg .. "bb"
|
||||
end ]]
|
||||
--widget:disconnect_signal("mouse::leave", mouse_leave)
|
||||
end
|
||||
|
||||
widget:connect_signal("mouse::enter", mouse_enter)
|
||||
widget:connect_signal("button::press", button_press)
|
||||
--widget:connect_signal("button::press", button_press)
|
||||
--widget:connect_signal("button::release", button_release)
|
||||
widget:connect_signal("mouse::leave", mouse_leave)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local awful = require("awful")
|
||||
local gears = require("gears")
|
||||
local dbus_proxy = require("dbus_proxy")
|
||||
local dbus_proxy = require("src.lib.dbus_proxy")
|
||||
local lgi = require("lgi")
|
||||
local naughty = require("naughty")
|
||||
|
||||
|
||||
1
awesome/src/lib/dbus_proxy
Submodule
1
awesome/src/lib/dbus_proxy
Submodule
Submodule awesome/src/lib/dbus_proxy added at c9253bde3f
@@ -325,20 +325,20 @@ function overflow:set_scroll_factor(factor)
|
||||
|
||||
|
||||
local function update_scroll()
|
||||
self._private.scroll_factor = overflow.rubato_timed.pos
|
||||
self._private.scroll_factor = self.rubato_timed.pos
|
||||
self:emit_signal("widget::layout_changed")
|
||||
self:emit_signal("property::scroll_factor", factor)
|
||||
end
|
||||
|
||||
-- Make sure it only subscribes once
|
||||
if first_call then
|
||||
overflow.rubato_timed:subscribe(update_scroll)
|
||||
self.rubato_timed:subscribe(update_scroll)
|
||||
--first_call = false
|
||||
end
|
||||
|
||||
-- Set the target to the new target + remaining target from last scroll. This makes it scroll faster and correctly.
|
||||
overflow.rubato_timed.target = math.min(1,
|
||||
math.max(factor + (overflow.rubato_timed.target - overflow.rubato_timed.pos), 0))
|
||||
self.rubato_timed.target = math.min(1,
|
||||
math.max(factor + (self.rubato_timed.target - self.rubato_timed.pos), 0))
|
||||
end
|
||||
|
||||
function overflow:get_scroll_factor()
|
||||
|
||||
@@ -389,7 +389,6 @@ local function create_tasks()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return tasks
|
||||
end
|
||||
|
||||
@@ -405,7 +404,7 @@ local selected_day = {
|
||||
|
||||
return function(s)
|
||||
-- The calendar grid
|
||||
local calendar_matrix = wibox.widget { layout = wibox.layout.grid }
|
||||
local calendar_matrix = wibox.widget { layout = wibox.layout.grid, spacing = dpi(2) }
|
||||
|
||||
local weeks = wibox.widget { layout = wibox.layout.fixed.vertical }
|
||||
|
||||
@@ -541,7 +540,7 @@ return function(s)
|
||||
border_color = border,
|
||||
border_width = Theme_config.calendar.day.border_width,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(0))
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
@@ -642,7 +641,7 @@ return function(s)
|
||||
border_color = border,
|
||||
border_width = Theme_config.calendar.day.border_width,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(0))
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
@@ -752,7 +751,7 @@ return function(s)
|
||||
border_color = border,
|
||||
border_width = Theme_config.calendar.day.border_width,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(0))
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end
|
||||
},
|
||||
widget = wibox.container.constraint,
|
||||
|
||||
1005
awesome/src/modules/calendar/init.lua
Normal file
1005
awesome/src/modules/calendar/init.lua
Normal file
File diff suppressed because it is too large
Load Diff
125
awesome/src/modules/calendar/task_info.lua
Normal file
125
awesome/src/modules/calendar/task_info.lua
Normal file
@@ -0,0 +1,125 @@
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local gcolor = require("gears.color")
|
||||
local gtable = require("gears.table")
|
||||
local gshape = require("gears.shape")
|
||||
local gobject = require("gears.object")
|
||||
local wibox = require("wibox")
|
||||
|
||||
local icondir = awful.util.getdir("config") .. "src/assets/icons/calendar/"
|
||||
|
||||
local task_info = { mt = {} }
|
||||
task_info._private = {}
|
||||
|
||||
function task_info.new(args)
|
||||
args = args or {}
|
||||
if not args.task then return end
|
||||
args.screen = args.screen or awful.screen.focused()
|
||||
local ret = gobject {}
|
||||
gtable.crush(ret, task_info, true)
|
||||
|
||||
local task_info_widget = wibox.widget {
|
||||
{
|
||||
{ -- Task detail
|
||||
{ -- Calendar color
|
||||
widget = wibox.container.background,
|
||||
shape = function(cr, _, height)
|
||||
gshape.rounded_rect(cr, dpi(10), height, dpi(8))
|
||||
end,
|
||||
},
|
||||
{
|
||||
{ -- Summary
|
||||
widget = wibox.widget.textbox,
|
||||
text = ret.summary,
|
||||
valign = "center",
|
||||
align = "left",
|
||||
id = "summary",
|
||||
},
|
||||
{ -- Date long
|
||||
widget = wibox.widget.textbox,
|
||||
text = ret.date_long,
|
||||
valign = "center",
|
||||
align = "right",
|
||||
id = "date_long",
|
||||
},
|
||||
{ -- From - To
|
||||
widget = wibox.widget.textbox,
|
||||
text = ret.from_to,
|
||||
valign = "center",
|
||||
align = "left",
|
||||
id = "from_to",
|
||||
},
|
||||
{ -- Repeat information
|
||||
widget = wibox.widget.textbox,
|
||||
text = ret.repeat_info,
|
||||
valign = "center",
|
||||
align = "right",
|
||||
id = "repeat_info",
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
{ -- Location
|
||||
{
|
||||
widget = wibox.widget.imagebox,
|
||||
image = gcolor.recolor_image(icondir .. "location.svg", Theme_config.calendar.task_info.location_icon_color),
|
||||
resize = false,
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
},
|
||||
{
|
||||
widget = wibox.widget.textbox,
|
||||
text = ret.location,
|
||||
valign = "center",
|
||||
align = "left",
|
||||
id = "location",
|
||||
},
|
||||
id = "location_container",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
{ -- Alarm
|
||||
{
|
||||
widget = wibox.widget.imagebox,
|
||||
image = gcolor.recolor_image(icondir .. "alarm.svg", Theme_config.calendar.task_info.alarm_icon_color),
|
||||
resize = false,
|
||||
valign = "center",
|
||||
halign = "center",
|
||||
},
|
||||
{
|
||||
widget = wibox.widget.textbox,
|
||||
text = ret.alarm,
|
||||
valign = "center",
|
||||
align = "left",
|
||||
id = "alarm",
|
||||
},
|
||||
id = "alarm_container",
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
},
|
||||
id = "task_detail",
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
bg = Theme_config.calendar.task_info.bg,
|
||||
fg = Theme_config.calendar.task_info.fg,
|
||||
shape = Theme_config.calendar.task_info.shape,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
ret.widget = awful.popup {
|
||||
widget = task_info_widget,
|
||||
ontop = true,
|
||||
visible = true,
|
||||
bg = "#00000000",
|
||||
x = mouse.coords().x,
|
||||
y = mouse.coords().y,
|
||||
screen = args.screen
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
function task_info.mt:__call(...)
|
||||
task_info.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(task_info, task_info.mt)
|
||||
@@ -3,7 +3,6 @@
|
||||
--------------------------------------------------------------------------------------------------------------
|
||||
-- Awesome Libs
|
||||
local awful = require("awful")
|
||||
local async = require("async")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
local Gio = require("lgi").Gio
|
||||
local gears = require("gears")
|
||||
@@ -170,9 +169,12 @@ return function(screen)
|
||||
local indicators = { layout = wibox.layout.flex.horizontal, spacing = dpi(5) }
|
||||
local col = Theme_config.dock.indicator_bg
|
||||
for _, c in ipairs(client.get()) do
|
||||
local icon_name = pr.icon
|
||||
if icon_name:match(string.lower(c.class or c.name)) or c.class:match(string.lower(icon_name)) or
|
||||
c.name:match(string.lower(icon_name)) then
|
||||
local icon_name = string.lower(pr.icon)
|
||||
if not c or not c.valid then return end
|
||||
if not c.class then c.class = "" end
|
||||
local class = string.lower(c.class)
|
||||
icon_name = string.match(icon_name, ".*/(.*)%.[svg|png]")
|
||||
if class == icon_name or class:match(icon_name) or icon_name:match(class) then
|
||||
if c == client.focus then
|
||||
col = Theme_config.dock.indicator_focused_bg
|
||||
elseif c.urgent then
|
||||
|
||||
@@ -27,6 +27,6 @@ awful.screen.connect_for_each_screen(
|
||||
require("src.modules.notification-center.init")(s)
|
||||
require("src.modules.window_switcher.init")(s)
|
||||
require("src.modules.application_launcher.init")(s)
|
||||
require("src.modules.calendar.calendar")(s)
|
||||
require("src.modules.calendar.init") { screen = s }
|
||||
end
|
||||
)
|
||||
|
||||
@@ -8,6 +8,8 @@ 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/notifications/"
|
||||
|
||||
@@ -84,72 +86,16 @@ return function(s)
|
||||
halign = "right",
|
||||
}
|
||||
|
||||
local left_button = wibox.widget {
|
||||
{
|
||||
{
|
||||
widget = wibox.container.background,
|
||||
bg = Theme_config.notification_center.dnd.disabled,
|
||||
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 color = Theme_config.notification_center.dnd.disabled
|
||||
|
||||
local right_button = wibox.widget {
|
||||
{
|
||||
{
|
||||
widget = wibox.container.background,
|
||||
bg = Theme_config.notification_center.dnd.border_enabled,
|
||||
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 rubato = require("src.lib.rubato")
|
||||
|
||||
local rubato_timed = rubato.timed { duration = 1, pos = 0 }
|
||||
|
||||
local toggle_button = wibox.widget {
|
||||
{
|
||||
id = "background",
|
||||
widget = wibox.widget {
|
||||
fit = function(_, width, height)
|
||||
return width, height
|
||||
end,
|
||||
draw = function(_, _, cr, width, height)
|
||||
-- Clear for next drawing
|
||||
--cr:set_operator(cairo.Operator.CLEAR);
|
||||
local function move_dnd()
|
||||
local function toggle_animation(pos)
|
||||
if pos > 43 then return end
|
||||
return function(_, _, cr, width, height)
|
||||
cr:set_source(gears.color(Theme_config.notification_center.dnd.bg));
|
||||
cr:paint();
|
||||
cr:set_source(gears.color(Theme_config.notification_center.dnd.disabled))
|
||||
cr:move_to(rubato_timed.pos, 0)
|
||||
local x = rubato_timed.pos
|
||||
cr:set_source(gears.color(color))
|
||||
cr:move_to(pos, 0)
|
||||
local x = pos
|
||||
local y = 5
|
||||
local newwidth = width / 2 - 10
|
||||
local newheight = height - 10
|
||||
@@ -165,11 +111,19 @@ return function(s)
|
||||
cr:close_path()
|
||||
cr:fill()
|
||||
end
|
||||
|
||||
rubato_timed:subscribe(move_dnd)
|
||||
rubato_timed.target = width / 2 + 5
|
||||
end
|
||||
}
|
||||
|
||||
local rubato_timed
|
||||
|
||||
local toggle_button = wibox.widget {
|
||||
{
|
||||
widget = wibox.widget {
|
||||
fit = function(_, width, height)
|
||||
return width, height
|
||||
end,
|
||||
draw = toggle_animation(0, Theme_config.notification_center.dnd.disabled),
|
||||
},
|
||||
id = "background",
|
||||
},
|
||||
active = false,
|
||||
widget = wibox.container.background,
|
||||
@@ -183,22 +137,35 @@ return function(s)
|
||||
end,
|
||||
}
|
||||
|
||||
toggle_button:connect_signal(
|
||||
"button::press",
|
||||
function()
|
||||
toggle_button:buttons(
|
||||
gears.table.join(
|
||||
awful.button({}, 1, function()
|
||||
if toggle_button.active then
|
||||
toggle_button.active = not toggle_button.active
|
||||
toggle_button.border_color = Theme_config.notification_center.dnd.border_disabled
|
||||
color = Theme_config.notification_center.dnd.disabled
|
||||
User_config.dnd = false
|
||||
rubato_timed.target = 5
|
||||
else
|
||||
toggle_button.active = not toggle_button.active
|
||||
toggle_button.border_color = Theme_config.notification_center.dnd.border_enabled
|
||||
color = Theme_config.notification_center.dnd.enabled
|
||||
User_config.dnd = true
|
||||
rubato_timed.target = 50
|
||||
rubato_timed.target = 43
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
rubato_timed = rubato.timed {
|
||||
duration = 0.5,
|
||||
pos = 5,
|
||||
subscribed = function(pos)
|
||||
toggle_button:get_children_by_id("background")[1].draw = toggle_animation(pos)
|
||||
toggle_button:emit_signal("widget::redraw_needed")
|
||||
end
|
||||
}
|
||||
|
||||
local dnd = wibox.widget {
|
||||
{
|
||||
|
||||
@@ -482,7 +482,8 @@ return function(s)
|
||||
autostart = true,
|
||||
call_now = true,
|
||||
callback = function()
|
||||
get_spotify_metadata()
|
||||
--!Rewrite entire playerctl module for better performance
|
||||
--get_spotify_metadata()
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
@@ -149,6 +149,9 @@ Theme_config.calendar = {
|
||||
fg = color["Grey100"],
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(2),
|
||||
shape = function(cr, w, h)
|
||||
gears.shape.rounded_rect(cr, w, h, dpi(8))
|
||||
end,
|
||||
day = {
|
||||
today_border_color = color["Blue200"],
|
||||
bg = color["Grey900"],
|
||||
@@ -160,7 +163,7 @@ Theme_config.calendar = {
|
||||
border_color = color["Grey800"],
|
||||
border_width = dpi(2),
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(4))
|
||||
gears.shape.rounded_rect(cr, width, height, dpi(8))
|
||||
end,
|
||||
},
|
||||
task = {
|
||||
|
||||
@@ -20,11 +20,8 @@ User_config = {
|
||||
"picom --experimental-backends",
|
||||
"xfce4-power-manager",
|
||||
"light-locker --lock-on-suspend --lock-on-lid &",
|
||||
"spotify",
|
||||
"discord",
|
||||
"/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1",
|
||||
"setxkbmap -option caps:swapescape",
|
||||
"jamesdsp"
|
||||
},
|
||||
|
||||
--[[
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
local awful = require("awful")
|
||||
local Gio = require("lgi").Gio
|
||||
local gears = require("gears")
|
||||
|
||||
return function(table)
|
||||
for _, t in ipairs(table) do
|
||||
awful.spawn(t);
|
||||
end
|
||||
local path = gears.filesystem.get_xdg_config_home() .. "autostart/"
|
||||
local handler = io.popen("ls " .. path)
|
||||
if not handler then return end
|
||||
|
||||
for file in handler:lines() do
|
||||
local app = Gio.DesktopAppInfo.new_from_filename(path .. file)
|
||||
if app then
|
||||
Gio.AppInfo.launch_uris_async(Gio.AppInfo.create_from_commandline(Gio.DesktopAppInfo.get_string(app,
|
||||
"Exec"), nil, 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,9 +39,9 @@ function Get_icon(class, name)
|
||||
local icon_string = Gio.DesktopAppInfo.get_string(desktop_app_info, "Icon")
|
||||
if icon_string then
|
||||
icon_string = string.lower(icon_string)
|
||||
if icon_string:match(class) or class:match(icon_string) then
|
||||
if icon_string == class or icon_string == name then
|
||||
return Get_gicon_path(app_info.get_icon(app))
|
||||
elseif icon_string:match(name) or name:match(icon_string) then
|
||||
elseif icon_string:match(class) then
|
||||
return Get_gicon_path(app_info.get_icon(app))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
local awful = require("awful")
|
||||
|
||||
--[[ local lgi = require("lgi")
|
||||
local pulseaudio = require("lua_libpulse_glib")
|
||||
local ppretty = require("pl.ppretty")
|
||||
|
||||
local pa = pulseaudio.new()
|
||||
|
||||
local ctx = pa:context("My Test App")
|
||||
|
||||
ctx:connect(nil, function(state)
|
||||
if state == 4 then
|
||||
print("Connection is ready")
|
||||
|
||||
ctx:get_sinks(function(sinks)
|
||||
ppretty.dump(sinks)
|
||||
end)
|
||||
end
|
||||
end) ]]
|
||||
|
||||
awful.spawn.with_line_callback(
|
||||
[[bash -c "LC_ALL=C pactl subscribe"]],
|
||||
{
|
||||
|
||||
@@ -4,12 +4,13 @@ local watch = awful.widget.watch
|
||||
local total_prev = 0
|
||||
local idle_prev = 0
|
||||
|
||||
--!Find a better way that doesn't need manual GC since it has a huge performance impact
|
||||
watch(
|
||||
[[ cat "/proc/stat" | grep '^cpu ' ]],
|
||||
3,
|
||||
function(_, stdout)
|
||||
local user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice =
|
||||
stdout:match("(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s")
|
||||
local user, nice, system, idle, iowait, irq, softirq, steal =
|
||||
stdout:match("(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s(%d+)%s")
|
||||
|
||||
local total = user + nice + system + idle + iowait + irq + softirq + steal
|
||||
|
||||
@@ -21,6 +22,7 @@ watch(
|
||||
|
||||
total_prev = total
|
||||
idle_prev = idle
|
||||
|
||||
collectgarbage("collect")
|
||||
end
|
||||
)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
require("src.tools.helpers.cpu_temp")
|
||||
require("src.tools.helpers.cpu_usage")
|
||||
--!Find a better way that doesn't need manual GC since it has a huge performance impact
|
||||
--require("src.tools.helpers.cpu_usage")
|
||||
require("src.tools.helpers.cpu_freq")
|
||||
require("src.tools.helpers.ram")
|
||||
require("src.tools.helpers.gpu_usage")
|
||||
require("src.tools.helpers.gpu_temp")
|
||||
require("src.tools.helpers.audio")
|
||||
--require("src.tools.helpers.backlight")
|
||||
require("src.tools.helpers.backlight")
|
||||
|
||||
345
awesome/src/tools/helpers/playerctl.lua
Normal file
345
awesome/src/tools/helpers/playerctl.lua
Normal file
@@ -0,0 +1,345 @@
|
||||
-- 99.9% Stolen from bling
|
||||
|
||||
local gobject = require("gears.object")
|
||||
local gtable = require("gears.table")
|
||||
local gtimer = require("gears.timer")
|
||||
local gstring = require("gears.string")
|
||||
|
||||
local playerctl = { mt = {} }
|
||||
playerctl._private = {}
|
||||
|
||||
function playerctl:play_pause(player)
|
||||
player = player or self._private.manager.players[1]
|
||||
if player then
|
||||
player:play_pause()
|
||||
end
|
||||
end
|
||||
|
||||
function playerctl:next(player)
|
||||
player = player or self._private.manager.players[1]
|
||||
if player then
|
||||
player:next()
|
||||
end
|
||||
end
|
||||
|
||||
function playerctl:previous(player)
|
||||
player = player or self._private.manager.players[1]
|
||||
if player then
|
||||
player:previous()
|
||||
end
|
||||
end
|
||||
|
||||
function playerctl:cycle_loop(player)
|
||||
player = player or self._private.manager.players[1]
|
||||
if player then
|
||||
local loop_status = player.loop_status
|
||||
if loop_status == "NONE" then
|
||||
player:set_loop_status("TRACK")
|
||||
elseif loop_status == "TRACK" then
|
||||
player:set_loop_status("PLAYLIST")
|
||||
elseif loop_status == "PLAYLIST" then
|
||||
player:set_loop_status("NONE")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function playerctl:cycle_shuffle(player)
|
||||
player = player or self._private.manager.players[1]
|
||||
if player then
|
||||
player:set_shuffle(not player.shuffle)
|
||||
end
|
||||
end
|
||||
|
||||
function playerctl:set_position(position, player)
|
||||
player = player or self._private.manager.players[1]
|
||||
if player then
|
||||
player:set_position(position * 1000000)
|
||||
end
|
||||
end
|
||||
|
||||
function playerctl:get_manager()
|
||||
return self._private.manager
|
||||
end
|
||||
|
||||
function playerctl:get_current_player()
|
||||
return self._private.manager.players[1].name
|
||||
end
|
||||
|
||||
local function emit_metadata_callback(self, title, artist, art_url, album, new, player_name)
|
||||
title = gstring.xml_escape(title)
|
||||
artist = gstring.xml_escape(artist)
|
||||
album = gstring.xml_escape(album)
|
||||
|
||||
if player_name == "spotify" then
|
||||
art_url = art_url:gsub("open.spotify.com", "i.scdn.co")
|
||||
end
|
||||
|
||||
if not art_url or art_url == "" then
|
||||
else
|
||||
awesome.emit_signal("playerctl::title_artist_album", title, artist, "", player_name)
|
||||
self:emit_signal("metadata", title, artist, "", album, new, player_name)
|
||||
end
|
||||
end
|
||||
|
||||
local function metadata_callback(self, player, metadata)
|
||||
if self.update_on_activity then
|
||||
self._private.manager:mover_player_to_front(player)
|
||||
end
|
||||
|
||||
local data = metadata.value
|
||||
local title = data["xesam:title"] or ""
|
||||
local artist = data["xesam:artist"] or ""
|
||||
for i = 2, #data["xesam:artist"] do
|
||||
artist = artist .. ", " .. data["xesam:artist"][i]
|
||||
end
|
||||
local art_url = data["mpris:artUrl"] or ""
|
||||
local album = data["xesam:album"] or ""
|
||||
|
||||
if player == self._private.manager.players[1] then
|
||||
if (not player == self._private.last_player) or (not title == self._private.manager.last_title) or
|
||||
(not artist == self._private.manager.last_artist) or (not art_url == self._private.manager.last_art_url) then
|
||||
if (title == "") and (artist == "") and (art_url == "") then return end
|
||||
|
||||
if (not self._private.metadata_timer) and self._private.metadata_timer.started then
|
||||
self._private.metadata_timer:stop()
|
||||
end
|
||||
|
||||
self._private.metadata_timer = gtimer {
|
||||
timeout = 1,
|
||||
autostart = true,
|
||||
single_shot = true,
|
||||
callback = function()
|
||||
emit_metadata_callback(self, title, artist, art_url, album, true, player.name)
|
||||
end
|
||||
}
|
||||
|
||||
self._private.manager.pos_timer:again()
|
||||
self._private.manager.last_title = title
|
||||
self._private.manager.last_artist = artist
|
||||
self._private.manager.last_art_url = art_url
|
||||
self._private.last_player = player
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function pos_callback(self)
|
||||
local player = self._private.manager.players[1]
|
||||
if player then
|
||||
local pos = player:get_position() / 1000000
|
||||
local dur = (player.metadata.value["mpris:length"] or 0) / 1000000
|
||||
if (not pos == self._private.last_pos) or (not dur == self._private.last_length) then
|
||||
self._private.pos = pos
|
||||
self._private.dur = dur
|
||||
self:emit_signal("position", pos, dur, player.player_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function playback_status_callback(self, player, status)
|
||||
if self.update_on_activity then
|
||||
self._private.manager:mover_player_to_front(player)
|
||||
end
|
||||
|
||||
if player == self._private.manager.players[1] then
|
||||
self._private.active_player = player
|
||||
|
||||
if status == "PLAYING" then
|
||||
self:emit_signal("playerctl::playback_status", true, player.player_name)
|
||||
awesome.emit_signal("playerctl::playback_status", true, player.player_name)
|
||||
else
|
||||
self:emit_signal("playerctl::playback_status", false, player.player_name)
|
||||
awesome.emit_signal("playerctl::playback_status", false, player.player_name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function loop_callback(self, player, loop_status)
|
||||
if self.update_on_activity then
|
||||
self._private.manager:mover_player_to_front(player)
|
||||
end
|
||||
|
||||
if player == self._private.manager.players[1] then
|
||||
self._private.active_player = player
|
||||
self:emit_signal("loop_status", loop_status, player.player_name)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
local function shuffle_callback(self, player, shuffle)
|
||||
if self.update_on_activity then
|
||||
self._private.manager:mover_player_to_front(player)
|
||||
end
|
||||
|
||||
if player == self._private.manager.players[1] then
|
||||
self._private.active_player = player
|
||||
self:emit_signal("shuffle", shuffle, player.player_name)
|
||||
end
|
||||
end
|
||||
|
||||
local function exit_callback(self, player)
|
||||
if player == self._private.manager.players[1] then
|
||||
self:emit_signal("playerctl::exit", player.player_name)
|
||||
end
|
||||
end
|
||||
|
||||
local function name_is_selected(self, name)
|
||||
if self.ignore[name.name] then
|
||||
return false
|
||||
end
|
||||
if self.priority > 0 then
|
||||
for _, arg in pairs(self.priority) do
|
||||
if arg == name.name or arg == "%any" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
local function init_player(self, name)
|
||||
if name_is_selected(self, name) then
|
||||
local player = self._private.Playerctl.Player.new_from_name(name)
|
||||
self._private.manager:manage_player(player)
|
||||
player.on_metadata = function(p, m)
|
||||
metadata_callback(self, p, m)
|
||||
end
|
||||
player.on_playback_status = function(p, s)
|
||||
playback_status_callback(self, p, s)
|
||||
end
|
||||
player.on_loop_status = function(p, s)
|
||||
loop_callback(self, p, s)
|
||||
end
|
||||
player.on_shuffle = function(p, s)
|
||||
shuffle_callback(self, p, s)
|
||||
end
|
||||
player.on_exit = function(p)
|
||||
exit_callback(self, p)
|
||||
end
|
||||
|
||||
if not self._private.pos_timer.started then
|
||||
self._private.pos_timer:start()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function player_compare(self, a, b)
|
||||
local player_a = self._private.Playerctl.Player(a)
|
||||
local player_b = self._private.Playerctl.Player(b)
|
||||
local i = math.huge
|
||||
local ai = nil
|
||||
local bi = nil
|
||||
|
||||
if player_a == player_b then
|
||||
return 0
|
||||
end
|
||||
|
||||
for index, name in ipairs(self.priority) do
|
||||
if name == "%any" then
|
||||
i = (i == math.huge) and index or i
|
||||
elseif name == player_a.player_name then
|
||||
ai = ai or index
|
||||
elseif name == player_b.player_name then
|
||||
bi = bi or index
|
||||
end
|
||||
end
|
||||
|
||||
if not ai and not bi then
|
||||
return 0
|
||||
elseif not ai then
|
||||
return (bi < i) and 1 or -1
|
||||
elseif not bi then
|
||||
return (ai < i) and -1 or 1
|
||||
elseif ai == bi then
|
||||
return 0
|
||||
else
|
||||
return (ai < bi) and -1 or 1
|
||||
end
|
||||
end
|
||||
|
||||
local function get_current_player(self, player)
|
||||
local title = player:get_title() or "Unknown"
|
||||
local artist = player:get_artist() or "Unknown"
|
||||
local album = player:get_album() or "Unknown"
|
||||
local art_url = player:print_metadata_prop("mpris:artUtl") or ""
|
||||
|
||||
emit_metadata_callback(self, title, artist, art_url, album, false, player.player_name)
|
||||
playback_status_callback(self, player, player.playback_status)
|
||||
loop_callback(self, player, player.loop_status)
|
||||
end
|
||||
|
||||
local function start_manager(self)
|
||||
self._private.manager = self.private.Playerctl.PlayerManager()
|
||||
|
||||
if #self.priority > 0 then
|
||||
self._private.manager:set_sort_func(function(a, b)
|
||||
return player_compare(self, a, b)
|
||||
end)
|
||||
end
|
||||
|
||||
self._private.pos_timer = gtimer {
|
||||
timeout = 1,
|
||||
callback = function()
|
||||
pos_callback(self)
|
||||
end
|
||||
}
|
||||
|
||||
for _, name in ipairs(self._private.manager.player_names) do
|
||||
init_player(self, name)
|
||||
end
|
||||
|
||||
if self._private.manager.players[1] then
|
||||
get_current_player(self, self._private.manager.players[1])
|
||||
end
|
||||
|
||||
local _self = self
|
||||
|
||||
function self._private.manager:on_name_appeared(name)
|
||||
init_player(_self, name)
|
||||
end
|
||||
|
||||
function self._private.manager:on_player_appeared(player)
|
||||
if player == self.players[1] then
|
||||
_self._private.active_player = player
|
||||
end
|
||||
end
|
||||
|
||||
function self._private.manager:on_player_vanished(player)
|
||||
if #self.players == 0 then
|
||||
_self._private.metadata_timer:stop()
|
||||
_self._private.pos_timer:stop()
|
||||
_self:emit_signal("playerctl::noplayers")
|
||||
awesome.emit_signal("playerctl::noplayers")
|
||||
elseif player == _self._private.active_player then
|
||||
_self._private.active_player = self.players[1]
|
||||
get_current_player(_self, _self._private.active_player)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function playerctl.new(args)
|
||||
args = args or {}
|
||||
|
||||
local ret = gobject {}
|
||||
gtable.crush(ret, playerctl, true)
|
||||
|
||||
ret.update_on_activity = true
|
||||
ret.interval = 1
|
||||
|
||||
|
||||
ret._private = {}
|
||||
|
||||
ret._private.Playerctl = require("lgi").Playerctl
|
||||
ret._private.manager = nil
|
||||
|
||||
gtimer.delayed_call(function()
|
||||
start_manager(ret)
|
||||
end)
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
function playerctl.mt:__call(...)
|
||||
return playerctl.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(playerctl, playerctl.mt)
|
||||
@@ -1,6 +1,14 @@
|
||||
local ical = {}
|
||||
local gfilesystem = require("gears.filesystem")
|
||||
local gobject = require("gears.object")
|
||||
local gtable = require("gears.table")
|
||||
local naughty = require("naughty")
|
||||
|
||||
local json = require("src.lib.json-lua.json-lua")
|
||||
|
||||
local ical = { mt = {} }
|
||||
ical.VCALENDAR = {}
|
||||
ical._private = {}
|
||||
ical._private.cache = {}
|
||||
ical._private.parser = {}
|
||||
|
||||
--[[
|
||||
@@ -63,24 +71,74 @@ ical._private.parser = {}
|
||||
DTSTAMP = "...",
|
||||
]]
|
||||
|
||||
---Takes a path to an .ical file then parses it into a lua table and returns it
|
||||
---@param path string Path to the .ical file
|
||||
---@return table | nil calendar New calendar table or nil on error
|
||||
function ical.new(path)
|
||||
local handler = io.open(path, "r")
|
||||
function ical._private.add_to_cache(file, vcal)
|
||||
-- Copy file to src/config/files/calendar/
|
||||
local path = gfilesystem.get_configuration_dir() .. "src/config/"
|
||||
local file_name = file:match(".*/(.*)")
|
||||
if not
|
||||
os.execute("cp " ..
|
||||
file .. " " .. gfilesystem.get_configuration_dir() .. "src/config/files/calendar/" .. file_name) then
|
||||
naughty.notification({
|
||||
app_name = "Systemnotification",
|
||||
title = "Error",
|
||||
text = "Could not copy file to config/files/calendar/",
|
||||
timeout = 0,
|
||||
urgency = "critical",
|
||||
})
|
||||
return
|
||||
end
|
||||
local handler = io.open(path .. "calendar.json", "r")
|
||||
if not handler then return end
|
||||
local json_data = json:decode(handler:read("a"))
|
||||
handler:close()
|
||||
if not (type(json_data) == "table") then return end
|
||||
table.insert(json_data, {
|
||||
file = file_name,
|
||||
VCALENDAR = vcal,
|
||||
})
|
||||
|
||||
json_data = json:encode(json_data)
|
||||
|
||||
handler = io.open(path .. "calendar.json", "w")
|
||||
if not handler then return end
|
||||
handler:write(json_data)
|
||||
handler:close()
|
||||
end
|
||||
|
||||
function ical:add_calendar(file)
|
||||
local handler = io.open(file, "r")
|
||||
if not handler then return end
|
||||
|
||||
-- Check if the line is a BEGIN:VCALENDAR
|
||||
local v, k = handler:read("l"):match("([A-Z]+):([A-Z]+)")
|
||||
|
||||
local vcal = {}
|
||||
if v:match("BEGIN") and k:match("VCALENDAR") then
|
||||
table.insert(ical.VCALENDAR, ical._private.parser.VCALENDAR(handler))
|
||||
return ical
|
||||
vcal = self._private.parser.VCALENDAR(handler)
|
||||
table.insert(self.VCALENDAR, vcal)
|
||||
self._private.add_to_cache(file, vcal)
|
||||
end
|
||||
end
|
||||
|
||||
function ical.new(args)
|
||||
args = args or {}
|
||||
local ret = gobject {}
|
||||
gtable.crush(ret, ical, true)
|
||||
local path = gfilesystem.get_configuration_dir() .. "src/config/calendar.json"
|
||||
local handler = io.open(path, "r")
|
||||
if not handler then return end
|
||||
local json_data = json:decode(handler:read("a"))
|
||||
handler:close()
|
||||
if not (type(json_data) == "table") then return end
|
||||
--Load into the cache
|
||||
for _, v in ipairs(json_data) do
|
||||
ret._private.cache[v.file] = v.VCALENDAR
|
||||
table.insert(ret.VCALENDAR, v.VCALENDAR)
|
||||
end
|
||||
return ical
|
||||
end
|
||||
|
||||
function ical._private.parser.VEVENT(handler)
|
||||
function ical._private.parser:VEVENT(handler)
|
||||
local VEVENT = {}
|
||||
|
||||
while true do
|
||||
@@ -92,11 +150,11 @@ function ical._private.parser.VEVENT(handler)
|
||||
|
||||
local v, k = line:match("(.*):(.*)")
|
||||
if v:match("CREATED") then
|
||||
VEVENT.CREATED = ical._private.parser.to_datetime(k)
|
||||
VEVENT.CREATED = self._private.parser.to_datetime(k)
|
||||
elseif v:match("LAST-MODIFIED") then
|
||||
VEVENT.LAST_MODIFIED = ical._private.parser.to_datetime(k)
|
||||
VEVENT.LAST_MODIFIED = self._private.parser.to_datetime(k)
|
||||
elseif v:match("DTSTAMP") then
|
||||
VEVENT.DTSTAMP = ical._private.parser.to_datetime(k)
|
||||
VEVENT.DTSTAMP = self._private.parser.to_datetime(k)
|
||||
elseif v:match("UID") then
|
||||
VEVENT.UID = k
|
||||
elseif v:match("SUMMARY") then
|
||||
@@ -104,20 +162,20 @@ function ical._private.parser.VEVENT(handler)
|
||||
elseif v:match("RRULE") then
|
||||
VEVENT.RRULE = {
|
||||
FREQ = k:match("FREQ=([A-Z]+)"),
|
||||
UNTIL = ical._private.parser.to_datetime(k:match("UNTIL=([TZ0-9]+)")),
|
||||
UNTIL = self._private.parser.to_datetime(k:match("UNTIL=([TZ0-9]+)")),
|
||||
WKST = k:match("WKST=([A-Z]+)"),
|
||||
COUNT = k:match("COUNT=([0-9]+)"),
|
||||
INTERVAL = k:match("INTERVAL=([0-9]+)")
|
||||
}
|
||||
elseif v:match("DTSTART") then
|
||||
VEVENT.DTSTART = {
|
||||
DTSTART = ical._private.parser.to_datetime(k),
|
||||
DTSTART = self._private.parser.to_datetime(k),
|
||||
TZID = v:match("TZID=([a-zA-Z-\\/]+)"),
|
||||
VALUE = v:match("VALUE=([A-Z]+)")
|
||||
}
|
||||
elseif v:match("DTEND") then
|
||||
VEVENT.DTEND = {
|
||||
DTEND = ical._private.parser.to_datetime(k),
|
||||
DTEND = self._private.parser.to_datetime(k),
|
||||
TZID = v:match("TZID=([a-zA-Z-\\/]+)"),
|
||||
VALUE = v:match("VALUE=([A-Z]+)")
|
||||
}
|
||||
@@ -134,11 +192,12 @@ function ical._private.parser.VEVENT(handler)
|
||||
}
|
||||
elseif v:match("BEGIN") then
|
||||
if k:match("VALARM") then
|
||||
VEVENT.VALARM = ical._private.parser.VALARM(handler)
|
||||
VEVENT.VALARM = self._private.parser:VALARM(handler)
|
||||
end
|
||||
elseif v:match("UID") then
|
||||
VEVENT.UID = k
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--VEVENT.duration = VEVENT.DTSTART.DTSTART - VEVENT.DTEND.DTEND
|
||||
|
||||
return VEVENT
|
||||
@@ -153,7 +212,7 @@ function ical._private.parser.alarm_to_time(alarm)
|
||||
return time .. unit
|
||||
end
|
||||
|
||||
function ical._private.parser.VALARM(handler)
|
||||
function ical._private.parser:VALARM(handler)
|
||||
local VALARM = {}
|
||||
|
||||
while true do
|
||||
@@ -169,7 +228,7 @@ function ical._private.parser.VALARM(handler)
|
||||
elseif v:match("TRIGGER;VALUE=DURATION") then
|
||||
VALARM.TRIGGER = {
|
||||
VALUE = v:match("VALUE=(.*):"),
|
||||
TRIGGER = ical._private.parser.alarm_to_time(k)
|
||||
TRIGGER = self._private.parser.alarm_to_time(k)
|
||||
}
|
||||
elseif v:match("DESCRIPTION") then
|
||||
VALARM.DESCRIPTION = k
|
||||
@@ -179,7 +238,7 @@ function ical._private.parser.VALARM(handler)
|
||||
return VALARM
|
||||
end
|
||||
|
||||
function ical._private.parser.VCALENDAR(handler)
|
||||
function ical._private.parser:VCALENDAR(handler)
|
||||
local VCALENDAR = {}
|
||||
VCALENDAR.VEVENT = {}
|
||||
VCALENDAR.VTIMEZONE = {}
|
||||
@@ -199,9 +258,9 @@ function ical._private.parser.VCALENDAR(handler)
|
||||
VCALENDAR.VERSION = k
|
||||
elseif v:match("BEGIN") then
|
||||
if k:match("VTIMEZONE") then
|
||||
VCALENDAR.VTIMEZONE = ical._private.parser.VTIMEZONE(handler)
|
||||
VCALENDAR.VTIMEZONE = self._private.parser:VTIMEZONE(handler)
|
||||
elseif k:match("VEVENT") then
|
||||
table.insert(VCALENDAR.VEVENT, ical._private.parser.VEVENT(handler))
|
||||
table.insert(VCALENDAR.VEVENT, self._private.parser:VEVENT(handler))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -211,7 +270,7 @@ function ical._private.parser.VCALENDAR(handler)
|
||||
return VCALENDAR
|
||||
end
|
||||
|
||||
function ical._private.parser.VTIMEZONE(handler)
|
||||
function ical._private.parser:VTIMEZONE(handler)
|
||||
local VTIMEZONE = {}
|
||||
|
||||
while true do
|
||||
@@ -227,9 +286,9 @@ function ical._private.parser.VTIMEZONE(handler)
|
||||
end
|
||||
if v:match("BEGIN") then
|
||||
if k:match("DAYLIGHT") then
|
||||
VTIMEZONE.DAYLIGHT = ical._private.parser.DAYLIGHT(handler)
|
||||
VTIMEZONE.DAYLIGHT = self._private.parser:DAYLIGHT(handler)
|
||||
elseif k:match("STANDARD") then
|
||||
VTIMEZONE.STANDARD = ical._private.parser.STANDARD(handler)
|
||||
VTIMEZONE.STANDARD = self._private.parser:STANDARD(handler)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -237,7 +296,7 @@ function ical._private.parser.VTIMEZONE(handler)
|
||||
return VTIMEZONE
|
||||
end
|
||||
|
||||
function ical._private.parser.DAYLIGHT(handler)
|
||||
function ical._private.parser:DAYLIGHT(handler)
|
||||
local DAYLIGHT = {}
|
||||
|
||||
while true do
|
||||
@@ -249,13 +308,13 @@ function ical._private.parser.DAYLIGHT(handler)
|
||||
|
||||
local v, k = line:match("(.*):(.*)")
|
||||
if v:match("TZOFFSETFROM") then
|
||||
DAYLIGHT.TZOFFSETFROM = ical._private.parser.offset(k)
|
||||
DAYLIGHT.TZOFFSETFROM = self._private.parser.offset(k)
|
||||
elseif v:match("TZOFFSETTO") then
|
||||
DAYLIGHT.TZOFFSETTO = ical._private.parser.offset(k)
|
||||
DAYLIGHT.TZOFFSETTO = self._private.parser.offset(k)
|
||||
elseif v:match("TZNAME") then
|
||||
DAYLIGHT.TZNAME = k
|
||||
elseif v:match("DTSTART") then
|
||||
DAYLIGHT.DTSTART = ical._private.parser.to_datetime(k)
|
||||
DAYLIGHT.DTSTART = self._private.parser.to_datetime(k)
|
||||
elseif v:match("RRULE") then
|
||||
DAYLIGHT.RRULE = {
|
||||
FREQ = k:match("FREQ=([A-Z]+)"),
|
||||
@@ -271,7 +330,7 @@ end
|
||||
---Parses the STANDARD property into a table
|
||||
---@param handler table
|
||||
---@return table STANDARD The STANDARD property as a table
|
||||
function ical._private.parser.STANDARD(handler)
|
||||
function ical._private.parser:STANDARD(handler)
|
||||
local STANDARD = {}
|
||||
|
||||
-- Read each line until END:STANDARD is read
|
||||
@@ -285,13 +344,13 @@ function ical._private.parser.STANDARD(handler)
|
||||
-- Break down each line into the property:value
|
||||
local v, k = line:match("(.*):(.*)")
|
||||
if v:match("TZOFFSETFROM") then
|
||||
STANDARD.TZOFFSETFROM = ical._private.parser.offset(k)
|
||||
STANDARD.TZOFFSETFROM = self._private.parser.offset(k)
|
||||
elseif v:match("TZOFFSETTO") then
|
||||
STANDARD.TZOFFSETTO = ical._private.parser.offset(k)
|
||||
STANDARD.TZOFFSETTO = self._private.parser.offset(k)
|
||||
elseif v:match("TZNAME") then
|
||||
STANDARD.TZNAME = k
|
||||
elseif v:match("DTSTART") then
|
||||
STANDARD.DTSTART = ical._private.parser.to_datetime(k)
|
||||
STANDARD.DTSTART = self._private.parser.to_datetime(k)
|
||||
elseif v:match("RRULE") then
|
||||
STANDARD.RRULE = {
|
||||
FREQ = k:match("FREQ=([A-Z]+)"),
|
||||
@@ -329,4 +388,8 @@ function ical._private.parser.offset(offset)
|
||||
return s * (tonumber(h) * 3600 + tonumber(m) * 60)
|
||||
end
|
||||
|
||||
return ical
|
||||
function ical.mt:__call(...)
|
||||
return ical.new(...)
|
||||
end
|
||||
|
||||
return setmetatable(ical, ical.mt)
|
||||
|
||||
@@ -67,64 +67,17 @@ local list_update = function(widget, buttons, _, _, objects)
|
||||
|
||||
tag_widget:buttons(create_buttons(buttons, object))
|
||||
|
||||
--#region Rubato and Color animation
|
||||
|
||||
-- Background rubato init
|
||||
local r_timed_bg = rubato.timed { duration = 0.5 }
|
||||
local g_timed_bg = rubato.timed { duration = 0.5 }
|
||||
local b_timed_bg = rubato.timed { duration = 0.5 }
|
||||
|
||||
-- starting color
|
||||
r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(Theme_config.taglist.bg)
|
||||
|
||||
|
||||
-- Foreground rubato init
|
||||
local r_timed_fg = rubato.timed { duration = 0.5 }
|
||||
local g_timed_fg = rubato.timed { duration = 0.5 }
|
||||
local b_timed_fg = rubato.timed { duration = 0.5 }
|
||||
|
||||
-- starting color
|
||||
r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(Theme_config.taglist.fg)
|
||||
|
||||
-- Subscribable function to have rubato set the bg/fg color
|
||||
local function update_bg()
|
||||
tag_widget:set_bg("#" ..
|
||||
color.utils.rgba_to_hex { math.max(0, r_timed_bg.pos), math.max(0, g_timed_bg.pos), math.max(0, b_timed_bg.pos) })
|
||||
end
|
||||
|
||||
local function update_fg()
|
||||
tag_widget:set_fg("#" ..
|
||||
color.utils.rgba_to_hex { math.max(0, r_timed_fg.pos), math.max(0, g_timed_fg.pos), math.max(0, b_timed_fg.pos) })
|
||||
end
|
||||
|
||||
-- Subscribe to the function bg and fg
|
||||
r_timed_bg:subscribe(update_bg)
|
||||
g_timed_bg:subscribe(update_bg)
|
||||
b_timed_bg:subscribe(update_bg)
|
||||
r_timed_fg:subscribe(update_fg)
|
||||
g_timed_fg:subscribe(update_fg)
|
||||
b_timed_fg:subscribe(update_fg)
|
||||
|
||||
-- Both functions to set a color, if called they take a new color
|
||||
local function set_bg(newbg)
|
||||
r_timed_bg.target, g_timed_bg.target, b_timed_bg.target = color.utils.hex_to_rgba(newbg)
|
||||
end
|
||||
|
||||
local function set_fg(newfg)
|
||||
r_timed_fg.target, g_timed_fg.target, b_timed_fg.target = color.utils.hex_to_rgba(newfg)
|
||||
end
|
||||
|
||||
tag_widget.container.margin.label:set_text(object.index)
|
||||
-- Use the wraper function to call the set_bg and set_fg based on the client state
|
||||
if object.urgent == true then
|
||||
set_bg(Theme_config.taglist.bg_urgent)
|
||||
set_fg(Theme_config.taglist.fg_urgent)
|
||||
elseif object == awful.screen.focused().selected_tag then
|
||||
set_bg(Theme_config.taglist.bg_focus)
|
||||
set_fg(Theme_config.taglist.fg_focus)
|
||||
if object == awful.screen.focused().selected_tag then
|
||||
tag_widget:set_bg(Theme_config.taglist.bg_focus)
|
||||
tag_widget:set_fg(Theme_config.taglist.fg_focus)
|
||||
elseif object.urgent == true then
|
||||
tag_widget:set_bg(Theme_config.taglist.bg_urgent)
|
||||
tag_widget:set_fg(Theme_config.taglist.fg_urgent)
|
||||
else
|
||||
set_fg(Theme_config.taglist.fg)
|
||||
set_bg(Theme_config.taglist.bg)
|
||||
tag_widget:set_bg(Theme_config.taglist.bg)
|
||||
tag_widget:set_fg(Theme_config.taglist.fg)
|
||||
end
|
||||
--#endregion
|
||||
|
||||
@@ -154,6 +107,16 @@ local list_update = function(widget, buttons, _, _, objects)
|
||||
strategy = "exact",
|
||||
layout = wibox.container.constraint,
|
||||
})
|
||||
|
||||
--[[ awful.spawn.easy_async_with_shell(
|
||||
"ps -o cmd " .. client.pid .. " | tail -n 1",
|
||||
function(stdout)
|
||||
local cmd = stdout:gsub("\n", "")
|
||||
local app_info = Gio.AppInfo.create_from_commandline(cmd, client.name, {})
|
||||
local exec = Gio.AppInfo.get_executable(app_info)
|
||||
icon:get_children_by_id("icon")[1].image = Get_icon(exec)
|
||||
end
|
||||
) ]]
|
||||
end
|
||||
|
||||
Hover_signal(tag_widget)
|
||||
|
||||
@@ -94,54 +94,6 @@ local list_update = function(widget, buttons, label, _, objects)
|
||||
|
||||
local text, _ = label(object, task_widget.container.layout_it.title)
|
||||
|
||||
|
||||
--#region Rubato and Color animation
|
||||
|
||||
-- Background rubato init
|
||||
local r_timed_bg = rubato.timed { duration = 0.5 }
|
||||
local g_timed_bg = rubato.timed { duration = 0.5 }
|
||||
local b_timed_bg = rubato.timed { duration = 0.5 }
|
||||
|
||||
-- starting color
|
||||
r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos = color.utils.hex_to_rgba(Theme_config.tasklist.bg)
|
||||
|
||||
|
||||
-- Foreground rubato init
|
||||
local r_timed_fg = rubato.timed { duration = 0.5 }
|
||||
local g_timed_fg = rubato.timed { duration = 0.5 }
|
||||
local b_timed_fg = rubato.timed { duration = 0.5 }
|
||||
|
||||
-- starting color
|
||||
r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos = color.utils.hex_to_rgba(Theme_config.tasklist.fg)
|
||||
|
||||
-- Subscribable function to have rubato set the bg/fg color
|
||||
local function update_bg()
|
||||
task_widget:set_bg("#" .. color.utils.rgba_to_hex { r_timed_bg.pos, g_timed_bg.pos, b_timed_bg.pos })
|
||||
end
|
||||
|
||||
local function update_fg()
|
||||
task_widget:set_fg("#" .. color.utils.rgba_to_hex { r_timed_fg.pos, g_timed_fg.pos, b_timed_fg.pos })
|
||||
end
|
||||
|
||||
-- Subscribe to the function bg and fg
|
||||
r_timed_bg:subscribe(update_bg)
|
||||
g_timed_bg:subscribe(update_bg)
|
||||
b_timed_bg:subscribe(update_bg)
|
||||
r_timed_fg:subscribe(update_fg)
|
||||
g_timed_fg:subscribe(update_fg)
|
||||
b_timed_fg:subscribe(update_fg)
|
||||
|
||||
-- Both functions to set a color, if called they take a new color
|
||||
local function set_bg(newbg)
|
||||
r_timed_bg.target, g_timed_bg.target, b_timed_bg.target = color.utils.hex_to_rgba(newbg)
|
||||
end
|
||||
|
||||
local function set_fg(newfg)
|
||||
r_timed_fg.target, g_timed_fg.target, b_timed_fg.target = color.utils.hex_to_rgba(newfg)
|
||||
end
|
||||
|
||||
--#endregion
|
||||
|
||||
if object == client.focus then
|
||||
if text == nil or text == '' then
|
||||
task_widget.container.layout_it.title:set_margins(0)
|
||||
@@ -159,11 +111,11 @@ local list_update = function(widget, buttons, label, _, objects)
|
||||
task_tool_tip:remove_from_object(task_widget)
|
||||
end
|
||||
end
|
||||
set_bg(Theme_config.tasklist.bg_focus)
|
||||
set_fg(Theme_config.tasklist.fg_focus)
|
||||
task_widget:set_bg(Theme_config.tasklist.bg_focus)
|
||||
task_widget:set_fg(Theme_config.tasklist.fg_focus)
|
||||
task_widget.container.layout_it.title:set_text(text)
|
||||
else
|
||||
set_bg(Theme_config.tasklist.bg)
|
||||
task_widget:set_bg(Theme_config.tasklist.bg)
|
||||
task_widget.container.layout_it.title:set_text('')
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user