npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sonos-simple-cli

v0.1.2

Published

Control Sonos from CLI with pause|play mute toggle and more, with Alfred support for keyboard shortcuts

Downloads

4

Readme

Sonos Simple CLI

There are many better projects out there.

But this is one I am working on to play with Node CLI and to use personally for the control of my own Sonos speakers.

Features

  • [x] acts only only the configured device via roomName config file ~/.sonos.json
  • [x] caches a found/configured device (faster startup)
  • [x] supports pause/play toggle, and prev/next, vol +/-
  • [x] built in support for Alfred Workflow (and thus a global hotkey shortcut)
  • [x] configuration file ~/.sonos.json to setup which roomName you want to use
  • [ ] fix Alfred path so we don't need the ~/bin/ symlink
  • [ ] better configuration file setup
  • [ ] support for "get first" vs. configured roomName

Thanks

A big thanks to the Sonos API implementation Lib I'm using:

https://github.com/bencevans/node-sonos

Install

$ npm install sonos-simple-cli -g

If you want to use Alfred Workflow - it has path problems which I'm currently solving with an explicit symlink (something more elegant coming)

cd ~
mkdir bin
cd bin
ln -s $(which sonos-simple-cli) sonos-simple-cli

Development / Manual Install

if for some reason, you want to develop on this and play with it, here's a guide which shuld get you setup and functional pretty easily.

cd ~
mkdir bin
git clone https://github.com/zeroasterisk/sonos-simple-cli.git sonos-simple-cli-repo
ln -s sonos-simple-cli-repo/sonos.js sonos-simple-cli
cd sonos-simple-cli-repo
npm install

Manual Script Running

$ node ~/bin/sonos.js help
-----------------------------
----- Sonos Simple CLI ------
-----------------------------
sonos-simple-cli playpause
sonos-simple-cli play
sonos-simple-cli pause
sonos-simple-cli next
sonos-simple-cli prev
sonos-simple-cli volup
sonos-simple-cli voldown
sonos-simple-cli mute
sonos-simple-cli unmute
sonos-simple-cli mutetoggle
sonos-simple-cli clearCache
-----------------------------

$ ~/bin/sonos-simple-cli playpause
  > SONOS set to PAUSED
  Beastie Boys "I Don't Know"
    @ 58/180 sec

Configure for Alfred

Install Alfred if not already installed.

To get the workflow, just double-click on sonos-simple-cli.alfredworkflow and install it.

You will recognise Alfred workflows by their .alfredworkflow file extension and their icon.

To install a workflow, simply double-click the workflow file on your Mac. Alfred will show you a preview of the name and description of the workflow as well as the details for the developer, if available. Click the "Import" button to add the workflow to the sidebar on the left.

http://support.alfredapp.com/workflows:installing/

  • CMD+F7 -> prev
  • CMD+F8 -> play/pause
  • CMD+F9 -> next
  • CMD+F10 -> mutetoggle
  • CMD+F11 -> volume down
  • CMD+F12 -> volume up

Manual Setup in Alfred

here's how I created the Alfred Worflow

Alfred > Workflows

Click + (bottom left) to add a new Workflow

Click + (top right) to add an trigger > hotkey

Then choose your hotkey and save.

Click + (top right) to add an action -> run script

select /bin/bash at the top, then enter the following

source ~/.profile
/usr/local/bin/node ~/bin/sonos.js pauseplay

ss

then click save.

Finally, drag a line between them.

ss

Bonus Points, output when done

Add an output > notification and setup as follows

ss

then connect and you're all set