ctl

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Overview

Package ctl implements the main controller used for all of the available resetting schemes (e.g. multi, wall.)

Index

Constants

View Source
const (
	HookReset int = iota
	HookAltRes
	HookNormalRes
	HookLock
	HookUnlock
	HookWallPlay
	HookWallReset
)

Hook types

Variables

This section is empty.

Functions

func Run

func Run(conf *cfg.Profile) error

Run creates a new controller with the given configuration profile and runs it.

Types

type Controller

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

Controller manages all of the components necessary for resetti to run and handles communication between them.

func (*Controller) CreateSleepbgLock

func (c *Controller) CreateSleepbgLock()

CreateSleepbgLock creates the sleepbg.lock file.

func (*Controller) DeleteSleepbgLock

func (c *Controller) DeleteSleepbgLock(ignoreErrors bool)

DeleteSleepbgLock deletes the sleepbg.lock file.

func (*Controller) FocusInstance

func (c *Controller) FocusInstance(id int)

FocusInstance switches focus to the given instance.

func (*Controller) PlayInstance

func (c *Controller) PlayInstance(id int)

PlayInstance switches focus to the given instance, marks it as the active instance, and starts playing it.

func (*Controller) ResetInstance

func (c *Controller) ResetInstance(id int) bool

ResetInstance attempts to reset the given instance and returns whether or not the reset was successful.

func (*Controller) RunHook

func (c *Controller) RunHook(hook int)

RunHook runs the hook of the given type if it exists.

func (*Controller) SetPriority

func (c *Controller) SetPriority(id int, prio bool)

SetPriority sets the priority of the instance in the CPU manager.

func (*Controller) ToggleResolution

func (c *Controller) ToggleResolution(id int)

ToggleResolution switches the given instance between the normal and alternate resolution.

type CpuManager

type CpuManager interface {
	// Run handles state updates and moves instances between affinity groups.
	Run(context.Context, *sync.WaitGroup)

	// SetPriority sets the priority state of the given instance.
	SetPriority(int, bool)

	// Update updates the affinity state of the given instance as needed based on
	// the state change.
	Update(mc.Update)
}

CpuManager controls how much CPU time is given to each instance bsaed on its state.

func NewCpuManager

func NewCpuManager(instances []mc.InstanceInfo, states []mc.State, conf *cfg.Profile) (CpuManager, error)

NewCpuManager creates a new cpuManager for the given instances and config profile. If necessary, it prompts the user for root permission and runs the cgroup creation script.

type Frontend

type Frontend interface {
	// Input processes a single user input.
	Input(Input)

	// ProcessEvent processes a miscellanous event from the X server.
	ProcessEvent(x11.Event)

	// Setup takes in all of the potentially needed dependencies and prepares
	// the Frontend to handle user input.
	Setup(frontendDependencies) error

	// Update processes a single instance state update.
	Update(mc.Update)
}

A Frontend handles user-facing I/O (input handling, instance actions, OBS output) and communicates with a Controller.

type Input

type Input struct {
	Bind cfg.Bind
	Held bool
	X, Y int
}

An Input represents a single user input.

type MovingWall

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

MovingWall implements a "moving wall" interface, where the user can see one or more groups of instances on an OBS projector and manage them from there.

func (*MovingWall) Input

func (m *MovingWall) Input(input Input)

Input processes a single user input.

func (*MovingWall) ProcessEvent

func (m *MovingWall) ProcessEvent(evt x11.Event)

ProcessEvent implements Frontend.

func (*MovingWall) Setup

func (m *MovingWall) Setup(deps frontendDependencies) error

Setup implements Frontend.

func (*MovingWall) Update

func (m *MovingWall) Update(update mc.Update)

Update processes a single instance state update.

type Multi

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

Multi implements a traditional Multi-instance interface, where the user plays and resets one instance at a time.

func (*Multi) Input

func (m *Multi) Input(input Input)

Input implements Frontend.

func (*Multi) ProcessEvent

func (m *Multi) ProcessEvent(x11.Event)

ProcessEvent implements Frontend.

func (*Multi) Setup

func (m *Multi) Setup(deps frontendDependencies) error

Setup implements Frontend.

func (*Multi) Update

func (m *Multi) Update(update mc.Update)

Update implements Frontend.

type ProjectorController

type ProjectorController struct {
	Active bool // Whether the projector is focused

	BaseWidth, BaseHeight int // OBS canvas size
	// contains filtered or unexported fields
}

ProjectorController maintains information about the state of the OBS projector and the mouse pointer.

func (*ProjectorController) Focus

func (p *ProjectorController) Focus() error

Focus finds the wall projector and focuses it.

func (*ProjectorController) InBounds

func (p *ProjectorController) InBounds(x, y int) bool

InBounds returns whether or not the given coordinates are outside the bounds of the projector window.

func (*ProjectorController) ProcessEvent

func (p *ProjectorController) ProcessEvent(evt x11.Event)

ProcessEvent processes a single event.

func (*ProjectorController) Setup

func (p *ProjectorController) Setup(conf *cfg.Profile, obs *obs.Client, x *x11.Client) error

Setup sets up the ProjectorController.

func (*ProjectorController) ToScreen

func (p *ProjectorController) ToScreen(x, y int) (int, int)

ToScreen translates the given OBS video coordinates to screen coordinates.

func (*ProjectorController) ToVideo

func (p *ProjectorController) ToVideo(x, y int) (int, int)

ToVideo translates the given screen coordinates to OBS video coordinates.

func (*ProjectorController) Unfocus

func (p *ProjectorController) Unfocus()

Unfocus signals that the user left the projector.

type Wall

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

Wall implements a standard "Wall" interface, where the user can see all of their instances on an OBS projector and manage them from there.

func (*Wall) Input

func (w *Wall) Input(input Input)

Input implements Frontend.

func (*Wall) ProcessEvent

func (w *Wall) ProcessEvent(evt x11.Event)

ProcessEvent implements Frontend.

func (*Wall) Setup

func (w *Wall) Setup(deps frontendDependencies) error

Setup implements Frontend.

func (*Wall) Update

func (w *Wall) Update(update mc.Update)

Update implements Frontend.

Jump to

Keyboard shortcuts

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