SpotifyをTerminalで使う!spotify-tuiの設定・ポイントを解説の絵文字

SpotifyをTerminalで使う!spotify-tuiの設定・ポイントを解説

2022-06-05

2022-06-05

はじめに

こんにちは、音楽聴くの大好きで作りたいと思うこふです。

実際に使った様子

ちなみにターミナルのソフトウェアは iTerm2 を使っています。

Terminal ソフトウェアの設定により、背景・透過などは異なるかと思いますが、関係はありません。

プログラミング経験は不要ですが、馴染みのないツール・用語があると思います。ご了承ください。

導入する手順

インストールと API の取得・設定のみです。

Terminal 系のソフトウェアをインストール

こだわりがなければ基本的に標準で入っているもので大丈夫です。

カスタマイズしやすい、付属機能が多いなど便利な点はあります。

iTerm2 のダウンロード:https://iterm2.com/

spotify-tui のインストール

1❯ brew install spotify-tui

API の情報を作成・取得・反映

Spotify のDeveloper ページにアクセスします。

CREATE AN APP をクリックし、以下のような画面でアプリ名・説明を入力します。

※アプリ名を見て、何に利用しているか分かれば OK です。


リダイレクト用の URL を設定します。

http://localhost:8888/callbackです。

Terminal の再起動してから、sptと入力して spotify-tui を起動します。

上記のように Client ID・Client Secret を入力します。

ポートの設定は後から変更できるので、上記の入力以外は ENTER を押してパスして大丈夫です。


以下のようにクライアント(自分側の)設定ファイルが生成されるので、編集することで上書きが可能です。

具体的には、Client ID・Client Secret・Port・Device IDです。

1You can edit the config at anytime at ${HOME}/.config/spotify-tui/client.yml. (for snap ${HOME}/snap/spt/current/.config/spotify-tui/client.yml)

使い方解説

設定を工夫します。新たにファイルを作成します。

1❯ vim ~/.config/spotify-tui/config.yml

以下は公式配布されているものです。

ここから各種色・ショートカットを変更できます。

1# Sample config file 2 3# The theme colours can be an rgb string of the form "255, 255, 255" or a string that references the colours from your terminal theme: Reset, Black, Red, Green, Yellow, Blue, Magenta, Cyan, Gray, DarkGray, LightRed, LightGreen, LightYellow, LightBlue, LightMagenta, LightCyan, White. 4theme: 5 active: Cyan # current playing song in list 6 banner: LightCyan # the "spotify-tui" banner on launch 7 error_border: Red # error dialog border 8 error_text: LightRed # error message text (e.g. "Spotify API reported error 404") 9 hint: Yellow # hint text in errors 10 hovered: Magenta # hovered pane border 11 inactive: Gray # borders of inactive panes 12 playbar_background: Black # background of progress bar 13 playbar_progress: LightCyan # filled-in part of the progress bar 14 playbar_progress_text: Cyan # song length and time played/left indicator in the progress bar 15 playbar_text: White # artist name in player pane 16 selected: LightCyan # a) selected pane border, b) hovered item in list, & c) track title in player 17 text: '255, 255, 255' # text in panes 18 header: White # header text in panes (e.g. 'Title', 'Artist', etc.) 19 20behavior: 21 seek_milliseconds: 5000 22 volume_increment: 10 23 # The lower the number the higher the "frames per second". You can decrease this number so that the audio visualisation is smoother but this can be expensive! 24 tick_rate_milliseconds: 250 25 # Enable text emphasis (typically italic/bold text styling). Disabling this might be important if the terminal config is otherwise restricted and rendering text escapes interferes with the UI. 26 enable_text_emphasis: true 27 # Controls whether to show a loading indicator in the top right of the UI whenever communicating with Spotify API 28 show_loading_indicator: true 29 # Disables the responsive layout that makes the search bar smaller on bigger 30 # screens and enforces a wide search bar 31 enforce_wide_search_bar: false 32 # Determines the text icon to display next to "liked" Spotify items, such as 33 # liked songs and albums, or followed artists. Can be any length string. 34 # These icons require a patched nerd font. 35 liked_icon:36 shuffle_icon: 🔀 37 repeat_track_icon: 🔂 38 repeat_context_icon: 🔁 39 playing_icon:40 paused_icon:41 # Sets the window title to "spt - Spotify TUI" via ANSI escape code. 42 set_window_title: true 43 44keybindings: 45 # Key stroke can be used if it only uses two keys: 46 # ctrl-q works, 47 # ctrl-alt-q doesn't. 48 back: 'ctrl-q' 49 50 jump_to_album: 'a' 51 52 # Shift modifiers use a capital letter (also applies with other modifier keys 53 # like ctrl-A) 54 jump_to_artist_album: 'A' 55 56 manage_devices: 'd' 57 decrease_volume: '-' 58 increase_volume: '+' 59 toggle_playback: ' ' 60 seek_backwards: '<' 61 seek_forwards: '>' 62 next_track: 'n' 63 previous_track: 'p' 64 copy_song_url: 'c' 65 copy_album_url: 'C' 66 help: '?' 67 shuffle: 'ctrl-s' 68 repeat: 'r' 69 search: '/' 70 audio_analysis: 'v' 71 jump_to_context: 'o' 72 basic_view: 'B' 73 add_item_to_queue: 'z'

おすすめの変更箇所は、ボリュームの上下の幅です。

標準値は 10%の値ですが、5%がおすすめです。

1behavior: 2 volume_increment: 5

GUI では面倒なことをやるべきだと思っています。そのため、主に選曲することに利用して便利だと感じます。


補足ですが、Spotifyd を使うことで、spotify-tui ではできないことも可能です。spotify-tui は公式の Web API でできることしか対応できません。

参考:https://github.com/Spotifyd/spotifyd

注意点

実装されていない機能も数多くあります。以下がロードマップとなっています。

ロードマップ:https://github.com/Rigellute/spotify-tui#high-level-requirements-yet-to-be-implemented

おわりに

これで Terminal から Spotify を使えるようになり、マウス操作が不要となりました。コマンドを適宜覚えて、上手に活用しようと思います。

参考




共有する