: case-sensitive; may contain regex
-#
-# Options:
-# -c check if a window is open by class instead of by name (case-sensitive;
-# class can be specified using the full qualified class string [i.e.
-# class and classname; e.g. "xterm.XTerm"]; does not allow regex)
-#
-# Exit codes:
-# 0: window is open
-# 1: window is not open
-# 2: no arguments error
-#
-
-if [ "$#" -eq 0 ]; then
- exit 2
-fi
-
-while getopts :c OPT; do
- case "${OPT}" in
- c) OPT_CLASS=true;;
- esac
-done
-shift $((OPTIND - 1))
-
-getWindIdsInClass() {
- echo "$(wmctrl -lx | awk -v class="${1}" '$3 ~ class {print $1}')"
-}
-
-if [ "${OPT_CLASS}" = 'true' ]; then
- if [ -n "$(getWindIdsInClass "${1}")" ]; then
- isWindOpen=true
- fi
-else
- while IFS= read wind; do
- if echo "${wind}" | grep -q "${1}"; then
- isWindOpen=true
- fi
- done < <(wmctrl -l | awk '{$1=$2=$3=""; print $0}' | sed 's/^[ \t]*//')
-fi
-
-if [ "${isWindOpen}" = 'true' ]; then
- exit 0
-fi
-
-exit 1
-
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy