all repos — dotfiles @ 7aea05e57ad97627f5907f1e8e220b61cc467254

my *nix dotfiles

home/bin/np.sh (view raw)

 1#!/usr/bin/env bash
 2
 3stripnl() {
 4    printf '%s' "${1##"\n"}"
 5}
 6
 7check_playing() {
 8    status="$(cmus-remote -Q | grep status | cut -d ' ' -f 2)"
 9    [[ "$status" == "paused" ]] && exit
10}
11
12check_playing
13mapfile np < <(cmus-remote -Q | grep tag | head -n3 | sort -r | cut -d ' ' -f 3-)
14track="$(stripnl "${np[0]}")"
15artist="$(stripnl "${np[1]}")"
16
17case "$1" in
18    "-a")
19        printf '%s' "$artist"
20        ;;
21    "-t")
22        printf '%s' "$track"
23        ;;
24    *)
25        printf '%s - %s\n' "$artist" "$track" 
26esac