GithubHelp home page GithubHelp logo

Comments (2)

QiangF avatar QiangF commented on July 20, 2024

run-or-raise.sh

#!/bin/bash -e
# this script requires:
#
#   - A running herbstluftwm instance
#   - herbstclient
#   - xdotool
# todo: support two pairs of properties

prog="$0"
usage() {
    echo "Usage: $prog PROPERTY VALUE [CMD..]"
    echo ""
    echo "This tries to a window whose PROPERTY equals VALUE."
    echo "If such a window is found, it is focused using »herbstclient jumpto«."
    echo "If not, the given programe CMD is executed."
    echo ""
    echo "PROPERTY is one of:"
    echo "  class (the second entry of WM_CLASS)"
    echo "  classname (the first entry of WM_CLASS)"
    echo "  name (the window title)"
    echo ""
    echo "Example: $prog class Firefox firefox"
}

insufficient_arguments() {
    echo "Insufficiently many arugments." >&2
    usage >&2
    exit 1
}

property="$1" ; shift || insufficient_arguments
value="$1" ; shift || insufficient_arguments
focused_winid=$(herbstclient get_attr clients.focus.winid)
if winid=$(xdotool search  --all --maxdepth 2 "--$property" "$value") ; then
    for i in $winid ; do
        target_winid=$(printf "0x%x\n" "$i")
        if [[ $target_winid == $focused_winid ]] ; then
            herbstclient substitute LASTWIN my_lastwin jumpto LASTWIN
            # herbstclient set_attr clients.focus.minimized true
        else
            herbstclient silent jumpto $target_winid && break
        fi
    done
else
    if [ -n "$*" ] ; then
        # only
        "$@" &
    fi
fi

from herbstluftwm.

QiangF avatar QiangF commented on July 20, 2024

I have an Emacs window with window name "editor". The command below will find the window on all tags:

xdotool search  --all --class Emacs

The command below won't find window if it on another tag:

xdotool search  --all --name editor

from herbstluftwm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.