efe123b498
sb-music: fix song parsing wget: keep history in ~/.cache zsh: more readable vcs prompt nvim: fix python lsp path add maps for verilog cleanup files !!!BREAKING: change colorscheme dwm: cleanup files dmenu: manage colors through XResources system: change colorscheme, system-wide add relevent script adapt XResources management add $XDG_STATE_HOME directory filesystem cleanup
26 lines
1.1 KiB
Bash
Executable File
26 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env sh
|
||
|
||
######################################################################
|
||
# @author : swytch (adapted from Luke Smith - lukesmith.xyz)
|
||
# @file : sb-music
|
||
# @license : GPLv3
|
||
# @created : Saturday Feb 13, 2021 18:05:21 CET
|
||
#
|
||
# @description : music block for dwmblocks
|
||
######################################################################
|
||
|
||
|
||
unicode() { sed "s/[‘’]/'/g;s/[“”]/\"/g"; }
|
||
format() { sed "s/^volume:n\/a.*//g;/^volume:/d;s/\\&/&/g;s/\\[paused\\].*//g;s/\\[playing\\].*//g"; }
|
||
|
||
mpc="$(mpc --format "%albumartist% ~ %artist% ~ %title%")"
|
||
title="$(echo "$mpc" | head -n1 | cut -d'~' -f3 | unicode)"
|
||
[ "$(echo "$title" | wc -c)" -gt 18 ] && title="$(printf "%.15s..." "$title")"
|
||
artist="$(echo "$mpc" | head -n1 | cut -d'~' -f1 | unicode)"
|
||
[ "Various Artists " = "$artist" ] &&
|
||
artist="$(echo "$mpc" | head -n1 | cut -d'~' -f2 | unicode)"
|
||
[ "$(echo "$artist" | wc -c)" -gt 18 ] && artist="$(printf "%.15s..." "$artist")"
|
||
status="$(echo "$mpc" | tail -n2 | format)"
|
||
|
||
[ -n "$status" ] && printf " %s %s-%s " "$status" "$artist" "$title"
|