diff options
author | Giuseppe | 2017-06-13 20:43:17 +0200 |
---|---|---|
committer | Giuseppe | 2017-06-13 20:44:05 +0200 |
commit | 300a0b207bf74c962c5ad948d101d16539d1ee51 (patch) | |
tree | e5f28d73e353e1e629c18a28b48eb620c0b0cefc | |
parent | bc246dc1865a1516b34cc666ac445963014ff186 (diff) | |
download | aur-300a0b207bf74c962c5ad948d101d16539d1ee51.tar.gz |
Make preexec.sh return if i3 is not running.
Fix some problems that aa92ef2 had.
-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) |