Skip to content

Instantly share code, notes, and snippets.

Last active Apr 19, 2017
What would you like to do?
A dashing widget which displays the currently playing song on a squeezebox player.

Logitech Squeezebox Now Playing


Screenshot: Squeezebox Widget in action


Squeezebox Now Playing is a a Dashing widget which which displays now playing information from a Logitech Squeezebox player.


Install the widget using dashing install 9714028 or do it manually: Copy squeezebox.rb to the '/jobs' directory. Create a folder called squeezebox under /widgets. Copy, squeezebox.html and squeezebox.scss into /widgets/squeezebox.

Add the following code snippet to your dashboard .erb file:

<li data-row="1" data-col="1" data-sizex="2" data-sizey="2">
   <div data-id="now-playing" data-view="Squeezebox" data-title="Squeezebox"></div>


Edit the two constants at the beginning of squeezebox.rb:

  • LMS_URL: URL to your Squeebox Server (also known as Logitech Media Server). f.e.: http://myhomeserver:9000
  • SB_PLAYER_ID: ID of the player, can be the IP address or the MAC address. This information can be found on the webinterface under "Settings".
class Dashing.Squeezebox extends Dashing.Widget
ready: ->
# This is fired when the widget is done being rendered
onData: (data) ->
# Handle incoming data
# You can access the html node of this widget with `@node`
# Example: $(@node).fadeOut().fadeIn() will make the node flash each time data comes in.
<h1>Squeezebox Now Playing</h1>
<div class="cover-image-holder">
<img class="cover-image" data-bind-src="artwork_url" />
<div data-bind="current_title"></div>
<div data-bind="artist"></div>
<div data-bind="title"></div>
<i class="icon-background icon-music"></i>
require 'json'
require 'net/http'
require 'uri'
LMS_URL = 'http://my-sbserver:9000'
SB_PLAYER_ID = 'my-player-mac-or-ip'
def slim_request(params)
form_data = { 'id' => 1,
'method' => 'slim.request',
'params' => params,
uri = URI.parse(LMS_URL + '/jsonrpc.js')
http =, uri.port)
request =
request.body = form_data.to_json
response = JSON.parse(http.request(request).body)
return response['result']
def send_to_widget(artist, title, current_title, artwork_url)
send_event 'now-playing', { artist: artist,
title: title,
artwork_url: artwork_url,
current_title: current_title }
SCHEDULER.every '5s', :first_in => 0 do
player_status = [ SB_PLAYER_ID, [ 'status', '-', 1, 'tags:cgABbehldiqtyrSuoKLNJ' ] ]
data = slim_request(player_status)
if data['player_connected'] == 1
case data['mode']
when 'play'
if data['playlist_loop'][0].has_key?('album')
title = data['playlist_loop'][0]['album']
title = data['playlist_loop'][0]['title']
send_to_widget(data['playlist_loop'][0]['artist'], title, data['current_title'], LMS_URL + '/' + data['playlist_loop'][0]['artwork_url'])
when 'pause'
send_to_widget('paused', '', data['current_title'], LMS_URL + '/imageproxy/paused')
when 'stop'
send_to_widget('stopped', '', '', LMS_URL + '/imageproxy/stopped')
# player is not connected
send_to_widget('squeezebox is disconnected', '', '',LMS_URL + '/imageproxy/disconnected')
.widget-squeezebox h1 {
font-weight: bold;
.widget-squeezebox {
background: #00ff99;
.widget-squeezebox .cover-image {
width: 150px;
height: 150px;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment