#! /bin/zsh play-music-message () { clean echo local string="[ (omx) $1 ]" local len=${#string} local pad_side=$(( ($COLUMNS - $len)/2 )) local pad_right=$(( $len + $pad_side )) local pad_string_right="${(r:$pad_right:: :)string}" local pad_left=$(( $pad_side + $pad_right )) local pad_string_left="${(l:$pad_left:: :)pad_string_right}" echo $pad_string_left } check-for-tty5 () { if [[ $TTY = /dev/tty5 ]]; then return 0 else echo "Error: Not in tty5." >&2 return 1 fi } play-music () { # music only in tty5 check-for-tty5 [[ $? != 0 ]] && return 1 # files to play local -a mn mm=($@) # do it clear play-music-message $mm omx-play-whatever $OMX_MUS_MOD $mm } alias pm=play-music alias plm=play-music play-music-loop () { check-for-tty5 [[ $? != 0 ]] && return 1 local -a files files=($@) local sleep_time=1 local done_sleep_time=$(( $sleep_time * ${#files} )) while (true); do for f in $files; do play-music-message "$f " omx-play-whatever $OMX_MUS_MOD $f sleep $sleep_time done sleep $done_sleep_time done } alias pml=play-music-loop alias plml=play-music-loop