This directory contains a few scripts and snippets I use to control cmus.
All scripts should be copied to somewhere on your path. I usually install them to my personal bin directory (~/bin/), but as long as it is somewhere on your path, it doesn't matter!
The main script in this repo (and the main focus) is nowplay.
nowplay uses a single call to cmus-remote to get information about the status of cmus and the currently playing track and then parses out and displays the artist/song-title information.
nowplay can be ran in a terminal to get now playing information from cmus.
It can also be called in a .conkyrc script to display track information on the desktop in conky.
If you use a terminal multiplexer like screen or tmux - you could dedicate a window, or a pane in your layout to a script which uses nowplay to display track information.
Contained here are a few additional scripts and snippets that serve to demonstrate several uses for nowplay. I've also included some other cmus related shortcuts I use.
statuspane - An example monitor to be ran in a pane in a screen or tmux session.
If you use tmux or screen, you might use a multi-pane setup and want a particular pane to display some system information, including the currently playing track.
The screenshot below shows statuspane running in the bottom right pane in a tmux session.
statustty - is a very silly usage of nowplay (requires nowplay and ptymsg).
What this does is monitors cmus and sends a message to ALL terminals/pty's each time cmus's status changes.
e.g.
Each time a new track starts playing, or the player is stopped, or paused, or resumed.
It's not particularly useful because it spams ALL applications running in ALL terminals/pty's. So you'll get now-playing information spammed into terminals running applications like cmus and vim.
This was just one of my failed experiments that I thought was interesting. A better idea might be to set up some kind of subscriber pattern and register the pty's that you want to see now-playing information in. NOTE: Debian no longer seems to use pty's so the ptymsg script does not work. It still works in Windows under cygwin.
ptymsg - is a script used by statustty to send a message to all pty's.
NOTE: Debian no longer seems to use pty's - so the ptymsg script does not work.
It still works in Windows under cygwin.
The following snippets are just some random ideas of uses for nowplay.
The first three are things I actually use in my current setup on Linux (at home) and on Windows (at work).
conky.conf.snippet - is a line from my conky.conf - showing how to use nowplay in conky.
aliases - contains some aliases which I have set up in my .bashrc. These allow me to control cmus from any terminal without having to type "cmus-remote {parameters}" each time. Instead I simply type play, or pause, or next etc.
nowplay2 - is an example snippet showing how to use nowplay to copy track information to the clipboard via xclip.
To control cmus from your desktop, you simply set up some short-cut keys that call various cmus-remote commands. This should work for any desktop environment. All you need to do open up the settings manager for your chosen desktop and find the section that will allow you to create a new key-bind. The exact instructions to do this will vary from desktop to desktop. A simple web-search should allow you to find out how to create a custom keybind for your desktop environment.
Once you know how to create a new keybind, you can create a new key-bind and bind it to the cmus-remote command that you require.
e.g.
For play, you would bind the command cmus-remote -p
to whatever your chosen key is - a media key on your keyboard, or ctrl+alt+p, or whatever!
For stop, you would bind cmus-remote -s
to whatever key you want.
Personally I don't use a typical desktop environment on my Linux PCs. I use dwm - a lightweight, tiling window manager for X11 (It also works on Windows - again, via Cygwin).
dwm.config.h.snippet - is a snippet from my config.h for dwm, which binds cmus-remote commands to my media keys on my laptop.
dwm is a tiling window manager that can be built and ran on any platform that supports X11. Linux, BSD, Mac (probably) and even including Windows (with cygwin!)
To control cmus from the Windows desktop see WINDOWS.md.