awesome-wm-widgets/_widgets/spotify-widget.md

99 lines
3.3 KiB
Markdown
Raw Normal View History

---
layout: page
---
# Spotify widget
2022-01-24 03:05:55 +01:00
This widget displays currently playing song on [Spotify for Linux](https://www.spotify.com/download/linux/) client: ![screenshot](../awesome-wm-widgets/assets/img/widgets/screenshots/spotify-widget/spo-wid-1.png)
2020-06-12 21:52:51 +02:00
Some features:
- 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
## Controls
- left click - play/pause
- scroll up - play next song
- scroll down - play previous song
## Dependencies
2020-11-15 03:26:34 +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-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. |
2020-11-15 03:26:34 +01:00
| `show_tooltip` | `true` | Show tooltip on hover with information about the playing song |
| `timeout` | 1 | How often in seconds the widget refreshes |
2022-07-17 02:50:24 +02:00
| `sp_bin` | `sp` | Path to the `sp` binary. Required if `sp` is not in environment PATH. |
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,
2022-07-17 02:50:24 +02:00
show_tooltip = false,
sp_bin = gears.filesystem.get_configuration_dir() .. 'scripts/sp'
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:
2022-01-24 03:05:55 +01:00
![screenshot](../awesome-wm-widgets/assets/img/widgets/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:
2022-01-24 03:05:55 +01:00
![screenshot](../awesome-wm-widgets/assets/img/widgets/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
2022-07-17 02:50:24 +02:00
# This widget will work by default if the binary is in the system PATH
2019-12-15 21:38:54 +01:00
sudo cp ./sp /usr/local/bin/
2022-07-17 02:50:24 +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-12-15 21:38:54 +01:00
```
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'
}),
...
```