From 972508e74de6e41fd2633b1405c032935f8d9a3c Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 12 Dec 2019 11:02:24 -0600 Subject: [PATCH 1/5] WIP pipeline --- apps/neovim/settings.vim | 2 +- bin/fsw | 18 +++++++++++-- bin/pipeline | 55 ++++++++++++++++++++++++++++++++++++++++ bin/upload | 2 ++ readme.md | 1 + setup | 1 + shell/bash/aliases | 3 ++- shell/bash/bashrc | 4 +-- 8 files changed, 80 insertions(+), 6 deletions(-) create mode 100755 bin/pipeline diff --git a/apps/neovim/settings.vim b/apps/neovim/settings.vim index 349d8a7..88eb70a 100644 --- a/apps/neovim/settings.vim +++ b/apps/neovim/settings.vim @@ -105,7 +105,7 @@ highlight GitGutterChangeDelete ctermbg=black guibg=black hi NonText ctermfg=black guifg=black set hidden " allows buffer switching without saving -set shortmess=Ia " hide vim intro, skip lots of file messages/prompts +set shortmess+=Ia " hide vim intro, skip lots of file messages/prompts set history=1000 " undo files diff --git a/bin/fsw b/bin/fsw index 57a35a5..08331cd 100755 --- a/bin/fsw +++ b/bin/fsw @@ -40,21 +40,32 @@ ${I}${I}${I}'.*' /etc/secrets \$HOME/.secrets USAGE } +dbg() { + if [[ ! -z ${FSW_DEBUG+x} ]]; then + echo -e "[debug] fsw: $@" + fi +} + if [[ $1 = '-h' ]] || [[ $1 = '--help' ]] || [[ -z $1 ]]; then help exit 0 fi FSW_EVENTS="${FSW_EVENTS:-close_write}" +dbg "Events: $FSW_EVENTS" SHELL_COMMAND="${1}"; shift +dbg "Command: $SHELL_COMMAND" FILTER="${1}"; shift +dbg "Filter: $FILTER" +dbg "Directory: ${1}" DIRS=("${1:-.}"); shift if [[ -e $FILTER ]]; then # TODO: this is a sad hack/workaround echo "It looks like your filter is an actual file. I'll just watch that for you." DIRS=("${FILTER}") fi -while [[ ! -z $1 ]]; do +while [[ ! -z $1 ]] && $(realpath $1) &> /dev/null; do + dbg "Directory: ${1}" DIRS+=("$1"); shift done inotifywait -m -e "${FSW_EVENTS}" -r "${DIRS[@]}" 2>&1 \ @@ -62,12 +73,15 @@ inotifywait -m -e "${FSW_EVENTS}" -r "${DIRS[@]}" 2>&1 \ | while read -r dir events filename; do if [[ "$dir $events" = "Watches established." ]]; then echo "Ready." + dbg "Directory: ${DIRS[@]}" else export FSW_FILENAME="$filename" export FSW_DIR="$dir" export FSW_PATH="$dir$filename" export FSW_FILE_EVENTS="$events" export FSW_EVENT="$events $dir$filename" - <<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}" + dbg "Event:\n $(date)\n $FSW_PATH\n $FILTER\n $FSW_EVENT\n $dir $events $filename\n ${SHELL_COMMAND}" + dbg "Filtered Event: $(<<< "$FSW_PATH" grep -P "$FILTER")" + <<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}" fi done diff --git a/bin/pipeline b/bin/pipeline new file mode 100755 index 0000000..b39ea47 --- /dev/null +++ b/bin/pipeline @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +SAVED_PIPELINE_DIR="$EDFP/pipelines" +mkdir -p "$SAVED_PIPELINE_DIR" + +if [[ ! -z "${1+x}" ]]; then + pdir="$SAVED_PIPELINE_DIR/$1"; shift + mkdir -p "$pdir" + if [[ -z ${1+x} ]]; then + td="$(mktemp -p "$pdir" -d "tmp_pipeline.XXXXXXXX")" + cleanup_trap="rm -rf \"$td\"" + else + td="$pdir/$1"; shift + mkdir -p "$td" + fi + transform="$pdir/transform" +else + td="$(mktemp --tmpdir -d pipeline.XXXXXXXX)" + transform="$td/transform" + cleanup_trap="rm -rf \"$td\"" +fi + +if [[ ! -e "$transform" ]]; then + echo -e "#!/usr/bin/env bash\n# for ${td}\n\nbase64" > "$transform" +fi + +in="$td/in" +out="$td/out" + +chmod +x "$transform" +echo "Hello World" > "$in" + +touch /tmp/ll.log +FSW_DEBUG=1 fswi \ + "bash -c '< \"$in\" \"$transform\" > \"$out\"'" \ + 'in$|transform$' \ + "$td" "$pdir" \ &> /tmp/ll.log & +watcher="$!" + +if [[ -z ${cleanup_trap+x} ]]; then + trap "kill \"$watcher\"" EXIT +else + trap "${cleanup_trap}; kill \"$watcher\"" EXIT +fi + +nvim \ + --cmd 'set shm+=atIWF' \ + --cmd 'set shm-=Oo' \ + -o "$in" "$transform" "$out" \ + --cmd 'set autoread' \ + --cmd 'set updatetime=250' \ + --cmd 'autocmd CursorHold,CursorHoldI silent write' + --cmd 'autocmd BufWrite * sleep 500m | checktime' + +# TODO: vim set autoread diff --git a/bin/upload b/bin/upload index 38936ac..18882c7 100755 --- a/bin/upload +++ b/bin/upload @@ -1,5 +1,7 @@ #!/usr/bin/env bash +# TODO: progress bar! + HOST="ld" f="${1}" diff --git a/readme.md b/readme.md index 479de71..67087df 100644 --- a/readme.md +++ b/readme.md @@ -78,6 +78,7 @@ Here are some bullet points on my workflow: * Makefile instead of setup script * [Vimux](https://github.com/benmills/vimux)? * Nerd Fonts with ligatures and icons for Kitty +* Setup network file sharing directory [upstream]: https://git.faceless.lytedev.io/lytedev/dotfiles diff --git a/setup b/setup index 1465e2a..8050fed 100755 --- a/setup +++ b/setup @@ -1,6 +1,7 @@ #!/usr/bin/env bash # TODO: ascii art header since I'm a leet haxx0r +# TODO: quiet mode? dfp=$(cd "$(dirname "${BASH_SOURCE[0]}" )/" && pwd) source "${dfp}/scripts/setup_helpers.bash" diff --git a/shell/bash/aliases b/shell/bash/aliases index e19c153..71eba07 100644 --- a/shell/bash/aliases +++ b/shell/bash/aliases @@ -108,7 +108,8 @@ alias sctlu="systemctl --user" alias logs="sudo journalctl" alias logsr="sudo journalctl -r" alias logsf="sudo journalctl -f" -alias btctl="sudo bluetoothctl" +alias bt="sudo bluetoothctl" +alias btctl="bt" alias pt="htop -t" # experimental htop tree-view-by-default alias resrc="source \$HOME/.bashrc" alias redshift="redshift -r -l 39.0997:-94.5786 -t 6500K:2500K" diff --git a/shell/bash/bashrc b/shell/bash/bashrc index 2543424..c1b595a 100644 --- a/shell/bash/bashrc +++ b/shell/bash/bashrc @@ -12,9 +12,9 @@ NICE_HOME="$HOME" # TODO: better logic for auto-detecting alternative home directories? # 1. check dirname(basename $HOME)) matches username # 2. check /home/$username -[[ $(basename "${HOME}") = "usr" ]] && NICE_HOME="$(realpath "$HOME/..")" [[ $(basename "${HOME}") = ".home" ]] && NICE_HOME="$(realpath "$HOME/..")" -# TODO: nice home explicitly definable on a per-device (env) basis +[[ -e "${HOME}/.nice_home" ]] && NICE_HOME="$(cat "${HOME}/.nice_home")" +[[ -e "${EDFP}/.nice_home" ]] && NICE_HOME="$(cat "${EDFP}/.nice_home")" export NICE_HOME export NOTES_DIR="$NICE_HOME/doc/notes" From 76594427ff4b991b4695847d2c3d0d110932c0c5 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 12 Dec 2019 13:00:03 -0600 Subject: [PATCH 2/5] Pipelines! --- bin/linewise | 10 ++++++++++ bin/pipeline | 23 ++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100755 bin/linewise diff --git a/bin/linewise b/bin/linewise new file mode 100755 index 0000000..50711ad --- /dev/null +++ b/bin/linewise @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +if [[ ! -z "${1+x}" ]]; then + while read r; do + <<< "${r}" "$1" + done +else + echo "No reader program provided." + exit 1 +fi diff --git a/bin/pipeline b/bin/pipeline index b39ea47..0f589f5 100755 --- a/bin/pipeline +++ b/bin/pipeline @@ -25,16 +25,21 @@ if [[ ! -e "$transform" ]]; then fi in="$td/in" +if [[ ! -z "${1+x}" ]]; then + in="${1}"; shift +fi out="$td/out" +if [[ ! -z "${1+x}" ]]; then + out="${1}"; shift +fi chmod +x "$transform" echo "Hello World" > "$in" -touch /tmp/ll.log -FSW_DEBUG=1 fswi \ +fswi \ "bash -c '< \"$in\" \"$transform\" > \"$out\"'" \ 'in$|transform$' \ - "$td" "$pdir" \ &> /tmp/ll.log & + "$td" "$pdir" &> /dev/null & watcher="$!" if [[ -z ${cleanup_trap+x} ]]; then @@ -43,13 +48,17 @@ else trap "${cleanup_trap}; kill \"$watcher\"" EXIT fi +job="call jobstart(['inotifywait', '-m', '-e', 'close_write', '${out}'], {'on_stdout':{j,d,e->execute('checktime')}})" +echo "$job" + +# this will only autosave (and therefore autoreload) for the out buffer (since +# it was opened last) - autosaving (and therefore autorunning) is potentially +# very scary nvim \ --cmd 'set shm+=atIWF' \ --cmd 'set shm-=Oo' \ -o "$in" "$transform" "$out" \ --cmd 'set autoread' \ --cmd 'set updatetime=250' \ - --cmd 'autocmd CursorHold,CursorHoldI silent write' - --cmd 'autocmd BufWrite * sleep 500m | checktime' - -# TODO: vim set autoread + --cmd 'autocmd CursorHold,CursorHoldI silent write' \ + --cmd "$(<<< "$job" tr "'" '"')" From b81bdf6abd767e4f071e78b8478c52eab4a75479 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 12 Dec 2019 13:17:20 -0600 Subject: [PATCH 3/5] errors break things? --- bin/fsw | 2 +- bin/linewise | 2 +- bin/pipeline | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/bin/fsw b/bin/fsw index 08331cd..fd40d37 100755 --- a/bin/fsw +++ b/bin/fsw @@ -82,6 +82,6 @@ inotifywait -m -e "${FSW_EVENTS}" -r "${DIRS[@]}" 2>&1 \ export FSW_EVENT="$events $dir$filename" dbg "Event:\n $(date)\n $FSW_PATH\n $FILTER\n $FSW_EVENT\n $dir $events $filename\n ${SHELL_COMMAND}" dbg "Filtered Event: $(<<< "$FSW_PATH" grep -P "$FILTER")" - <<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}" + <<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}" &> /dev/null fi done diff --git a/bin/linewise b/bin/linewise index 50711ad..2b337f7 100755 --- a/bin/linewise +++ b/bin/linewise @@ -2,7 +2,7 @@ if [[ ! -z "${1+x}" ]]; then while read r; do - <<< "${r}" "$1" + <<< "${r}" "$@" done else echo "No reader program provided." diff --git a/bin/pipeline b/bin/pipeline index 0f589f5..1d53fd7 100755 --- a/bin/pipeline +++ b/bin/pipeline @@ -49,7 +49,6 @@ else fi job="call jobstart(['inotifywait', '-m', '-e', 'close_write', '${out}'], {'on_stdout':{j,d,e->execute('checktime')}})" -echo "$job" # this will only autosave (and therefore autoreload) for the out buffer (since # it was opened last) - autosaving (and therefore autorunning) is potentially From 8d1e86feb4ebccec06233f8ea1f67b75d63cf222 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Thu, 12 Dec 2019 13:31:18 -0600 Subject: [PATCH 4/5] Logging for pipelines? --- bin/fsw | 2 +- bin/pipeline | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/fsw b/bin/fsw index fd40d37..08331cd 100755 --- a/bin/fsw +++ b/bin/fsw @@ -82,6 +82,6 @@ inotifywait -m -e "${FSW_EVENTS}" -r "${DIRS[@]}" 2>&1 \ export FSW_EVENT="$events $dir$filename" dbg "Event:\n $(date)\n $FSW_PATH\n $FILTER\n $FSW_EVENT\n $dir $events $filename\n ${SHELL_COMMAND}" dbg "Filtered Event: $(<<< "$FSW_PATH" grep -P "$FILTER")" - <<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}" &> /dev/null + <<< "$FSW_PATH" grep -P "$FILTER" > /dev/null 2>&1 && eval "${SHELL_COMMAND}" fi done diff --git a/bin/pipeline b/bin/pipeline index 1d53fd7..fb42f12 100755 --- a/bin/pipeline +++ b/bin/pipeline @@ -33,13 +33,17 @@ if [[ ! -z "${1+x}" ]]; then out="${1}"; shift fi +# TODO: if no logging, log="/dev/null" +log="$td/log" + chmod +x "$transform" echo "Hello World" > "$in" +touch "$log" fswi \ - "bash -c '< \"$in\" \"$transform\" > \"$out\"'" \ + "bash -c 'cd \"$td\" && < \"$in\" \"$transform\" | tee \"$out\"'" \ 'in$|transform$' \ - "$td" "$pdir" &> /dev/null & + "$td" "$pdir" &> "$log" & watcher="$!" if [[ -z ${cleanup_trap+x} ]]; then From 0d0e131714c756be933e158919908c19e0c35b2b Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 31 Dec 2019 14:26:44 -0600 Subject: [PATCH 5/5] Stuff --- apps/htop/rc | 27 --------------------------- de/bspwm/wmstart | 5 +---- de/libinput/touchpad.conf | 1 + 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/apps/htop/rc b/apps/htop/rc index 73e2ece..e69de29 100644 --- a/apps/htop/rc +++ b/apps/htop/rc @@ -1,27 +0,0 @@ -# Beware! This file is rewritten by htop when settings are changed in the interface. -# The parser is also very primitive, and not human-friendly. -fields=0 48 17 18 38 39 40 2 46 47 49 1 -sort_key=46 -sort_direction=1 -hide_threads=0 -hide_kernel_threads=1 -hide_userland_threads=1 -shadow_other_users=0 -show_thread_names=0 -show_program_path=0 -highlight_base_name=1 -highlight_megabytes=1 -highlight_threads=1 -tree_view=1 -header_margin=1 -detailed_cpu_time=0 -cpu_count_from_zero=0 -update_process_names=0 -account_guest_in_cpu_meter=0 -color_scheme=0 -delay=15 -left_meters=LeftCPUs2 Memory Swap -left_meter_modes=1 1 1 -right_meters=RightCPUs2 Tasks LoadAverage Uptime -right_meter_modes=1 2 2 2 -vim_mode=1 diff --git a/de/bspwm/wmstart b/de/bspwm/wmstart index 5d244e9..5f68f09 100755 --- a/de/bspwm/wmstart +++ b/de/bspwm/wmstart @@ -1,6 +1,3 @@ #!/usr/bin/env bash -# allows bspwm to reload when killed -while true; do - bspwm || break -done +bspwm diff --git a/de/libinput/touchpad.conf b/de/libinput/touchpad.conf index cc9c592..6c7b894 100644 --- a/de/libinput/touchpad.conf +++ b/de/libinput/touchpad.conf @@ -5,4 +5,5 @@ Section "InputClass" MatchIsTouchpad "on" Option "Tapping" "on" Option "NaturalScrolling" "true" + Option "DisableWhileTyping" "false" EndSection