From f328341d9481e0548c6342811e6c3f5a64ef6a02 Mon Sep 17 00:00:00 2001 From: Oliver Schraml Date: Thu, 12 Jul 2018 16:31:46 +0200 Subject: [PATCH] i3_selectwindow.sh: full change of script README.md: init .gitignore: init i3_selectwindow.config_sample: init --- .gitignore | 7 ++++++ README.md | 40 +++++++++++++++++++++++++++++++++++ i3_selectwindow.config_sample | 4 ++++ i3_selectwindow.sh | 29 +++++++++++++++++++------ 4 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 i3_selectwindow.config_sample mode change 100644 => 100755 i3_selectwindow.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ccc156a --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*~ +.*.sw? +.sw? +\#*\# +DEADJOE + +/i3_selectwindow.config diff --git a/README.md b/README.md new file mode 100644 index 0000000..40c341e --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# i3_selectwindow.sh +Allows the user to jump directly to a window even if its on a different workspace or physical screen with a sample keybinding in the .i3/config + +For example: +bindsym Mod1+Tab exec '/home/myuser/git/i3_selectwindow/i3_selectwindow.sh' + +## Reqirements +It uses [sed](https://www.gnu.org/software/sed/), [grep](http://www.gnu.org/software/grep/), [i3-msg](https://i3wm.org/), [jq](https://github.com/stedolan/jq), [dmenu](https://i3wm.org/) and [bashisms](https://en.wikipedia.org/wiki/Bashism). So please make sure that you have them installed. For example with [apt](https://wiki.debian.org/Apt) for [debian](https://www.debian.org/) + +## Configuration +The colours of the dmenu can be configured in the file i3_selectwindow.config and its the only purpose of that file. +It is stored in the same directory as the script is. You can also rename the i3_selectwindow.config_sample to i3_selectwindow.config and perform an your color changes. +This one is excluded from git that you do not get anoyed by changes in there. +```sh +cat i3_selectwindow.config_sample +dmsb="#1C1C1C" +dmsf="#000000" +dmnb="#000000" +dmnf="#FBFBFB" +``` + +## Usage +As its triggered by a keybinding you dont need to run it from the termianl. +But if yes, just run the script, there are no parameters and you will get only one output if you select something: +```bash +./i3_selectwindow.sh +[{"success":true}] +``` + +## .gitignore +```bash +cat .gitignore +*~ +.*.sw? +.sw? +\#*\# +DEADJOE + +/i3_selectwindow.config +``` diff --git a/i3_selectwindow.config_sample b/i3_selectwindow.config_sample new file mode 100644 index 0000000..e9d8686 --- /dev/null +++ b/i3_selectwindow.config_sample @@ -0,0 +1,4 @@ +dmsb="#1C1C1C" +dmsf="#000000" +dmnb="#000000" +dmnf="#FBFBFB" diff --git a/i3_selectwindow.sh b/i3_selectwindow.sh old mode 100644 new mode 100755 index 291fcc1..92abaa5 --- a/i3_selectwindow.sh +++ b/i3_selectwindow.sh @@ -1,11 +1,22 @@ #!/bin/bash -#wmclass=$(i3-msg -t get_tree | jq -r '.' | grep class | grep -v i3bar | sed -e 's/ *//g;s/"class"://g;s/^"//g;s/",$//g' | awk '{print NR, $0}') +shopt -s nullglob globstar +sctpa="$(dirname ${0})" +confpa="${sctpa}/i3_selectwindow.config" -#wmtittle=$(i3-msg -t get_tree | jq -r '.' | grep title | grep -v i3bar | sed -e 's/ *//g;s/"title"://g;s/^"//g;s/",$//g' | awk '{print NR, $0}' | dmenu -l 4) +dmsb="#005577" +dmsf="#eeeeee" +dmnb="#222222" +dmnf="#bbbbbb" -#wmNR=$(echo ${wmtittle} | awk '{print $1}') -#wmclass=$(i3-msg -t get_tree | jq -r '.' | grep class | grep -v i3bar | sed -e 's/ *//g;s/"class"://g;s/^"//g;s/",$//g' | awk '{print NR, $0}' | grep -E "^${wmNR} "| sed -e "s/^${wmNR} //g") -#wmtittle=$(echo "${wmtittle}" | sed -e "s/^${wmNR} //g") +if [ -f "${confpa}" ]; then + source "${confpa}" +fi + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi tmpid="" tmpclass="" @@ -20,6 +31,10 @@ do if ! [ -z "$(echo ${line} | grep -v i3bar | grep -E \"class\")" ] then tmpclass=$(echo ${line} | grep -E "class" | sed -e 's/ *//g;s/"class"://g;s/^"//g;s/",$//g') + if [ "${tmpclass}" == "Firefox-esr" ] + then + line="\"title\":firefox" + fi fi if ! [ -z "$(echo ${line} | grep -v i3bar | grep -E \"title\")" ] @@ -28,6 +43,8 @@ do echo "$tmptitle $tmpclass $tmpid" fi -done<<<$(i3-msg -t get_tree | jq -r '.' | grep -B1 "type.*con" -A41 | grep -E "id...[0-9]+|class|title") | dmenu -l 4) +done<<<$(i3-msg -t get_tree | jq -r '.' | grep -B1 "type.*con" -A41 | grep -E "id...[0-9]+|class|title") | dmenu -l 4 -i -sb "$dmsb" -sf "$dmsf" -nb "$dmnb" -nf "$dmnf") + +[ -z "${choice}" ] && exit i3-msg "[con_id="$(echo $choice | awk '{print $3}')"]" focus