From 89fc59d6e4bbeb1778c6aaaee776122dcf790871 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Wed, 1 Mar 2023 10:04:57 -0500 Subject: [PATCH] be safer, keep more leafs around --- brc2 | 25 ++++++++++++++++++++----- mount-latest-subvol | 8 ++++---- pkgs | 1 + switch-mail-host | 8 ++++---- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/brc2 b/brc2 index f23de9b..c65e578 100644 --- a/brc2 +++ b/brc2 @@ -742,7 +742,7 @@ beetag() { # PijokVipiotOzeph is just a random string for a delimiter # shellcheck disable=SC2016 # obvious reason - mapfile -t initial_ls < <(beet ls -f '%ifdef{rating,$rating }'"$fstring"'$genre | $artist - $album - $title $length $id PijokVipiotOzeph $path' "$@" | { if $random; then sort -R --random-source=$pl_seed_path; else cat; fi; } ) + mapfile -t initial_ls < <(beet ls -f '%ifdef{rating,$rating }'"$fstring"'$genre | $title - $artist - $album $length $id PijokVipiotOzeph $path' "$@" | { if $random; then sort -R --random-source=$pl_seed_path; else cat; fi; } ) id_count=${#initial_ls[@]} for line in "${initial_ls[@]}"; do path="${line#*PijokVipiotOzeph }" @@ -782,6 +782,15 @@ beetag() { echo "$ls_line" fi done + if $doplay; then + #{ mpv --profile=a --volume=$volume --idle 2>&1 & } 2>/dev/null + mpv --profile=a --volume=$volume --idle & + # if we dont sleep, we get error like this: + # socat[1103381] E connect(5, AF=1 "/tmp/mpvsock", 14): Connection refused + # and strangely, it persists until mpv is restarted. + # .1 sleep was too little. + sleep .2 + fi while true; do id=${ids[j]} @@ -794,6 +803,8 @@ beetag() { if $doplay; then # https://stackoverflow.com/a/7687716 # note: duplicated down below + # + # notes on old method of invoking mpv each time: # https://superuser.com/questions/305933/preventing-bash-from-displaying-done-when-a-background-command-finishes-execut # we can't disown or run in a subshell or set +m because all that # disabled job control from working properly in ways we want. @@ -801,7 +812,10 @@ beetag() { # is that we are waiting in 2 second intervals and checking if the # background job exists. Instead, we should make mpv just idle # when it is done with a song and then send it a command to play a new track. - { mpv --profile=a --volume=$volume "$path" 2>&1 & } 2>/dev/null + #{ mpv --profile=a --volume=$volume "$path" 2>&1 & } 2>/dev/null + # old + #{ beet play "--args=--volume=$volume" "id:$id" 2>&1 & } 2>/dev/null + mpvrpc '{ "command": ["loadfile", "'"$path"'"] }' erasable_line=false fi while true; do @@ -841,8 +855,7 @@ beetag() { else doplay=true kill-bg-quiet - { mpv --profile=a --volume=$volume "$path" 2>&1 & } 2>/dev/null - #{ beet play "--args=--volume=$volume" "id:$id" 2>&1 & } 2>/dev/null + mpvrpc '{ "command": ["loadfile", "'"$path"'"] }' erasable_line=false fi beetag-nostatus 1 @@ -1290,9 +1303,11 @@ order by timeSent;" mycheologs() { local days q days=${1:-16} + # timezone compared to utc. note: this will need adjustment for spring/fall. + zone_offset=$(( 60 * 60 * 5 )) q=" select - datetime(substr(timeSent,0,11), 'unixepoch'), + datetime(substr(timeSent,0,11) - $zone_offset, 'unixepoch'), body from messages where timeSent > $(( (EPOCHSECONDS - days * 60 * 60 * 24) * 1000 )) diff --git a/mount-latest-subvol b/mount-latest-subvol index 449297f..4c1ee2f 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -415,12 +415,12 @@ for vol in ${all_vols[@]}; do leaf_vols=($vol.leaf.*) count=${#leaf_vols[@]} leaf_limit_time=$(( EPOCHSECONDS - 60*60*24*60 )) # 60 days - leaf_new_limit_time=$(( EPOCHSECONDS - 60*60*24 )) # 1 day - # this goes backwards from oldest. leaf_new_limit_time is just in case - # the order gets screwed up or something. + leaf_new_limit_time=$(( EPOCHSECONDS - 60*60*24 * 5 )) # 5 days this + # goes backwards from oldest. leaf_new_limit_time is a safety + # measure to ensure we don't delete very recent leafs. for leaf in ${leaf_vols[@]}; do leaf_time=$(date -d ${leaf#"$vol".leaf.} +%s) - if (( leaf_limit_time > leaf_time || ( leaf_new_limit_time > leaf_time && count > 15 ) )); then + if (( leaf_limit_time > leaf_time || ( leaf_new_limit_time > leaf_time && count > 30 ) )); then x btrfs sub del $leaf fi count=$((count-1)) diff --git a/pkgs b/pkgs index 289d6bb..b5403ba 100644 --- a/pkgs +++ b/pkgs @@ -86,6 +86,7 @@ p3=( build-essential bwm-ng ccache + cheese cloc # pretty complex config. i just setup to ignore my password managerf # according to the docs, and C-M-v to open the main window diff --git a/switch-mail-host b/switch-mail-host index 4e8dfde..651c96e 100644 --- a/switch-mail-host +++ b/switch-mail-host @@ -204,11 +204,11 @@ if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then fi EOF if ! $host2_only; then - cat <<'EOF' + cat <