Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
streetturtle committed Mar 30, 2021
1 parent bb541ec commit 8558f58
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 13 deletions.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
# Spotify Search and Play

![screenrecord](./screenshots/screenrecord.gif)
A spotlight-like search for spotify, allow searching albums, artists, playlists and tracks and playing the selected item on Spotify client for macOS:

![screenrecord](./screenshots/screenrecord.gif)

Note that after restarting hammerspoon the default search type will be reset to tracks.

# Installation

This app uses Spotify's search API, so you need to create a developer account in order to use it, go to [Developer Dashboard](https://developer.spotify.com/dashboard/) and register, then create a client id and a secret.

- install [Hammerspoon](http://www.hammerspoon.org/) - a powerfull automation tool for OS X
- Manually:

Download the [latest release], and drag Hammerspoon.app from your Downloads folder to Applications.
- Homebrew:

```brew install hammerspoon --cask```

- download [spotify-search-and-play.spoon](https://github.com/fork-my-spoons/gitlab-merge-requests.spoon/raw/master/gitlab-merge-requests.spoon.zip), unzip and double click on a .spoon file. It will be installed under `~/.hammerspoon/Spoons` folder.

- open ~/.hammerspoon/init.lua and add the following snippet, adding your parameters:

```lua
-- Spotify search and play
hs.loadSpoon("spotify-search-and-play")
spoon['spotify-search-and-play']:setup({
client_id = '<your client id>',
secret = '<your secret>'
})
spoon['spotify-search-and-play']:bindHotkeys({
show={{"alt"}, "S"}}
)
```

The above config will set up <kbd>⌥</kbd> + <kbd>s</kbd> to open the app.
15 changes: 3 additions & 12 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ obj.__index = obj
obj.name = "spotify-search-and-play"
obj.version = "1.0"
obj.author = "Pavel Makhov"
obj.homepage = "https://github.com/fork-my-spoons/spotify-search-and-play.spoon"
obj.homepage = "https://fork-my-spoons.github.io/"
obj.license = "MIT - https://opensource.org/licenses/MIT"

obj.refresh_token_req_header = nil
obj.token = nil
obj.token_expires_at = nil
obj.choose = nil
obj.delayed_timer = nil
obj.item_type_to_search = 'track'
obj.item_type_to_search = nil
obj.iconPath = hs.spoons.resourcePath("icons")

local user_icon = hs.styledtext.new('', { font = {name = 'feather', size = 12 }})
Expand Down Expand Up @@ -134,18 +134,9 @@ function obj:init()
t = require("hs.webview.toolbar")
a = t.new("myConsole", {
{ id = "album", selectable = true, image = hs.image.imageFromPath(obj.iconPath .. '/compact-disc.png'):template(true)},
-- { id = "NSToolbarSpaceItem" },
{ id = "artist", selectable = true, image = hs.image.imageFromPath(obj.iconPath .. '/microphone.png'):template(true)},
-- { id = "NSToolbarSpaceItem" },
{ id = "playlist", selectable = true, image = hs.image.imageFromPath(obj.iconPath .. '/playlist.png'):template(true)},
-- { id = "NSToolbarSpaceItem" },
{ id = "track", selectable = true, image = hs.image.imageFromPath(obj.iconPath .. '/musical-note.png'):template(true)},
-- { id = "notShown", default = false, image = hs.image.imageFromName("NSBonjour") },
-- { id = "navGroup", label = "Navigation", groupMembers = { "navLeft", "navRight" }},
-- { id = "navLeft", image = hs.image.imageFromName("NSGoLeftTemplate"), allowedAlone = false },
-- { id = "navRight", image = hs.image.imageFromName("NSGoRightTemplate"), allowedAlone = false },
-- { id = "NSToolbarFlexibleSpaceItem" },
-- { id = "cust", label = "customize", fn = function(t, w, i) t:customizePanel() end, image = hs.image.imageFromName("NSAdvanced") }
}):canCustomize(true)
:autosaves(true)
:selectedItem("track")
Expand All @@ -165,7 +156,7 @@ end

function obj:setup(args)
self.refresh_token_req_header = hs.base64.encode(args.client_id .. ':' .. args.secret)
-- print('refresh_token_req_header = ' .. self.refresh_token_req_header)
self.item_type_to_search = args.default_search_type or 'track'
end

function obj:show()
Expand Down

0 comments on commit 8558f58

Please sign in to comment.