dot

packages and services management
Log | Files | Refs | README

commit 4279dbc3735e1e38bf33120c9234640d99fee650
parent 16934cefa503b2c1ae6307695b25beae0b89c7d9
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sat, 22 Jul 2017 13:05:20 +0200

status: simpler format.  ./bin/: removed pointless scripts

Diffstat:
Dbin/daemon | 0
Dbin/dofiles | 4----
Dbin/man-raw | 5-----
Mbin/status | 48++++++++++++++++++++++--------------------------
Rbin/name -> bin/term-name | 0
Dbin/vmstatus | 15---------------
Dbin/www-tree | 99-------------------------------------------------------------------------------
Rbin/www-tree.1 -> bin/www.1 | 0
8 files changed, 22 insertions(+), 149 deletions(-)

diff --git a/bin/daemon b/bin/daemon diff --git a/bin/dofiles b/bin/dofiles @@ -1,4 +0,0 @@ -path=$1 name=$2 -shift 2 - -find "$path" -name "$name" -exec "$@" {} + diff --git a/bin/man-raw b/bin/man-raw @@ -1,5 +0,0 @@ -# open a man page in sam(1) - -tmp="$(mktemp)" - -man "$@" | sed 's/.//g' diff --git a/bin/status b/bin/status @@ -6,11 +6,9 @@ START=' ' STOP=' ' -# # Maildir format, just file count in "$MAIL/new" -# -status_mail() -{ + +mail=$( if [ -d "$MAIL/new" ] then mail="$(find "$MAIL/new" -type f | wc -l | tr -d '\t ')" @@ -19,19 +17,17 @@ status_mail() printf %s "$mail" fi -} +) -status_date() -{ +date=$( date +'%Z %m/%d %H:%M' -} +) # from neofetch(1) -status_memory() -{ +memory=$( case "$(uname -s)" in (Linux) while IFS=': ' read -r key value unit @@ -60,11 +56,10 @@ status_memory() esac printf 'MEM %s/%sM' "$((used))" "$((total))" -} +) -status_cpu() -{ +cpu=$( printf 'CPU ' vmstat 1 2 | awk ' @@ -83,31 +78,32 @@ status_cpu() ' # load average - uptime | sed -r 's/.*load[^0-9]*([0-9.]*).*/ \1/' | tr -d '\n' -} + uptime | sed -r 's/.*[Ll]oad[^0-9]*([0-9.]*).*/ \1/' | tr -d '\n' +) -status_battery() -{ +battery=$( [ -f /sys/class/power_supply/*/capacity ] && printf 'BAT %d%%' "`cat /sys/class/power_supply/*/capacity`" -} +) + +disk=$( + : +) -main() + +status() { printf %s "$START" while [ "$#" -gt 0 ] do - segment="$(status_"$1")" - - printf %s "$segment" - [ "$segment" ] && [ $# -gt 1 ] && printf %s "$SEPARATOR" - + printf %s "$1" + [ "$1" ] && [ $# -gt 1 ] && printf %s "$SEPARATOR" shift done - printf '%s\n' "$STOP" + printf %s "$STOP" } -[ $# -gt 0 ] && main "$@" || main mail memory cpu battery date +status "$mail" "$memory" "$cpu" "$battery" "$disk" "$date" diff --git a/bin/name b/bin/term-name diff --git a/bin/vmstatus b/bin/vmstatus @@ -1,15 +0,0 @@ -vmstat -w 1 | awk ' - -NR == 2 { - split($0, keys, " ") -} - -NR > 2 { - split($0, values, " ") - - for (i = length(values); i > 0; i--) - table[keys[i]] = values[i] - - print table["fre"] -}' - diff --git a/bin/www-tree b/bin/www-tree @@ -1,99 +0,0 @@ -# mostly plain text static website generator - - -LAYOUT="layout.html" -CONVERTER="${CONVERTER:-madown}" - - -#1 - name of item being parsed -#2 - input remaining to parse - -parse() -{ - # print the input up to the next keyword, and shift position in input - printf %s "${2%%{{*}" - - # check for remaining keywords - [ "${2##*{{*}" ] && return 0 - - # take the separator out of the keyword - set -- "$1" "${2#*{{}" - - # execute the keyword action and print its output - case "${2%%\}\}*}" in - - *content* ) : - [ -f "$1" ] && $CONVERTER < "$1" - ;; - - *list* ) - [ -z "${1##*/*}" ] && [ "${1##*/}" = 'index.md' ] && list "${1%/*}" - ;; - - *nav* ) - parse "$1" "$(nav)" - ;; - - *title* ) - printf %s "$1" | sed -r 's|^\.||; /^.+$/ s|^| > |; s|/| > |g' - ;; - - *root* ) - if [ "${1##*/*}" ] - then - printf '.' - else - printf %s "$1" | sed 's|[^/]||g; s|/|../|g; s|/$||' - fi - ;; - esac - - parse "$1" "${2#*\}\}}" -} - - -# HTML list of the current directory content. - -#1 - directroy to list - -list() -{ - printf '<ul>\n' - - ( - cd "$1" || exit 1 - find . -type d -mindepth 1 -maxdepth 1 ! -name 'index.*' | sort - find . -type f -mindepth 1 -maxdepth 1 ! -name 'index.*' \ - ! -name '*.md' | sort - ) | sed -r 's|./(.*)|<li><a href="\1">\1</a></li>|' - - printf '</ul>' -} - - -# HTML line of relative links to first level directory - -nav() -{ - find . -mindepth 1 -maxdepth 1 -type d ! -path '*/.*' | sort | - sed -r 's|..(.*)| <a href="{{ root }}/\1/">\1</a>|' -} - - -main() -{ - if [ ! -f layout.html ] - then - printf '%s: no "%s" file in "%s"\n' "${0##*/}" "$LAYOUT" "$PWD" - exit 1 - fi - - # create index.html pages for each non-dotfile directory - find . -name '*.md' -type f | sed 's|\./||' | while IFS='' read -r f - do - parse "$f" "$(cat "$LAYOUT")" > "${f%.md}.html" - done -} - - -main "$@" diff --git a/bin/www-tree.1 b/bin/www.1