summaryrefslogtreecommitdiff
path: root/blog/spotifyd.md
blob: 56a46b8be4c4e1f0a54178f3b7bf1bffa8a2e482 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
title: "Spotify on Linux"
date: 2020-07-09
draft: false
---

I've been trying to use command-line tools more often recently, and that
includes my music software. For a long time, I was using the official Spotify
client for linux, with an AUR package [here][spotaur]. This was fine for
a while, but I really wanted to be able to use it on the commandline. This post
is documentation on where I went with this.
<!--more-->

## Beginnings
I started by doing a search for "spotify tui". This led me to a number of
options, but the only standalone one I could find was [`ncspot`][ncspot], a TUI
written in Rust. I used `cargo install` to build and compile ncspot, and was
presented with a screen allowing me to enter my username and password.

Following that, I was shown to the main screen, which looks like this:

![ncspot main page](https://files.devosmium.xyz/s/232qlo6g.png)

I could use the arrow keys or `hjkl` to navigate the tabs and songs, and `F1`,
`F2`, and `F3` to navigate the different contexts[^1]. The keybindings were
a bit confusing (`Shift-p` to toggle playback, and `>`/`<` to skip songs).

This is what the album view looked like:
![ncspot album view](https://files.devosmium.xyz/s/lwufwnj0.png)

This worked well for me, for a little while. Eventually I got tired of not being
able to control it from my phone or control other devices from my laptop.

## Enter Spotifyd
For those who don't know, Spotifyd is an open source spotify client that runs as
a system service. Its major benefit to me is the ability to use Spotify Connect
to control or be controlled by other devices like my phone. Spotifyd is part of
the AUR for different audio backends, so the install was a simple `yay -S
spotifyd-pulseaudio`.

Following the documentation at the project's [github][spotifyd-github], I filled
out a configuration file, which is tracked in my [dotfiles][dotfiles-spotd]
repository. My password is tracked by [`pass`][pass], so I can put that command
in the configuration file without worrying about my password getting leaked into
git. There's also a systemd service, that I placed in my `.config/systemd`
folder to run as a user service.

With `spotifyd` enabled and running, I found a frontend in
[`spotify-tui`][spotifytui], another TUI written in Rust. I followed the README
directions and created my OAuth application. With my Client ID/Secret in hand,
I managed to authenticate with the Spotify API and could select devices.

One of the advantages of spotifytui over ncspot at least is that it supports
Spotify Connect, so that I can control both the `spotifyd` service running on my
laptop and any other clients running on my network, including my phone.

The main layout of `spotify-tui` looks like this:
![spotify-tui main layout](https://files.devosmium.xyz/s/xyh6dpwd.png)

Overall I like `spotify-tui` a lot more than `ncspot`, but I'm keeping it on my
system in case I need to run multiple clients at once.

`spotify-tui` is available in the AUR as `yay -S spotify-tui`.

[^1]: Queue, Search, and Library, respectively

[spotaur]: https://aur.archlinux.org/packages/spotify/
[ncspot]: https://github.com/hrkfdn/ncspot
[spotifyd-github]: https://github.com/Spotifyd/spotifyd
[dotfiles-spotd]:
https://git.sr.ht/~muirrum/dotfiles/tree/master/.config/spotifyd/spotifyd.conf
[pass]: https://passwordstore.org
[spotifytui]: https://github.com/Rigellute/spotify-tui