various improvements and fixes
authorIan Kelling <ian@iankelling.org>
Sun, 9 Apr 2017 06:34:55 +0000 (23:34 -0700)
committerIan Kelling <ian@iankelling.org>
Thu, 4 May 2017 23:42:08 +0000 (16:42 -0700)
brc

diff --git a/brc b/brc
index d8cfd227b6e7315d62f3405b8ba3c849675a1b79..5b3054ac4f5535e54f614c7287fd88816a72a400 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() {
@@ -534,6 +536,52 @@ 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
+    # riot
+    im.vector.alpha
+    me.ccrama.redditslide
+    net.gaast.giggity
+    net.osmand.plus
+    # caldav tasks thing
+    org.dmfs.tasks
+    org.fdroid.fdroid
+    org.quantumbadger.redreader
+    org.secuso.privacyfriendlyweather
+    org.smssecure.smssecure
+    org.fedorahosted.freeotp
+    com.ghostsq.commander
+)
+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 +913,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"
@@ -945,6 +1012,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
@@ -1239,8 +1325,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 +1672,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