Skip to content

Commit

Permalink
feat: add ability to add spacer to Dock
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Sep 4, 2023
1 parent 87f906c commit 4961726
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions internal/dock/dock.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (d TileData) GetPath() string {

// PAItem is a dock plist persistent-apps item object
type PAItem struct {
GUID int `plist:"GUID"`
GUID int `plist:"GUID,omitempty"`
TileType string `plist:"tile-type"`
TileData TileData `plist:"tile-data"`
}
Expand Down Expand Up @@ -145,17 +145,27 @@ func LoadDockPlist(path ...string) (*Plist, error) {
// AddApp adds an app to the dock plist
func (p *Plist) AddApp(appPath string) error {

papp := PAItem{
GUID: rand.Intn(9999999999),
TileType: "file-tile",
TileData: TileData{
FileData: FileData{
URLString: appPath,
URLStringType: 0,
var papp PAItem
if len(appPath) == 0 { // add spacer for "" blank apps
papp = PAItem{
TileType: "small-spacer-tile",
TileData: TileData{
FileLabel: "",
},
FileLabel: fileNameWithoutExtTrimSuffix(appPath),
FileType: 41,
},
}
} else {
papp = PAItem{
GUID: rand.Intn(9999999999),
TileType: "file-tile",
TileData: TileData{
FileData: FileData{
URLString: appPath,
URLStringType: 0,
},
FileLabel: fileNameWithoutExtTrimSuffix(appPath),
FileType: 41,
},
}
}

p.PersistentApps = append(p.PersistentApps, papp)
Expand Down

0 comments on commit 4961726

Please sign in to comment.