~palb91/bwm

727680a68f14dad443d3cd0f0c27c7a5a8f5bbb2 — Pierre-Albéric TROUPLIN 1 year, 3 months ago 1308fd1
feat: add Xwayland support (with xdotool)
1 files changed, 15 insertions(+), 0 deletions(-)

M bwm
M bwm => bwm +15 -0
@@ 59,6 59,11 @@ menu() {
        | sed 's/ .*// ; q'
}

use_Xwayland() {
    query='recurse(.nodes[]?, .floating_nodes[]?) | select(.focused).shell'
    [[ "$(swaymsg -t get_tree | jq -r "${query}")" = 'xwayland' ]]
}


# Parse arguments, check dependancies
parse_args() {


@@ 84,6 89,10 @@ parse_args() {
    [[ "${cmd}" = 'wl-copy' ]] && [[ "${asset}" = 'both' ]] \
        && die 'Cannot copy both username and password.'

    # Use xdotool for Xwayland windows
    [[ "${cmd}" = 'wtype' ]] && use_Xwayland \
        && cmd=xdotool

    check_dep "${cmd}"
}



@@ 155,6 164,12 @@ type_or_copy() {

        # Add a short delay before typing
        set -- -s 150 "${@}"

    elif [[ "${cmd}" = 'xdotool' ]]; then
        [[ "${asset}" = 'both' ]] \
            && set -- "${credentials[user]}"$'\t'"${credentials[pass]}"

        set -- sleep 0.15 type "${@}"
    fi

    exec "${cmd}" "${@}"