From: Ian Kelling Date: Thu, 13 Jun 2024 14:15:07 +0000 (-0400) Subject: mostly fixes, some improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=e801d1a57f0b30c57c6f644ab06a0f790159b236;p=distro-setup mostly fixes, some improvements --- diff --git a/brc2 b/brc2 index c857670..bb33b7d 100644 --- a/brc2 +++ b/brc2 @@ -925,7 +925,7 @@ beetag() { else pl_state_file=sorted fi - pl_state_dir=/i/info/pl-state + pl_state_dir=/b/data/pl-state if [[ $playlist ]]; then pl_state_dir=$pl_state_dir/$playlist else diff --git a/distro-end b/distro-end index 232170f..5378579 100755 --- a/distro-end +++ b/distro-end @@ -1826,7 +1826,7 @@ EOF equivs-build tox sudo dpkg -i tox_1.0_all.deb rm -rf ./tox* - pi beets python3-discogs-client + pi beets cd rm -r "$tmpdir" fi diff --git a/ffs b/ffs index 0bb4ae7..d6dc01f 100755 --- a/ffs +++ b/ffs @@ -28,99 +28,6 @@ # the top half for a 1080p stream, this is how: # https://superuser.com/questions/1106674/how-to-add-blank-lines-above-the-bottom-in-terminal # -# potential improvement: sometimes I probably want to stream full height -# window. I could add an option for that. - -# potential improvement: setup a function which automatically mutes after some time, or -# after some time of no audio input. - - -### begin background/development docs ### - -# zmq vs stdin commands: -# -# * zmq allows targeting a specific filter when there are duplicates. -# -# * if you type stdin command too slow, ffmpeg will die because it stops -# doing normal work while it is waiting. -# -# * zmq returns a result to the calling process, rather than printing to -# stdout. -# -# * the only simple zmq tool I found, zmqsend, requires compiling. I -# used the latest ffmpeg 7.0.1. Build like so: -# -# p build-dep ffmpeg/aramo -# ./configure --enable-libzmq # i already had libzmq3-dev installed -# make alltools -# cp tools/zmqsend /a/opt/bin -# -# * ffmpeg debug output was useful in testing zmq commands. -# -# * Important documentation for stdin commands is only found by typing -# "c" into the stdin of ffmpeg and reading the output. -# -# -# -# stdin command docs, before I abandoned it for zmq: -# mkfifo -m 0600 /tmp/iank-ffmpeg -# # ffmpeg sits and waits until we do this. dunno why. -# echo >/tmp/iank-ffmpeg & -# ffmpeg ... /tmp/iank-ffmpeg -# echo "cdrawbox -1 t fill" >/tmp/iank-ffmpeg -# echo "cdrawtext -1 reinit text=''" >/tmp/iank-ffmpeg -# echo "cvolume -1 volume=1" >/tmp/iank-ffmpeg - - -# For testing: to show the number of audio channels in a resulting file -# https://stackoverflow.com/questions/47905083/how-to-check-number-of-channels-in-my-audio-wav-file-using-ffmpeg-command -# -# ffprobe -i /tmp/out.wav -show_entries stream=channels -select_streams a:0 -of compact=p=0:nk=1 -v 0 - -# for a right/left speaker test: -# https://askubuntu.com/questions/148363/which-linux-command-can-i-use-to-test-my-speakers-for-current-talk-radio-output -# p install alsa-utils -# speaker-test -t wav -c 2 -l 1 - -# There are 2 other options for audio, so I wanted to do a little -# performance measurement of this method. -# 1 is to combine the 2 audio sources in pulse, -# https://unix.stackexchange.com/questions/351764/create-combined-source-in-pulseaudio . -# 1 is to record mumble and combine in post processing. - -### benchmark / perf tests: these are pretty inaccurate. -# 29 seconds cpu use. video bitrate 1500k, 8 fps, 2x keyframe interval. -# * 64k vorbis: 69.7% -# * 128k vorbis: 70.1% (used in subsequent tests) -# * 1 audio input: 64.3% -# * 0 audio inputs: 59.2% - -# how I did perf testing: add -to 00:00:30 to ffmpeg opts to -# conveniently exit after measurement. Then run: -# -# ffmpeg "${opts[@]}" & -# pid=$! -# sleep 29 -# ps -p $pid -o %cpu -# kill %% - -# filter for only 1 audio input: -#-filter_complex "[0]azmq,volume=precision=fixed;[1]zmq='b=tcp\://127.0.0.1\:5557',drawbox=color=0x262626,drawtext=fontsize=90: fontcolor=beige: x=40: y=40: text=''" -# filter with 0 audio input: -# -filter_complex "[0]zmq='b=tcp\://127.0.0.1\:5557',drawbox=color=0x262626,drawtext=fontsize=90: fontcolor=beige: x=40: y=40: text=''" - - -# When things weren't working, I did some checking on newer ffmpeg to -# see if that helped. It never did. I compiled the latest ffmpeg release -# tarball, 7.0.1, and tried the version in debian bullseye by schrooting -# before running ffmpeg. Building was just configure; make, but then I -# found some flags that were needed. gpl flags r just because I noticed them. -# ./configure --enable-libzmq --enable-libpulse --enable-libvorbis --enable-gpl --enable-version3 -# - -### end background/development docs ### if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi @@ -427,3 +334,92 @@ if $watch; then kill %% rm -f $HOME/.iank-stream-on fi + + + +### begin background/development docs ### + +# zmq vs stdin commands: +# +# * zmq allows targeting a specific filter when there are duplicates. +# +# * if you type stdin command too slow, ffmpeg will die because it stops +# doing normal work while it is waiting. +# +# * zmq returns a result to the calling process, rather than printing to +# stdout. +# +# * the only simple zmq tool I found, zmqsend, requires compiling. I +# used the latest ffmpeg 7.0.1. Build like so: +# +# p build-dep ffmpeg/aramo +# ./configure --enable-libzmq # i already had libzmq3-dev installed +# make alltools +# cp tools/zmqsend /a/opt/bin +# +# * ffmpeg debug output was useful in testing zmq commands. +# +# * Important documentation for stdin commands is only found by typing +# "c" into the stdin of ffmpeg and reading the output. +# +# +# +# stdin command docs, before I abandoned it for zmq: +# mkfifo -m 0600 /tmp/iank-ffmpeg +# # ffmpeg sits and waits until we do this. dunno why. +# echo >/tmp/iank-ffmpeg & +# ffmpeg ... /tmp/iank-ffmpeg +# echo "cdrawbox -1 t fill" >/tmp/iank-ffmpeg +# echo "cdrawtext -1 reinit text=''" >/tmp/iank-ffmpeg +# echo "cvolume -1 volume=1" >/tmp/iank-ffmpeg + + +# For testing: to show the number of audio channels in a resulting file +# https://stackoverflow.com/questions/47905083/how-to-check-number-of-channels-in-my-audio-wav-file-using-ffmpeg-command +# +# ffprobe -i /tmp/out.wav -show_entries stream=channels -select_streams a:0 -of compact=p=0:nk=1 -v 0 + +# for a right/left speaker test: +# https://askubuntu.com/questions/148363/which-linux-command-can-i-use-to-test-my-speakers-for-current-talk-radio-output +# p install alsa-utils +# speaker-test -t wav -c 2 -l 1 + +# There are 2 other options for audio, so I wanted to do a little +# performance measurement of this method. +# 1 is to combine the 2 audio sources in pulse, +# https://unix.stackexchange.com/questions/351764/create-combined-source-in-pulseaudio . +# 1 is to record mumble and combine in post processing. + +### benchmark / perf tests: these are pretty inaccurate. +# 29 seconds cpu use. video bitrate 1500k, 8 fps, 2x keyframe interval. +# * 64k vorbis: 69.7% +# * 128k vorbis: 70.1% (used in subsequent tests) +# * 1 audio input: 64.3% +# * 0 audio inputs: 59.2% + +# how I did perf testing: add -to 00:00:30 to ffmpeg opts to +# conveniently exit after measurement. Then run: +# +# ffmpeg "${opts[@]}" & +# pid=$! +# sleep 29 +# ps -p $pid -o %cpu +# kill %% + +# filter for only 1 audio input: +#-filter_complex "[0]azmq,volume=precision=fixed;[1]zmq='b=tcp\://127.0.0.1\:5557',drawbox=color=0x262626,drawtext=fontsize=90: fontcolor=beige: x=40: y=40: text=''" +# filter with 0 audio input: +# -filter_complex "[0]zmq='b=tcp\://127.0.0.1\:5557',drawbox=color=0x262626,drawtext=fontsize=90: fontcolor=beige: x=40: y=40: text=''" + + +# When things weren't working, I did some checking on newer ffmpeg to +# see if that helped. It never did. I compiled the latest ffmpeg release +# tarball, 7.0.1, and tried the version in debian bullseye by schrooting +# before running ffmpeg. Building was just configure; make, but then I +# found some flags that were needed. gpl flags r just because I noticed them. +# ./configure --enable-libzmq --enable-libpulse --enable-libvorbis --enable-gpl --enable-version3 +# + +### end background/development docs ### diff --git a/filesystem/usr/local/bin/abrowser b/filesystem/usr/local/bin/abrowser index 7892cc7..d3ce643 100755 --- a/filesystem/usr/local/bin/abrowser +++ b/filesystem/usr/local/bin/abrowser @@ -43,11 +43,13 @@ i3-msg -t get_tree | jq -e '.nodes[].nodes[].nodes[].nodes | [.[]] + ( [.[].node # prefer abrowser if type -P abrowser &>/dev/null; then - abrowser "$@" & + b=abrowser else - firefox "$@" & + b=firefox fi +$b "$@" & + # on a fast computer, .5 is too fast, 1 is ok. on x200, 1 is too fast, 2 is ok. sleep 2 # debug @@ -60,7 +62,7 @@ if (( $# == 0 )) && ! i3-msg -t get_tree | jq --stream -r 'select(.[1]|scalars!= # into a single array instead of a list of arrays with [.[]], or else # it will add the arrays a bunch of times and give several results. # comm gives us just the new id. - id=$(i3-msg -t get_tree | jq -e '.nodes[].nodes[].nodes[].nodes | [.[]] + ( [.[].nodes[]]) + ( [.[].nodes[].nodes[]]) + ( [.[].nodes[].nodes[].nodes[]]) | .[] | select(.window_properties.class=="abrowser") | .id' | comm -23 - $tmpf | head -n1) + id=$(i3-msg -t get_tree | jq -e '.nodes[].nodes[].nodes[].nodes | [.[]] + ( [.[].nodes[]]) + ( [.[].nodes[].nodes[]]) + ( [.[].nodes[].nodes[].nodes[]]) | .[] | select(.window_properties.class=="'$b'") | .id' | comm -23 - $tmpf | head -n1) rm -f $tmpf if [[ $id ]]; then i3-msg "[con_id=$id] mark abrowser" diff --git a/i3-split-maybe b/i3-split-maybe index 0a98c90..bb425ef 100755 --- a/i3-split-maybe +++ b/i3-split-maybe @@ -22,9 +22,10 @@ # limitations under the License. -# This anticipates when we want to tab windows. There are 2 options of -# when to do it: just after a window is created, or just before a window -# is created. +# This anticipates when we want to tab windows. +# +# There are 2 options of when to do it: just after a window is created, +# or just before a window is created. # # * Doing it after a window is created allows you to move a window into # the split that only has 1 window, whereas the other way doesn't. For @@ -45,7 +46,8 @@ # the window is closed, and I don't want single window splits hanging around, # so I close them out in # -# I have a keybind which disables both, it runs /b/ds/i3-auto-layout-toggle +# I have a keybind which disables both, super+shift+u, it runs +# /b/ds/i3-auto-layout-toggle # import sys @@ -89,35 +91,42 @@ def set_layout(i3): workspace = win.workspace() #pprint(vars(workspace.rect)) - screen_width = workspace.rect.width - screen_height = workspace.rect.height - half_w = screen_width / 2 + 1 - half_h = screen_height / 2 + 1 + screen_w = workspace.rect.width + screen_h = workspace.rect.height + half_w = screen_w / 2 + 1 + half_h = screen_h / 2 + 1 w = win.rect.width h = win.rect.height ph = parent.rect.height pw = parent.rect.width - # There is potential for future use with < 1920, but I'm - # not thinking about it yet. - if ( screen_width < 1920 or parent.layout == 'tabbed' or gp.layout == 'tabbed'): + if ( parent.layout == 'tabbed' or gp.layout == 'tabbed'): return - # print('d2: len(parent.nodes)', len(parent.nodes),' > 1', - # 'and ( ph ',ph,' > h + 10',h + 10,' or pw',pw,' > w',w,' )', - # 'and w <= half_w',half_w,'+ and h <= half_h',half_h) + # debug + print('d2: len(parent.nodes):', len(parent.nodes),' > 1', + 'and ( ph:',ph,' > h + 10:',h + 10,' or pw:',pw,' > w:',w,' )', + 'and (screen_w:',screen_w,' < screen_h:',screen_h,' or w <= half_w:',half_w,')', + 'and h <= half_h:',half_h,'))') # h + 10 because a tabbed window loses high compared to its parent. # Note, it is redundant since we check above if the parent is tabbed, # but just being cautious. + # + # condition in english + # the parent container is bigger + # and we are on a vertical screen or our window is <= half the screen width + # and we are <= half the screen height if (len(parent.nodes) > 1 and ( ph > h + 10 or pw > w ) - and w <= half_w and h <= half_h ): + and ( screen_w < screen_h or w <= half_w ) + and h <= half_h )): i3.command('split vertical, layout tabbed') # print('d1: tabbed') + ### further potential use cases: # We could automatically do a vertical split when there are 2 or 3 diff --git a/i3-sway/bar.conf b/i3-sway/bar.conf index d1457be..75e345b 100644 --- a/i3-sway/bar.conf +++ b/i3-sway/bar.conf @@ -1,4 +1,21 @@ -# need this for kde connect +# by default, new workspaces are created on whatever screen doesn't have +# one active or else the current one. That is annoying, I have one +# primary monitor, I don't want a new workspace created on secondary +# monitor just because I happen be focused on it. This fixes that. +workspace 1 output primary +workspace 2 output BIG-LEFT +workspace 3 output BIG-RIGHT +workspace 4 output BIG-RIGHT +workspace 5 output BIG-RIGHT +workspace 6 output BIG-RIGHT +workspace 7 output BIG-RIGHT +workspace 8 output BIG-RIGHT +workspace 9 output BIG-RIGHT +workspace 10 output BIG-RIGHT + +default_orientation vertical + +# bar is needed for kde connect bar { # keep it only on secondary monitor to save space and make for less diff --git a/i3-sway/common.conf b/i3-sway/common.conf index 40b1bb5..79f26bb 100644 --- a/i3-sway/common.conf +++ b/i3-sway/common.conf @@ -63,7 +63,7 @@ bindsym $mod+r $ex "/a/bin/ds/xl" bindsym $mod+t $ex "i3-set-layout splitv" #bindsym $mod+Shift+t move workspace to output up -bindsym $mod+Shift+t move workspace to output right +bindsym $mod+Shift+t move workspace to output BIG-RIGHT eDP-1 bindsym $mod+g $ex "i3-set-layout tabbed" @@ -90,17 +90,18 @@ bindsym $mod+shift+Right move right bindsym $mod+shift+Up move up bindsym $mod+shift+Down move down -bindsym $mod+Shift+a move container to workspace 4 -bindsym $mod+a workspace 4 +bindsym $mod+Shift+a move container to workspace 1 +bindsym $mod+a workspace 1 -bindsym $mod+Shift+s move container to workspace 3 -bindsym $mod+s workspace 3 -bindsym $mod+Shift+d move container to workspace 2 -bindsym $mod+d workspace 2 +bindsym $mod+Shift+s move container to workspace 4 +bindsym $mod+s workspace 4 -bindsym $mod+Shift+f move container to workspace 1 -bindsym $mod+f workspace 1 +bindsym $mod+Shift+d move container to workspace 3 +bindsym $mod+d workspace 3 + +bindsym $mod+Shift+f move container to workspace 2 +bindsym $mod+f workspace 2 bindsym $mod+Shift+z move container to workspace 5 bindsym $mod+z workspace 5 @@ -109,7 +110,7 @@ bindsym $mod+Shift+x move container to workspace 6 bindsym $mod+x workspace 6 bindsym $mod+v split vertical -bindsym $mod+Shift+v split horizontal +bindsym $mod+Shift+v move workspace to output BIG-LEFT # 122 = XF86AudioLowerVolume, keyboardio function + t bindcode 122 $ex "toggle-mute unmute"; mode "ptt" @@ -140,8 +141,9 @@ bindsym $mod+shift+6 [class="Emacs" title="^(?!#[a-zA-Z][a-zA-Z-]*$)"] move work bindsym $mod+c kill -bindsym $mod+Shift+Home move container to workspace 7 -bindsym $mod+Home workspace 7 +bindsym $mod+Home split horizontal +bindsym $mod+Shift+End move container to workspace 7 +bindsym $mod+End workspace 7 bindsym $mod+Shift+q move container to workspace 8 bindsym $mod+q workspace 8 @@ -195,10 +197,6 @@ hide_edge_borders vertical # Start clipster daemon #exec --no-startup-id /a/opt/clipster/clipster -d - -# shortcut to selection widget (primary) -bindsym $mod+End $ex "/b/ds/toggle-mute" - # title bars but no borders. i tried this out a bit #default_border normal 0 diff --git a/laptop-xrandr b/laptop-xrandr index 6701e74..bed869d 100755 --- a/laptop-xrandr +++ b/laptop-xrandr @@ -22,29 +22,67 @@ set -e; . /usr/local/lib/bash-bear; set +e +xf=$(mktemp) +xrandr >$xf + # eg eDP-1 connected primary -laptop_out=$(xrandr | awk '$3 == "primary" {print $1}') -output=$(xrandr | grep -E "^(HDMI|DP)[^ ]* connected [0-9]" | awk '{print $1}' ||:) +laptop_out=$(awk '$3 == "primary" {print $1}' $xf) +output=$(grep -E "^(HDMI|DP)[^ ]* connected [0-9]" $xf| awk '{print $1}' ||:) + +edid() { + card=$1 + sha256sum