diff --git a/.local/bin/scripts/bak b/.local/bin/scripts/bak index 2e1119d..697abdd 100755 --- a/.local/bin/scripts/bak +++ b/.local/bin/scripts/bak @@ -1,7 +1,6 @@ #!/bin/sh suffix="${2:-bak}" orig="${1%%.$suffix}" -echo $orig if test -e "$orig.$suffix" then test -e "$orig" && mv -v "$orig" /tmp diff --git a/.local/bin/scripts/git-lno b/.local/bin/scripts/git-lno index bc793ff..e3f4ea7 100755 --- a/.local/bin/scripts/git-lno +++ b/.local/bin/scripts/git-lno @@ -3,10 +3,10 @@ # Useful when the history has been manipulated loc="$(git lo --color=always "$@")" upstream="$(git lo --color=always @{push} "$@")" -a=$(echo $loc | wc -l) -b=$(echo $upstream | wc -l) +countLoc=$(echo $loc | wc -l) +countUp=$(echo $upstream | wc -l) halfcols="$(expr $(tput cols) / 2)" -for i in $(seq 1 $(test $a -le $b && echo "$a" || echo "$b")); do +for i in $(seq 1 $(expr $countLoc \& $countLoc \< $countUp \| $countUp)); do printf "%-${halfcols}s $(test $halfcols -lt 100 && echo '\\n')%s\n" "$(echo $loc | head -n $i | tail -1)" "$(echo $upstream | head -n $i | tail -1)" # use columns instead? - need to interleave! done | ${PAGER:-less} diff --git a/.local/bin/scripts/retest b/.local/bin/scripts/retest index 3aa655c..cdaebac 100755 --- a/.local/bin/scripts/retest +++ b/.local/bin/scripts/retest @@ -5,6 +5,9 @@ case "$1" in ([0-9]*) code=$1; shift;; esac task="${1:-test}" test $# -gt 1 && prefix=":$2:" -gradle=$(test -x "./gradlew" && echo "./gradlew" || echo "gradle") +gradle=$(test -x "./gradlew"; expr gradle \& $? \| ./gradlew) -( exit $code ); while test $? -eq $code; do $gradle ${prefix}clean$(echo $task | sed -e 's/^./\U&/') ${prefix}$task "${@:3}"; done +( exit $code ) +while test $? -eq $code +do $gradle ${prefix}clean$(echo $task | sed -e 's/^./\U&/') ${prefix}$task "${@:3}" +done diff --git a/.local/bin/scripts/st b/.local/bin/scripts/st index 6dc843f..c19c649 100755 --- a/.local/bin/scripts/st +++ b/.local/bin/scripts/st @@ -5,15 +5,15 @@ if test -f "$subscript" then shift && $subscript "$@" else apikey=$(grep apikey $XDG_CONFIG_HOME/syncthing/config.xml | cut -d '>' -f2 | cut -d '<' -f1) - parseargs() { - echo hi - } case "$1" in (browse|completion|file|ignores|need|status) for arg in "${@:2}" do case "$arg" in ([0-9]) depth=$arg;; (*) path="$arg";; esac done - query="db/$1?folder=$(test -n "$path" && echo "${path%%/*}" || echo "data")&levels=${depth:-1}$(case "$path" in (*/*) echo "&prefix=${path#*/}";; esac)";; + query=$(echo "db/$1?folder=$(expr "${path%%/*}" \& "$path" \| data) + $(expr levels \& "$1" = "browse" \| page)=${depth:-1} + $(case "$path" in (*/*) echo "$(expr "prefix" \& "$1" = "browse" \| "$1")=${path#*/}";; esac)" | + tr -d ' ' | paste -s -d'&');; (*) query="$1";; esac shift diff --git a/.local/bin/scripts/st-diff b/.local/bin/scripts/st-diff index 2c8ad10..ee02542 100755 --- a/.local/bin/scripts/st-diff +++ b/.local/bin/scripts/st-diff @@ -21,6 +21,6 @@ if test "$#" -gt 0 esac fi else - find "$DATA/2-standards/notes/journal" -name "intentions.sync-conflict*" -exec jrnl intentions --import --file {} \; -delete + find "$DATA/2-standards/notes/journal" -name "intentions*sync-conflict*" -exec sh -c 'basename {} | cut -d. -f1 | xargs -i% jrnl % --import --file {}' \; -delete find -name '*sync-conflict*' -exec st-diff $quick '{}' \; fi diff --git a/.local/bin/scripts/susrave b/.local/bin/scripts/susrave index c2e9814..81a5230 100755 --- a/.local/bin/scripts/susrave +++ b/.local/bin/scripts/susrave @@ -1,40 +1,39 @@ #!/bin/sh - -# Sets Workrave mode to quiet and waits the given amount of minutes (default: 10) +# Set Workrave mode to quiet and wait the given amount of minutes (default: 10) # If no amount is given or the -f flag is provided, it checks whether a fullscreen application is running and if no, exits -# On exit or Ctrl-C (SIGINT) it sets the Workrave mode back to normal +# On exit or Ctrl-C (SIGINT) set Workrave mode back to normal while true; do - case $1 in - (-q) quiet=1; shift 1;; - (-f) fullscreen=1; shift 1;; - (*) break;; - esac + case $1 in + (-q) quiet=1; shift 1;; + (-f) fullscreen=1; shift 1;; + (*) break;; + esac done getFullscreen() { - # See https://askubuntu.com/a/1265587 - # Get screen size - root_geo=$(xwininfo -root | awk -F'[ +x]' '$3 ~ /-geometry/ {printf "%dx%d",$4/'"$(xrandr | grep ' connected ' | wc -l)"',$5}') - # Check if any window fills the screen - xwininfo -root -tree | grep $root_geo | grep -qv "\(Desktop\|has no name\)" + # See https://askubuntu.com/a/1265587 + # Get screen size + root_geo=$(xwininfo -root | awk -F'[ +x]' '$3 ~ /-geometry/ {printf "%dx%d",$4/'"$(xrandr | grep ' connected ' | wc -l)"',$5}') + # Check if any window fills the screen + xwininfo -root -tree | grep $root_geo | grep -qv "\(Desktop\|has no name\)" } setWorkraveOperationMode() { - dbus-send --session --dest=org.workrave.Workrave --type=method_call \ + dbus-send --session --dest=org.workrave.Workrave --type=method_call \ /org/workrave/Workrave/Core org.workrave.CoreInterface.SetOperationMode \ string:"$1" } resetWorkraveMode() { - test "$quiet" || echo "Setting Workrave operation mode to normal" - setWorkraveOperationMode "normal" + test "$quiet" || echo "Setting Workrave operation mode to normal" + setWorkraveOperationMode "normal" } trap resetWorkraveMode EXIT INT test "$quiet" || echo "Silencing workrave" setWorkraveOperationMode "quiet" while true; do - sleep ${1:-10}m - test "$fullscreen" && getFullscreen || break + sleep ${1:-10}m + test "$fullscreen" && getFullscreen || break done diff --git a/.local/bin/scripts/update-keyboard-layout b/.local/bin/scripts/update-keyboard-layout index 4136391..ecbdb36 100755 --- a/.local/bin/scripts/update-keyboard-layout +++ b/.local/bin/scripts/update-keyboard-layout @@ -4,7 +4,7 @@ umask 0 case $ACTION in (add) id=1;; (remove) id=0;; - (*) id=$(test -c /dev/ttyACM0 && echo 1 || echo 0);; + (*) id=$(! test -c /dev/ttyACM0; echo $?);; esac echo "Keyboard layout update to $id($ACTION) at $(date)" export XAUTHORITY="/run/user/1000/Xauthority" DISPLAY=:0