Skip to content

Commit

Permalink
Update dock.go
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Sep 15, 2023
1 parent 4452130 commit 5159077
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions internal/dock/dock.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,21 @@ func (p *Plist) Save() error {
return fmt.Errorf("failed to backup plist: %w", err)
}

jdat, err := p.AsJSON()
if err != nil {
return fmt.Errorf("failed to marshal plist to json: %w", err)
}
utils.Indent(log.Debug, 3)(fmt.Sprintf("dock plist: %s", string(jdat)))

// write dock plist to temp file
tmp, err := os.Create("/tmp/dock.plist")
tmp, err := os.CreateTemp("", "dock.plist")
if err != nil {
return fmt.Errorf("failed to create temp file: %v", err)
}
utils.Indent(log.WithField("plist", "/tmp/dock.plist").Info, 3)("writing temp dock plist")
defer os.Remove(tmp.Name())

utils.Indent(log.WithField("plist", tmp.Name()).Info, 3)("writing temp dock plist")
if err := plist.NewBinaryEncoder(tmp).Encode(p); err != nil {
return fmt.Errorf("failed to decode plist: %w", err)
}
tmp.Close()

// import plist and restart dock
if err := p.importPlist("/tmp/dock.plist"); err != nil {
if err := p.importPlist(tmp.Name()); err != nil {
return fmt.Errorf("failed to import plist: %w", err)
}
return p.kickstart()
Expand Down

0 comments on commit 5159077

Please sign in to comment.