diff --git a/pkg/clipboard/service.go b/pkg/clipboard/service.go index 3dd688d7..8e34b9a0 100644 --- a/pkg/clipboard/service.go +++ b/pkg/clipboard/service.go @@ -57,6 +57,7 @@ func (s *Service) OnStartup(_ context.Context) core.Result { s.Core().Action("clipboard.setText", setText) s.Core().Action("gui.clipboard.write", setText) s.Core().Action("clipboard.setImage", setImage) + s.Core().Action("gui.clipboard.writeImage", setImage) s.Core().Action("clipboard.clear", clear) s.Core().Action("gui.clipboard.clear", clear) s.Core().Action("gui.clipboard.read", read) diff --git a/pkg/environment/service.go b/pkg/environment/service.go index 755f1acd..352bf931 100644 --- a/pkg/environment/service.go +++ b/pkg/environment/service.go @@ -48,6 +48,14 @@ func (s *Service) OnStartup(_ context.Context) core.Result { } return core.Result{Value: ThemeInfo{IsDark: isDark, Theme: themeName(isDark)}, OK: true} }) + s.Core().Action("gui.theme.set", func(_ context.Context, opts core.Options) core.Result { + t, _ := opts.Get("task").Value.(TaskSetTheme) + isDark, err := s.setThemeOverride(t.Theme) + if err != nil { + return core.Result{Value: err, OK: false} + } + return core.Result{Value: ThemeInfo{IsDark: isDark, Theme: themeName(isDark)}, OK: true} + }) // Register theme change callback — broadcasts ActionThemeChanged via IPC s.cancelTheme = s.platform.OnThemeChange(func(isDark bool) { diff --git a/pkg/notification/service.go b/pkg/notification/service.go index faacc0a2..9e443e99 100644 --- a/pkg/notification/service.go +++ b/pkg/notification/service.go @@ -46,18 +46,34 @@ func (s *Service) OnStartup(_ context.Context) core.Result { granted, err := s.platform.RequestPermission() return core.Result{}.New(granted, err) }) + s.Core().Action("gui.notification.requestPermission", func(_ context.Context, _ core.Options) core.Result { + granted, err := s.platform.RequestPermission() + return core.Result{}.New(granted, err) + }) s.Core().Action("notification.revokePermission", func(_ context.Context, _ core.Options) core.Result { return core.Result{Value: nil, OK: true}.New(s.platform.RevokePermission()) }) + s.Core().Action("gui.notification.revokePermission", func(_ context.Context, _ core.Options) core.Result { + return core.Result{Value: nil, OK: true}.New(s.platform.RevokePermission()) + }) s.Core().Action("notification.registerCategory", func(_ context.Context, opts core.Options) core.Result { t, _ := opts.Get("task").Value.(TaskRegisterCategory) s.categories[t.Category.ID] = t.Category return core.Result{OK: true} }) + s.Core().Action("gui.notification.registerCategory", func(_ context.Context, opts core.Options) core.Result { + t, _ := opts.Get("task").Value.(TaskRegisterCategory) + s.categories[t.Category.ID] = t.Category + return core.Result{OK: true} + }) s.Core().Action("notification.clear", func(_ context.Context, opts core.Options) core.Result { t, _ := opts.Get("task").Value.(TaskClear) return core.Result{Value: nil, OK: true}.New(s.clear(t.ID)) }) + s.Core().Action("gui.notification.clear", func(_ context.Context, opts core.Options) core.Result { + t, _ := opts.Get("task").Value.(TaskClear) + return core.Result{Value: nil, OK: true}.New(s.clear(t.ID)) + }) s.Core().Action("notification.send", send) s.Core().Action("gui.notification.send", send) return core.Result{OK: true} diff --git a/pkg/systray/service.go b/pkg/systray/service.go index 992937cb..1d8a2e45 100644 --- a/pkg/systray/service.go +++ b/pkg/systray/service.go @@ -61,6 +61,26 @@ func (s *Service) OnStartup(_ context.Context) core.Result { return core.Result{Value: err, OK: false} } }) + s.Core().Action("gui.tray.showMessage", func(_ context.Context, opts core.Options) core.Result { + t := taskShowMessageFromOptions(opts) + if err := s.manager.ShowMessage(t.Title, t.Message); err == nil { + return core.Result{OK: true} + } else { + fallback := s.Core().Action("notification.send").Run(context.Background(), core.NewOptions( + core.Option{Key: "task", Value: notification.TaskSend{Options: notification.NotificationOptions{ + Title: t.Title, + Message: t.Message, + }}}, + )) + if fallback.OK { + return core.Result{OK: true} + } + if fallbackErr, ok := fallback.Value.(error); ok { + return core.Result{Value: coreerr.E("systray.showMessage", "tray message failed and notification fallback failed", fallbackErr), OK: false} + } + return core.Result{Value: err, OK: false} + } + }) s.Core().Action("systray.showPanel", func(_ context.Context, _ core.Options) core.Result { // Panel show — deferred (requires WindowHandle integration) return core.Result{OK: true}