From: Ian Kelling Date: Tue, 18 Jun 2024 23:29:51 +0000 (-0400) Subject: various improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=87c3f2244a47ad10a031a27d0d0456f0a7defd21;p=distro-setup various improvements --- diff --git a/.bashrc b/.bashrc index 814c9af..ac78814 100644 --- a/.bashrc +++ b/.bashrc @@ -55,10 +55,16 @@ HISTIGNORE='pass *:otp *:oathtool *:histrm *' umask 022 -if [[ $EUID == 1000 && $TERM == linux && ! $DISPLAY && $(tty) = /dev/tty1 && -x /usr/bin/startx ]] && \ - tmp=$(systemctl status |& head) && \ - grep -qi '^ *state: running' <<<"$tmp" && grep -qi '^ *failed: 0' <<<"$tmp" && grep -qi '^ *jobs: 0' <<<"$tmp"; then - startx +if [[ $EUID == 1000 && $TERM == linux && ! $DISPLAY && $(tty) = /dev/tty1 && -x /usr/bin/startx ]]; then + if tmp=$(systemctl status |& head) && \ + grep -qi '^ *state: running' <<<"$tmp" && grep -qi '^ *failed: 0' <<<"$tmp" && grep -qi '^ *jobs: 0' <<<"$tmp"; then + startx + else + echo "systemctl status |& head:" + printf "%s\n" "$tmp" + echo: systemctl list-jobs: + systemctl list-jobs + fi fi #### if (in diff --git a/brc b/brc index 0745bff..d359f65 100644 --- a/brc +++ b/brc @@ -354,6 +354,7 @@ mysrc() { mysrc /a/bin/small-misc-bash/ll-function mysrc /a/bin/distro-functions/src/package-manager-abstractions +mysrc /a/bin/fai/fai/config/distro-install-common/bash-misc-funcs # things to remember: # ALT-C - cd into the selected directory @@ -2964,33 +2965,6 @@ nonet() { m() { printf "%s\n" "$*"; "$@"; } m2() { printf "%s\n" "$*" >&2; "$@"; } -# update file. note: duplicated in mail-setup. -# updates $ur u result to true or false -# updates $reload to true if file updated is in /etc/systemd/system -u() { - local tmp tmpdir dest="$1" - local base="${dest##*/}" - local dir="${dest%/*}" - if [[ $dir != "$base" ]]; then - # dest has a directory component - mkdir -p "$dir" - fi - # shellcheck disable=SC2034 # see comment at top of function - ur=false # u result - tmpdir="$(mktemp -d)" - cat >$tmpdir/"$base" - tmp=$(rsync -ic $tmpdir/"$base" "$dest") - if [[ $tmp ]]; then - printf "%s\n" "$tmp" - # shellcheck disable=SC2034 # see comment at top of function - ur=true - if [[ $dest == /etc/systemd/system/* ]]; then - # shellcheck disable=SC2034 # see comment at top of function - reload=true - fi - fi - rm -rf $tmpdir -} uptime() { diff --git a/brc2 b/brc2 index f9acada..d6ff1a4 100644 --- a/brc2 +++ b/brc2 @@ -2037,12 +2037,12 @@ apache-strip() { for f in $(find . -type f -maxdepth 1); do if head -n1 "$f"| grep -E '^#!/bin/bash\b' &>/dev/null; then { head -n 20 $f | tac | sed '/^# limitations under the License.$/,/^# Copyright.*Ian Kelling$/d' | tac; tail -n+21 $f; } |sponge $f; fi ; done } -chrome() { +chro() { if type -p chromium &>/dev/null; then cmd=chromium else cd / - cmd="schroot -c bullseye chromium" + cmd="schroot -c bookworm chromium" CHROMIUM_FLAGS='--enable-remote-extensions' $cmd & r fi } @@ -3033,40 +3033,59 @@ EOF ) } +# sudo maybe +# +# passes on any initial -* args to sudo. +sudm() { + local arg + local -a sudo_opts + for arg; do + if [[ $arg == -* ]]; then + sudo_opts+=("$arg") + shift + else + break + fi + done + if [[ $EUID == 0 ]]; then + "$@" + else + sudo "${sudo_opts[@]}" "$@" + fi +} -mns() { # mount namespace +mns-setup() { + local ns ns=$1 - shift - s mkdir -p /root/mount_namespaces - if ! sudo mountpoint /root/mount_namespaces >/dev/null; then - m sudo mount --bind /root/mount_namespaces /root/mount_namespaces + sudm mkdir -p /root/mount_namespaces + if ! sudm mountpoint /root/mount_namespaces >/dev/null; then + m sudm mount --bind /root/mount_namespaces /root/mount_namespaces fi - m sudo mount --make-private /root/mount_namespaces - if [[ ! -e /root/mount_namespaces/$ns ]]; then - m sudo touch /root/mount_namespaces/$ns + m sudm mount --make-private /root/mount_namespaces + if ! sudm test -e /root/mount_namespaces/$ns; then + m sudm touch /root/mount_namespaces/$ns fi - if ! sudo mountpoint /root/mount_namespaces/$ns >/dev/null; then - m sudo unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true + if ! sudm mountpoint /root/mount_namespaces/$ns >/dev/null; then + m sudm unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true fi - m sudo -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@" + +} + +mns() { # mount namespace + local ns + ns=$1 + shift + mns-setup $ns + m sudm -E /usr/bin/nsenter --mount=/root/mount_namespaces/$ns "$@" } mnsd() { # mount namespace + systemd namespace + local ns unit ns=$1 unit=$2 shift 2 - s mkdir -p /root/mount_namespaces - if ! sudo mountpoint /root/mount_namespaces >/dev/null; then - m sudo mount --bind /root/mount_namespaces /root/mount_namespaces - fi - m sudo mount --make-private /root/mount_namespaces - if [[ ! -e /root/mount_namespaces/$ns ]]; then - m sudo touch /root/mount_namespaces/$ns - fi - if ! sudo mountpoint /root/mount_namespaces/$ns >/dev/null; then - m sudo unshare --propagation slave --mount=/root/mount_namespaces/$ns /bin/true - fi + mns-setup $ns pid=$(servicepid $unit) tmpf=$(mktemp --tmpdir $unit.XXXXXXXXXX) @@ -4104,6 +4123,25 @@ sdncmdroot() { # systemd namespace root command } +# systemd network namespace (not mount) cmd +# usage: UNIT CMD... +sdnncmd() { + local unit pid tmpf + if (( $# <= 1 )); then + echo $0: error wrong number of args >&2 + return 1 + fi + unit=$1 + shift + pid=$(servicepid $unit) + tmpf=$(mktemp --tmpdir $unit.XXXXXXXXXX) + export -p >$tmpf + printf "%s " "${@@Q}" >>$tmpf + echo >>$tmpf + m sudo nsenter -t $pid -n sudo -u $USER -i bash -c ". $tmpf & rm $tmpf" +} + + mailnnbash() { sdnbash mailnn } diff --git a/distro-end b/distro-end index 88ff40b..d8a6cc5 100755 --- a/distro-end +++ b/distro-end @@ -1383,7 +1383,11 @@ s DEBIAN_FRONTEND=noninteractive pi wireshark # listed in the default config as suggested. # /run/usr/1000 i noticed was missing for pulseaudio # /run/user/0 just seemed like a not bad idea, given the above +# +# /root gives us our bashrc, making various things a lot more +# convenient tu /etc/schroot/desktop/fstab <<'EOF' +/root /root none rw,bind 0 0 /p /p none rw,bind 0 0 /a /a none rw,bind 0 0 /run /run none rw,bind 0 0 @@ -1420,11 +1424,11 @@ sgo schrootupdate.timer -# for my roommate +# for testing firefox specific issues case $distro in - trisquel) + trisquel|ubuntu) m mkschroot -s /a/bin/fai/fai/config/files/etc/apt/sources.list.d/bookworm.list/BOOKWORM_FREE \ - debian bookworm firefox-esr pulseaudio chromium + debian bookworm chromium ;; debian) pi chromium diff --git a/ffs b/ffs index d63668b..0570787 100755 --- a/ffs +++ b/ffs @@ -186,11 +186,18 @@ else stream_res=$primary_res fi -# for 1080p, default 256k is poor quality. 500 is ok. 1500 is a bit -# better, so go with that. Also, that is about 2x what is recommended -# in https://livekit.io/webrtc/bitrate-guide (our framerate is lower). +stream_x=${stream_res%x*} +stream_y=${stream_res#*x} -bitrate=$(( ( ${stream_res/x/*} ) / 1380 )) +# leave out our i3 window borders +stream_res=$(( stream_x - 4 ))x$(( stream_y - 4)) + + +# 1000 is a bit blury, 1500 is pretty clear +# note https://livekit.io/webrtc/bitrate-guide (our framerate is lower) + +# Scale our bitrate to 1500 1080p +bitrate=$(( ( stream_x * stream_y ) / ( (1920*1080) / 1000 ) )) # 8 seems fine. be conservative by going a bit higher. framerate=10 @@ -306,7 +313,7 @@ if pkill -f ^ffmpeg.\*icecast://source.\*/fsf; then sleep 1 fi -#echo executing: ffmpeg ${opts[@]} +echo executing: ffmpeg ${opts[@]} #{ sleep 1; ffp &>/dev/null & } @@ -455,4 +462,9 @@ fi # ./configure --enable-libzmq --enable-libpulse --enable-libvorbis --enable-gpl --enable-version3 # +# note: when playing back, text is going to look aliased unless you +# watch it in a window that is exactly as bit or bigger than the +# recording: tabbed i3 window shrinks things. or, use: mpv +# --video-unscaled + ### end background/development docs ### diff --git a/i3-abrowser b/i3-abrowser index 2afbff3..a43c21d 100755 --- a/i3-abrowser +++ b/i3-abrowser @@ -44,6 +44,7 @@ fi # spawn and mark if we dont have a mark already if ! /a/c/i3-focus-maybe abrowser; then + i3-msg "workspace 2" i3-split-maybe $b "$@" & # on a fast computer, .5 is too fast, 1 is ok. on x200, 1 is too fast, 2 is ok. diff --git a/i3-emacs b/i3-emacs index 19fc46a..3337dcb 100755 --- a/i3-emacs +++ b/i3-emacs @@ -27,6 +27,7 @@ if [[ $id ]]; then i3-msg "[con_id=\"$id\"] focus" else + i3-msg "workspace 2" i3-split-maybe emacsclient -c fi diff --git a/i3-konsole b/i3-konsole index 92afe30..c18e588 100755 --- a/i3-konsole +++ b/i3-konsole @@ -27,6 +27,7 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${P if ! /a/c/i3-focus-maybe term; then + i3-msg "workspace 2" i3-split-maybe konsole & sleep 1 diff --git a/i3-sway/common.conf b/i3-sway/common.conf index 435c5fe..8d0d5d9 100644 --- a/i3-sway/common.conf +++ b/i3-sway/common.conf @@ -194,7 +194,8 @@ bindsym $mod+shift+y $ex "/a/exe/i3-chat" # is used in the bar {} block below. font pango:monospace 7 -hide_edge_borders vertical +# not helpful when i have split screen from myx +#hide_edge_borders vertical #exec --no-startup-id /usr/lib/x86_64-linux-gnu/libexec/kdeconnectd @@ -205,7 +206,7 @@ hide_edge_borders vertical #default_border normal 0 # default border is like 2 pixels -default_border pixel +default_border pixel 2 # for debugging #default_border normal 10 @@ -221,5 +222,5 @@ default_border pixel for_window [class="focus" instance="focus"] floating disable client.focused #4c7899 #285577 #ffffff #2e9ef4 #ff4400 -client.focused_inactive #333333 #5f676a #ffffff #484e50 #DBEEF4 +client.focused_inactive #333333 #5f676a #ffffff #484e50 #B8C8CD client.unfocused #333333 #222222 #888888 #292d2e #B8C8CD diff --git a/mail-setup b/mail-setup index 7ce6a0d..cdbf9e8 100755 --- a/mail-setup +++ b/mail-setup @@ -361,31 +361,8 @@ reload=false if [[ -e /var/local/mail-setup-reload ]]; then reload=true fi -# update file. -# if the file changed, ur=true, else false. -# note: duplicated in brc -u() { - local tmp tmpdir dest="$1" - local base="${dest##*/}" - local dir="${dest%/*}" - if [[ $dir != "$base" ]]; then - # dest has a directory component - mkdir -p "$dir" - fi - ur=false # u result - tmpdir=$(mktemp -d) - cat >$tmpdir/"$base" - tmp=$(rsync -ic $tmpdir/"$base" "$dest") - if [[ $tmp ]]; then - printf "%s\n" "$tmp" - ur=true - if [[ $dest == /etc/systemd/system/* ]]; then - touch /var/local/mail-setup-reload - reload=true - fi - fi - rm -rf $tmpdir -} + +source /a/bin/fai/fai/config/distro-install-common/bash-misc-funcs setini() { key="$1" value="$2" section="$3" file="/etc/radicale/config" diff --git a/subdir_files/.local/share/konsole/profileian.profile b/subdir_files/.local/share/konsole/profileian.profile index 4063026..55cd61e 100644 --- a/subdir_files/.local/share/konsole/profileian.profile +++ b/subdir_files/.local/share/konsole/profileian.profile @@ -5,7 +5,7 @@ Font=Noto Mono,12,-1,5,50,0,0,0,0,0 [General] AlternatingBackground=0 AlternatingBars=0 -ErrorBackground=2 +ErrorBackground=1 LocalTabTitleFormat=%w Name=profileian Parent=FALLBACK/