Adding lots of cool stuff to dotfiles

This commit is contained in:
Antoine Phan
2024-02-29 01:00:26 -05:00
parent b5ad2b6c39
commit dd2ef8ddac
390 changed files with 35966 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
components = {}
function load_module(m, a)
assert(type(m) == "string", "module name is mandatory, bail out");
if not components[m] then
components[m] = { "libwireplumber-module-" .. m, type = "module", args = a }
end
end
function load_optional_module(m, a)
assert(type(m) == "string", "module name is mandatory, bail out");
if not components[m] then
components[m] = { "libwireplumber-module-" .. m, type = "module", args = a, optional = true }
end
end
function load_pw_module(m)
assert(type(m) == "string", "module name is mandatory, bail out");
if not components[m] then
components[m] = { "libpipewire-module-" .. m, type = "pw_module" }
end
end
function load_script(s, a)
if not components[s] then
components[s] = { s, type = "script/lua", args = a }
end
end
function load_monitor(s, a)
load_script("monitors/" .. s .. ".lua", a)
end
function load_access(s, a)
load_script("access/access-" .. s .. ".lua", a)
end

View File

@@ -0,0 +1,19 @@
default_access = {}
default_access.properties = {}
default_access.rules = {}
function default_access.enable()
if default_access.enabled == false then
return
end
load_access("default", {
rules = default_access.rules
})
if default_access.properties["enable-flatpak-portal"] then
-- Enables portal permissions via org.freedesktop.impl.portal.PermissionStore
load_module("portal-permissionstore")
load_access("portal")
end
end

View File

@@ -0,0 +1,29 @@
alsa_monitor = {}
alsa_monitor.properties = {}
alsa_monitor.rules = {}
function alsa_monitor.enable()
if alsa_monitor.enabled == false then
return
end
-- The "reserve-device" module needs to be loaded for reservation to work
if alsa_monitor.properties["alsa.reserve"] then
load_module("reserve-device")
end
load_monitor("alsa", {
properties = alsa_monitor.properties,
rules = alsa_monitor.rules,
})
if alsa_monitor.properties["alsa.midi"] then
load_monitor("alsa-midi", {
properties = alsa_monitor.properties,
})
-- The "file-monitor-api" module needs to be loaded for MIDI device monitoring
if alsa_monitor.properties["alsa.midi.monitoring"] then
load_module("file-monitor-api")
end
end
end

View File

@@ -0,0 +1,14 @@
libcamera_monitor = {}
libcamera_monitor.properties = {}
libcamera_monitor.rules = {}
function libcamera_monitor.enable()
if libcamera_monitor.enabled == false then
return
end
load_monitor("libcamera", {
properties = libcamera_monitor.properties,
rules = libcamera_monitor.rules,
})
end

View File

@@ -0,0 +1,14 @@
v4l2_monitor = {}
v4l2_monitor.properties = {}
v4l2_monitor.rules = {}
function v4l2_monitor.enable()
if v4l2_monitor.enabled == false then
return
end
load_monitor("v4l2", {
properties = v4l2_monitor.properties,
rules = v4l2_monitor.rules,
})
end

View File

@@ -0,0 +1,63 @@
device_defaults = {}
device_defaults.enabled = true
device_defaults.properties = {
-- store preferences to the file system and restore them at startup;
-- when set to false, default nodes and routes are selected based on
-- their priorities and any runtime changes do not persist after restart
["use-persistent-storage"] = true,
-- the default volumes to apply to ACP device nodes, in the linear scale
--["default-volume"] = 0.064,
--["default-input-volume"] = 1.0,
-- Whether to auto-switch to echo cancel sink and source nodes or not
["auto-echo-cancel"] = true,
-- Sets the default echo-cancel-sink node name to automatically switch to
["echo-cancel-sink-name"] = "echo-cancel-sink",
-- Sets the default echo-cancel-source node name to automatically switch to
["echo-cancel-source-name"] = "echo-cancel-source",
}
-- Sets persistent device profiles that should never change when wireplumber is
-- running, even if a new profile with higher priority becomes available
device_defaults.persistent_profiles = {
{
matches = {
{
-- Matches all devices
{ "device.name", "matches", "*" },
},
},
profile_names = {
"off",
"pro-audio"
}
},
}
function device_defaults.enable()
if device_defaults.enabled == false then
return
end
-- Selects appropriate default nodes and enables saving and restoring them
load_module("default-nodes", device_defaults.properties)
-- Selects appropriate profile for devices
load_script("policy-device-profile.lua", {
persistent = device_defaults.persistent_profiles
})
-- Selects appropriate device routes ("ports" in pulseaudio terminology)
-- and enables saving and restoring them together with
-- their properties (per-route/port volume levels, channel maps, etc)
load_script("policy-device-routes.lua", device_defaults.properties)
if device_defaults.properties["use-persistent-storage"] then
-- Enables functionality to save and restore default device profiles
load_module("default-profile")
end
end

View File

@@ -0,0 +1,42 @@
stream_defaults = {}
stream_defaults.enabled = true
stream_defaults.properties = {
-- whether to restore the last stream properties or not
["restore-props"] = true,
-- whether to restore the last stream target or not
["restore-target"] = true,
-- the default channel volume for new streams whose props were never saved
-- previously. This is only used if "restore-props" is set to true.
["default-channel-volume"] = 1.0,
}
stream_defaults.rules = {
-- Rules to override settings per node
-- {
-- matches = {
-- {
-- { "application.name", "matches", "pw-play" },
-- },
-- },
-- apply_properties = {
-- ["state.restore-props"] = false,
-- ["state.restore-target"] = false,
-- ["state.default-channel-volume"] = 0.5,
-- },
-- },
}
function stream_defaults.enable()
if stream_defaults.enabled == false then
return
end
-- Save and restore stream-specific properties
load_script("restore-stream.lua", {
properties = stream_defaults.properties,
rules = stream_defaults.rules,
})
end

View File

@@ -0,0 +1,155 @@
alsa_monitor.enabled = true
alsa_monitor.properties = {
-- Create a JACK device. This is not enabled by default because
-- it requires that the PipeWire JACK replacement libraries are
-- not used by the session manager, in order to be able to
-- connect to the real JACK server.
--["alsa.jack-device"] = false,
-- Reserve devices via org.freedesktop.ReserveDevice1 on D-Bus
-- Disable if you are running a system-wide instance, which
-- doesn't have access to the D-Bus user session
["alsa.reserve"] = true,
--["alsa.reserve.priority"] = -20,
--["alsa.reserve.application-name"] = "WirePlumber",
-- Enables MIDI functionality
["alsa.midi"] = true,
-- Enables monitoring of alsa MIDI devices
["alsa.midi.monitoring"] = true,
-- MIDI bridge node properties
["alsa.midi.node-properties"] = {
-- Name set for the node with ALSA MIDI ports
["node.name"] = "Midi-Bridge",
-- Removes longname/number from MIDI port names
--["api.alsa.disable-longname"] = true,
},
-- These properties override node defaults when running in a virtual machine.
-- The rules below still override those.
["vm.node.defaults"] = {
["api.alsa.period-size"] = 256,
["api.alsa.headroom"] = 8192,
},
}
alsa_monitor.rules = {
-- An array of matches/actions to evaluate.
--
-- If you want to disable some devices or nodes, you can apply properties per device as the following example.
-- The name can be found by running pw-cli ls Device, or pw-cli dump Device
--{
-- matches = {
-- {
-- { "device.name", "matches", "name_of_some_disabled_card" },
-- },
-- },
-- apply_properties = {
-- ["device.disabled"] = true,
-- },
--}
{
-- Rules for matching a device or node. It is an array of
-- properties that all need to match the regexp. If any of the
-- matches work, the actions are executed for the object.
matches = {
{
-- This matches all cards.
{ "device.name", "matches", "alsa_card.*" },
},
},
-- Apply properties on the matched object.
apply_properties = {
-- Use ALSA-Card-Profile devices. They use UCM or the profile
-- configuration to configure the device and mixer settings.
["api.alsa.use-acp"] = true,
-- Use UCM instead of profile when available. Can be
-- disabled to skip trying to use the UCM profile.
--["api.alsa.use-ucm"] = true,
-- Don't use the hardware mixer for volume control. It
-- will only use software volume. The mixer is still used
-- to mute unused paths based on the selected port.
--["api.alsa.soft-mixer"] = false,
-- Ignore decibel settings of the driver. Can be used to
-- work around buggy drivers that report wrong values.
--["api.alsa.ignore-dB"] = false,
-- The profile set to use for the device. Usually this is
-- "default.conf" but can be changed with a udev rule or here.
--["device.profile-set"] = "profileset-name",
-- The default active profile. Is by default set to "Off".
--["device.profile"] = "default profile name",
-- Automatically select the best profile. This is the
-- highest priority available profile. This is disabled
-- here and instead implemented in the session manager
-- where it can save and load previous preferences.
["api.acp.auto-profile"] = false,
-- Automatically switch to the highest priority available port.
-- This is disabled here and implemented in the session manager instead.
["api.acp.auto-port"] = false,
-- Other properties can be set here.
--["device.nick"] = "My Device",
},
},
{
matches = {
{
-- Matches all sources.
{ "node.name", "matches", "alsa_input.*" },
},
{
-- Matches all sinks.
{ "node.name", "matches", "alsa_output.*" },
},
},
apply_properties = {
--["node.nick"] = "My Node",
--["node.description"] = "My Node Description",
--["priority.driver"] = 100,
--["priority.session"] = 100,
--["node.pause-on-idle"] = false,
--["monitor.channel-volumes"] = false
--["resample.quality"] = 4,
--["resample.disable"] = false,
--["channelmix.normalize"] = false,
--["channelmix.mix-lfe"] = false,
--["channelmix.upmix"] = true,
--["channelmix.upmix-method"] = "psd", -- "none" or "simple"
--["channelmix.lfe-cutoff"] = 150,
--["channelmix.fc-cutoff"] = 12000,
--["channelmix.rear-delay"] = 12.0,
--["channelmix.stereo-widen"] = 0.0,
--["channelmix.hilbert-taps"] = 0,
--["channelmix.disable"] = false,
--["dither.noise"] = 0,
--["dither.method"] = "none", -- "rectangular", "triangular" or "shaped5"
--["audio.channels"] = 2,
--["audio.format"] = "S16LE",
--["audio.rate"] = 44100,
--["audio.allowed-rates"] = "32000,96000",
--["audio.position"] = "FL,FR",
--["api.alsa.period-size"] = 1024,
--["api.alsa.period-num"] = 2,
--["api.alsa.headroom"] = 0,
--["api.alsa.start-delay"] = 0,
--["api.alsa.disable-mmap"] = false,
--["api.alsa.disable-batch"] = false,
--["api.alsa.use-chmap"] = false,
--["api.alsa.multirate"] = true,
--["latency.internal.rate"] = 0
--["latency.internal.ns"] = 0
--["clock.name"] = "api.alsa.0"
--["session.suspend-timeout-seconds"] = 5, -- 0 disables suspend
},
},
}

View File

@@ -0,0 +1,36 @@
default_access.enabled = true
default_access.properties = {
-- Enable the use of the flatpak portal integration.
-- Disable if you are running a system-wide instance, which
-- doesn't have access to the D-Bus user session
["enable-flatpak-portal"] = true,
}
default_access.rules = {
{
matches = {
{
{ "pipewire.access", "=", "flatpak" },
{ "media.category", "=", "Manager" },
},
},
default_permissions = "all",
},
{
matches = {
{
{ "pipewire.access", "=", "flatpak" },
},
},
default_permissions = "rx",
},
{
matches = {
{
{ "pipewire.access", "=", "restricted" },
},
},
default_permissions = "rx",
},
}

View File

@@ -0,0 +1,38 @@
libcamera_monitor.enabled = true
libcamera_monitor.rules = {
-- An array of matches/actions to evaluate.
{
-- Rules for matching a device or node. It is an array of
-- properties that all need to match the regexp. If any of the
-- matches work, the actions are executed for the object.
matches = {
{
-- This matches all cards.
{ "device.name", "matches", "libcamera_device.*" },
},
},
-- Apply properties on the matched object.
apply_properties = {
-- ["device.nick"] = "My Device",
},
},
{
matches = {
{
-- Matches all sources.
{ "node.name", "matches", "libcamera_input.*" },
},
{
-- Matches all sinks.
{ "node.name", "matches", "libcamera_output.*" },
},
},
apply_properties = {
--["node.nick"] = "My Node",
--["priority.driver"] = 100,
--["priority.session"] = 100,
--["node.pause-on-idle"] = false,
},
},
}

View File

@@ -0,0 +1,38 @@
v4l2_monitor.enabled = true
v4l2_monitor.rules = {
-- An array of matches/actions to evaluate.
{
-- Rules for matching a device or node. It is an array of
-- properties that all need to match the regexp. If any of the
-- matches work, the actions are executed for the object.
matches = {
{
-- This matches all cards.
{ "device.name", "matches", "v4l2_device.*" },
},
},
-- Apply properties on the matched object.
apply_properties = {
-- ["device.nick"] = "My Device",
},
},
{
matches = {
{
-- Matches all sources.
{ "node.name", "matches", "v4l2_input.*" },
},
{
-- Matches all sinks.
{ "node.name", "matches", "v4l2_output.*" },
},
},
apply_properties = {
--["node.nick"] = "My Node",
--["priority.driver"] = 100,
--["priority.session"] = 100,
--["node.pause-on-idle"] = false,
},
},
}

View File

@@ -0,0 +1,23 @@
-- Provide the "default" pw_metadata, which stores
-- dynamic properties of pipewire objects in RAM
load_module("metadata")
-- Default client access policy
default_access.enable()
-- Load devices
alsa_monitor.enable()
v4l2_monitor.enable()
libcamera_monitor.enable()
-- Track/store/restore user choices about devices
device_defaults.enable()
-- Track/store/restore user choices about streams
stream_defaults.enable()
-- Link nodes by stream role and device intended role
load_script("intended-roles.lua")
-- Automatically suspends idle nodes after 3 seconds
load_script("suspend-node.lua")