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
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
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() {
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
}
)
}
+# 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)
}
+# 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
}
# 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
-# 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
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
sleep 1
fi
-#echo executing: ffmpeg ${opts[@]}
+echo executing: ffmpeg ${opts[@]}
#{ sleep 1; ffp &>/dev/null & }
# ./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 ###
# 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.
i3-msg "[con_id=\"$id\"] focus"
else
+ i3-msg "workspace 2"
i3-split-maybe
emacsclient -c
fi
if ! /a/c/i3-focus-maybe term; then
+ i3-msg "workspace 2"
i3-split-maybe
konsole &
sleep 1
# 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
#default_border normal 0
# default border is like 2 pixels
-default_border pixel
+default_border pixel 2
# for debugging
#default_border normal 10
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
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"
[General]
AlternatingBackground=0
AlternatingBars=0
-ErrorBackground=2
+ErrorBackground=1
LocalTabTitleFormat=%w
Name=profileian
Parent=FALLBACK/