spicetify / cli

Command-line tool to customize Spotify client. Supports Windows, MacOS, and Linux.
https://spicetify.app
GNU Lesser General Public License v2.1
18.17k stars 716 forks source link

Add more vim bindings to keyboardShortcut.js #27

Closed rien333 closed 4 years ago

rien333 commented 5 years ago

The keybindings extension rocks! Excellent way to incoperate spotify into my more keyboard focused workflow (which could be a reason to bring more such nerds to this app).

It would be great if keyboardShortcut.js provided even more vim shortcuts, though. I especially miss a way to go back one page, and to some extent I want to be able to go the top/bottom of the page. I propose modeling these shortcuts based on qutebrowser, a vim-inspired web browser. So going forward/backward would be shift+h/l, jumping to the bottom/top would be g/G. For consistency, follow should be f (see also zathura, the vim inspired pdf reader) instead of what it is now. Maybe / for focusing the search bar as well?

My javascript is sort of eh so I won't be able to do it myself, at least not until some later time.

rien333 commented 5 years ago

Looking at the source file, there already seems to be some code to implement e.g. going backward/foward (sorry for missing this). Given the probably somewhat nerdy following, it might be a good idea to make it consistently follow vim bindings, though.

khanhas commented 5 years ago

I'm glad you like it! Your suggestions are reasonable, I should comply with keyboard-driven softwares out there instead of inventing my own keybinds.

I did make a few changes here: https://github.com/khanhas/spicetify-cli/blob/7f8205a50d69166bf865547e7a4ccbb277766f5a/Extensions/keyboardShortcut.js

If you have time, please test it out.

I added G/Shift+G scroll top/bottom, / to search, changed navigating forward/backward to shift+H/L, activate follow link function to F and added some documentation for users who want to change or add their own keybinds.

If you think of any more feature that are suitable for Spotify client, please do tell me.

khanhas commented 5 years ago

To install that, run:

curl https://raw.githubusercontent.com/khanhas/spicetify-cli/7f8205a50d69166bf865547e7a4ccbb277766f5a/Extensions/keyboardShortcut.js -o "$(dirname "$(spicetify -c)")/Extensions/keyboardShortcut.js"
spicetify apply
rien333 commented 5 years ago

Works great, tysm! It's a little difficult to get search bar to unfocus with the keyboard though, say when I want to select one of the search results. Not really sure if anything can be done about that, though. Intuitively, I think ESC would fit this purpose, but that might problematic. A modifier key + / might be a better way to unfocus.

dereknelson commented 5 years ago

@rien333 any further discussion on unfocusing with the keyboard? started using vim about 3 months ago, then vimium with chrome, and since then have been scouring the internet for months for a plugin like this and I could cry with happiness rn (bless you @khanhas) - definitely looking to contribute to improve the vim experience on spotify.

rien333 commented 5 years ago

I'm not a vim user actually - but all my main apps have vim shortcuts - so I don't have a ton of ideas about making spotify even more vim like. The most intuitive way to unfocus textfields with the keyboard still seems ESC to me, which currently just clears the text in the bar. Be sure to make a pull request/post in this thread if you have spotify keyboard experience improvements!

khanhas commented 5 years ago

Feel free to pitch your ideas here. I will help you on developing keystroke callbacks if I can.

dereknelson commented 5 years ago

@khanhas I think we should come up with a keybind to blur focus on the search field, because having to use a mouse for anything kinda ruins the point of using the keybinds in the first place.

first thing I'm most interested in is being able to queue from hitting "f". I have two ideas:

  1. a keybind to "right click" and open the context menu modal, and parse that for links: image
  2. (and the more ideal solution, IMO) prepending q to a link result, so it would look like this: image I noticed you exposed queue song which is how the 2nd one would work, all we'd have to do is get the URI somehow.
AtomToast commented 4 years ago

I have a few comments on the vim shortcuts:
first of all big <3 been looking for these for spotify for ever.

Next I have some issues with the shortcuts:

I also have some suggestions for new shortcuts:

Edit: another thing I forgot to mention was to ctrl+h/l to jump back and forward songs like with ctrl+left/right

rien333 commented 4 years ago

Another good binding idea: seeking in tracks with , (backward) and . (forward), much like mpv and cmus.

Edit: can be done like this so:

registerBind(",", false, false, false, seekBackward);

...

function seekBackward() {
        Spicetify.Player.seek(Spicetify.Player.getProgress() + parseInt(-10) * 1000);
}
rien333 commented 4 years ago

That said, @khanhas, how do you bind the period key (i.e. . )? I tried DECIMAL_POINT from keyboardshortcut.js, but that didn't work. I know you can use keycodes, but e.g. xev and showkeys report different values, and from context/examples it's not clear what and how keycodes should be used.

khanhas commented 4 years ago

@rien333 It's 190 You can get other keycode from this website: https://keycode.info/

khanhas commented 4 years ago

Also, I found no time to implement any of suggestions. You guys are always welcomed to make a pull request, I will take a look, improve or bug fix if it's needed.