dotfiles

custom dotfiles
git clone git://git.pyratebeard.net/dotfiles.git
Log | Files | Refs | README

commit cbe540602e00f2a46588b651e7b39c332895976d
parent 2677a382c9deb0a099ff9ee4542ce4e730d5e9ce
Author: pyratebeard <root@pyratebeard.net>
Date:   Wed, 29 Jun 2022 12:40:20 +0100

updates to ahoy, checkip, powerdl, welcome.zsh. mv todosync into dots

Diffstat:
Mbin/bin/ahoy | 99++++++++++++++++++++++++++++++-------------------------------------------------
Mbin/bin/checkip | 26+++++++++-----------------
Mbin/bin/powerdl | 22+++++++++++++---------
Abin/bin/todosync | 13+++++++++++++
Mzsh/.zsh/welcome.zsh | 8+++-----
5 files changed, 76 insertions(+), 92 deletions(-)

diff --git a/bin/bin/ahoy b/bin/bin/ahoy @@ -55,86 +55,57 @@ usage() { heading() { header="$(echo ${1} | sed -e 's/\(.\)/\1 /g')" - echo -e "${lighter_black}┌─── ${light_magenta}${header}${reset}" - echo -e "${lighter_black}└────────────────────────── ─ ─ ${reset}" + echo -e "${blue}├┄ ${light_white}${header}${reset}" } tasking() { heading ${FUNCNAME[0]} - local -r tasking_file="$HOME/lib/documents/pyratewiki/tasking.md" - local due_count=0 - local overdue_count=0 - declare -a due_tasks - declare -a overdue_tasks - while IFS= read -r line ; do - date="$(echo "${line}" | awk -F: '{print $NF}')" - if [[ ${date} -eq $(date +%Y%m%d) ]] ; then - (( due_count=due_count+1 )) - due_tasks+="${line}\n" - elif [[ ${date} -lt $(date +%Y%m%d) ]] ; then - (( overdue_count=overdue_count+1 )) - overdue_tasks+="${line}\n" - fi - done < <(awk '/due:/ && !/[X]/' < "${tasking_file}") + total_tasks=$(cat $HOME/.todo | wc -l) - echo -e "you have ${light_green}${due_count}${reset} task(s) due today" - if [[ ${display_tasks} -eq 1 ]] && [[ ${due_count} -gt 0 ]] ; then - echo -e "${due_tasks}" - fi - if [[ ${overdue_count} -eq 0 ]] ; then - echo -e "there are ${light_green}${overdue_count}${reset} task(s) overdue" - else - echo -e "there are ${red}${overdue_count}${reset} task(s) overdue" - if [[ ${display_tasks} -eq 1 ]] ; then - echo -e "${overdue_tasks}" - fi - fi - echo + echo -e "${blue}│${reset}you have ${light_green}${total_tasks}${reset} task(s)" } # check nightly backups backups() { heading ${FUNCNAME[0]} - local -r backup_log="/var/log/securebak/securebak.log" - - for backup in email buku ; do - if grep -E "^$(date +%Y%m%dT04):.*${backup}.*successful" "${backup_log}" >/dev/null ; then - echo -e "schway! ${backup} was ${light_green}successful${reset}" - elif grep -E "^$(date +%Y%m%dT04):.*${backup}.*failed" "${backup_log}" >/dev/null ; then - echo -e "frak! ${backup} ${red}failed${reset}" - else - echo -e "drek, ${backup} ${red}didn't run${reset}" + local backup_success=0 + local failed="" + _repos=$(find /var/dedup/* -maxdepth 1 -type d -prune -printf '%f\n') + for r in ${_repos} ; do + _latest=$(find /var/dedup/${r}/archive -type f \ + -exec stat -c '%X %n' {} \; | \ + sort -nr | \ + awk -F\/ 'NR==1 {print $NF}') + if [[ "${_latest}" -lt $(date +%Y%m%d) ]] ; then + backup_success=$(( backup_success + 1 )) + failed+="${r} " fi done - echo + [[ ${backup_success} -gt 0 ]] \ + && echo -e "${blue}│${reset}frak! ${failed}${red}failed${reset}" \ + || echo -e "${blue}│${reset}schway! backup ${light_green}successful${reset}" } # weather in current location weather() { heading ${FUNCNAME[0]} - #local -r location="$(curl -s "https://ipvigilante.com/" | jq -r '.data.city_name')" - #wttr=$(curl -s "wttr.in/${location}?format=%l:+%f+%C\n" | tr '[:upper:]' '[:lower:]') - #if [[ ${wttr} == "unknown location"* ]] ; then - # echo -e "weather is ${red}unavailable${reset}" - #else - # echo -e "${wttr}" - #fi if [ -f /tmp/weather ] ; then - cat /tmp/weather + wttr=$(cat /tmp/weather | awk -F\: '{print $2}' | cut -c 2-) + echo -e "${blue}│${reset}${wttr}" else $HOME/bin/weather fi - echo } # you've got mail mail() { heading ${FUNCNAME[0]} - local -r mail_dir="$HOME/lib/documents/email" + local -r mail_dir="$HOME/var/mbox" local -r pyratebeard_mail=$(find "${mail_dir}"/pyratebeard/INBOX/new/ -type f | wc -l) - echo -e "you have ${light_green}${pyratebeard_mail}${reset} new mail(s)" - echo + local -r unread_mail=$(find "${mail_dir}"/pyratebeard/INBOX/cur/ -type f ! -name "*S" | wc -l) + echo -e "${blue}│${reset}you have ${light_green}${pyratebeard_mail}${reset} new mail(s)" + echo -e "${blue}│${reset}you have ${light_green}${unread_mail}${reset} unread mail(s)" } # not currently used but keeping for future reference @@ -149,16 +120,15 @@ getnews() { rss() { heading ${FUNCNAME[0]} if [ -f ~/.newsboat/cache.db.lock ] ; then - echo -e "${light_black}waiting for newsboat refresh...${reset}" + echo -e "${blue}│${reset}${light_black}waiting for newsboat refresh...${reset}" sleep 10 fi local unread_count unread_count=$(sqlite3 ~/.newsboat/cache.db "select count(unread) from rss_item where unread = 1;") local queued_pods queued_pods=$(wc -l ~/.newsboat/queue | awk '{print $1}') - echo -e "there are ${blue}${unread_count}${reset} unread items" - echo -e "you have ${blue}${queued_pods}${reset} queued podcast" - echo + echo -e "${blue}│${reset}there are ${light_green}${unread_count}${reset} unread items" + echo -e "${blue}│${reset}you have ${light_green}${queued_pods}${reset} queued podcasts" } servers() { @@ -169,7 +139,7 @@ servers() { ${reset}" local server="$1" if [ "${server}" == "all" ] ; then - for node in blacksun grimoire pyratetube octoweb octomail mordhaus ; do + for node in blacksun grimoire pyratetube mordhaus ; do heading "${node}" uptime=$(ssh -q "${node}" "uptime -p | cut -b4- | sed 's/\(,\|ear\|eek\(s\)\|ay\(s\)\|our\(s\)\|inute\(s\)\)//g'") echo -e "uptime is ${uptime}" @@ -185,9 +155,12 @@ ${reset}" } main() { - echo -e "${cyan} - a h o y, ${yellow}$(whoami) -${reset}" + echo -e "${blue}│${magenta} ┳━┓┳ ┳┏━┓┓ ┳ +${blue}│${magenta} ┃━┫┃━┫┃ ┃┗┏┛ +${blue}│${magenta} ┛ ┇┇ ┻┛━┛ ┇ +${blue}└──┄┄────┄┄───┐${yellow} + $(whoami) ${blue}│ +┌──┄┄────┄┄───┘${reset}" # ██ ▄ █ ████▄ ▀▄ ▄ ▄ # █ █ █ █ █ █ █ █ █ # █▄▄█ ██▀▀█ █ █ ▀█ █ @@ -209,11 +182,15 @@ ${reset}" #echo -e " greetings, ${white}\033[7m $(whoami) ${reset}\n" tasking + echo -e "${blue}│${reset}" backups + echo -e "${blue}│${reset}" weather + echo -e "${blue}│${reset}" mail + echo -e "${blue}│${reset}" rss - echo + echo -e "${blue}└──┄┄────┄┄${reset}" } if [ $# -eq 0 ] ; then diff --git a/bin/bin/checkip b/bin/bin/checkip @@ -1,23 +1,15 @@ #!/usr/bin/zsh - ipCmd=$(dig +short myip.opendns.com @resolver1.opendns.com) -ipFile="/tmp/current_ip" +ipFile="$HOME/tmp/current_ip" +pager="https://pager.pyratebeard.net/vpn" -if [ $# -eq 0 ] ; then - if [ ! -f $ipFile ] ; then - echo "$ipCmd" > $ipFile - fi - - if [[ $ipCmd != $(cat $ipFile) ]] ; then - echo "vpn ip has changed to $ipCmd" | mutt -s "vpn ip" root@pyratebeard.net - echo "$ipCmd" > $ipFile - fi -else - while getopts "c" opt ; do - case ${opt} in - c) echo ${ipCmd} ;; - esac - done +if [ ! -f $ipFile ] ; then + echo "$ipCmd" > $ipFile fi +if [[ $ipCmd != $(cat $ipFile) ]] && [[ $ipCmd != "" ]] ; then + curl -d "ip changed to ${ipCmd}" ${pager} + echo "$ipCmd" > $ipFile +fi +echo "$ipCmd" diff --git a/bin/bin/powerdl b/bin/bin/powerdl @@ -6,20 +6,24 @@ powerzone_url="https://powerzonemetal.uk/" powerzone_show_prefix="" powerzone_dir="$HOME/lib/music/powerzone" -show_num=$(curl -s ${powerzone_url} | grep "<h4>Show #" | head -n1 | awk -F\# '$2>0 {print substr($2,1,3)}') -if [[ ! $(find ${powerzone_dir} -name "powerzone-*${show_num}-*.mp3" | wc -l) -eq 0 ]] ; then +#latest_show=$(curl -s ${powerzone_url} | grep "/shows/" | head -n1 | sed -n 's/.*href="\([^"]*\).*/\1/p' | awk -F/ '{print $3}') + +latest_show=$(curl -s "${powerzone_url}shows/" | grep "/shows/" | head -n1 | tail -n1 | sed -n 's/.*href="\([^"]*\).*/\1/p' | awk -F/ '{print $3}') +#show_num=$(curl -s ${powerzone_url} | grep "<h4>Show #" | head -n1 | awk -F\# '$2>0 {print substr($2,1,3)}') + +if [[ ! $(find ${powerzone_dir} -name "powerzone-*${latest_show}-*.mp3" | wc -l) -eq 0 ]] ; then echo "file exists" exit 0 fi -if [[ ${show_num} =~ ^[0-9]+([.][0-9]+)?$ ]] ; then - powerzone_show_prefix="shows/show-" -else - powerzone_show_prefix="shows/" -fi -mixcloud_show_url=$(curl -s "${powerzone_url}${powerzone_show_prefix}${show_num}/" | grep mixcloud | grep feed | awk -F\= '{print $5}' | awk -F\& '{print $1}' | sed 's/%3A/\:/' | sed 's&%2F&/&g') +#if [[ ${show_num} =~ ^[0-9]+([.][0-9]+)?$ ]] ; then +# powerzone_show_prefix="shows/show-" +#else +# powerzone_show_prefix="shows/" +#fi +mixcloud_show_url=$(curl -Ls "${powerzone_url}shows/${latest_show}/" | grep mixcloud | grep feed | awk -F\= '{print $5}' | awk -F\& '{print $1}' | sed 's/%3A/\:/' | sed 's&%2F&/&g') download_filename=$(echo ${mixcloud_show_url} | awk -F\/ '{print $5}') youtube-dl -q -o "${powerzone_dir}/${download_filename}" "${mixcloud_show_url}" -ffmpeg -loglevel quiet -i ${powerzone_dir}/${download_filename} -metadata title="${download_filename}" -metadata artist="powerzone" -metadata album="powerzone" -metadata track="${show_num}" -metadata genre="metal" "${powerzone_dir}/${download_filename}.mp3" +ffmpeg -loglevel quiet -i ${powerzone_dir}/${download_filename} -metadata title="${download_filename}" -metadata artist="powerzone" -metadata album="powerzone" -metadata track="${latest_show}" -metadata genre="metal" "${powerzone_dir}/${download_filename}.mp3" rm -f "${powerzone_dir}/${download_filename}" diff --git a/bin/bin/todosync b/bin/bin/todosync @@ -0,0 +1,13 @@ +#!/bin/sh + +LOCAL_TODO="$HOME/.todo" +REMOTE_TODO="storage/documents/markor/todo.txt" +REMOTE_HOST="artoo" +DAEMON_RESTART="SVDIR=/data/data/com.termux/files/usr/var/service sv restart todod" + +exec inotifywait -e close_write -m $LOCAL_TODO|while read TODOFILE; do + echo rsyncing + rsync -e "ssh -i $HOME/.ssh/todod" $LOCAL_TODO $REMOTE_HOST:$REMOTE_TODO + ssh -i $HOME/.ssh/todod $REMOTE_HOST "${DAEMON_RESTART}" + echo finished rsync +done diff --git a/zsh/.zsh/welcome.zsh b/zsh/.zsh/welcome.zsh @@ -15,14 +15,12 @@ audio_vol() { # script run on first terminal script() { - cat ~/tmp/pyratebeard_ansi_md if [[ ${PTS} -eq "2" ]] ; then audio_vol - tmux new -s main -n '~' hashwall -f '#131313' -b '#1e1b1c' -s 12 - if [[ ${TMUX_PANE} == '%0' ]] ; then - ~/bin/ahoy - fi + xrandr --output HDMI-2 --primary --output DVI-D-1 --rotate left + tmux new -s main -n 'vim' + [[ ${TMUX_PANE} == "%0" ]] && $HOME/bin/ahoy fi }