Skip to content

Commit

Permalink
Add system notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusziade committed Jan 5, 2023
1 parent 7d93862 commit e99a65d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@ module github.com/marcusziade/songlink-cli.git
go 1.19

require github.com/atotto/clipboard v0.1.4

require (
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb // indirect
github.com/martinlindhe/notify v0.0.0-20181008203735-20632c9a275a // indirect
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2 // indirect
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb h1:6S+TKObz6+Io2c8IOkcbK4Sz7nj6RpEVU7TkvmsZZcw=
github.com/deckarep/gosx-notifier v0.0.0-20180201035817-e127226297fb/go.mod h1:wf3nKtOnQqCp7kp9xB7hHnNlZ6m3NoiOxjrB9hFRq4Y=
github.com/martinlindhe/notify v0.0.0-20181008203735-20632c9a275a h1:nQcAxLK581HrmqF0TVy2GC3iFjB8X+aWGtxQ/t2uyGE=
github.com/martinlindhe/notify v0.0.0-20181008203735-20632c9a275a/go.mod h1:zL1p4SieQ27ZZ4V4KdVYdEcSkVl1OwNoi8xI1r5hJkc=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2 h1:MZF6J7CV6s/h0HBkfqebrYfKCVEo5iN+wzE4QhV3Evo=
gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2/go.mod h1:s1Sn2yZos05Qfs7NKt867Xe18emOmtsO3eAKbDaon0o=
7 changes: 4 additions & 3 deletions songlink.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package main

import (
"encoding/json"
"fmt"
"log"
"net/http"
"net/url"
"strings"

"github.com/atotto/clipboard"
"github.com/martinlindhe/notify"
)

// The LinksResponse model
Expand All @@ -22,6 +22,7 @@ type LinksResponse struct {
func main() {
clipboard, err := clipboard.ReadAll()
if err != nil {
notify.Notify("Songlink", "Error", "Error reading clipboard", "Try again")
return
}
getLinks(clipboard)
Expand Down Expand Up @@ -50,9 +51,9 @@ func getLinks(searchURL string) {
}
nonLocalURL := strings.ReplaceAll(linksRes.PageUrl, "/fi", "")
clipboard.WriteAll(nonLocalURL)
fmt.Print("\nSuccess ✅\n", nonLocalURL, "\nSong.link URL copied to the clipboard\n\n")
notify.Notify("Success ✅", nonLocalURL, "Song.link URL copied to the clipboard", "")
} else {
fmt.Println("\n❌", response.Status, "Check the search URL and retry.")
notify.Notify("Error ❌", response.Status, "Check the music URL and retry.", "")
}
}

Expand Down

0 comments on commit e99a65d

Please sign in to comment.