From: Ian Kelling Date: Tue, 29 Aug 2023 03:15:13 +0000 (-0400) Subject: fixes and improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=c300392f92092b3a89281df462d42710f25d0351;p=distro-setup fixes and improvements --- diff --git a/brc b/brc index ddb6e79..b78e08f 100644 --- a/brc +++ b/brc @@ -1706,6 +1706,11 @@ histrm() { history -w } +# history without the date +histplain() { + history "$@" | cut -d' ' -f 7- +} + ccomp grep k ks ksu histrm @@ -2121,10 +2126,17 @@ sk() { # see bash-template/style-guide.md for justifications local quotes others - quotes=2048,2068,2086,2206 + quotes=2048,2068,2086,2206,2254 others=2029,2033,2054,2164 shellcheck -W 999 -x -e $quotes,$others "$@" || return $? } +# sk with quotes. For checking scripts that we expect to take untrusted +# input in order to verify we quoted vars. +skq() { + local others + others=2029,2033,2054,2164 + shellcheck -W 999 -x -e $others "$@" || return $? +} skgit() { local f @@ -2696,6 +2708,34 @@ spark() pdfwc() { local f; for f; do echo "$f" "$(pdfinfo "$f" | awk '/^Pages:/ {print $2}')"; done } + +# nvm install script appended this to my .bashrc. I dont want to run it all the time, +# so put it in a function. +nvm-init() { + export NVM_DIR="$HOME/.nvm" + # shellcheck disable=SC1091 # may not exist, & third party + [ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh" # This loads nvm + # shellcheck disable=SC1091 # may not exist, & third party + [ -s "$NVM_DIR/bash_completion" ] && source "$NVM_DIR/bash_completion" # This loads nvm bash_completion +} + + +leap-year() { + if date -d 'february 29' &>/dev/null; then + year_days=366 + else + year_days=365 + fi + echo $year_days +} + +# on-battery +on-bat() { + if [[ -e /sys/class/power_supply/AC/online && $( >(pee cat 'ts "%F %T"|dd of='$log_path' status=none') if $verbose; then - printf " options: conf_only=%s\ndry_run=%s\nrate_limit=%s\nverbose=%s\ncmd_arg=%s" "$conf_only" "$dry_run" "$rate_limit" "$verbose" "$cmd_arg" + printf " options: conf_only=%s\ndry_run=%s\nrate_limit=%s\nverbose=%s\ncmd_arg=%s\n" "$conf_only" "$dry_run" "$rate_limit" "$verbose" "$cmd_arg" fi if [[ -v targets ]]; then diff --git a/distro-end b/distro-end index 50cb175..3fdcea3 100755 --- a/distro-end +++ b/distro-end @@ -2183,7 +2183,7 @@ esac case $HOSTNAME in kw|x3) sd /etc/cups/client.conf <<'EOF' -ServerName printserver0.office.fsf.org +ServerName printserver1.office.fsf.org EOF ;; esac diff --git a/mail-setup b/mail-setup index 65682c2..e753fbe 100755 --- a/mail-setup +++ b/mail-setup @@ -885,7 +885,7 @@ EOF case $HOSTNAME in bk) -u /etc/spamassassin/my_thishost.cf <<'EOF' + u /etc/spamassassin/my_thishost.cf <<'EOF' # note: these are duplicated in exim config # veth0/1 # bk bk_ip6 internal_networks 10.173.8.1/32 10.173.8.2/32 85.119.83.50/32 2001:ba8:1f1:f0c9::2 @@ -908,8 +908,8 @@ EOF internal_networks 10.173.8.1/32 10.173.8.2/32 72.14.176.105/32 2600:3c00::f03c:91ff:fe6d:baf8/128 trusted_networks 10.173.8.1/32 10.173.8.2/32 72.14.176.105/32 2600:3c00::f03c:91ff:fe6d:baf8/128 EOF -;; - esac + ;; +esac ##### end spamassassin config @@ -3690,6 +3690,9 @@ EOF test_to=${test_tos[0]} for t in ${test_tos[@]:1}; do + if [[ $test_from == *@gnu.org && $t == *@gnu.org ]]; then + continue + fi test_to+=", $t" done case $test_from in diff --git a/mailtest-check b/mailtest-check index c3c0bd2..54db2c2 100755 --- a/mailtest-check +++ b/mailtest-check @@ -88,7 +88,7 @@ main() { ;; *) folders=(/m/md/l/testignore) - froms=(testignore@je.b8.nz testignore@expertpathologyreview.com testignore@amnimal.ninja ian@iankelling.org z@zroe.org iank@gnu.org) + froms=(testignore@je.b8.nz testignore@expertpathologyreview.com testignore@amnimal.ninja ian@iankelling.org z@zroe.org) if ! $int; then ### begin rsyncing fencepost email ### # We dont want to exit if rsync fails, that will get caught by @@ -145,7 +145,7 @@ EOF for folder in ${folders[@]}; do for from in ${froms[@]}; do declare -i missing_dnswl=0 - declare -i dnsfail=0 + #declare -i dnsfail=0 declare -i unexpected=0 latest= last_sec=0 @@ -262,7 +262,8 @@ EOF rm -f $resultfile for r in ${results[@]}; do case $r in - # iank: for when we want to handle dns errors differently + # iank: for when we want to handle dns errors differently. + # also uncomment declaration of dnsfail above. # DKIM_INVALID|T_SPF_TEMPERROR|T_SPF_HELO_TEMPERROR) # dnsfail+=1 # ;; diff --git a/myi3status b/myi3status index 944319e..9aeccca 100755 --- a/myi3status +++ b/myi3status @@ -3,11 +3,53 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # usage: -# * left click seconds to reset main timer +# +# * left click seconds to reset & enable main timer which shows 30 +# minutes in blue and half hours in orange. +# # * right click seconds to disable minutes & half hours of main timer -# * left click minutes to reset 2nd timer. +# +# * left click minutes to reset & enable 2nd timer. +# # * right click minutes to disable 2nd timer +# docs: +# +# Sections from right to left. +# +# section #1, labeled day_percent +# +# 1. Thousandths of a 16 hour day left. 1 = 57.6 seconds. +# 2. Bar of one thousand of a day which gets shorter by ninths. One ninth is 6.4 seconds. +# 3. Start of the day (only the non-zero numbers). Set this with the ds command. +# 4. The time right now. +# 5. Ten thousands of the year left. 1 = 52:34 minutes (leap year = 52:42) +# 6. Bar of 1/10,000 of a year shrinking by ninths. 1 ninth = 5:50 minutes (leap year = 5:51 mins). +# +# section #2, labeled seconds +# +# block characters, ▉, are added every 3 seconds, a total of 20 for 1 +# minute. The groups of 5 blocks = 15 seconds each. +# +# section #3, labeled mins +# +# Only enabled by clicking on seconds, see usage. +# +# Block characters are added every minute until 30, then reset. There +# are 6 groups of 5 minutes. +# +# Section #4 +# +# Half hours in orange, grouped into groups of 2. This will grow until +# it fills the screen. +# +# Section #5 & 6 +# +# Only enabled by clicking on mins section, see usage. +# +# These repeat sections 3 and 4 in violet and some other color. +# +# if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi source /a/bin/errhandle/err @@ -21,15 +63,22 @@ fast_blocks=30 start=$EPOCHSECONDS domins=false +if date -d 'february 29' &>/dev/null; then + days_in_this_year=366 +else + days_in_this_year=365 +fi get_daystart() { - if [[ /b/data/daystart -ot /b/data/daystart-generated && $day_tmp ]]; then + if [[ /b/data/daystart -ot /b/data/daystart-generated && $day_start_24h ]]; then return 0 fi - day_tmp=$(cat /b/data/daystart) - day_start_hour=${day_tmp%??} - day_start_min=${day_tmp: -2} + day_start_24h=$(cat /b/data/daystart) + day_start_sig_digits=${day_start_24h%?} + day_start_sig_digits=${day_start_sig_digits%0} + day_start_hour=${day_start_24h%??} + day_start_min=${day_start_24h: -2} echo $day_start_hour > /b/data/daystart-generated echo $day_start_min >> /b/data/daystart-generated day_start=$(date -d $day_start_hour:$day_start_min +%s) @@ -168,6 +217,8 @@ main() { i_end=$(( time % 60 / 3 + 1 )) if (( i_end - i > 15 )); then printf " " + elif (( i_end == 1 && i == 0 )); then + printf B elif (( i < i_end )); then printf ▉ else @@ -185,11 +236,13 @@ main() { day_start=$(date -d $day_start_hour:$day_start_min +%s) fi - spark_index="$(( (100000 -($EPOCHSECONDS - $day_start)*100000 / (16*60*60) ) % 100 / 11 ))" + # there are 9 spark levels, 1/9 = .111.... In order to keep it in bash math, we upscale + # the number and divide by 111, 3 digits is good enough accuracy. + spark_index="$(( (1000000 -($EPOCHSECONDS - $day_start)*1000000 / (16*60*60) ) % 1000 / 111 ))" spark=" ▁▂▃▄▅▆▇█" # note: 960 minutes, so 10 minutes is about 1% day_thousandth=$(( 1000 - (EPOCHSECONDS - day_start)*1000 / (16*60*60) )) - printf %s "$day_thousandth${spark:spark_index:1} $(date "+%l:%M")" + printf %s "$day_thousandth${spark:spark_index:1}$day_start_sig_digits $(date "+%l:%M")" # .1% of a waking year is ~5.75 hours, or 365 thousandths of a day. # 1% of a waking year is 3.7 days @@ -197,8 +250,8 @@ main() { year_start=$(date +%s -d 'january 1 6am') year_days=$(( (EPOCHSECONDS - year_start) / (24*60*60) )) year_start=$(( year_start + year_days * 8*60*60 )) - year_spark_index=$(( ( 100000 - (EPOCHSECONDS - year_start)*100000 / (365*16*60*60) ) % 100 / 11 )) - year_tenthousandth=$(( 10000 - (EPOCHSECONDS - year_start)*10000 / (365*16*60*60) )) + year_spark_index=$(( ( 1000000 - (EPOCHSECONDS - year_start)*1000000 / (days_in_this_year*16*60*60) ) % 1000 / 111 )) + year_tenthousandth=$(( 10000 - (EPOCHSECONDS - year_start)*10000 / (days_in_this_year*16*60*60) )) printf %s " $year_tenthousandth${spark:year_spark_index:1}" diff --git a/pkgs b/pkgs index 58aa7e4..9c6f907 100644 --- a/pkgs +++ b/pkgs @@ -107,6 +107,8 @@ p3=( dosfstools dnsutils python3-dnspython + # better du in t11+ + duf duplicity elinks evince @@ -127,6 +129,7 @@ p3=( fonts-roboto fonts-thai-tlwg fonts-thai-tlwg-otf + ftp-upload fzf xfonts-intl-asian fonts-sil-lateef