feat: initial gosleep-timer implementation
Go TUI sleep timer with modular architecture. - Config: YAML-based, profile inheritance, auto WM detection - Engine: timer, executor, stage pipeline (pre→timer→post) - Modules: workspace (niri/hyprland/kde), media, lock, kill, notify, sound, brightness, mute, custom, script - TUI: bubbletea app with profiles, module toggles, progress bar - CLI: run, list-profiles, export, import, history, stats - History: JSONL log with statistics - QR: config export as ASCII QR
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package media
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/forust/gosleep-timer/config"
|
||||
"github.com/forust/gosleep-timer/modules"
|
||||
)
|
||||
|
||||
type MediaModule struct{}
|
||||
|
||||
func (m *MediaModule) Name() string {
|
||||
return "media"
|
||||
}
|
||||
|
||||
func (m *MediaModule) Enabled(cfg *config.Modules) bool {
|
||||
return cfg.Media != nil && cfg.Media.Enabled
|
||||
}
|
||||
|
||||
func (m *MediaModule) BuildCmds(ctx *modules.ModuleContext, stage modules.Stage) []string {
|
||||
if stage != modules.StagePre {
|
||||
return nil
|
||||
}
|
||||
if ctx.Config.Media.Action == "none" {
|
||||
return nil
|
||||
}
|
||||
return []string{fmt.Sprintf("playerctl %s", ctx.Config.Media.Action)}
|
||||
}
|
||||
|
||||
func (m *MediaModule) Validate() error {
|
||||
if _, err := exec.LookPath("playerctl"); err != nil {
|
||||
return fmt.Errorf("media: playerctl not found")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
modules.Register(&MediaModule{})
|
||||
}
|
||||
Reference in New Issue
Block a user