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,43 @@
|
||||
package kill
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/forust/gosleep-timer/config"
|
||||
"github.com/forust/gosleep-timer/modules"
|
||||
)
|
||||
|
||||
type KillModule struct{}
|
||||
|
||||
func (m *KillModule) Name() string {
|
||||
return "kill"
|
||||
}
|
||||
|
||||
func (m *KillModule) Enabled(cfg *config.Modules) bool {
|
||||
return cfg.Kill != nil && cfg.Kill.Enabled && len(cfg.Kill.Processes) > 0
|
||||
}
|
||||
|
||||
func (m *KillModule) BuildCmds(ctx *modules.ModuleContext, stage modules.Stage) []string {
|
||||
if stage != modules.StagePre {
|
||||
return nil
|
||||
}
|
||||
|
||||
var cmds []string
|
||||
for _, proc := range ctx.Config.Kill.Processes {
|
||||
if proc == "" {
|
||||
continue
|
||||
}
|
||||
cmds = append(cmds, fmt.Sprintf("pkill %s", proc))
|
||||
}
|
||||
return cmds
|
||||
}
|
||||
|
||||
func (m *KillModule) Validate() error {
|
||||
_, err := exec.LookPath("pkill")
|
||||
return err
|
||||
}
|
||||
|
||||
func init() {
|
||||
modules.Register(&KillModule{})
|
||||
}
|
||||
Reference in New Issue
Block a user