Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow caching to be controlled in the config file (and in a more fine-grained way) #85

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var (
)

type Configuration struct {
CacheWorkspaces bool `toml:"cache_workspaces"` // Cache workspace properties (Tiling enablement, Current layout, proportions)
CacheWindows bool `toml:"cache_windows"` // Cache window properties ( Positions, Dimensions)
TilingEnabled bool `toml:"tiling_enabled"` // Tile windows on startup
TilingLayout string `toml:"tiling_layout"` // Initial tiling layout
TilingCycle []string `toml:"tiling_cycle"` // Cycle layout order
Expand All @@ -42,6 +44,15 @@ type Configuration struct {
Systray map[string]string `toml:"systray"` // Event bindings for systray icon
}

/*
Partially for backward compatibility, partially to stop the config file getting huge,
for the options which are not commonly needed/wanted, set their default values.
*/
func SetConfigDefaults() {
Config.CacheWindows = true
Config.CacheWorkspaces = true
}

func InitConfig() {

// Create config folder if not exists
Expand Down Expand Up @@ -85,6 +96,8 @@ func readConfig(configFilePath string, initial bool) {
fmt.Printf("FILES: \n log: %s\n lock: %s\n cache: %s\n config: %s\n\n", Args.Log, Args.Lock, Args.Cache, configFilePath)
}

SetConfigDefaults()

// Decode config file into struct
_, err := toml.DecodeFile(configFilePath, &Config)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions desktop/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (ws *Workspace) Restore(flag uint8) {
}

func (ws *Workspace) Write() {
if common.CacheDisabled() {
if common.CacheDisabled() || !common.Config.CacheWorkspaces {
return
}

Expand All @@ -261,7 +261,7 @@ func (ws *Workspace) Write() {
}

func (ws *Workspace) Read() *Workspace {
if common.CacheDisabled() {
if common.CacheDisabled() || !common.Config.CacheWorkspaces {
return ws
}

Expand Down
4 changes: 2 additions & 2 deletions store/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (c *Client) Update() {
}

func (c *Client) Write() {
if common.CacheDisabled() {
if common.CacheDisabled() || !common.Config.CacheWindows {
return
}

Expand All @@ -368,7 +368,7 @@ func (c *Client) Write() {
}

func (c *Client) Read() *Client {
if common.CacheDisabled() {
if common.CacheDisabled() || !common.Config.CacheWindows {
return c
}

Expand Down