X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc2;h=5f0a5ff45f5ee11430b1d232c6fed78473686b2a;hb=5a6e794f459b3e83b6d665e05d0ab0c8bc6cdfbe;hp=1a6db0cc38d5d4978c389c9d0d1418d2a36d90db;hpb=523b7ff889aaafdcd997d84b2a06744993018e89;p=distro-setup diff --git a/brc2 b/brc2 index 1a6db0c..5f0a5ff 100644 --- a/brc2 +++ b/brc2 @@ -58,6 +58,13 @@ source /a/bin/log-quiet/logq-function source /a/bin/bash_unpublished/source-semi-priv source /a/bin/bash_unpublished/source-state +if [[ $HOSTNAME == "$MAIL_HOST" ]]; then + export MAIL_HOST_P=t +else + export NOT_MAIL_HOST_P=t +fi + + source /a/bin/log-quiet/logq-function # not used @@ -366,6 +373,17 @@ anki() { schroot -c buster -- anki } +daycat() { + ngset + hrcat /m/md/daylert/{cur,new}/* + ngreset +} +dayclear() { + ngset + rm -f /m/md/daylert/{cur,new}/* +} + + acat() { ngset hrcat /m/md/alerts/{cur,new}/* @@ -428,22 +446,19 @@ astudio() { # Convert brains file path to url and vice versa # usage: brains [URL_OR_PATH] brains() { - _iki-convert '(/a)?/f/brains' brains.fsf.org/wiki "$@" + _iki-convert brains.fsf.org/wiki "$@" } glue() { - _iki-convert '(/a)?/f/gluestick' gluestick.office.fsf.org "$@" + _iki-convert gluestick.office.fsf.org "$@" } -# usage: $0 REPO_PATH [URL_OR_PATH] +# usage: see above _iki-convert() { - local url prefix path input err repo_dir dir url_dir url - repo_dir="$1" - prefix="$2" - shift 2 - err=false - if $err; then - return 1 - fi + local url url_prefix path input err repo_dir dir url_dir url name + url_prefix="$1" + name="${url_prefix%%.*}" + repo_dir="/f/$name" + shift if [[ $1 ]]; then input="$*" else @@ -451,7 +466,7 @@ _iki-convert() { fi case $input in http*) - path="$repo_dir/${input##http*://"$prefix"/}" + path="$repo_dir/${input##http*://"$url_prefix"/}" if [[ $path == */ ]]; then path=${path%/}.mdwn fi @@ -459,8 +474,8 @@ _iki-convert() { ;; *) path=$(fp "$input") - url_dir=$(echo "$path" | sed -r "s,^$repo_dir/,,") - url="https://$prefix/$url_dir" + url_dir=$(echo "$path" | sed -r "s,^(/a)?$repo_dir/,,") + url="https://$url_prefix/$url_dir" url="${url%.mdwn}/" j echo "$url" ;; @@ -733,7 +748,7 @@ mpvrpc-percent-pos() { # q quit # ret next # -beetag() { +beetag() { local last_genre_i fstring tag id char new_item char_i genre tag remove doplay i j random path local do_rare_genres read_wait help line lsout tmp ls_line skip_lookback local escape_char escaped_input expected_input skip_input_regex right_pad erasable_line seek_sec @@ -1791,6 +1806,66 @@ satoshi() { # $1 satoshi in usd printf "$%.2f\n" "$(echo "scale=10; $price * $1"| bc -l)" fi } + +# Bitcoin holds open the wallet file. this causes problems for a +# secondary computer running bitcoin and receiving a backup. So, as a +# workaround, I intend to manually enable the wallet when I want to use +# it and leave it disabled otherwise. +walleton() { + local active + active=false + no_on=true + if [[ ! $(readlink -f /var/lib/bitcoind/wallets) == /q/wallets ]]; then + if systemctl --quiet is-active bitcoind; then + if [[ -e /tmp/no-bitcoinon ]]; then + no_on=true + else + if [[ $EUID == 0 ]]; then + m install -T -o iank -g iank /dev/null /tmp/no-bitcoinon + else + m touch /tmp/no-bitcoinon + fi + fi + active=true + m ser stop bitcoind + fi + m s ln -s /q/wallets /var/lib/bitcoind + sudo chown -h bitcoin:bitcoin /var/lib/bitcoind/wallets + if $active; then + m ser start bitcoind + if ! $no_on; then + m rm /tmp/no-bitcoinon + fi + fi + fi +} +walletoff() { + local active + active=false + no_on=true + if [[ $(readlink -f /var/lib/bitcoind/wallets) == /q/wallets ]]; then + if systemctl --quiet is-active bitcoind; then + if [[ -e /tmp/no-bitcoinon ]]; then + no_on=true + else + if [[ $EUID == 0 ]]; then + m install -T -o iank -g iank /dev/null /tmp/no-bitcoinon + else + m touch /tmp/no-bitcoinon + fi + fi + active=true + m ser stop bitcoind + fi + m rm /var/lib/bitcoind/wallets + if $active; then + m ser start bitcoind + if ! $no_on; then + m rm /tmp/no-bitcoinon + fi + fi + fi +} #### end bitcoin related things @@ -2199,6 +2274,8 @@ tl() { t s w } + +# help me focus. opens 2 windows. focus() { /p/c/proc/focus/linux-amd64/focus & watcharb5 @@ -2206,12 +2283,17 @@ focus() { } +# Display a list of the active window title +# i've been on with 10 second samples going back +# 5 minutes. If I've been on one window for 10 seconds +# or longer, then display the second count. +# +# Press any key to exit. watcharb5() { local char ret - killall arbtt-capture ||: + killall arbtt-capture &>/dev/null ||: rm -f ~/.arbtt/capture.log arbtt-capture --sample-rate=10 & - clear while true; do arb5 ret=0 @@ -2228,30 +2310,49 @@ watcharb5() { killall arbtt-capture ||: return 0 fi - clear done } arb5() { - local i l sec - i=0 + local i j l sec blanks line + local -a arbtt_lines if [[ ! -e ~/.arbtt/capture.log ]]; then sleep 5 fi - # https://stackoverflow.com/questions/56486272/how-to-concat-multiple-fields-to-same-line-with-jq - arbtt-dump -l 30 -t json | jq -r '.[] | [ ( .inactive / 1000 | floor ) , ( .windows[] | select (.active == true) |.title) ] | @tsv' \ - | tac | while read -r sec l; do - if (( i % 6 == 0 && i >= 2 )); then - echo "## $(( i / 6 + 1 )) ##" - fi - if (( sec > 10 )); then - printf "%3d %s\n" $sec "$l" - else - printf " %s\n" "$l" - fi - i=$(( i + 1 )) + blanks=$(( LINES - 34 )) + for (( i=0; i < blanks; i++ )); do + echo done + + { + i=0 + j=0 + # https://stackoverflow.com/questions/56486272/how-to-concat-multiple-fields-to-same-line-with-jq + arbtt_lines=$(arbtt-dump -l 30 -t json | \ + jq -r '.[] | [ ( .inactive / 1000 | floor ) , ( .windows[] | select (.active == true) |.title) ] | @tsv' | tac) + for line in "${arbtt_lines[@]}"; do + read -r sec l <<<"$line" + if (( j >= LINES )); then + break + fi + if (( i % 6 == 0 && i >= 2 )); then + j=$(( j + 1 )) + echo "## $(( i / 6 + 1 )) ##" + fi + if (( sec > 10 )); then + printf "%3d %s\n" $sec "$l" | sed -r "s/^(.{$COLUMNS}).*/\1/" + else + printf " %s\n" "$l" | sed -r "s/^(.{$COLUMNS}).*/\1/" + fi + i=$(( i + 1 )) + j=$(( j + 1 )) + done + while (( j < 34 && j < LINES )); do + echo + j=$(( j + 1 )) + done + } | tac } arbttlog() { @@ -2885,6 +2986,34 @@ myprof() { popd } + +# Tail all recent prof logs. Copying from profanity has unwanted line breaks +# especially for links. +profr() { + case $HOSTNAME in + kd) + profr-local + ;; + *) + ssh b8.nz profr-local + ;; + esac +} + +profr-local() { + local d0 d1 + local -a files + d0="$(date +%Y_%m_%d).log" + d1="$(date -d '1 day ago' +%Y_%m_%d).log" + ngset + files=(/d/p/profanity/chatlogs/iank_at_fsf.org/{*,rooms/*}/{$d0,$d1}) + ngreset + if (( ${#files[@]} > 0 )); then + cat "${files[@]}" | sort | tail -n 40 + fi +} + + # Tail pms in the last day, for the case where we restart profanity and # didn't check for pms beforehand. Assume the most recent logs are on kd. # If that isn't the case, use prof-recent-local @@ -2898,7 +3027,6 @@ prof-recent() { ;; esac } - prof-recent-local() { local d dates date files f # consider making the day count passed by parameter. note: this works: $(date -d '2 day ago' +%Y_%m_%d) @@ -2918,6 +3046,35 @@ prof-recent-local() { done } +prof-sort() { + case $HOSTNAME in + kd) + prof-recent-sort + ;; + *) + ssh b8.nz prof-recent-sort + ;; + esac +} + +prof-recent-sort() { + local d dates date files f + # consider making the day count passed by parameter. note: this works: $(date -d '2 day ago' +%Y_%m_%d) + dates=("$(date +%Y_%m_%d)" "$(date -d '1 day ago' +%Y_%m_%d)" ) + files=() + for d in /d/p/profanity/chatlogs/iank_at_fsf.org/!(rooms); do + for date in ${dates[@]}; do + f=$d/$date.log + if [[ -e $f ]]; then + files+=($f) + fi + done + done + for f in "${files[@]}"; do + sed "s/\$/ $f/" $f + done | sort +} + # usage: debvm DEBIAN_VERSION RAM_MB debvm() { @@ -3010,6 +3167,7 @@ ngo() { otp() { oathtool --totp -b "$*" | xclip -selection clipboard } +# run cmd and copy output j() { "$@" |& pee "xclip -r -selection clipboard" cat } @@ -3998,13 +4156,18 @@ fi # rg with respecting vcs ignore files rgv() { ret=0 + # settings that are turned off for pipes, keep them on. + # Found by searching for "terminal" in --help + # --heading + # -n + # # -. = search dotfiles # -z = search zipped files # -i = case insensitive # -M = max columns # --no-messages because of annoying errors on broken symlinks # --no-ignore-parent because i have /a/.git which ignores almost everything under it. - command rg -. -z --no-messages -i -M 900 --no-ignore-parent -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$? + command rg -n --heading -. -z --no-messages -i -M 900 --no-ignore-parent -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$? return $ret } @@ -4092,6 +4255,13 @@ hssh-update() { fi } +noi3bar() { + touch /tmp/noi3bar +} +i3bar() { + rm -fv /tmp/noi3bar +} + export BASEFILE_DIR=/a/bin/fai-basefiles