2018-09-14 03:53:46 +02:00
---
layout: page
---
# Spotify widget
2020-06-12 21:52:51 +02:00
This widget displays currently playing song on [Spotify for Linux ](../awesome-wm-widgets/assets/img/screenshots/spotify-widgetttps://www.spotify.com/download/linux/ ) client: ![screenshot ](../awesome-wm-widgets/assets/img/screenshots/spotify-widget/spo-wid-1.png )
Some features:
2018-09-14 03:53:46 +02:00
- status icon which shows if music is currently playing
2019-12-15 21:38:54 +01:00
- artist and name of the current song
2020-06-12 21:52:51 +02:00
- dim widget if spotify is paused
- trim long artist/song names
- tooltip with more info about the song
2018-09-14 03:53:46 +02:00
## Controls
- left click - play/pause
- scroll up - play next song
- scroll down - play previous song
## Dependencies
2019-12-15 21:38:54 +01:00
Note that widget uses the Arc icon theme, so it should be [installed ](../awesome-wm-widgets/assets/img/screenshots/spotify-widgetttps://github.com/horst3180/arc-icon-theme#installation ) first under ** /usr/share/icons/Arc/** folder.
2018-09-14 03:53:46 +02:00
2019-12-15 21:38:54 +01:00
## Customization
2018-09-25 01:18:45 +02:00
2019-12-15 21:38:54 +01:00
It is possible to customize widget by providing a table with all or some of the following config parameters:
2018-09-25 01:18:45 +02:00
2019-12-15 21:38:54 +01:00
| 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:54 +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. |
| `show_tooltip` | `true` | Show tooltip on hover with information about the playing song |
2020-06-12 21:52:51 +02:00
2018-09-25 01:18:45 +02:00
2019-12-15 21:38:54 +01:00
### Example:
2018-09-25 01:18:45 +02:00
2019-12-15 21:38:54 +01:00
```lua
spotify_widget({
font = 'Ubuntu Mono 9',
play_icon = '/usr/share/icons/Papirus-Light/24x24/categories/spotify.svg',
2020-06-12 21:52:51 +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,
show_tooltip = false
2019-12-15 21:38:54 +01:00
})
```
2018-09-25 01:18:45 +02:00
2020-06-12 21:52:51 +02:00
Gives following widget
Playing:
![screenshot ](../awesome-wm-widgets/assets/img/screenshots/spotify-widget/spotify-widget-custom-playing.png )
2018-09-25 01:18:45 +02:00
2020-06-12 21:52:51 +02:00
Paused:
![screenshot ](../awesome-wm-widgets/assets/img/screenshots/spotify-widget/spotify-widget-custom-paused.png )
2018-09-25 01:18:45 +02:00
2019-12-15 21:38:54 +01:00
## Installation
2018-09-25 01:18:45 +02:00
2019-12-15 21:38:54 +01:00
First you need to have spotify CLI installed, it uses dbus to communicate with spotify-client:
```bash
2020-07-14 17:01:04 +02:00
git clone https://gist.github.com/fa6258f3ff7b17747ee3.git
cd ./fa6258f3ff7b17747ee3
2019-12-15 21:38:54 +01:00
chmod +x sp
sudo cp ./sp /usr/local/bin/
```
Then clone repo under ** ~/.config/awesome/** and add widget in **rc.lua** :
```lua
local spotify_widget = require("awesome-wm-widgets.spotify-widget.spotify")
...
s.mytasklist, -- Middle widget
{ -- Right widgets
layout = wibox.layout.fixed.horizontal,
...
-- 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'
}),
...
```