dotfiles

*nix config files
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

commit 9da96a629ef0153bcb0675a51597ae101471ff22
parent 40801795ca7d639bb70d44030da0116f53410cc9
Author: pyratebeard <root@pyratebeard.net>
Date:   Fri, 23 Sep 2022 21:43:13 +0100

weeklymusictoot

cmus-display-script (modified) for capturing what is being listened to. wmt script to toot about it

Diffstat:
Acmus/.cmus/cmus-status-display | 46++++++++++++++++++++++++++++++++++++++++++++++
Acmus/bin/wmt | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 107 insertions(+), 0 deletions(-)

diff --git a/cmus/.cmus/cmus-status-display b/cmus/.cmus/cmus-status-display @@ -0,0 +1,46 @@ +#!/bin/sh +# +# cmus-status-display +# +# Usage: +# in cmus command ":set status_display_program=cmus-status-display" +# +# This scripts is executed by cmus when status changes: +# cmus-status-display key1 val1 key2 val2 ... +# +# All keys contain only chars a-z. Values are UTF-8 strings. +# +# Keys: status file url artist album discnumber tracknumber title date +# - status (stopped, playing, paused) is always given +# - file or url is given only if track is 'loaded' in cmus +# - other keys/values are given only if they are available +# + +output() +{ + # write status to ~/cmus-status.txt (not very useful though) + echo "$*" >> ~/.cmus/wmt.txt 2>&1 + + # WMI (http://wmi.modprobe.de/) + #wmiremote -t "$*" &> /dev/null +} + +while test $# -ge 2 +do + eval _$1='$2' + shift + shift +done + +if test -n "$_file" && test -n "$_title" && [[ "$_status" == "playing" ]] ; then + if [[ $(cmus-remote -Q | grep "set play_library" | awk '{print $NF}') == "false" ]] ; then + _underscore=$(echo $_title | sed 's/\ /_/g') + _playlist=$(grep -i -e "$_title\|$_underscore" ~/.cmus/playlists/* | awk -F: '{print $1}' | awk -F/ '{print $NF}' | head -n1) + test -n "$_playlist" && output "custom $_playlist playlist" + elif [[ $(cmus-remote -Q | grep "set play_library" | awk '{print $NF}') == "true" ]] ; then + output "$_album by $_artist" + fi + #output "[$_status] $_artist - $_album - $_title ($_date) $duration" +elif test -n "$_url" && [[ "$_status" == "playing" ]] ; then + output "$_url" +fi diff --git a/cmus/bin/wmt b/cmus/bin/wmt @@ -0,0 +1,61 @@ +#!/bin/sh +# ██ +# ░██ +# ███ ██ ██████████ ██████ +# ░░██ █ ░██ ░░██░░██░░██ ░░░██░ +# ░██ ███░██ ░██ ░██ ░██ ░██ +# ░████░████ ░██ ░██ ░██ ░██ +# ███░ ░░░██ ███ ░██ ░██ ░░██ +# ░░░ ░░░ ░░░ ░░ ░░ ░░ +# w e e k l y m u s i c t o o t + +# output of cmus-status-display script +music_list="$HOME/.cmus/wmt.txt" + +# toot command path +toot="$HOME/src/warez/toot/bin/toot" + +# sort list by number of plays +weekmusic=$(sort $music_list | uniq -c | sort -nr | \ + awk '{$1=""; print $0}' | \ + tr '[:upper:]' '[:lower:]' | \ + sed 's/^/\*\ /') + +# generate toot and count characters +char=$(cat <<wmt | wc -m +(automated) #weeklymusictoot + +this week i listened to: + +$weekmusic +wmt +) + +# if characters is more than 500 the toot will fail +# we delete the last entry in the list until +# there are less than 500 chars +until [ ${char} -lt 500 ] ; do +weekmusic=$(echo "$weekmusic" | sed '$d') +cat <<wmt +$weekmusic +wmt +char=$(cat <<wmt | wc -m +(automated) #weeklymusictoot + +this week i listened to: + +$weekmusic +wmt +) +sleep 1 +done + +# generate toot then delete list for next week +# if it fails page me +cat <<wmt | $toot post && rm -f ${music_list} || curl -d "wmt failed to send" https://pager.pyratebeard.net/wmt +(automated) #weeklymusictoot + +this week i have been listening to: + +$weekmusic +wmt