Skip to content

Commit

Permalink
Merge pull request #28 from budlabs/dev
Browse files Browse the repository at this point in the history
prelle i3get update, adding get visible and focus visible
  • Loading branch information
budRich authored Sep 12, 2018
2 parents 3ef483b + 76e6250 commit 5d73ca0
Show file tree
Hide file tree
Showing 11 changed files with 768 additions and 203 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# i3ass - i3 assistance scripts

This is a collection of scripts I have made to
Expand All @@ -17,7 +16,7 @@ Or follow the instructions below to install from github:
[![](https://budrich.github.io/img/awd/assinstafina.gif)](https://budrich.github.io/img/org/assinstafina.gif)

**clone the repository**
`git clone https://github.com/budRich/i3ass.git`
`git clone https://github.com/budlabs/i3ass.git`

**run the installation script**
*(for further instructions: `./install.sh -h`)*
Expand All @@ -36,8 +35,6 @@ Execute a script with the `-h` flag to display help about the command. There are
`i3get -h` display [i3get] help
`i3get -v` display [i3get] version

*I have some more or less useful example scripts using **i3ass** in the [i3add] repository.*


|**file** | **function** |
|:--------|:--------------------------|
Expand All @@ -50,12 +47,25 @@ Execute a script with the `-h` flag to display help about the command. There are
[i3viswiz]|Focus switching and visible-window-info
[i3var] |Set or get a i3 variable
[i3Kornhe]|move and resize windows gracefully
[focusvisible]|Focus a visible window
[getvisible]|Print the id of a visible window
[install.sh]|Installation script
[Makefile]| -


## updates

### 2018.09.12.0

Added [focusvisible] and [getvisible].
[i3get] now allows multiple search criterion and longoptions:

```shell
i3get --class Thunar --instance thunar --ret wtf
```

The command above will print **w**orkspace, **t**itle and **f**loatstate of the first found window that have **both** the class *Thunar* and instance *thunar*.

### v.0.1.77

cleaned up [i3flip] code and added ability to flip in layouts other then tabbed|stacked.
Expand Down Expand Up @@ -128,6 +138,8 @@ More directions then p,n,prev,next are now allowed. up, left, prev, u, l, p all

All **i3ass** scripts are licensed with the **MIT license**

[focusvisible]: https://github.com/budRich/i3ass/tree/master/focusvisible
[getvisible]: https://github.com/budRich/i3ass/tree/master/getvisible
[i3flip]: https://github.com/budRich/i3ass/tree/master/i3flip
[i3fyra]: https://github.com/budRich/i3ass/tree/master/i3fyra
[i3get]: https://github.com/budRich/i3ass/tree/master/i3get
Expand Down
29 changes: 29 additions & 0 deletions focusvisible/README.md
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
48 changes: 48 additions & 0 deletions focusvisible/focusvisible.1
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
159 changes: 159 additions & 0 deletions focusvisible/focusvisible.sh
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 "${@}"




31 changes: 31 additions & 0 deletions getvisible/README.md
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
52 changes: 52 additions & 0 deletions getvisible/getvisible.1
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
Loading

0 comments on commit 5d73ca0

Please sign in to comment.