core

package
v1.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: MIT Imports: 59 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModeCenter  = Mode(wallpaper.Center)
	ModeCrop    = Mode(wallpaper.Crop)
	ModeFit     = Mode(wallpaper.Fit)
	ModeSpan    = Mode(wallpaper.Span)
	ModeStretch = Mode(wallpaper.Stretch)
	ModeTile    = Mode(wallpaper.Tile)
)
View Source
const AppName = "Bing Wallpaper Changer"

Variables

Functions

func FromMock added in v1.0.5

func FromMock(t testing.TB) bool

FromMock returns true if the test is running in mock mode.

func GetWallpaper

func GetWallpaper() (string, error)

GetWallpaper returns the path to the current wallpaper.

func MockServers added in v1.0.5

func MockServers(t testing.TB)

MockServers sets up mock servers for the Bing and Hiragana API.

func Run added in v1.0.18

func Run(execute func(*Config) *Image, cfg *Config)

Run executes the given function with the given configuration.

func SetWallpaper

func SetWallpaper(path string, mode Mode) error

SetWallpaper sets the wallpaper from the given path.

func WithFuriganaApiAppId added in v1.0.11

func WithFuriganaApiAppId(appId string) crawlerConfigOption

func WithGoogleAppCredentials added in v1.0.11

func WithGoogleAppCredentials(credentials string) crawlerConfigOption

func WithUseGoogleText2SpeechService added in v1.0.13

func WithUseGoogleText2SpeechService(use bool) crawlerConfigOption

func WithUseGoogleTranslateService added in v1.0.16

func WithUseGoogleTranslateService(use bool) crawlerConfigOption

Types

type Audio added in v1.0.13

type Audio struct {
	Encoding   string
	Location   string
	Source     io.Reader
	SampleRate int32
}

func (*Audio) Close added in v1.0.13

func (a *Audio) Close() error

Implements the io.Closer interface.

func (*Audio) Dump added in v1.0.13

func (a *Audio) Dump(path string) error

Dump dumps the audio to the target path.

func (*Audio) Play added in v1.0.13

func (a *Audio) Play() error

Play plays the audio.

type Config added in v1.0.14

type Config struct {
	ApiPort                     int                                             `json:"-"`
	AutoPlayAudio               bool                                            `json:"autoPlayAudio"`
	Day                         types.Enum[types.Day, types.Days]               `json:"day"`
	Mode                        types.Enum[Mode, Modes]                         `json:"mode"`
	Region                      types.Enum[types.Region, types.Regions]         `json:"region"`
	Resolution                  types.Enum[types.Resolution, types.Resolutions] `json:"resolution"`
	DrawDescription             bool                                            `json:"drawDescription"`
	DrawQRCode                  bool                                            `json:"drawQRCode"`
	Watermark                   string                                          `json:"watermark"`
	DownloadOnly                bool                                            `json:"downloadOnly"`
	DownloadDirectory           string                                          `json:"downloadDirectory"`
	RotateCounterClockwise      bool                                            `json:"rotateCounterClockwise"`
	GoogleAppCredentials        string                                          `json:"googleAppCredentials"`
	FuriganaApiAppId            string                                          `json:"furiganaApiAppId"`
	UseGoogleText2SpeechService bool                                            `json:"useGoogleText2SpeechService"`
	UseGoogleTranslateService   bool                                            `json:"useGoogleTranslateService"`
	Daemon                      bool                                            `json:"daemon"`
	Debug                       bool                                            `json:"debug"`
	DimImage                    types.Percent                                   `json:"dimImage"`
}

type Controller added in v1.1.8

type Controller struct {
	// contains filtered or unexported fields
}

Controller is the controller of the application.

func (*Controller) OnExit added in v1.1.8

func (c *Controller) OnExit()

OnExit is called when the application is closed.

func (*Controller) OnReady added in v1.1.8

func (c *Controller) OnReady()

OnReady initializes the application.

type Image

type Image struct {
	image.Image
	Audio         *Audio
	Description   string
	SearchURL     string
	DownloadURL   string
	Location      string
	DimmedPercent float32
}

Image is a wrapper around the image.Image interface.

func DownloadAndDecode

func DownloadAndDecode(day types.Day, region types.Region, resolution types.Resolution, opts ...crawlerConfigOption) (*Image, error)

DownloadAndDecode fetches the Bing wallpaper and decodes it.

func SetupTestImage

func SetupTestImage(t testing.TB) *Image

SetupTestImage returns a test image

func (*Image) Dim added in v1.1.7

func (img *Image) Dim(percentage types.Percent) error

Dim dims the image by the specified percentage (0.0-100.0).

func (*Image) DrawDescription

func (img *Image) DrawDescription(position types.Position, fontName string) error

DrawDescription draws a title onto the given image.

func (*Image) DrawQRCode

func (img *Image) DrawQRCode(resolution types.Resolution, position types.Position) error

DrawQRCode draws a QR code onto the given image.

func (*Image) DrawWatermark

func (img *Image) DrawWatermark(watermarkFile string, rotateCounterClockwise bool) error

DrawWatermark draws a watermark onto the given image.

func (*Image) EncodeAndDump

func (img *Image) EncodeAndDump(targetDir string) (string, error)

EncodeAndDump encodes the image and dumps it to the target directory. If audio description is available, it will be dumped as well.

func (*Image) Equals

func (i *Image) Equals(other *Image) bool

Equals returns true if the given image is equal to the receiver.

func (*Image) Update added in v1.1.0

func (i *Image) Update(o *Image)

Update updates the receiver with the given image.

type Mode added in v1.0.4

type Mode wallpaper.Mode

Mode represents the wallpaper mode.

func (Mode) String added in v1.1.5

func (m Mode) String() string

String returns the string representation of the mode.

type Modes added in v1.1.5

type Modes []Mode

Modes represents a list of wallpaper modes.

func (Modes) Contains added in v1.1.5

func (ms Modes) Contains(m Mode) bool

Contains returns true if the mode is in the list of modes.

type Server added in v1.1.7

type Server struct {
	// contains filtered or unexported fields
}

func NewServer added in v1.1.7

func NewServer(config *Config, controller *Controller) *Server

NewServer creates a new server.

func (*Server) GetPort added in v1.1.9

func (s *Server) GetPort() int

GetPort returns the port number of the server.

func (*Server) Start added in v1.1.7

func (s *Server) Start() error

Start starts the server.

func (*Server) Stop added in v1.1.7

func (s *Server) Stop() error

Stop stops the server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL