 
 refreshFrequency: 3000
 
-template: (output) ->
-  info = output.split('@')
-  title = info[0].trim()
-  artist = info[1].trim()
-  status =
-    if info.length >= 3
-      info[2].trim()
-    else
-      ''
-  keyDiv = "<div class='text key'>&nbsp;spotify&nbsp;</div>"
-  titleDiv = "<div class='text value'>&nbsp;#{title}&nbsp;</div>"
-  artistDiv = "<div class='text value'>&nbsp;#{artist}&nbsp;</div>"
-  statusDiv = 
-    if status != ''
-      "<div class='text value'>&nbsp;#{status}&nbsp;</div>"
+label: 'spotify'
+
+render: (output) ->
+  json = JSON.parse(output)
+  if json.state == 'not running'
+    return ''
+  keyDiv = "<div class='text label'>&nbsp;#{@label}&nbsp;</div>"
+  titleDiv = "<div class='text value'>&nbsp;#{json.title}&nbsp;</div>"
+  artistDiv = "<div class='text value'>&nbsp;#{json.artist}&nbsp;</div>"
+  statusDiv =
+    if json.state != 'playing'
+      "<div class='text value'>&nbsp;#{json.state}&nbsp;</div>"
     else
       ''
   """

    font-size: 14px;
    color: #2b2b2b;

  .key
    align-self: center;
    margin: 5px 0px 5px 5px;
    background-color: #ffa3c1;

    #{statusDiv}
  </div>
  """

style:
  """
