X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc;h=5105c59611ac9f623471c6812bc27f9cc53eed75;hb=HEAD;hp=a5c645c52c8fc309e86c20685e07bd4296263643;hpb=ef3bbffe6d2a08ebd735ba4f09c7bd0fbea585a0;p=distro-setup diff --git a/brc b/brc index a5c645c..32a2c66 100644 --- a/brc +++ b/brc @@ -774,6 +774,50 @@ EOF done } +screenrtp() { + + local ip port xoffset + read -r ip port xoffset <<<"$@" + + setxenv + + if [[ ! $port ]]; then + port=9999 + fi + + while true; do + # By default, plugged in screen goes to the right side, so we need an + # offset that is the same as the laptop's x resolution. If we are in + # mirror mode, then we don't need an offset. + if [[ ! $xoffset ]]; then + xoffset=0 + laptop_x=$(xrandr | awk '$1 == "LVDS-1" {print $4}' | sed 's/x.*//') || { sleep 1; continue; } + total_x=$(xdpyinfo| awk '$1 == "dimensions:" {print $2}' | sed 's/x.*//') || { sleep 1; continue; } + screen2_res=$(xrandr | awk '$2 == "connected" && $1 != "LVDS-1" { print $3 }' | sed 's/+.*//') + if (( laptop_x < total_x )); then + xoffset=$laptop_x + fi + fi + + m ffmpeg -probesize 50M -thread_queue_size 50 \ + -video_size $screen2_res -f x11grab -framerate 30 -i :0.0+$xoffset.0 \ + -vcodec libx264 -g 1 -tune zerolatency -preset ultrafast -pix_fmt yuv420p -x264-params repeat-headers=1 \ + -f rtp_mpegts rtp://$ip:$port ||: + + + sleep 1 + done +} + +setxenv() { + if [[ ! $DISPLAY ]]; then + export DISPLAY=:0.0 + fi + if [[ ! $XAUTHORITY ]]; then + export XAUTHORITY=$HOME/.Xauthority + fi +} + #### end fsf section @@ -815,25 +859,40 @@ fpst() { # file paste } _khfix-common() { - local host ip port file key tmp - read -r host ip port < <(timeout -s 9 2 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to ([^ ]+) \[([^\]*)] port ([0-9]+).*/\1 \2 \3/p" ||: ) + local host ip port file key tmp ssh_host alias + ssh_host=$1 + { + read -r host ip port + read -r alias; + # note ":graph:" is needed or else we get a trailing \r out of ssh, + # dunno why. web search says terminals add \r, so I tried adding -T + # to turn off psuedo terminal, but it didnt help. + } < <(timeout -s 9 2 ssh -TN -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $ssh_host |& + sed -rn "s/debug1: Connecting to ([^ ]+) \[([^\]*)] port ([0-9]+).*/\1 \2 \3/p; +s/^debug1: using hostkeyalias: ([[:graph:]]*).*/\1/p" ||: ) file=$(readlink -f ~/.ssh/known_hosts) if [[ ! $ip ]]; then echo "khfix: ssh failed" return 1 fi + ip_entry=$ip + host_entry=$host + if [[ $alias ]]; then + host_entry="$alias" + fi if [[ $port != 22 ]]; then ip_entry="[$ip]:$port" - host_entry="[$host]:$port" - else - ip_entry=$ip - host_entry=$host + if [[ ! $alias ]]; then + host_entry="[$host]:$port" + fi fi - if [[ $host != "$ip" ]]; then + if [[ $host_entry != "$ip_entry" ]]; then tmp=$(mktemp) ssh-keygen -F "$host_entry" -f $file >$tmp || [[ $? == 1 ]] # 1 when it doesnt exist in the file if [[ -s $tmp ]]; then key=$(sed -r 's/^.*([^ ]+ +[^ ]+) *$/\1/' $tmp) + else + echo "khfix WARNING: did not find host entry:$host_entry in known_hosts" fi rm $tmp if [[ $key ]]; then @@ -845,12 +904,13 @@ _khfix-common() { ssh-keygen -F "$ip_entry" -f $file >$tmp || [[ $? == 1 ]] if [[ -s $tmp ]]; then key=$(sed -r 's/^.*([^ ]+ +[^ ]+) *$/\1/' $tmp) + else + echo "khfix WARNING: did not find ip entry:$ip_entry in known_hosts" fi rm $tmp if [[ $key ]]; then grep -Fv "$key" "$file" | sponge "$file" fi - ll ~/.ssh/known_hosts } khfix-r() { # known hosts fix without syncing to root user _khfix-common "$@" || return 1 @@ -1375,7 +1435,12 @@ egrinid() { sed -rn '/testignore|jtuttle|eximbackup/!s/^[^ ]+ ([^ ]+) [^ ]+ [^ ]+ <= ([^ ]+).* id=([^ ]+) T="(.*)" from (<[^ ]+> .*$)/\1 \5\n \3\n \4/p' <${1:-/var/log/exim4/mainlog} } etailin() { - tail -F /var/log/exim4/mainlog | sed -rn '/testignore|jtuttle|eximbackup/!s/^[^ ]+ ([^ ]+) [^ ]+ [^ ]+ <= ([^ ]+).*T="(.*)" from (<[^ ]+> .*$)/\1 \4\n \3/p' + local -a tail_arg + tail_arg=(-n500) + if [[ $1 ]]; then + tail_arg=($@) + fi + tail "${tail_arg[@]}" -F /var/log/exim4/mainlog | sed -rn '/testignore|jtuttle|eximbackup/!s/^[^ ]+ ([^ ]+) [^ ]+ [^ ]+ <= ([^ ]+).*T="(.*)" from (<[^ ]+> .*$)/\1 \4\n \3/p' } @@ -2046,9 +2111,9 @@ nags() { /usr/bin/nagstamon & } -# profanity screen +# profanity tmux profsrc() { - screen -RD -S profanity + screen -L profanity a } # i dont want to wait for konsole to exit... @@ -2474,29 +2539,19 @@ skmodified() { } -# sk on all the files in current git repo (except those excluded) +# sk on all the files in current git repo skgit() { - local f toplevel orig_dir tmp skip pattern - local -a ls_files excludes sk_files + local f toplevel orig_dir tmp + local -a ls_files sk_files toplevel=$(git rev-parse --show-toplevel) if [[ $PWD != "$toplevel" ]]; then orig_dir=$PWD cd $toplevel fi - excludes=( - 'disabled/*' - ) - tmp=$(git ls-files | shuf) + # tracked & untracked files + tmp=$(git ls-files && git ls-files --others --exclude-standard) mapfile -t ls_files <<<"$tmp" for f in "${ls_files[@]}"; do - skip=false - for pattern in "${excludes[@]}"; do - if [[ $f == $pattern ]]; then - skip=true - break - fi - done - if $skip; then continue; fi if sk-p "$f"; then sk_files+=("$f") fi @@ -2741,8 +2796,15 @@ sl() { slr() { sl --rsync "$@" } -sss() { # ssh solo - sl -oControlMaster=no -oControlPath=/ "$@" + + +# ssh solo +# +# WARNING: If you are trying to use -i, remember that keys added to +# agent previously will still be tried. Use ssh-add -D to remove all +# keys from the agent. +sss() { + ssh -oControlMaster=no -oControlPath=/ "$@" } # kill off old shared socket then ssh ssk() { @@ -3385,6 +3447,39 @@ if [[ $- == *i* ]]; then fi + +lp22viewers() { + v=0 + roomv=(0 0) + rooms=(jupiter saturn) + for ip in 209.51.188.25 live.fsf.org; do + out=$(curl -sS --insecure https://$ip/) + for i in 0 1 2; do + room=${rooms[i]} + while read -r n; do + v=$((v+n)) + roomv[$i]=$(( ${roomv[$i]} + n )) + done < <(printf "%s\n" "$out" | grep -Po "$room.*?current[^0-9]*[0-9]*" | grep -o '[0-9]*$' ) + done + done + printf "total: %s " $v + for i in 0 1; do + room=${rooms[i]} + printf "$room: %s " "${roomv[$i]}" + done + echo +} + +arpflush() { + local default_route_dev + default_route_dev=$(ip r show default | sed 's/.*dev \([^ ]*\).*/\1/' | head -n1) + m s ip n flush dev "$default_route_dev" +} + +dsh() { + command dsh -c "$@" +} + # * stuff that makes sense to be at the end