small improvements
[distro-setup] / brc
diff --git a/brc b/brc
index d8cfd227b6e7315d62f3405b8ba3c849675a1b79..d82c852204879cc3d0b55d85547a90630c5c67fb 100644 (file)
--- a/brc
+++ b/brc
@@ -272,14 +272,16 @@ _khfix_common() {
     local h=${1##*@}
     local x
     ssh-keygen -R $h -f $(readlink -f ~/.ssh/known_hosts)
-    if ! x=$(timeout 0.1 ssh -oBatchMode=yes -v $1 |& sed -rn "s/debug1: Connecting to $h \[([^\]*)].*/\1/p"); then
+    x=$(timeout 1 ssh -oBatchMode=yes -v $1 |& sed -rn "s/debug1: Connecting to $h \[([^\]*)].*/\1/p")
+    if [[ ! $x ]]; then
         echo "khfix: ssh failed"
         return 1
     fi
+    echo "khfix: removing key for $x"
     ssh-keygen -R $x -f $(readlink -f ~/.ssh/known_hosts)
 }
 khfix() { # known hosts fix
-    _khfix_common "$@"
+    _khfix_common "$@" || return 1
     ssh $1 :
 }
 khcopy() {
@@ -488,7 +490,7 @@ dt() {
     date "+%A, %B %d, %r" "$@"
 }
 
-dus() {
+dus() { # du, sorted, default arg of
     du -sh ${@:-*} | sort -h
 }
 
@@ -534,6 +536,53 @@ faf() { # find all files
 
 fastboot() { /a/opt/androidsdk/platform-tools/fastboot "$@"; }
 
+
+# List of apps to install/update
+# Create from existing manually installed apps by doing
+# fdroidcl search -i, then manually removing
+# automatically installed/preinstalled apps
+fdroid_pkgs=(
+    at.bitfire.davdroid
+    com.fsck.k9
+    com.ichi2.anki
+    com.notecryptpro
+    com.nutomic.syncthingandroid
+    com.termux
+    de.danoeh.antennapod
+    de.marmaro.krt.ffupdater
+    im.vector.alpha # riot
+    me.ccrama.redditslide
+    net.gaast.giggity
+    net.osmand.plus
+    org.dmfs.tasks # caldav tasks thing
+    org.fdroid.fdroid
+    org.quantumbadger.redreader
+    org.secuso.privacyfriendlyweather
+    org.smssecure.smssecure
+    org.fedorahosted.freeotp
+    com.ghostsq.commander
+    me.tripsit.tripmobile
+    # https://forum.xda-developers.com/android/software-hacking/wip-selinux-capable-superuser-t3216394
+    me.phh.superuser
+)
+fdup() {
+    local -A installed updated
+    local p
+    fdroidcl update
+    for p in $(fdroidcl search -i| grep -o "^\S\+"); do
+        installed[$p]=true
+    done
+    for p in $(fdroidcl search -u| grep -o "^\S\+"); do
+        updated[$p]=false
+    done
+    for p in ${fdroid_pkgs[@]}; do
+        ${installed[$p]:-false} || fdroidcl install $p
+    done
+    for p in ${!installed[@]}; do
+        ${updated[$p]:-true} || fdroidcl upgrade $p
+    done
+}
+
 ff() {
     if type -P firefox &>/dev/null; then
         firefox "$@"
@@ -865,6 +914,25 @@ make-targets() {
     make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}'
 }
 
+mbenable() {
+    mb=$1
+    dst=/m/4e/$1
+    src=/m/md/$1
+    set -x
+    mv -T $src $dst || { set +x; return 1; }
+    ln -s -T $dst $src
+    set +x
+}
+mbdisable() {
+    mb=$1
+    dst=/m/md/$1
+    src=/m/4e/$1
+    set -x
+    if [[ -L $dst ]]; then rm $dst; fi
+    mv -T $src $dst
+    set +x
+}
+
 
 mkc() {
     mkdir "$1"
@@ -930,14 +998,6 @@ pick-trash() {
     done
 }
 
-postconfin() {
-    local MAPFILE
-    mapfile -t
-    local s
-    [[ $EUID == 0 ]] || s=s
-    $s postconf -ev "${MAPFILE[@]}"
-}
-
 pub() {
     rld /a/h/_site/ li:/var/www/iankelling.org/html
 }
@@ -945,6 +1005,25 @@ pub() {
 pubip() { curl -4s https://icanhazip.com; }
 whatismyip() { pubip; }
 
+pumpa() {
+    # fixes the menu bar in xmonad. this won\'t be needed when xmonad
+    # packages catches up on some changes in future (this is written in
+    # 4/2017)
+    #
+    # geekosaur: so you'll want to upgrade to xmonad 0.13 or else use a
+    # locally modified XMonad.Hooks.ManageDocks that doesn't set the
+    # work area; turns out it's impossible to set correctly if you are
+    # not a fully EWMH compliant desktop environment
+    #
+    # geekosaur: chrome shows one failure mode, qt/kde another, other
+    # gtk apps a third, ... I came up with a setting that works for me
+    # locally but apparently doesn't work for others, so we joined the
+    # other tiling window managers in giving up on setting it at all
+    #
+    xprop -root -remove _NET_WORKAREA
+    command pumpa &r
+}
+
 
 pwgen() {
     # -m = min length
@@ -1008,6 +1087,22 @@ rlu() { # [OPTS] HOST PATH
     s rsync -rlpchviog --relative "${opts[@]}" "$path" "root@$host:/";
 }
 
+r2eadd() { # usage: name url
+    # initial setup of rss2email:
+    # r2e new r2e@iankelling.org
+    # that initializes files, and sets default email.
+    # Would have been simpler to just leave it off since i\'m not
+    # using the default email. Symlinks won\'t work, so we use binds.
+    # mkdir /p/c/binds/.config/
+    # mv ~/.config/rss2email.cfg /p/c/binds/.config/
+    # mkdir /p/c/binds/.local/share/
+    # mv ~/.local/share/rss2email.json /p/c/binds/.local/share/
+    # conflink
+    r2e add $1 "$2" $1@r2e.iankelling.org
+    # get up to date and don't send old entries now:
+    r2e run --no-send $1
+}
+r2e() { command r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg "$@"; }
 
 rspicy() { # usage: HOST DOMAIN
     # connect to spice vm remote host. use vspicy for local host
@@ -1239,8 +1334,8 @@ testexim() {
     # that is a pain. Exim debug args are documented here:
     # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_exim_command_line.html
     #
-# http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
-# note, for exim daemon, you can turn on debug options by
+    # http://www.exim.org/exim-html-current/doc/html/spec_html/ch-building_and_installing_exim.html
+    # note, for exim daemon, you can turn on debug options by
     # adding -d, etc to COMMONOPTIONS in
     # /etc/default/exim4
     # for testing external mail, you need the to address as final cmdline arg
@@ -1586,6 +1681,9 @@ elif [[ -s $HOME/.rvm/scripts/rvm ]]; then
     source $HOME/.rvm/scripts/rvm
 fi
 
+export GOPATH=$HOME/go
+path_add $GOPATH/bin
+
 
 path_add --end ~/.npm-global