diff options
author | Urbain Vaes <urbain@vaes.uk> | 2018-02-02 11:02:57 +0000 |
---|---|---|
committer | Urbain Vaes <urbain@vaes.uk> | 2018-02-21 15:34:26 +0000 |
commit | 4c57cf4c778a3327df584245fee0e727aa021be9 (patch) | |
tree | 6c1190b26b3dce07e16a7e4d8d6fada26b1c7bd2 | |
parent | 52c3b26195508150a3ffaed0ba8c493f5999a519 (diff) |
[qutebrowser] Handle empty input in user-password script
-rwxr-xr-x | bin/bin/workspace | 16 | ||||
-rwxr-xr-x | qutebrowser/.local/share/qutebrowser/userscripts/user-password | 16 |
2 files changed, 18 insertions, 14 deletions
diff --git a/bin/bin/workspace b/bin/bin/workspace index b42cc56..7f94ff1 100755 --- a/bin/bin/workspace +++ b/bin/bin/workspace @@ -18,16 +18,20 @@ act_on_container() { # Exit if empty [[ -z $target ]] && exit - # If new workspace has to be created - if [[ ! $target = [0-9]* ]]; then + # See if target exsits + existing_target=$(echo "$workspaces" | awk '{print $2}' | grep -F "$target") + # If new workspace has to be created + if [[ -n "$existing_target" ]]; then + target="$existing_target" + else # Add number to workspace name (start at 1, but allow 0) new_number=$(echo "$workspaces" | awk '$1!=p+1 && $1!=0 {exit;}{p=$1} END {print p+1}') target=$new_number:$target fi # Execute command - exec i3-msg $1 $target + exec i3-msg "$1" "$target" } act_on_workspace() { @@ -39,7 +43,7 @@ act_on_workspace() { next=$(echo "${workspaces}" | awk '$1 ~ /'$new_number'/ {print $2}') - i3-msg rename workspace to ${new_number}:${focused_name} + i3-msg rename workspace to "${new_number}":"${focused_name}" # ${variable//pattern} replaces all matches of pattern with nothing if [[ ! -z "${next// }" ]]; then @@ -51,6 +55,6 @@ act_on_workspace() { } # Command to use -[[ $1 = 'gw' ]] && act_on_container "workspace" $2 -[[ $1 = 'mc' ]] && act_on_container "move container to workspace" $2 +[[ $1 = 'gw' ]] && act_on_container "workspace" "$2" +[[ $1 = 'mc' ]] && act_on_container "move container to workspace" "$2" [[ $1 = 'mw' ]] && act_on_workspace "$2" diff --git a/qutebrowser/.local/share/qutebrowser/userscripts/user-password b/qutebrowser/.local/share/qutebrowser/userscripts/user-password index c2db041..a571220 100755 --- a/qutebrowser/.local/share/qutebrowser/userscripts/user-password +++ b/qutebrowser/.local/share/qutebrowser/userscripts/user-password @@ -1,10 +1,10 @@ #!/usr/bin/env bash -target=$(find $HOME/.password-store/ -name "*.gpg" -printf "%P\n" | dmenu -i -p "Get identifier for:") -username=$(basename $target .gpg | sed 's/\\/\\\\/g; s/"/\\"/g') -password=$(pass show ${target%.gpg} | sed 's/\\/\\\\/g; s/"/\\"/g') -echo "fake-key '<Esc>'" >> $QUTE_FIFO -echo "fake-key \"$username\"" >> $QUTE_FIFO -echo "fake-key '<Tab>'" >> $QUTE_FIFO -echo "fake-key \"$password\"" >> $QUTE_FIFO -echo "fake-key \"$password\"" > ~/.test +target=$(find "$HOME"/.password-store/ -name "*.gpg" -printf "%P\\n" | dmenu -i -p "Get identifier for:") +[[ -z "$target" ]] && exit +username=$(basename "$target" .gpg | sed 's/\\/\\\\/g; s/"/\\"/g') +password=$(pass show "${target%.gpg}" | sed 's/\\/\\\\/g; s/"/\\"/g') +{ echo "fake-key '<Esc>'"; + echo "fake-key \"$username\""; + echo "fake-key '<Tab>'"; + echo "fake-key \"$password\""; } >> "$QUTE_FIFO" |