-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from budlabs/dev
prelle i3get update, adding get visible and focus visible
- Loading branch information
Showing
11 changed files
with
768 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# `focusvisible` - Focus a visible window matching a criterion | ||
|
||
SYNOPSIS | ||
-------- | ||
|
||
`SCRIPTNAME` `-v`|`--version` | ||
`SCRIPTNAME` `-h`|`--help` | ||
`SCRIPTNAME` `-c`|`--class` CLASS | ||
`SCRIPTNAME` `-i`|`--instance` INSTANCE | ||
|
||
OPTIONS | ||
------- | ||
|
||
`-v`|`--version` | ||
Show version and exit. | ||
|
||
`-h`|`--help` | ||
Show help and exit. | ||
|
||
`-c`|`--class` CLASS | ||
Focus a visible window with a matching CLASS. | ||
|
||
`-i`|`--instance` INSTANCE | ||
Focus a visible window with a matching INSTANCE. | ||
|
||
DEPENDENCIES | ||
------------ | ||
|
||
getvisible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
.TH FOCUSVISIBLE 1 2018\-06\-06 Linux "User Manuals" | ||
.SH NAME | ||
.PP | ||
\fB\fCfocusvisible\fR \- Focus a visible window matching a criterion | ||
|
||
.SH SYNOPSIS | ||
.PP | ||
\fB\fCSCRIPTNAME\fR \fB\fC\-v\fR|\fB\fC\-\-version\fR | ||
.br | ||
\fB\fCSCRIPTNAME\fR \fB\fC\-h\fR|\fB\fC\-\-help\fR | ||
.br | ||
\fB\fCSCRIPTNAME\fR \fB\fC\-c\fR|\fB\fC\-\-class\fR CLASS | ||
.br | ||
\fB\fCSCRIPTNAME\fR \fB\fC\-i\fR|\fB\fC\-\-instance\fR INSTANCE | ||
|
||
.SH OPTIONS | ||
.PP | ||
\fB\fC\-v\fR|\fB\fC\-\-version\fR | ||
.br | ||
Show version and exit. | ||
|
||
.PP | ||
\fB\fC\-h\fR|\fB\fC\-\-help\fR | ||
.br | ||
Show help and exit. | ||
|
||
.PP | ||
\fB\fC\-c\fR|\fB\fC\-\-class\fR CLASS | ||
Focus a visible window with a matching CLASS. | ||
|
||
.PP | ||
\fB\fC\-i\fR|\fB\fC\-\-instance\fR INSTANCE | ||
Focus a visible window with a matching INSTANCE. | ||
|
||
.SH DEPENDENCIES | ||
.PP | ||
getvisible | ||
|
||
.SH AUTHOR | ||
.PP | ||
budRich | ||
\[la][email protected]\[ra] | ||
|
||
\[la]https://budrich.github.io\[ra] | ||
|
||
.SH SEE ALSO | ||
.PP | ||
i3viswiz(1), getvisible |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
#!/usr/bin/env bash | ||
|
||
__name="focusvisible" | ||
__version="0.003" | ||
__author="budRich" | ||
__contact='[email protected]' | ||
__created="2018-06-06" | ||
__updated="2018-09-03" | ||
|
||
main(){ | ||
|
||
eval set -- "$(getopt --name "$__name" \ | ||
--options vh::c:i: \ | ||
--longoptions version,help::,class:,instance: \ | ||
-- "$@" | ||
)" | ||
|
||
while true; do | ||
[[ $1 = -- ]] && option="$1" || { | ||
option="${1##--}" | ||
option="${option##-}" | ||
} | ||
|
||
case "$option" in | ||
|
||
i|c|instance|class ) | ||
target=${option,,} target=${target:0:1} | ||
arg="${2:-}" | ||
shift 2 | ||
;; | ||
|
||
v|version ) printinfo version ; exit ;; | ||
h|help ) printinfo "${2:-}" ; exit ;; | ||
-- ) shift ; break ;; | ||
* ) break ;; | ||
|
||
esac | ||
done | ||
|
||
{ [[ -z $target ]] || [[ -z $arg ]] ;} \ | ||
&& ERX "not valid $target $arg" | ||
|
||
conid=$(getvisible "-${target}" "$arg") | ||
|
||
[[ -z $conid ]] \ | ||
&& ERX "$arg window not visible" | ||
|
||
i3-msg -q "[con_id=$conid]" focus | ||
|
||
} | ||
|
||
printinfo(){ | ||
about=\ | ||
'`focusvisible` - Focus a visible window matching a criterion | ||
SYNOPSIS | ||
-------- | ||
`SCRIPTNAME` `-v`|`--version` | ||
`SCRIPTNAME` `-h`|`--help` | ||
`SCRIPTNAME` `-c`|`--class` CLASS | ||
`SCRIPTNAME` `-i`|`--instance` INSTANCE | ||
OPTIONS | ||
------- | ||
`-v`|`--version` | ||
Show version and exit. | ||
`-h`|`--help` | ||
Show help and exit. | ||
`-c`|`--class` CLASS | ||
Focus a visible window with a matching CLASS. | ||
`-i`|`--instance` INSTANCE | ||
Focus a visible window with a matching INSTANCE. | ||
DEPENDENCIES | ||
------------ | ||
getvisible | ||
' | ||
|
||
bouthead=" | ||
${__name^^} 1 ${__created} Linux \"User Manuals\" | ||
======================================= | ||
NAME | ||
---- | ||
" | ||
|
||
boutfoot=" | ||
AUTHOR | ||
------ | ||
${__author} <${__contact}> | ||
<https://budrich.github.io> | ||
SEE ALSO | ||
-------- | ||
i3viswiz(1), getvisible | ||
" | ||
|
||
|
||
case "$1" in | ||
# print version info to stdout | ||
version ) | ||
printf '%s\n' \ | ||
"$__name - version: $__version" \ | ||
"updated: $__updated by $__author" | ||
exit | ||
;; | ||
# print help in markdown format to stdout | ||
md ) printf '%s' "# ${about}" ;; | ||
|
||
# print help in markdown format to README.md | ||
mdg ) printf '%s' "# ${about}" > "${__dir}/README.md" ;; | ||
|
||
# print help in troff format to __dir/__name.1 | ||
man ) | ||
printf '%s' "${bouthead}" "${about}" "${boutfoot}" \ | ||
| go-md2man > "${__dir}/${__name}.1" | ||
;; | ||
|
||
# print help to stdout | ||
* ) | ||
printf '%s' "${about}" | awk ' | ||
BEGIN{ind=0} | ||
$0~/^```/{ | ||
if(ind!="1"){ind="1"} | ||
else{ind="0"} | ||
print "" | ||
} | ||
$0!~/^```/{ | ||
gsub("[`*]","",$0) | ||
if(ind=="1"){$0=" " $0} | ||
print $0 | ||
} | ||
' | ||
;; | ||
esac | ||
} | ||
|
||
ERR(){ >&2 echo "[WARNING]" "$*"; } | ||
ERX(){ >&2 echo "[ERROR]" "$*" && exit 1 ; } | ||
|
||
init(){ | ||
__source="$(readlink -f "${BASH_SOURCE[0]}")" | ||
__dir="$(cd "$(dirname "${__source}")" && pwd)" | ||
} | ||
|
||
init | ||
main "${@}" | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# `getvisible` - Print the **con_id** of a visible window matching a criterion | ||
|
||
SYNOPSIS | ||
-------- | ||
|
||
`SCRIPTNAME` `-v`|`--version` | ||
`SCRIPTNAME` `-h`|`--help` | ||
`SCRIPTNAME` `-c`|`--class` CLASS | ||
`SCRIPTNAME` `-i`|`--instance` INSTANCE | ||
|
||
OPTIONS | ||
------- | ||
|
||
`-v`|`--version` | ||
Show version and exit. | ||
|
||
`-h`|`--help` | ||
Show help and exit. | ||
|
||
`-c`|`--class` CLASS | ||
Print the **con_id** of a a visible window with a | ||
matching CLASS. | ||
|
||
`-i`|`--instance` INSTANCE | ||
Print the **con_id** of a a visible window with a | ||
matching INSTANCE. | ||
|
||
DEPENDENCIES | ||
------------ | ||
|
||
i3viswiz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.TH GETVISIBLE 1 2018\-06\-06 Linux "User Manuals" | ||
.SH NAME | ||
.PP | ||
\fB\fCgetvisible\fR \- Print the \fBcon\_id\fP of a visible window matching a criterion | ||
|
||
.SH SYNOPSIS | ||
.PP | ||
\fB\fCSCRIPTNAME\fR \fB\fC\-v\fR|\fB\fC\-\-version\fR | ||
.br | ||
\fB\fCSCRIPTNAME\fR \fB\fC\-h\fR|\fB\fC\-\-help\fR | ||
.br | ||
\fB\fCSCRIPTNAME\fR \fB\fC\-c\fR|\fB\fC\-\-class\fR CLASS | ||
.br | ||
\fB\fCSCRIPTNAME\fR \fB\fC\-i\fR|\fB\fC\-\-instance\fR INSTANCE | ||
|
||
.SH OPTIONS | ||
.PP | ||
\fB\fC\-v\fR|\fB\fC\-\-version\fR | ||
.br | ||
Show version and exit. | ||
|
||
.PP | ||
\fB\fC\-h\fR|\fB\fC\-\-help\fR | ||
.br | ||
Show help and exit. | ||
|
||
.PP | ||
\fB\fC\-c\fR|\fB\fC\-\-class\fR CLASS | ||
.br | ||
Print the \fBcon\_id\fP of a a visible window with a | ||
matching CLASS. | ||
|
||
.PP | ||
\fB\fC\-i\fR|\fB\fC\-\-instance\fR INSTANCE | ||
.br | ||
Print the \fBcon\_id\fP of a a visible window with a | ||
matching INSTANCE. | ||
|
||
.SH DEPENDENCIES | ||
.PP | ||
i3viswiz | ||
|
||
.SH AUTHOR | ||
.PP | ||
budRich | ||
\[la][email protected]\[ra] | ||
|
||
\[la]https://budrich.github.io\[ra] | ||
|
||
.SH SEE ALSO | ||
.PP | ||
i3viswiz(1), focusvisible |
Oops, something went wrong.