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 5, 2023
1 parent 1fdfe15 commit 3bdef20
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/dock/dock.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,19 @@ func (p *Plist) AddApp(appPath string) error {

// AddOther adds an other to the dock plist
func (p *Plist) AddOther(other database.Folder) error {
abspath, err := filepath.Abs(other.Path)
abspath := other.Path
home, err := os.UserHomeDir()
if err != nil {
return fmt.Errorf("failed to get user home directory: %v", err)
}
if abspath == "~" {
abspath = home
} else if strings.HasPrefix(abspath, "~/") {
abspath = filepath.Join(home, strings.TrimPrefix(abspath, "~/"))
}
abspath, err = filepath.Abs(abspath)
if err != nil {
return fmt.Errorf("failed to get absolute path for '%s': %v", other.Path, err)
return fmt.Errorf("failed to get absolute path for '%s': %v", abspath, err)
}
pother := POItem{
GUID: rand.Intn(9999999999),
Expand Down

0 comments on commit 3bdef20

Please sign in to comment.