diff --git a/common/config.go b/common/config.go index a0d5015..e1f7655 100644 --- a/common/config.go +++ b/common/config.go @@ -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 @@ -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 @@ -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 { diff --git a/desktop/workspace.go b/desktop/workspace.go index 6330e5b..5b879e5 100644 --- a/desktop/workspace.go +++ b/desktop/workspace.go @@ -235,7 +235,7 @@ func (ws *Workspace) Restore(flag uint8) { } func (ws *Workspace) Write() { - if common.CacheDisabled() { + if common.CacheDisabled() || !common.Config.CacheWorkspaces { return } @@ -261,7 +261,7 @@ func (ws *Workspace) Write() { } func (ws *Workspace) Read() *Workspace { - if common.CacheDisabled() { + if common.CacheDisabled() || !common.Config.CacheWorkspaces { return ws } diff --git a/store/client.go b/store/client.go index 7be171f..d835105 100644 --- a/store/client.go +++ b/store/client.go @@ -342,7 +342,7 @@ func (c *Client) Update() { } func (c *Client) Write() { - if common.CacheDisabled() { + if common.CacheDisabled() || !common.Config.CacheWindows { return } @@ -368,7 +368,7 @@ func (c *Client) Write() { } func (c *Client) Read() *Client { - if common.CacheDisabled() { + if common.CacheDisabled() || !common.Config.CacheWindows { return c }