From 29a86c9b34ee8cdb672344b59f676021248f31cc Mon Sep 17 00:00:00 2001 From: budRich Date: Wed, 12 Sep 2018 20:07:10 +0200 Subject: [PATCH 1/5] i3get: updated docs --- i3get/README.md | 32 +++-- i3get/i3get | 373 +++++++++++++++++++++++++++++++----------------- i3get/i3get.1 | 34 ++--- 3 files changed, 275 insertions(+), 164 deletions(-) diff --git a/i3get/README.md b/i3get/README.md index 05038f0..a24fdd3 100644 --- a/i3get/README.md +++ b/i3get/README.md @@ -9,48 +9,50 @@ SYNOPSIS DESCRIPTION ----------- -Search for `CRITERIA` in the output of `i3-msg -t get_tree`, -return desired information. If no arguments are passed. -`con_id` of acitve window is returned. +Search for `CRITERIA` in the output of `i3-msg -t +get_tree`, return desired information. If no +arguments are passed. `con_id` of acitve window +is returned. If there is more then one criterion, +all of them must be true to get results. OPTIONS ------- -`-v` +`-v`|`--version` Show version and exit -`-h` +`-h`|`--help` Show this help -`-a` +`-a`|`--active` Currently active window (default) -`-c` *CLASS* +`-c`|`--class` *CLASS* Search for windows with the given class -`-i` *INSTANCE* +`-i`|`--instance` *INSTANCE* Search for windows with the given instance -`-t` *TITLE* +`-t`|`--title` *TITLE* Search for windows with title. -`-n` *CON_ID* +`-n`|`--conid` *CON_ID* Search for windows with the given con_id -`-d` *CON_ID* +`-d`|`--winid` *CON_ID* Search for windows with the given window id -`-m` *CON_MARK* +`-m`|`--mark` *CON_MARK* Search for windows with the given mark -`-o` *TTL_FRMT* +`-o`|`--titleformat` *TTL_FRMT* Search for windows with the given titleformat -`-y` +`-y`|`--sync` Synch on. If this option is included, script will wait till target window exist. -`-r` [*OUTPUT*] +`-r`|`--ret` [*OUTPUT*] *OUTPUT* can be one or more of the following characters: diff --git a/i3get/i3get b/i3get/i3get index 24b7bf9..481c439 100755 --- a/i3get/i3get +++ b/i3get/i3get @@ -1,25 +1,156 @@ -#!/bin/sh +#!/bin/env bash -NAME="i3get" -VERSION="0.299" -AUTHOR="budRich" -CONTACT='robstenklippa@gmail.com' -CREATED="2017-03-08" -UPDATED="2018-06-30" +__name="i3get" +__version="0.3" +__author="budRich" +__contact='robstenklippa@gmail.com' +__created="2017-03-08" +__updated="2018-09-12" + +main(){ + local option optarg kol lopt sopt o synk + + synk=0 + + # default search for active window, return con_id + __sret=n + + declare -A __crit + declare -A options + + options[version]=v + options[help]=h:: + options[class]=c: + options[instance]=i: + options[title]=t: + options[conid]=n: + options[winid]=d: + options[ret]=r: + options[mark]=m: + options[titleformat]=o: + options[active]=a + options[sync]=y + + for o in "${!options[@]}"; do + [[ ${options[$o]} =~ ([:]*)$ ]] \ + && kol="${BASH_REMATCH[1]:-}" + lopt+="$o$kol," + sopt+="${options[$o]}" + done + + eval set -- "$(getopt --name "$__name" \ + --options "$sopt" \ + --longoptions "$lopt" \ + -- "$@" + )" + + while true; do + [[ $1 = -- ]] && option="$1" || { + option="${1##--}" + option="${option##-}" + optarg="${2:-}" + } + + case "$option" in + v | version ) printinfo version ; exit ;; + h | help ) printinfo "${optarg}" ; exit ;; + + i|instance) + __crit[instance]="${optarg}" && shift + ;; + + c|class) + __crit[class]="${optarg}" && shift + ;; + + t|title) + __crit[title]="${optarg}" && shift + ;; + + n|conid) + __crit[id]="${optarg}" && shift + ;; + + d|winid) + __crit[window]="${optarg}" && shift + ;; + + m|mark) + __crit[marks]="${optarg}" && shift + ;; + + o|titleformat) + __crit[title_format]="${optarg}" && shift + ;; + + a | active) __crit[focused]="true" ;; + r | ret ) __sret="${optarg}" && shift ;; + y | sync ) synk=1;; + + -- ) shift ; break ;; + * ) break ;; + + esac + shift + done + + # if no search is given, search for active window + [[ ${#__crit[@]} -eq 0 ]] && __crit[focused]=true + + result="$(getwindow)" + + ((synk==1)) && { + # timeout after 10 seconds + for ((i=0;i<100;i++)); do + sleep 0.1 + result=$(getwindow) + [ -n "$result" ] && break + done + } + + [ -n "$result" ] \ + && printf '%s\n' "${result}" \ + || ERX "no matching window." +} getwindow(){ - i3-msg -t get_tree \ - | awk -v RS=',' -F':' -v crit="${crit}" -v srch="${srch}" -v sret="${sret}" \ - 'BEGIN{hit="0"} + { + for c in "${!__crit[@]}"; do + echo -n "$c:${__crit[$c]}," + done + + echo -n "__START__," + + i3-msg -t get_tree + } | awk -v RS=',' -F':' -v sret="${__sret}" ' + BEGIN {hit=0;start=0;trg=0} + + # set crit array + start==0 && $0 !~ "__START__" && /./ { + crit[$1]=$2 + trg++ + } + + start==1 && hit!=trg { + for (c in crit) { + if ($(NF-1) ~ "\"" c "\"" && $NF ~ crit[c]) { + if (fid==cid) {hit++} + else {hit=1;fid=cid} + } + } + } + + # reset return array $1~"{\"id\"" || $2~"\"id\"" { cid=$NF + hit=0 for(k in r){if(k!="w"){r[k]=""}} if(sret ~ n) r["n"]=cid - if(hit==1){exit} + if(hit==trg){exit} } - $1 ~ crit && $2 ~ srch {hit=1;fid=cid} - $2 ~ crit && $3 ~ srch {hit=1;fid=cid} + + sret ~ t && $1=="\"title\"" {sub($1":","");r["t"]=$0} sret ~ c && $2 ~ "\"class\"" {r["c"]=$3} sret ~ i && $1=="\"instance\"" {r["i"]=$2} @@ -28,115 +159,26 @@ getwindow(){ sret ~ a && $1=="\"focused\"" {r["a"]=$2} sret ~ o && $1=="\"title_format\"" {r["o"]=$2} sret ~ w && $1=="\"num\"" {r["w"]=$2} - sret ~ f && $1=="\"floating\"" {r["f"]=$2;if(hit == "1")exit} + sret ~ f && $1=="\"floating\"" {r["f"]=$2;if (hit == trg)exit} + /__START__/ {start=1} + END{ - if(hit == "0") exit + if (hit==0) exit split(sret, aret, "") for (i=1; i <= length(sret); i++) { op=r[aret[i]] if(aret[i]!~/t|o/){gsub("[\"]","",op)} if(op!="") - printf("%s\n", op) + printf("%s\n", op) } } ' } -main(){ - synk=0 - sret=n - crit="\"focused\"" - srch=true - - while getopts :c:i:t:n:d:r:m:o:ayvh option - do - case "${option}" in - v) printf '%s\n' \ - "$NAME - version: $VERSION" \ - "updated: $UPDATED by $AUTHOR" - exit ;; - i) crit="\"instance\"" srch="${OPTARG}";; - c) crit="\"class\"" srch="${OPTARG}";; - t) crit="\"title\"" srch="${OPTARG}";; - n) crit="\"id\"" srch="${OPTARG}";; - d) crit="\"window\"" srch="${OPTARG}";; - m) crit="\"marks\"" srch="${OPTARG}";; - o) crit="\"title_format\"" srch="${OPTARG}";; - a) crit="\"focused\"" && srch="true";; - r) sret="${OPTARG}" ;; - y) synk=1;; - h|*) printinfo && exit ;; - esac - done - - result=$(getwindow) - - [ $synk = 1 ] && { - # timeout after 10 seconds - for ((i=0;i<100;i++)); do - sleep 0.1 - result=$(getwindow) - [ -n "$result" ] && break - done - } - - [ -n "$result" ] \ - && printf '%s\n' "${result}" \ - || exit 1 -} - printinfo(){ - case "$1" in - m ) printf '%s' "${about}" ;; - - f ) - printf '%s' "${bouthead}" - printf '%s' "${about}" - printf '%s' "${boutfoot}" - ;; - - ''|* ) - 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 -} - -bouthead=" -${NAME^^} 1 ${UPDATED} Linux \"User Manuals\" -======================================= - -NAME ----- -" - -boutfoot=" -AUTHOR ------- - -${AUTHOR} <${CONTACT}> - - -SEE ALSO --------- - -i3(1) -" - -about=' -`i3get` - Return information about i3wm. +about=\ +'`i3get` - Return information about i3wm. SYNOPSIS -------- @@ -147,48 +189,50 @@ SYNOPSIS DESCRIPTION ----------- -Search for `CRITERIA` in the output of `i3-msg -t get_tree`, -return desired information. If no arguments are passed. -`con_id` of acitve window is returned. +Search for `CRITERIA` in the output of `i3-msg -t +get_tree`, return desired information. If no +arguments are passed. `con_id` of acitve window +is returned. If there is more then one criterion, +all of them must be true to get results. OPTIONS ------- -`-v` +`-v`|`--version` Show version and exit -`-h` +`-h`|`--help` Show this help -`-a` +`-a`|`--active` Currently active window (default) -`-c` *CLASS* +`-c`|`--class` *CLASS* Search for windows with the given class -`-i` *INSTANCE* +`-i`|`--instance` *INSTANCE* Search for windows with the given instance -`-t` *TITLE* +`-t`|`--title` *TITLE* Search for windows with title. -`-n` *CON_ID* +`-n`|`--conid` *CON_ID* Search for windows with the given con_id -`-d` *CON_ID* +`-d`|`--winid` *CON_ID* Search for windows with the given window id -`-m` *CON_MARK* +`-m`|`--mark` *CON_MARK* Search for windows with the given mark -`-o` *TTL_FRMT* +`-o`|`--titleformat` *TTL_FRMT* Search for windows with the given titleformat -`-y` +`-y`|`--sync` Synch on. If this option is included, script will wait till target window exist. -`-r` [*OUTPUT*] +`-r`|`--ret` [*OUTPUT*] *OUTPUT* can be one or more of the following characters: @@ -225,16 +269,79 @@ DEPENDENCIES i3wm ' -if [ "$1" = "md" ]; then - printinfo m - exit -elif [ "$1" = "man" ]; then - printinfo f - exit -else - main "${@}" -fi +bouthead=" +${__name^^} 1 ${__created} Linux \"User Manuals\" +======================================= + +NAME +---- +" + +boutfoot=" +AUTHOR +------ + +${__author} <${__contact}> + + +SEE ALSO +-------- + +i3(1) +" + + 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(){ + set -o errexit + set -o pipefail + # set -o nounset + # set -o xtrace + __source="$(readlink -f "${BASH_SOURCE[0]}")" + __dir="$(cd "$(dirname "${__source}")" && pwd)" +} +init +eval __lastarg="\${$#}" +main "${@}" diff --git a/i3get/i3get.1 b/i3get/i3get.1 index 094a148..27730e4 100644 --- a/i3get/i3get.1 +++ b/i3get/i3get.1 @@ -1,4 +1,4 @@ -.TH I3GET 1 2018\-06\-30 Linux "User Manuals" +.TH I3GET 1 2017\-03\-08 Linux "User Manuals" .SH NAME .PP \fB\fCi3get\fR \- Return information about i3wm. @@ -11,70 +11,72 @@ .SH DESCRIPTION .PP -Search for \fB\fCCRITERIA\fR in the output of \fB\fCi3\-msg \-t get\_tree\fR, -return desired information. If no arguments are passed. -\fB\fCcon\_id\fR of acitve window is returned. +Search for \fB\fCCRITERIA\fR in the output of \fB\fCi3\-msg \-t +get\_tree\fR, return desired information. If no +arguments are passed. \fB\fCcon\_id\fR of acitve window +is returned. If there is more then one criterion, +all of them must be true to get results. .SH OPTIONS .PP -\fB\fC\-v\fR +\fB\fC\-v\fR|\fB\fC\-\-version\fR .br Show version and exit .PP -\fB\fC\-h\fR +\fB\fC\-h\fR|\fB\fC\-\-help\fR .br Show this help .PP -\fB\fC\-a\fR +\fB\fC\-a\fR|\fB\fC\-\-active\fR .br Currently active window (default) .PP -\fB\fC\-c\fR \fICLASS\fP +\fB\fC\-c\fR|\fB\fC\-\-class\fR \fICLASS\fP .br Search for windows with the given class .PP -\fB\fC\-i\fR \fIINSTANCE\fP +\fB\fC\-i\fR|\fB\fC\-\-instance\fR \fIINSTANCE\fP .br Search for windows with the given instance .PP -\fB\fC\-t\fR \fITITLE\fP +\fB\fC\-t\fR|\fB\fC\-\-title\fR \fITITLE\fP .br Search for windows with title. .PP -\fB\fC\-n\fR \fICON\_ID\fP +\fB\fC\-n\fR|\fB\fC\-\-conid\fR \fICON\_ID\fP .br Search for windows with the given con\_id .PP -\fB\fC\-d\fR \fICON\_ID\fP +\fB\fC\-d\fR|\fB\fC\-\-winid\fR \fICON\_ID\fP .br Search for windows with the given window id .PP -\fB\fC\-m\fR \fICON\_MARK\fP +\fB\fC\-m\fR|\fB\fC\-\-mark\fR \fICON\_MARK\fP .br Search for windows with the given mark .PP -\fB\fC\-o\fR \fITTL\_FRMT\fP +\fB\fC\-o\fR|\fB\fC\-\-titleformat\fR \fITTL\_FRMT\fP .br Search for windows with the given titleformat .PP -\fB\fC\-y\fR +\fB\fC\-y\fR|\fB\fC\-\-sync\fR .br Synch on. If this option is included, .br script will wait till target window exist. .PP -\fB\fC\-r\fR [\fIOUTPUT\fP] +\fB\fC\-r\fR|\fB\fC\-\-ret\fR [\fIOUTPUT\fP] .br \fIOUTPUT\fP can be one or more of the following characters: From c0d8cd5fbd30c149da3127da280610b6cd1285bc Mon Sep 17 00:00:00 2001 From: budRich Date: Wed, 12 Sep 2018 20:17:37 +0200 Subject: [PATCH 2/5] README.md: updated readme --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bb741b9..b033cf2 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - # i3ass - i3 assistance scripts This is a collection of scripts I have made to @@ -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`)* @@ -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** | |:--------|:--------------------------| @@ -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 +[getvisibel]|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. @@ -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 From 7492876cbac81e345caaf414203ee2a7e12cb38a Mon Sep 17 00:00:00 2001 From: budRich Date: Wed, 12 Sep 2018 20:18:02 +0200 Subject: [PATCH 3/5] prelle --- focusvisible/README.md | 29 +++++++ focusvisible/focusvisible.1 | 48 +++++++++++ focusvisible/focusvisible.sh | 159 +++++++++++++++++++++++++++++++++++ getvisible/README.md | 31 +++++++ getvisible/getvisible.1 | 52 ++++++++++++ getvisible/getvisible.sh | 158 ++++++++++++++++++++++++++++++++++ i3fyra/i3fyra | 1 + todo.md | 35 -------- 8 files changed, 478 insertions(+), 35 deletions(-) create mode 100644 focusvisible/README.md create mode 100644 focusvisible/focusvisible.1 create mode 100755 focusvisible/focusvisible.sh create mode 100644 getvisible/README.md create mode 100644 getvisible/getvisible.1 create mode 100755 getvisible/getvisible.sh delete mode 100644 todo.md diff --git a/focusvisible/README.md b/focusvisible/README.md new file mode 100644 index 0000000..468d3b3 --- /dev/null +++ b/focusvisible/README.md @@ -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 diff --git a/focusvisible/focusvisible.1 b/focusvisible/focusvisible.1 new file mode 100644 index 0000000..8b0f3c3 --- /dev/null +++ b/focusvisible/focusvisible.1 @@ -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]robstenklippa@gmail.com\[ra] + +\[la]https://budrich.github.io\[ra] + +.SH SEE ALSO +.PP +i3viswiz(1), getvisible diff --git a/focusvisible/focusvisible.sh b/focusvisible/focusvisible.sh new file mode 100755 index 0000000..f7feac0 --- /dev/null +++ b/focusvisible/focusvisible.sh @@ -0,0 +1,159 @@ +#!/usr/bin/env bash + +__name="focusvisible" +__version="0.003" +__author="budRich" +__contact='robstenklippa@gmail.com' +__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}> + + +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 "${@}" + + + + diff --git a/getvisible/README.md b/getvisible/README.md new file mode 100644 index 0000000..7ce24b7 --- /dev/null +++ b/getvisible/README.md @@ -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 diff --git a/getvisible/getvisible.1 b/getvisible/getvisible.1 new file mode 100644 index 0000000..c129530 --- /dev/null +++ b/getvisible/getvisible.1 @@ -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]robstenklippa@gmail.com\[ra] + +\[la]https://budrich.github.io\[ra] + +.SH SEE ALSO +.PP +i3viswiz(1), focusvisible diff --git a/getvisible/getvisible.sh b/getvisible/getvisible.sh new file mode 100755 index 0000000..a8a37c4 --- /dev/null +++ b/getvisible/getvisible.sh @@ -0,0 +1,158 @@ +#!/usr/bin/env bash + +__name="getvisible" +__version="0.004" +__author="budRich" +__contact='robstenklippa@gmail.com' +__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" + + found="$(i3viswiz "-${target}" | awk -v arg="$arg" ' + $NF~arg{print $2;exit} + ')" + + [[ -z $found ]] \ + && ERX "$arg window not visible" + + echo "$found" +} + +printinfo(){ +about=\ +'`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 +' + +bouthead=" +${__name^^} 1 ${__created} Linux \"User Manuals\" +======================================= + +NAME +---- +" + +boutfoot=" +AUTHOR +------ + +${__author} <${__contact}> + + +SEE ALSO +-------- + +i3viswiz(1), focusvisible +" + + + 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 "${@}" diff --git a/i3fyra/i3fyra b/i3fyra/i3fyra index 061d07f..ccf00dd 100755 --- a/i3fyra/i3fyra +++ b/i3fyra/i3fyra @@ -7,6 +7,7 @@ CONTACT='robstenklippa@gmail.com' CREATED="2017-01-14" UPDATED="2018-06-30" +[[ $hello = hell ]] main(){ local cmd target while getopts :vhas:l:w:z:m:p:t: option; do diff --git a/todo.md b/todo.md deleted file mode 100644 index 5ebac62..0000000 --- a/todo.md +++ /dev/null @@ -1,35 +0,0 @@ -# todo -- [ ] create Arch PKG -- [ ] make a update announcement video -- [ ] improve multimonitor support - - [ ] i3viswiz - - [ ] i3fyra -- [x] bump version numbers -- [x] fix strange hiding issue, i3run? -- [x] clean up i3fyra code -- [x] rewrite i3list -- [x] add function to i3wizvis to display parent container -- [x] improve i3run - - [x] track coordinates when hiding windows - - [x] don't spawn at cursor by default - - [x] add renaming option -- [x] write this todo list -- [x] review issues reported on github - - [x] i3flip - focus function in other direction - - [x] workspace bug, probably resolved - - [x] i3viswiz, multimonitor support, to fix - - [x] i3list /bin/sh - resolved - - [x] watsons issues -- [x] create better installation with make -- [x] rewrite install.sh -- [x] improve documentation - - [x] i3fyra - - [x] i3run - - [x] i3viswiz - - [x] i3list - - [x] i3flip - - [x] i3get - - [x] i3gw - - [x] i3var - - [x] README - From e608c59c7a4610f26f92b10291fd6f49abe812bf Mon Sep 17 00:00:00 2001 From: budRich Date: Wed, 12 Sep 2018 20:20:22 +0200 Subject: [PATCH 4/5] README.md: typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b033cf2..d458aed 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Execute a script with the `-h` flag to display help about the command. There are [i3var] |Set or get a i3 variable [i3Kornhe]|move and resize windows gracefully [focusvisible]|Focus a visible window -[getvisibel]|Print the id of a visible window +[getvisible]|Print the id of a visible window [install.sh]|Installation script [Makefile]| - From 76e6250a8ea75bffa19ab73c3d7d1e765225577a Mon Sep 17 00:00:00 2001 From: budRich Date: Wed, 12 Sep 2018 20:29:47 +0200 Subject: [PATCH 5/5] i3fyra: removed hello test --- i3fyra/i3fyra | 1 - 1 file changed, 1 deletion(-) diff --git a/i3fyra/i3fyra b/i3fyra/i3fyra index ccf00dd..061d07f 100755 --- a/i3fyra/i3fyra +++ b/i3fyra/i3fyra @@ -7,7 +7,6 @@ CONTACT='robstenklippa@gmail.com' CREATED="2017-01-14" UPDATED="2018-06-30" -[[ $hello = hell ]] main(){ local cmd target while getopts :vhas:l:w:z:m:p:t: option; do