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

Manage springboard-columns and springbaord-rows #44

Open
wants to merge 3 commits into
base: master
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
52 changes: 25 additions & 27 deletions internal/command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ func SaveConfig(c *Config) (err error) {
MinimizeToApplication: dPlist.MinimizeToApplication,
MruSpaces: dPlist.MruSpaces,
ShowRecents: dPlist.ShowRecents,
SpringboardColumns: dPlist.SpringboardColumns,
SpringboardRows: dPlist.SpringboardRows,
TileSize: dPlist.TileSize,
}

Expand Down Expand Up @@ -534,33 +536,6 @@ func LoadConfig(c *Config) (err error) {
return fmt.Errorf("failed to GetMissing=>Apps: %v", err)
}

if err := lpad.Config.Verify(); err != nil {
return fmt.Errorf("failed to verify conf post removal of missing apps: %v", err)
}

utils.Indent(log.Info, 2)("creating App folders and adding apps to them")
if err := lpad.ApplyConfig(lpad.Config.Apps, groupID, 1); err != nil {
return fmt.Errorf("failed to LoadConfig->ApplyConfig: %w", err)
}

// Re-enable the update triggers
if err := lpad.EnableTriggers(); err != nil {
return fmt.Errorf("failed to EnableTriggers: %v", err)
}

if err := restartDock(); err != nil {
return fmt.Errorf("failed to restart dock: %w", err)
}

if err := lpad.FixOther(); err != nil {
return fmt.Errorf("failed to fix Other folder: %w", err)
}

if len(lpad.Config.Desktop.Image) > 0 {
utils.Indent(log.WithField("image", lpad.Config.Desktop.Image).Info, 2)("setting desktop background image")
desktop.SetDesktopImage(lpad.Config.Desktop.Image)
}

if len(lpad.Config.Dock.Apps) > 0 || len(lpad.Config.Dock.Others) > 0 {
utils.Indent(log.Info, 2)("setting dock apps")
dPlist, err := dock.LoadDockPlist()
Expand Down Expand Up @@ -591,5 +566,28 @@ func LoadConfig(c *Config) (err error) {
}
}

utils.Indent(log.Info)("creating App folders and adding apps to them")
if err := lpad.ApplyConfig(lpad.Config.Apps, groupID, 1); err != nil {
return fmt.Errorf("failed to LoadConfig->ApplyConfig: %w", err)
}

// Re-enable the update triggers
if err := lpad.EnableTriggers(); err != nil {
return fmt.Errorf("failed to EnableTriggers: %v", err)
}

if err := restartDock(); err != nil {
return fmt.Errorf("failed to restart dock: %w", err)
}

if err := lpad.FixOther(); err != nil {
return fmt.Errorf("failed to fix Other folder: %w", err)
}

if len(lpad.Config.Desktop.Image) > 0 {
utils.Indent(log.WithField("image", lpad.Config.Desktop.Image).Info)("setting desktop background image")
desktop.SetDesktopImage(lpad.Config.Desktop.Image)
}

return nil
}
2 changes: 2 additions & 0 deletions internal/database/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ type DockSettings struct {
MinimizeToApplication bool `yaml:"minimize-to-application" json:"minimize-to-application,omitempty"`
MruSpaces bool `yaml:"mru-spaces" json:"mru-spaces,omitempty"`
ShowRecents bool `yaml:"show-recents" json:"show-recents,omitempty"`
SpringboardColumns int `yaml:"springboard-columns" json:"springboard-columns,omitempty"`
SpringboardRows int `yaml:"springboard-rows" json:"springboard-rows,omitempty"`
TileSize any `yaml:"tilesize" json:"tilesize,omitempty"`
}

Expand Down
8 changes: 8 additions & 0 deletions internal/dock/dock.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Plist struct {
Region string `plist:"region"`
ShowRecents bool `plist:"show-recents"`
ShowAppExposeGestureEnabled bool `plist:"showAppExposeGestureEnabled"`
SpringboardColumns int `plist:"springboard-columns,omitempty"`
SpringboardRows int `plist:"springboard-rows,omitempty"`
TileSize any `plist:"tilesize,omitempty"`
TrashFull bool `plist:"trash-full"`
Version int `plist:"version"`
Expand Down Expand Up @@ -236,6 +238,12 @@ func (p *Plist) ApplySettings(setting database.DockSettings) error {
return fmt.Errorf("large size must be between 16 and 128: %d", setting.LargeSize)
}
}
if v := setting.SpringboardColumns; v > 0 {
p.SpringboardColumns = setting.SpringboardColumns
}
if v := setting.SpringboardRows; v > 0 {
p.SpringboardRows = setting.SpringboardRows
}
switch v := setting.TileSize.(type) {
case float64:
if v < 16 && v > 128 {
Expand Down