Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions easyeffects-presetctrl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# EasyEffects PresetCTRL

This plugin allows you to control the active easy effects preset from a bar
widget.

## Plugin

| Field | Value |
| --- | --- |
| ID | `nuddel69/easyeffects-presetctrl` |
| Entries | Bar widget: `preset_picker`; panel: `picker`|

## Requirements

Install `easyeffects` on `PATH`.

## Usage

Ensure easy effects launched at least once during the current boot. Configure
your effects in the GUI and save them as presets. The widget interfaces with the
CLI and will present you with all available outputs.

The panel can also be accessed using the IPC command:

```sh
noctalia msg panel-toggle nuddel69/easyeffects-presetctrl:picker
```

## Settings

| Setting | Type | Default | Description |
| --- | --- | --- | --- |
| `glyph` | `glyph` | `music-cog` | Icon to be displayed in widget. |
| `label` | `string` | `Audio Preset` | Widget label |
| `show-glyph` | `bool` | `true` | Whether or not to show glyph in the widget |
| `show-label` | `bool` | `true` | Whether or not to show label in the widget |

## TODO

- Enable/Disable
- Input presets
SystemD service to start easyeffects in the background
165 changes: 165 additions & 0 deletions easyeffects-presetctrl/license

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions easyeffects-presetctrl/picker.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
local enabled = true
local presetIndex = 0
local presets = {}
local title = "Easy Effects Preset Picker"

local function section(title, control)
return ui.column({ gap = 8 }, {
ui.label({ text = title, fontWeight = "medium", color = "on_surface_variant" }),
control,
})
end

local function render()
panel.render(ui.column({ flexGrow = 1, gap = 16 }, {

-- Header
ui.row({ align = "center", justify = "space_between", gap = 8 }, {
ui.label({ text = title, fontSize = 16, fontWeight = "bold", color = "on_surface", flexGrow = 1 }),
ui.button({ glyph = "close", onClick = "onCloseClicked" }),
}),

-- Body
ui.scroll({ flexGrow = 1, gap = 16 }, {
section("Preset", ui.select({ options = presets, selectedIndex = presetIndex, onChange = "onPreset" })),

section("Enable EasyEffects?", ui.row({ gap = 12, align = "center" }, {
ui.toggle({ checked = enabled, onChange = "onToggle" }),
ui.label({ text = enabled and "Enabled" or "Disabled", flexGrow = 1 }),
})),

}),
}))
end

function onOpen(_context)
local inOutputPresets = false
presets = {}

noctalia.runStream(
"easyeffects -p",
function(line)
if line == "Output presets:" then
inOutputPresets = true
return
end

if line == "Input presets:" or line == "No input presets." then
inOutputPresets = false
return
end

if inOutputPresets then
-- Match: "^<index><TAB><preset>$"
local preset = line:match("^%d+\t(.+)$")

if preset then
table.insert(presets, preset)
render()
end
end
end
)
end

function onToggle(value)
enabled = value == "true"
render()
end

function onPreset(index, _text)
presetIndex = tonumber(index) or 0
noctalia.notify("EasyEffects PresetCTRL", table.concat({"Setting preset: ", presets[presetIndex +1]}))
if not noctalia.commandExists("easyeffects") then
noctalia.notify("EasyEffects PresetCTRL", table.concat({"Can't set preset: ", presets[presetIndex +1]}))
end

noctalia.runStream(
table.concat({"easyeffects -l", '"' .. presets[presetIndex + 1] .. '"'}),
function(line)
noctalia.notify("EasyEffects PresetCTRL", line)
end)

render()
end

function onCloseClicked()
panel.close()
end
49 changes: 49 additions & 0 deletions easyeffects-presetctrl/plugin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
id = "nuddel69/easyeffects-presetctrl"
name = "EasyEffects PresetCtrl"
version = "1.0.0"
plugin_api = 3
author = "Nuddel69"
license = "AGPL-3.0"
dependencies = ["easyeffects"]
tags = ["audio", "utility", "music"]
icon = "music-cog"
description = "A plugin to switch EasyEffects output presets from a simple widget"

[[widget]]
id = "preset_picker"
entry = "widget.luau"

[[widget.setting]]
key = "glyph"
type = "glyph"
label_key = "settings.glyph.label"
description_key = "settings.glyph.description"
default = "music-cog"

[[widget.setting]]
key = "show_glyph"
type = "bool"
label_key = "settings.show_glyph.label"
default = true

[[widget.setting]]
key = "label"
type = "string"
label_key = "settings.label.label"
description_key = "settings.label.description"
default = "Audio Preset"

[[widget.setting]]
key = "show_label"
type = "bool"
label_key = "settings.show_label.label"
default = true


[[panel]]
id = "picker"
entry = "picker.luau"
width = 420
height = 230
placement = "attached"
open_near_click = true
Binary file added easyeffects-presetctrl/thumbnail.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions easyeffects-presetctrl/translations/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"settings": {
"glyph": {
"label": "Glyph",
"description": "Icon to be displayed in widget"
},
"show_glyph": {
"label": "Show Glyph",
"description": "Whether or not to show glyph in the widget"
},
"label": {
"label": "Label",
"description": "Widget label"
},
"show_label": {
"label": "Show Label",
"description": "Whether or not to show label in the widget"
}
}
}
24 changes: 24 additions & 0 deletions easyeffects-presetctrl/widget.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
local label = noctalia.getConfig("label")
local glyph = noctalia.getConfig("glyph")
local showGlyph = noctalia.getConfig("show_glyph")
local showLabel = noctalia.getConfig("show_label")


local function render()
if showGlyph then
barWidget.setGlyph(glyph)
end
if showLabel then
barWidget.setText(label)
end
end

function update()
noctalia.setUpdateInterval(1000)
render()
end

function onClick()
noctalia.togglePanel("nuddel69/easyeffects-presetctrl:picker")
render()
end