diff options
Diffstat (limited to 'preexec.sh')
-rw-r--r-- | preexec.sh | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/preexec.sh b/preexec.sh index 769bda6f810f..c30fd992cdc4 100644 --- a/preexec.sh +++ b/preexec.sh @@ -2,11 +2,26 @@ __nwd_cmd= __nwd_previous_focused= __nwd_when_started= +__nwd_preexec() { + # Called before executing the command + + local no_i3 + no_i3=0 + [[ -z $DISPLAY || $(pgrep i3|wc -l) -eq 0 ]] && no_i3=1 + [[ $no_i3 -eq 1 || -z $__nwd_cmd ]] && return + + __nwd_cmd=$1 + __nwd_previous_focused=$(python3 /usr/share/nwd/focused_window.py) + __nwd_when_started=$(date +%s) +} + __nwd_precmd() { - local abort - abort=0 - [[ -z $DISPLAY || $(pgrep i3|wc -l) -eq 0 ]] && abort=1 - [[ $abort -eq 1 && -z $__nwd_cmd ]] && return + # Called before showing the next prompt + + local no_i3 + no_i3=0 + [[ -z $DISPLAY || $(pgrep i3|wc -l) -eq 0 ]] && no_i3=1 + [[ $no_i3 -eq 1 || -z $__nwd_cmd ]] && return local current_focused current_focused=$(python3 /usr/share/nwd/focused_window.py) @@ -21,16 +36,5 @@ __nwd_precmd() { __nwd_when_started= } -__nwd_preexec() { - local abort - abort=0 - [[ -z $DISPLAY || $(pgrep i3|wc -l) -eq 0 ]] && abort=1 - [[ $abort -eq 1 && -z $__nwd_cmd ]] && return - - __nwd_cmd=$1 - __nwd_previous_focused=$(python3 /usr/share/nwd/focused_window.py) - __nwd_when_started=$(date +%s) -} - [[ -z $(echo $preexec_functions|grep __nwd_preexec) ]] && preexec_functions+=(__nwd_preexec) [[ -z $(echo $precmd_functions|grep __nwd_precmd) ]] && precmd_functions+=(__nwd_precmd) |