2017-02-02 04:15:19 +01:00
# Spotify widget
2020-06-13 01:37:21 +02:00
This widget displays currently playing song on [Spotify for Linux ](https://www.spotify.com/download/linux/ ) client: ![screenshot ](./spo-wid-1.png )
Some features:
2017-02-02 04:15:19 +01:00
2017-06-21 22:42:50 +02:00
- status icon which shows if music is currently playing
2019-05-04 02:28:50 +02:00
- artist and name of the current song
2020-06-13 01:37:21 +02:00
- dim widget if spotify is paused
- trim long artist/song names
- tooltip with more info about the song
2017-06-21 22:42:50 +02:00
## Controls
- left click - play/pause
- scroll up - play next song
- scroll down - play previous song
## Dependencies
2017-04-01 04:12:36 +02:00
2017-02-02 04:15:19 +01:00
Note that widget uses the Arc icon theme, so it should be [installed ](https://github.com/horst3180/arc-icon-theme#installation ) first under ** /usr/share/icons/Arc/** folder.
2019-05-04 02:28:50 +02:00
## Customization
It is possible to customize widget by providing a table with all or some of the following config parameters:
| Name | Default | Description |
|---|---|---|
| `play_icon` | `/usr/share/icons/Arc/actions/24/player_play.png` | Play icon |
| `pause_icon` | `/usr/share/icons/Arc/actions/24/player_pause.png` | Pause icon |
| `font` | `Play 9` | Font |
2020-06-13 01:37:21 +02:00
| `dim_when_paused` | `false` | Decrease the widget opacity if spotify is paused |
| `dim_opacity` | `0.2` | Widget's opacity when dimmed, `dim_when_paused` should be set to `true` |
| `max_length` | `15` | Maximum lentgh of artist and title names. Text will be ellipsized if longer. |
2020-11-14 18:59:43 +01:00
| `show_tooltip` | `true` | Show tooltip on hover with information about the playing song |
2020-09-19 10:22:27 +02:00
| `timeout` | 1 | How often in seconds the widget refreshes |
2022-07-13 20:08:17 +02:00
| `sp_bin` | `sp` | Path to the `sp` binary. Required if `sp` is not in environment PATH. |
2020-06-13 01:37:21 +02:00
2019-05-04 02:28:50 +02:00
### Example:
```lua
spotify_widget({
font = 'Ubuntu Mono 9',
play_icon = '/usr/share/icons/Papirus-Light/24x24/categories/spotify.svg',
2020-06-13 01:37:21 +02:00
pause_icon = '/usr/share/icons/Papirus-Dark/24x24/panel/spotify-indicator.svg',
dim_when_paused = true,
dim_opacity = 0.5,
max_length = -1,
2022-07-13 20:08:17 +02:00
show_tooltip = false,
sp_bin = gears.filesystem.get_configuration_dir() .. 'scripts/sp'
2019-05-04 02:28:50 +02:00
})
```
2020-06-13 01:37:21 +02:00
Gives following widget
Playing:
![screenshot ](./spotify-widget-custom-playing.png )
2019-05-04 02:28:50 +02:00
2020-06-13 01:37:21 +02:00
Paused:
![screenshot ](./spotify-widget-custom-paused.png )
2019-05-04 02:28:50 +02:00
2017-02-02 04:15:19 +01:00
## Installation
2019-05-04 02:28:50 +02:00
First you need to have spotify CLI installed, it uses dbus to communicate with spotify-client:
```bash
2020-06-22 19:56:05 +02:00
git clone https://gist.github.com/fa6258f3ff7b17747ee3.git
cd ./fa6258f3ff7b17747ee3
2019-05-04 02:28:50 +02:00
chmod +x sp
2022-07-13 20:08:17 +02:00
# This widget will work by default if the binary is in the system PATH
2019-05-04 02:28:50 +02:00
sudo cp ./sp /usr/local/bin/
2022-07-13 20:08:17 +02:00
# Alternatively, you may save the binary anywhere and supply the path via this widget's sp_bin argument:
# cp ./sp ~/.config/awesome/scripts/
2019-05-04 02:28:50 +02:00
```
2017-02-02 04:15:19 +01:00
2019-05-04 02:28:50 +02:00
Then clone repo under ** ~/.config/awesome/** and add widget in **rc.lua** :
2017-02-02 04:15:19 +01:00
```lua
2018-01-07 01:08:40 +01:00
local spotify_widget = require("awesome-wm-widgets.spotify-widget.spotify")
2017-02-02 04:15:19 +01:00
...
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
...
2019-05-04 02:28:50 +02:00
-- default
spotify_widget(),
-- customized
spotify_widget({
font = 'Ubuntu Mono 9',
play_icon = '/usr/share/icons/Papirus-Light/24x24/categories/spotify.svg',
pause_icon = '/usr/share/icons/Papirus-Dark/24x24/panel/spotify-indicator.svg'
}),
2017-02-02 04:15:19 +01:00
...
```