Skip to content

Instantly share code, notes, and snippets.

@kylejohnson
Last active December 6, 2018 21:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylejohnson/8789893 to your computer and use it in GitHub Desktop.
Save kylejohnson/8789893 to your computer and use it in GitHub Desktop.
pianobar widget for Dashing.

Preview

Pianobar Widget Preview

Description

Displays the currently playing song from pianobar, a CLI client for pandora.com

Dependencies

Your system ruby must have the following gems installed: net/http, json and uri.

Usage

  1. dashing install 8789893
  2. Copy pianobar.rb somewhere on your system e.g. ~/.config/pianobar/pianobar.rb
  3. Make pianobar.rb executable e.g. chmod +x ~/.config/pianobar/pianobar.rb
  4. Ensure that the following line is present in your pianobar config file (typically ~/.config/pianobar/config): event_command = ~/.config/pianobar/pianobar.rb
  5. To include the widget in a dashboard, add the following snippet to the dashboard layout file:
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="pianobar" data-view="Pianobar"></div>
</li>

Support

This widget can be found as either a gist or a github repo.

If things aren't working, please open a github issue

class Dashing.Pianobar extends Dashing.Widget
<h1 class="title">Now Playing</h1>
<p class="songtitle" data-bind="title"></p>
<p>By</p>
<p class="artist" data-bind="artist"></p>
#!/usr/bin/env ruby
require 'net/http'
require 'json'
require 'uri'
my_dashboard = 'http://localhost:3030/widgets'
my_widget = 'pianobar'
dashing_auth_token = "YOUR_AUTH_TOKEN"
event = ARGV.first
if event == 'songstart'
d = {}
STDIN.each_line {
|line| d.store(*line.chomp.split('=', 2))
}
uri = URI.parse("#{my_dashboard}/#{my_widget}")
request = Net::HTTP::Post.new(uri.request_uri)
request.body = {
:auth_token => dashing_auth_token,
:artist => d['artist'],
:title => d['title'],
:coverArt => d['coverArt']
}.to_json
res = Net::HTTP.start(uri.host, uri.port) do |http|
http.request request
end
end
// ----------------------------------------------------------------------------
// Sass declarations
// ----------------------------------------------------------------------------
$mid-color: #396A92;
$light-color: #9AB4CB;
// ----------------------------------------------------------------------------
// Widget-text styles
// ----------------------------------------------------------------------------
.widget-pianobar {
background-color: $mid-color;
.title, p {
color: $light-color;
}
.artist, .songtitle {
color: #FDFDFD;
font-size:25px;
}
&.large h3 {
font-size: 65px;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment