#!/bin/bash if which rofi > /dev/null 2>&1 ; then /usr/bin/rofi -show window -config ~/VersionControl/configs/ALL_config/.global_rofi.conf exit $? fi shopt -s nullglob globstar sctpa="$(dirname ${0})" confpa="${sctpa}/i3_selectwindow.config" dmsb="#005577" dmsf="#eeeeee" dmnb="#222222" dmnf="#bbbbbb" if [ -f "${confpa}" ]; then source "${confpa}" fi typeit=0 if [[ $1 == "--type" ]]; then typeit=1 shift fi tmpid="" tmpclass="" tmptitle="" choice=$(while IFS= read -r line do if ! [ -z "$(echo ${line} | grep -E 'id...[0-9]+')" ] then tmpid=$(echo ${line} | grep -Eo "[0-9]+") fi 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\")" ] then tmptitle=$(echo ${line} | grep -E "title" | sed -e 's/ *//g;s/"title"://g;s/^"//g;s/",$//g') 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 -i -sb "$dmsb" -sf "$dmsf" -nb "$dmnb" -nf "$dmnf") [ -z "${choice}" ] && exit i3-msg "[con_id="$(echo $choice | awk '{print $3}')"]" focus