Add ready-to-use example modules
examples/modules/ ships complete, drop-in bread modules for common desktop automations (low-battery warning, pause-media-on-headphone-unplug, dock-monitors) plus a README on installing them. Complements Examples.md, which teaches the porting patterns. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
13f54ad4ca
commit
c47d50d16e
4 changed files with 108 additions and 0 deletions
25
examples/modules/pause-media-on-headphone-unplug.lua
Normal file
25
examples/modules/pause-media-on-headphone-unplug.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
-- pause-media-on-headphone-unplug — pause playback when headphones disconnect,
|
||||
-- so sound doesn't suddenly blast out of the speakers.
|
||||
--
|
||||
-- Drop-in: copy into ~/.config/bread/modules/. Requires `playerctl`.
|
||||
|
||||
local M = bread.module({ name = "pause-media-on-headphone-unplug", version = "1.0.0" })
|
||||
|
||||
local function looks_like_headphones(name)
|
||||
if not name then return false end
|
||||
name = name:lower()
|
||||
return name:find("head") ~= nil
|
||||
or name:find("earbud") ~= nil
|
||||
or name:find("airpod") ~= nil
|
||||
or name:find("buds") ~= nil
|
||||
end
|
||||
|
||||
function M.on_load()
|
||||
bread.on("bread.device.disconnected", function(event)
|
||||
if looks_like_headphones(event.data.name) then
|
||||
bread.exec("playerctl pause")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue