From: Ian Kelling Date: Sun, 30 Apr 2023 14:09:07 +0000 (-0400) Subject: fixes and improvemens X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=b186607514fbcf10bd5664ccb759a6e873f048c7;p=distro-setup fixes and improvemens --- diff --git a/.profile b/.profile index c78d022..1cd1848 100644 --- a/.profile +++ b/.profile @@ -2,5 +2,3 @@ echo this is ~/.profile, either my .bashrc_profile is unavailable or this is posix mode or not bash return 0 - -export PATH="$HOME/.cargo/bin:$PATH" diff --git a/brc b/brc index 75a7393..7d58392 100644 --- a/brc +++ b/brc @@ -1011,6 +1011,9 @@ etail2() { ccomp tail etail etail2 +showkeys() { + ssh "$@" cat .ssh/authorized_keys{,2} + } # print exim old pids @@ -1115,6 +1118,20 @@ faf() { # find all files. use -L to follow symlinks -o -name .undo-tree-history -prune \) -type f 2>/dev/null } +# usage ffconcat FILES_TO_CONCAT OUTPUT_FILE +ffconcat() { + local tmpf + tmpf=$(mktemp) + printf "file '%s'\n" "$1" >$tmpf + while (( $# > 1 )); do + shift + printf "file '%s'\n" "$1" >>$tmpf + done + # https://trac.ffmpeg.org/wiki/Concatenate + ffmpeg -f concat -safe 0 -i $tmpf -c copy "$1" + rm $tmpf +} + # full path without resolving symlinks fp() { local dir base diff --git a/brc2 b/brc2 index 73dc3da..676c597 100644 --- a/brc2 +++ b/brc2 @@ -1292,7 +1292,9 @@ cheogram-get-logs() { adb pull /storage/emulated/0/Download/Cheogram/Backup sqlite3 b /b/data/daystart +} #### begin bitcoin related things btc() { diff --git a/i3-sway/common.conf b/i3-sway/common.conf index a12b573..8cfceb7 100644 --- a/i3-sway/common.conf +++ b/i3-sway/common.conf @@ -101,6 +101,7 @@ bindsym $mod+9 workspace 10 # random keybind, feel free to change bindsym $mod+Shift+m border toggle +# 65 = space. # toggle tiling / floating bindcode $mod+Shift+65 floating toggle diff --git a/i3-sway/i3.conf b/i3-sway/i3.conf index d6bbdc2..32e2678 100644 --- a/i3-sway/i3.conf +++ b/i3-sway/i3.conf @@ -4,12 +4,31 @@ bindsym $mod+Shift+o exec "i3-nagbar -t warning -m 'You pressed the exit shortcu bindsym $mod+Shift+p restart # need this for kde connect +bar { +# the builtin prog +#status_command i3status + +#for faster testing +#status_command /a/bin/ds/myi3status +status_command /usr/local/bin/myi3status +#mode hide +# hidden_state hide +font pango:monospace 18 + +# i have no need for the tray icons so far +tray_output none + +# this display is interesting, but I don't use it. +# if I forget which workspace I'm in, I just tend to +# toggle between all of them. +workspace_buttons no +} + +## dont want to see this bar for now # bar { -# status_command i3status -# # #status_command /usr/local/bin/myi3status -# mode hide -# # hidden_state hide -# # font pango:monospace 14 +# status_command /p/c/myi3life +# tray_output none +# workspace_buttons no # } exec copyq diff --git a/myi3status b/myi3status old mode 100644 new mode 100755 index 6528532..500fd8f --- a/myi3status +++ b/myi3status @@ -2,6 +2,12 @@ # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later +# usage: +# * left click seconds to reset main timer +# * right click seconds to disable minutes & half hours of main timer +# * left click minutes to reset 2nd timer. +# * right click minutes to disable 2nd timer + if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi source /a/bin/errhandle/err @@ -9,97 +15,202 @@ source /a/bin/errhandle/err shopt -s nullglob shopt -s dotglob -shopt -s nullglob -for p in ~/.gem/ruby/*/bin; do - PATH="$PATH:$p" -done - -todaycache=/tmp/timetraptoday -newer() { - if [[ ! -e $todaycache ]]; then - return 1 - fi - ! find $todaycache -mmin $1 -type f -exec false {} + &>/dev/null -} -td() { /a/opt/timetrap/bin/t d -ftotal all -m '^w|x$' "$@"; } +mins=0 +half_hours=0 +fast_blocks=30 +start=$EPOCHSECONDS +domins=true + +day_tmp=$(cat /b/data/daystart) +day_start_hour=${day_tmp%??} +day_start_min=${day_tmp: -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) +# for after midnight but before the day start. +if (( day_start > EPOCHSECONDS )); then + day_start=$(date -d "$day_start_hour:$day_start_min yesterday" +%s) +fi + main() { - ps_char= - if [[ -e /dev/shm/iank-status ]]; then - eval $(< /dev/shm/iank-status) + ## debug + # if [[ $line ]]; then + # echo "line=$line" >>/tmp/t + # fi + case $line in + ""|"[") : ;; + *) + json="${line#,}" + case $(echo "$json" | jq -r .name) in + seconds) + case $(echo "$json" | jq -r .button) in + 1) + start=$EPOCHSECONDS + domins=true + ;; + 3) + domins=false + ;; + esac + ;; + mins) + case $(echo "$json" | jq -r .button) in + 1) + start2=$EPOCHSECONDS + ;; + 3) + start2= + ;; + esac + + ;; + esac + esac + + time=$((EPOCHSECONDS - start)) + total_mins=$(( time / 60 )) + mins=$(( total_mins % 30 )) + half_hours=$(( total_mins / 30 )) + + + + printf '[' + + + if [[ $start2 ]]; then + time2=$((EPOCHSECONDS - start2)) + total_mins2=$(( time2 / 60 )) + mins2=$(( total_mins2 % 30 )) + half_hours2=$(( total_mins2 / 30 )) + # this is duplicate of mins and half hours except for different + # colors and looking at vars above. + + # begin half hours + printf '{ "color": "#EFC93E", "full_text": "' + for ((i=half_hours2-1; i >= 0 ; i--)); do + printf ▉ + if (( i > 0 && i % 2 == 0 )); then + printf " " + fi + done + printf '"},' + + + # begin minutes + printf '{ "name":"mins2", "color":"#ED297D", "full_text": "' + for ((i=29; i >= 0 ; i--)); do + if (( i < mins2 )); then + printf ▉ + else + printf " " + fi + if (( i > 0 && i % 5 == 0 )); then + printf " " + fi + done + printf '"},' + fi - # clocked in or out? - cursheet=$(sqlite3 /p/.timetrap.db "select sheet from entries where end is NULL;") + if $domins; then + # begin half hours + printf '{ "color": "#FFB542", "full_text": "' + for ((i=half_hours-1; i >= 0 ; i--)); do + printf ▉ + if (( i > 0 && i % 2 == 0 )); then + printf " " + fi + done + printf '"},' - if [[ $cursheet ]]; then - if i3-msg -t get_bar_config bar-0 | grep '"mode":"dock"' &>/dev/null; then - i3-msg -q 'bar mode hide' + + # begin minutes + printf '{ "name":"mins", "color":"#0D6BDD", "full_text": "' + for ((i=29; i >= 0 ; i--)); do + if (( i < mins )); then + printf ▉ + else + printf " " + fi + if (( i > 0 && i % 5 == 0 )); then + printf " " + fi + done + printf '"},' + fi + + # begin seconds + printf '{ "name": "seconds", "full_text": "' + + for ((i=0; i < 20; i++)); do + # This first condition is to make the transition from full to empty + # be less jarring. We are filling a bucket of space with ticks of + # time, we would have to choose to show full or empty, but never + # both. Or we could have a half/tick to show full then empty real + # quick. I decided to try having it work like a snake, empty out the + # 1st quarter as we fill up the last quarter. + + if (( i > 0 && i % 5 == 0 )); then + printf " " fi - else - if i3-msg -t get_bar_config bar-0 | grep '"mode":"hide"' &>/dev/null; then - i3-msg -q 'bar mode dock' + i_end=$(( time % 60 / 3 + 1 )) + if (( i_end - i > 15 )); then + printf " " + elif (( i < i_end )); then + printf ▉ + else + printf " " fi - cursheet=out - fi + done + printf '"},' - # maybe sometime show work and x separate - if newer 3; then - today=$(< /tmp/timetraptoday) - elif newer 10; then - today=$(< /tmp/timetraptoday) - td -s today >/tmp/timetraptoday & - else - today=$(td -s today) - echo "$today" >/tmp/timetraptoday - fi + ## begin day percent, in thousandths, plus a spark block for ten_thousandth. + printf '{ "name": "day_percent", "full_text": "' - # hours remaining in the day: - - # work+study in the last week, not counting today. - # no arg to printf for the intentional behavior of no arg - # shellcheck disable=SC2183 - cache=/tmp/timetrap$(printf '%(%F)T') - if [[ -e $cache ]]; then - eval $(<$cache) - else - week=$(td -s '8 days ago' -e 'yesterday') - printf 'week="%s"\n' "$week" >$cache - week4=$(td -s '29 days ago' -e 'yesterday') - printf 'week4="%s"\n' "$week4" >>$cache - fi - # weekly work+study in the last 4 weeks, not counting today. - # todo later: - # 4 weeks - # ($x4week + $w4week + .05) /4 - #weekly work+study in the last 16 weeks, not counting today. - #weekly work+study in the last 52 weeks, not counting today. - - unixtime=$EPOCHSECONDS - midnight=$(date +%s -d 'tomorrow 00:00') - tmp=($(echo "scale=1; today_left=($midnight-$unixtime) / 60 / 60; -today_left; -done_today=($today + .05) /1; -/* hours I could do today by working 80% of the remainder time */ -today_left * .8 + done_today; -done_today; -($week + .05) /1; -($week4 + .05) /4"|bc)) - printf "[ { \"full_text\": \"" - if [[ $ps_char ]]; then - printf "%s| " "$ps_char" + + # after 24 hours, reset the day start + if (( day_start + 24 * 60 * 60 < EPOCHSECONDS )); then + day_start=$(date -d $day_start_hour:$day_start_min +%s) fi - printf "%s | left today %s %s | today %s | week %s | 4weeks %s | %s\" } ],\n" "$cursheet" "${tmp[@]}" "$(date "+%A, %B %d, %r")" + + spark_index="$(( (100000 -($EPOCHSECONDS - $day_start)*100000 / (16*60*60) ) % 100 / 11 ))" + 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")" + + # .1% of a waking year is ~5.75 hours, or 365 thousandths of a day. + # 1% of a waking year is 3.7 days + # A spark line of a thousandth of a waking year is 39 minutes. + 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) )) + printf %s " $year_tenthousandth${spark:year_spark_index:1}" + + + echo '"} +], +' } -# pass any arg and we just run once + +# pass any arg and we just run once. mainly for debugging if (( $# )); then main + + # debug + #echo date -d $day_start_hour:$day_start_min +%s + #echo day_start=$day_start now=$EPOCHSECONDS + else - printf '{ "version": 1 }\n[' + printf '{ "version": 1, "click_events": true }\n[' while true; do main - sleep 5 + line= + read -r -t 3 line ||: done fi diff --git a/pkgs b/pkgs index 5b67690..a5e2bfd 100644 --- a/pkgs +++ b/pkgs @@ -94,6 +94,7 @@ p3=( copyq cpulimit cron + csvkit cvs debian-archive-keyring debug-me @@ -146,10 +147,12 @@ p3=( glibc-doc goaccess gnome-screenshot + gpick grepmail guvcview # for my / office hp printers hplip + html-xml-utils hunspell i3lock i3status diff --git a/script-files b/script-files index 309d5bd..3c8b658 100644 --- a/script-files +++ b/script-files @@ -5,7 +5,8 @@ my_bin_files=( switch-mail-host switch-host2 btrbk-run mount-latest-subvol - check-subvol-stale myi3status + check-subvol-stale + myi3status mailbindwatchdog check-mailq unsaved-buffers.el diff --git a/switch-mail-host b/switch-mail-host index ffb0814..577d500 100644 --- a/switch-mail-host +++ b/switch-mail-host @@ -146,15 +146,16 @@ elif $host2_only; then mp_args="-m /a,/ar,/q,/qr" fi - -if $host2_only; then - if [[ $old_hostname != "$HOST2" ]]; then - err "\$old_hostname($old_hostname) != \$HOST2($HOST2). Rerun with --force if you really want this." +if ! $force; then + if $host2_only; then + if [[ $old_hostname != "$HOST2" ]]; then + err "\$old_hostname($old_hostname) != \$HOST2($HOST2). Rerun with --force if you really want this." + exit 1 + fi + elif [[ $old_hostname != "$MAIL_HOST" ]]; then + err "\$old_hostname($old_hostname) != \$MAIL_HOST($MAIL_HOST). Rerun with --force if you really want this." exit 1 fi -elif [[ $old_hostname != "$MAIL_HOST" ]] && ! $force; then - err "\$old_hostname($old_hostname) != \$MAIL_HOST($MAIL_HOST). Rerun with --force if you really want this." - exit 1 fi if [[ ! $new_host || ! $old_host ]]; then