config

package
v0.0.0-...-75edfd4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowlistSource

type AllowlistSource string

AllowlistSource indicates how an application was allowlisted

const (
	AllowlistSourceNone     AllowlistSource = ""         // Not allowlisted
	AllowlistSourceExplicit AllowlistSource = "explicit" // Explicitly added to allowlist
	AllowlistSourcePattern  AllowlistSource = "pattern"  // Matched by a pattern
	AllowlistSourceURL      AllowlistSource = "url"      // Matched by URL rule
)

type Application

type Application struct {
	ID              string          `json:"id" mapstructure:"id"`
	Name            string          `json:"name" mapstructure:"name"`
	WindowClass     string          `json:"window_class" mapstructure:"window_class"`
	PID             int             `json:"pid" mapstructure:"pid"`
	Allowlisted     bool            `json:"allowlisted" mapstructure:"allowlisted"`
	AllowlistSource AllowlistSource `json:"allowlist_source" mapstructure:"allowlist_source"`
}

Application represents a running application

type Config

type Config struct {
	// Global settings (not per-profile)
	VirtualDisplay DisplayConfig `json:"virtual_display" yaml:"virtual_display"`
	Overlay        OverlayConfig `json:"overlay" yaml:"overlay"`
	ServerPort     int           `json:"server_port" yaml:"server_port"`
	LogLevel       string        `json:"log_level" yaml:"log_level"`

	// Profile management
	ActiveProfileID string    `json:"active_profile_id" yaml:"active_profile_id"`
	Profiles        []Profile `json:"profiles" yaml:"profiles"`

	// Legacy fields - populated by Get() from active profile for backwards compat
	// These are included in JSON API responses but not serialized to YAML config files
	AllowlistPatterns      []string  `json:"allowlist_patterns,omitempty" yaml:"allowlist_patterns,omitempty"`
	AllowlistTitlePatterns []string  `json:"allowlist_title_patterns,omitempty" yaml:"allowlist_title_patterns,omitempty"`
	AllowlistedApps        []string  `json:"allowed_apps,omitempty" yaml:"allowed_apps,omitempty"`
	AllowlistURLRules      []UrlRule `json:"allowlist_url_rules,omitempty" yaml:"allowlist_url_rules,omitempty"`
	BrowserWindowClasses   []string  `json:"browser_window_classes,omitempty" yaml:"browser_window_classes,omitempty"`
	BrowserBlockedClasses  []string  `json:"browser_blocked_classes,omitempty" yaml:"browser_blocked_classes,omitempty"`
	PlaceholderImagePath   string    `json:"placeholder_image_path,omitempty" yaml:"placeholder_image_path,omitempty"`
	PlaceholderImagePaths  []string  `json:"placeholder_image_paths,omitempty" yaml:"placeholder_image_paths,omitempty"`
}

Config represents the application configuration

type DisplayConfig

type DisplayConfig struct {
	Width     int  `json:"width" yaml:"width"`
	Height    int  `json:"height" yaml:"height"`
	RefreshHz int  `json:"refresh_hz" yaml:"refresh_hz"`
	FPS       int  `json:"fps" yaml:"fps"`
	Enabled   bool `json:"enabled" yaml:"enabled"`
}

DisplayConfig represents virtual display configuration

type Geometry

type Geometry struct {
	X      int `json:"x" mapstructure:"x"`
	Y      int `json:"y" mapstructure:"y"`
	Width  int `json:"width" mapstructure:"width"`
	Height int `json:"height" mapstructure:"height"`
}

Geometry represents window geometry

type Manager

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

Manager handles configuration

func NewManager

func NewManager(configFile string) (*Manager, error)

NewManager creates a new configuration manager

func (*Manager) AddAllowlistedApp

func (m *Manager) AddAllowlistedApp(appClass string) error

AddAllowlistedApp adds an application to the allowlist of the active profile

func (*Manager) AddBrowserWindowClass

func (m *Manager) AddBrowserWindowClass(windowClass string) error

AddBrowserWindowClass stores a browser window class for URL-based allowlisting in the active profile

func (*Manager) AddPattern

func (m *Manager) AddPattern(pattern string) error

AddPattern adds an allowlist pattern to the active profile

func (*Manager) AddPlaceholderImage

func (m *Manager) AddPlaceholderImage(path string) error

AddPlaceholderImage adds a placeholder image path to the active profile

func (*Manager) AddTitlePattern

func (m *Manager) AddTitlePattern(pattern string) error

AddTitlePattern adds a title-only allowlist pattern to the active profile

func (*Manager) AddURLRule

func (m *Manager) AddURLRule(rule UrlRule) error

AddURLRule adds a URL allowlist rule to the active profile

func (*Manager) CleanupBrokenPlaceholderPaths

func (m *Manager) CleanupBrokenPlaceholderPaths() (int, error)

CleanupBrokenPlaceholderPaths removes placeholder image paths that point to non-existent files from all profiles. Returns the number of paths removed.

func (*Manager) ClearAllPlaceholderImages

func (m *Manager) ClearAllPlaceholderImages() error

ClearAllPlaceholderImages removes all placeholder image paths from the active profile

func (*Manager) ClearPlaceholderImage

func (m *Manager) ClearPlaceholderImage() error

ClearPlaceholderImage clears all placeholder images from the active profile

func (*Manager) CreateProfile

func (m *Manager) CreateProfile(name string) (*Profile, error)

CreateProfile creates a new profile with the given name

func (*Manager) DeleteProfile

func (m *Manager) DeleteProfile(profileID string) error

DeleteProfile deletes a profile by ID

func (*Manager) DuplicateProfile

func (m *Manager) DuplicateProfile(profileID, newName string) (*Profile, error)

DuplicateProfile creates a copy of an existing profile with a new name

func (*Manager) EnsureProfileDirectory

func (m *Manager) EnsureProfileDirectory(profileID string) error

EnsureProfileDirectory creates the profile directory structure if it doesn't exist

func (*Manager) Get

func (m *Manager) Get() *Config

Get returns the current configuration with legacy fields populated from active profile

func (*Manager) GetActiveProfile

func (m *Manager) GetActiveProfile() *Profile

GetActiveProfile returns a copy of the active profile

func (*Manager) GetActiveProfileID

func (m *Manager) GetActiveProfileID() string

GetActiveProfileID returns the active profile ID

func (*Manager) GetConfigDir

func (m *Manager) GetConfigDir() string

GetConfigDir returns the config directory path

func (*Manager) GetConfigPath

func (m *Manager) GetConfigPath() string

GetConfigPath returns the path to the config file

func (*Manager) GetLogLevel

func (m *Manager) GetLogLevel() string

GetLogLevel gets the log level

func (*Manager) GetPlaceholderImagePath

func (m *Manager) GetPlaceholderImagePath() string

GetPlaceholderImagePath returns the first placeholder image path Deprecated: Use GetPlaceholderImagePaths instead

func (*Manager) GetPlaceholderImagePaths

func (m *Manager) GetPlaceholderImagePaths() []string

GetPlaceholderImagePaths returns all placeholder image paths from the active profile

func (*Manager) GetPort

func (m *Manager) GetPort() int

GetPort gets the server port

func (*Manager) GetProfile

func (m *Manager) GetProfile(profileID string) (*Profile, error)

GetProfile returns a profile by ID

func (*Manager) GetProfilePlaceholderDir

func (m *Manager) GetProfilePlaceholderDir(profileID string) string

GetProfilePlaceholderDir returns the placeholder directory for a profile

func (*Manager) IsAllowlisted

func (m *Manager) IsAllowlisted(appClass string) bool

IsAllowlisted checks if an application is allowlisted in the active profile

func (*Manager) IsBrowserBlocked

func (m *Manager) IsBrowserBlocked(windowClass string) bool

IsBrowserBlocked checks if a browser window class is blocked in the active profile

func (*Manager) IsBrowserWindowClass

func (m *Manager) IsBrowserWindowClass(windowClass string) bool

IsBrowserWindowClass checks if a window class is recognized as a browser in the active profile

func (*Manager) IsPlaceholderImageUsedByOtherProfiles

func (m *Manager) IsPlaceholderImageUsedByOtherProfiles(path string) bool

IsPlaceholderImageUsedByOtherProfiles checks if the given image path is used by any profile other than the active profile

func (*Manager) ListProfiles

func (m *Manager) ListProfiles() []Profile

ListProfiles returns all profiles

func (*Manager) RemoveAllowlistedApp

func (m *Manager) RemoveAllowlistedApp(appClass string) error

RemoveAllowlistedApp removes an application from the allowlist of the active profile

func (*Manager) RemovePattern

func (m *Manager) RemovePattern(pattern string) error

RemovePattern removes an allowlist pattern from the active profile

func (*Manager) RemovePlaceholderImage

func (m *Manager) RemovePlaceholderImage(path string) error

RemovePlaceholderImage removes a placeholder image path from the active profile

func (*Manager) RemoveTitlePattern

func (m *Manager) RemoveTitlePattern(pattern string) error

RemoveTitlePattern removes a title-only allowlist pattern from the active profile

func (*Manager) RemoveURLRule

func (m *Manager) RemoveURLRule(ruleID string) error

RemoveURLRule removes a URL allowlist rule by ID from the active profile

func (*Manager) Save

func (m *Manager) Save() error

Save saves the current configuration to disk

func (*Manager) SetActiveProfile

func (m *Manager) SetActiveProfile(profileID string) error

SetActiveProfile switches to a different profile

func (*Manager) SetBrowserBlocked

func (m *Manager) SetBrowserBlocked(windowClass string, blocked bool) error

SetBrowserBlocked sets whether a browser window class is blocked in the active profile

func (*Manager) SetLogLevel

func (m *Manager) SetLogLevel(level string) error

SetLogLevel sets the log level

func (*Manager) SetPlaceholderImage

func (m *Manager) SetPlaceholderImage(path string) error

SetPlaceholderImage sets the custom placeholder image path (legacy, adds to active profile)

func (*Manager) SetPort

func (m *Manager) SetPort(port int) error

SetPort sets the server port

func (*Manager) Update

func (m *Manager) Update(cfg *Config) error

Update updates the entire configuration

func (*Manager) UpdateProfile

func (m *Manager) UpdateProfile(profile *Profile) error

UpdateProfile updates an existing profile

type OverlayConfig

type OverlayConfig struct {
	Enabled bool                     `json:"enabled" yaml:"enabled"`
	Widgets []map[string]interface{} `json:"widgets" yaml:"widgets"`
}

OverlayConfig represents overlay configuration

type Profile

type Profile struct {
	ID                     string    `json:"id" yaml:"id"`
	Name                   string    `json:"name" yaml:"name"`
	AllowlistPatterns      []string  `json:"allowlist_patterns" yaml:"allowlist_patterns"`
	AllowlistTitlePatterns []string  `json:"allowlist_title_patterns" yaml:"allowlist_title_patterns"`
	AllowlistedApps        []string  `json:"allowed_apps" yaml:"allowed_apps"`
	AllowlistURLRules      []UrlRule `json:"allowlist_url_rules" yaml:"allowlist_url_rules"`
	BrowserWindowClasses   []string  `json:"browser_window_classes" yaml:"browser_window_classes"`
	BrowserBlockedClasses  []string  `json:"browser_blocked_classes" yaml:"browser_blocked_classes"`
	PlaceholderImagePaths  []string  `json:"placeholder_image_paths" yaml:"placeholder_image_paths"`
}

Profile represents a named configuration profile with its own allowlists and placeholders

type UrlRule

type UrlRule struct {
	ID          string      `json:"id" yaml:"id"`
	Type        UrlRuleType `json:"type" yaml:"type"`
	Pattern     string      `json:"pattern" yaml:"pattern"`
	Description string      `json:"description,omitempty" yaml:"description,omitempty"`
}

UrlRule represents a URL allowlist rule

type UrlRuleType

type UrlRuleType string

UrlRuleType indicates the type of URL allowlist rule

const (
	UrlRuleTypePage      UrlRuleType = "page"
	UrlRuleTypeDomain    UrlRuleType = "domain"
	UrlRuleTypeSubdomain UrlRuleType = "subdomain"
)

type WindowInfo

type WindowInfo struct {
	ID              uint32   `json:"id" mapstructure:"id"`
	Title           string   `json:"title" mapstructure:"title"`
	Class           string   `json:"class" mapstructure:"class"`
	PID             int      `json:"pid" mapstructure:"pid"`
	Focused         bool     `json:"focused" mapstructure:"focused"`
	Geometry        Geometry `json:"geometry" mapstructure:"geometry"`
	IsNativeWayland bool     `json:"is_native_wayland" mapstructure:"is_native_wayland"` // True for native Wayland windows (no X11 ID)
	Desktop         int      `json:"desktop" mapstructure:"desktop"`                     // Virtual desktop number (-1 means all desktops/sticky)
}

WindowInfo represents information about a window

Jump to

Keyboard shortcuts

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