From 8558f58ad5896de8434123ebb1899e35806cd4ff Mon Sep 17 00:00:00 2001 From: streetturtle Date: Mon, 29 Mar 2021 21:34:20 -0400 Subject: [PATCH] update readme --- README.md | 36 +++++++++++++++++++++++++++++++++++- init.lua | 15 +++------------ 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a0b1169..ee69bb6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,37 @@ # Spotify Search and Play -![screenrecord](./screenshots/screenrecord.gif) \ No newline at end of file +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 = '', + secret = '' +}) +spoon['spotify-search-and-play']:bindHotkeys({ + show={{"alt"}, "S"}} +) +``` + +The above config will set up + s to open the app. \ No newline at end of file diff --git a/init.lua b/init.lua index f456536..4e27d1a 100644 --- a/init.lua +++ b/init.lua @@ -5,7 +5,7 @@ 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 @@ -13,7 +13,7 @@ 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 }}) @@ -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") @@ -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()