2022-01-08 06:33:24 +01:00
|
|
|
local awful = require("awful")
|
|
|
|
local gtimer = require("gears.timer")
|
2021-04-24 11:37:06 +02:00
|
|
|
local beautiful = require("beautiful")
|
2022-01-08 06:33:24 +01:00
|
|
|
local naughty = require("naughty")
|
2021-04-24 11:37:06 +02:00
|
|
|
|
|
|
|
-- Use CLI backend as default as it is supported on most if not all systems
|
|
|
|
local backend_config = beautiful.playerctl_backend or "playerctl_cli"
|
|
|
|
local backends = {
|
|
|
|
playerctl_cli = require(... .. ".playerctl_cli"),
|
2021-08-27 20:01:22 +02:00
|
|
|
playerctl_lib = require(... .. ".playerctl_lib"),
|
2021-04-24 11:37:06 +02:00
|
|
|
}
|
|
|
|
|
2022-01-08 06:33:24 +01:00
|
|
|
local backend = nil
|
|
|
|
|
2021-04-24 11:37:06 +02:00
|
|
|
local function enable_wrapper(args)
|
2022-01-08 06:33:24 +01:00
|
|
|
local open = naughty.action { name = "Open" }
|
|
|
|
|
|
|
|
open:connect_signal("invoked", function()
|
|
|
|
awful.spawn("xdg-open https://blingcorp.github.io/bling/#/signals/pctl")
|
|
|
|
end)
|
|
|
|
|
|
|
|
gtimer.delayed_call(function()
|
|
|
|
naughty.notify({
|
|
|
|
title = "Bling Error",
|
|
|
|
text = "Global signals are deprecated! Please take a look at the playerctl documentation.",
|
|
|
|
app_name = "Bling Error",
|
|
|
|
app_icon = "system-error",
|
|
|
|
actions = { open }
|
|
|
|
})
|
|
|
|
end)
|
|
|
|
|
2021-04-24 11:37:06 +02:00
|
|
|
backend_config = (args and args.backend) or backend_config
|
2022-01-08 06:33:24 +01:00
|
|
|
backend = backends[backend_config](args)
|
|
|
|
return backend
|
2021-04-24 11:37:06 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
local function disable_wrapper()
|
2022-01-08 06:33:24 +01:00
|
|
|
backend:disable()
|
2021-04-24 11:37:06 +02:00
|
|
|
end
|
|
|
|
|
2022-01-08 06:33:24 +01:00
|
|
|
return {
|
|
|
|
lib = backends.playerctl_lib,
|
|
|
|
cli = backends.playerctl_cli,
|
|
|
|
enable = enable_wrapper,
|
|
|
|
disable = disable_wrapper
|
|
|
|
}
|