Skip to content

Instantly share code, notes, and snippets.

@budRich
Last active August 11, 2017 22:45
Show Gist options
  • Save budRich/fd0244528cbc4309a1857b71d4c1394e to your computer and use it in GitHub Desktop.
Save budRich/fd0244528cbc4309a1857b71d4c1394e to your computer and use it in GitHub Desktop.
complicate application launching and increase autism in i3wm
#!/bin/bash
about(){
# ? show script info
# # pass function name as arg: details about that function
echo '
i3ass - version 0.3 - major rewrite
ctrl+c & ctrl+v: by budRich, 2017
testing: mxh-
Create layouts and launch apps in i3
i3ass [-options] [[function] [toptarg]...] [-funcoption [toptarg]...]
-- todo: --------
getpos...
fix all problems in functions
test all functions, note benchmark.
replace winid with con_id everywher
all containers have conky as root, or as defined in config.
change mark deliminator to _, to capture -1 neatly
mark sidebar ws with s
replace treeson2 with treeget
write notes program, level up to 0,4 taskbar edition.
-- ideas -------
rewrite i3 cnofig, on init, and layout load and new ws.
eliminate need for lowants shenanigans, disable float auto.
faster faster faster, smoother, smoother, smoother
taskbar.., alt-tab cykle taskbar
minimizer
splasher!
sidebar flickering on show, overlaying ghost? printscreen
sidebar rofi, greetscreen, if sidebar status not active: dmenu
daemon mode... '
}
# :::::::::: FUNCTIONS ::::::::::::
# -------- Initializone --------
init(){
# ? initialization function
# > wsget configset treeset sbinit wsinit
# 5.143, most time on launching sublime.
# last version: 8.477
cws=$(wsget)
configset
treeset
sbinit
wsinit
}
wsinit(){
# ? create main containers on ws
# ? synopsis: wsinit [workspace:INT]
# > wsget getmarks winghost winget configset configget applaunch
# < init
cws=${cws:=$(wsget)}
[[ -z $cnf ]] && configset
local trgws=${1:-$cws}
local init=0 rootid= mcnt= spwn=
for mark in $(getmarks); do
[[ $mark = ${trgws}_alfa ]] && init=1 && break
done
# init workspace
if [[ $init = 0 ]]; then
winghost -l t -w ${trgws} ${trgws}_mejn
winghost -p "${trgws}_alfa" "${trgws}_mejn"
winghost -p "${trgws}_space" "${trgws}_alfa"
mcnt=$(configget "global-settings-main")
rootid=$(conkylaunch ${trgws}_main_${mcnt} desktop)
[[ ! $trgws = "$cws" ]] && \
i3-msg [con_id=$rootid] move to workspace $trgws
i3-msg [con_id=$rootid] floating disable, \
move to mark "${trgws}_mejn", split h, layout tabbed
i3-msg [con_mark=${trgws}_mejn] layout default, split h
spwn=$(configget "container-${mcnt}-spawn")
applaunch "$spwn"
i3-msg [con_id=$rootid] focus
fi
i3-msg workspace ${trgws}
}
loapply(){
# ? apply layout
# ? synopsis: loapply layout:string
# > configget losplit winget
# < sbinit
local layout=$(configget "layout-$1")
local layoutlabel="$1"
local block=0 trgws=
for line in $(echo $layout | sed "s/,/ /g"); do
((block++))
char=0
for (( i=0; i<${#line}; i++ )); do
((char++))
cur="${line:$i:1}"
loc="${lyzed["${layoutlabel}-${block}-"$((char-1))]}"
abc="${lyzed["${layoutlabel}-$((block-1))-$char"]}"
lyzed["${layoutlabel}-${block}-${char}"]="$cur"
if [[ ${cur} == ${loc} ]]; then
((widthcounter++))
lyzed["${layoutlabel}-L${block}-$((char-1))"]=0
[[ $widthcounter -gt ${lyzed["${layoutlabel}-${cur}-width"]} ]] \
&& lyzed["${layoutlabel}-${cur}-width"]=$widthcounter
else
lyzed["${layoutlabel}-L${block}-$((char-1))"]=1
widthcounter=1
heightcounter=1
fi
if [[ ${cur} == ${abc} ]]; then
[[ $widthcounter == 1 ]] \
&& ((heightcounter+=lyzed["${layoutlabel}-${cur}-height"]))
lyzed["${layoutlabel}-B${char}-$((block-1))"]=0
[[ $heightcounter -gt ${lyzed["${layoutlabel}-${cur}-height"]} ]] \
&& lyzed["${layoutlabel}-${cur}-height"]=$heightcounter
else
lyzed["${layoutlabel}-B${char}-$((block-1))"]=1
fi
if [[ -z ${lyzed["${layoutlabel}-${cur}-pos"]} ]]; then
lyzed["${layoutlabel}-${cur}-pos"]="${block}-${char}"
lyzed["${layoutlabel}-${cur}-width"]=1
lyzed["${layoutlabel}-${cur}-height"]=1
lyzed["containers"]+="${cur}"
fi
done
lyzed["${layoutlabel}-width"]=$char
done
lyzed["${layoutlabel}-height"]=$block
# get ids of windows in layout, spawn if necesarry
for (( i=0; i<${#lyzed["containers"]}; i++ )); do
local curcon="${lyzed["containers"]:$i:1}"
local spwnwindow=$(configget "container-${curcon}-spawn")
local idop=$(winget $spwnwindow)
lyzed[${layoutlabel}-${curcon}-id]=${idop%%' '*}
done
# if only one container in layout
if [[ ${#lyzed["containers"]} -eq 1 ]]; then
local trgid="${lyzed[${layoutlabel}-${lyzed[containers]}-id]}"
[[ $optws ]] && trgws=$optws || trgws=${tre:=$(wsget)}
[[ $optws ]] && i3-msg "[con_id=${trgid}]" move to workspace ${optws}
i3-msg "[con_id=${trgid}]" floating disable, \
mark "${trgws}_${layoutlabel}_${curcon}_${trgid}_#"
[[ $optmark ]] && i3-msg "[con_id=${trgid}]" move to mark ${optmark}
else
output="@@@1 1 ${lyzed["${layoutlabel}-width"]} "
output+="${lyzed["${layoutlabel}-height"]}@@@"
while :; do
echo "$output"
tosplit="${output#*@@@}"
tosplit="${tosplit%%@@@*}"
splittish=$(losplit $tosplit "$layoutlabel")
output=${output/@@@$tosplit@@@/$splittish}
[[ $output =~ "@@@" ]] || break
done
fi
# make all containers tabbed
for (( i=0; i<${#lyzed["containers"]}; i++ )); do
curcon="${lyzed["containers"]:$i:1}"
trgid="${lyzed[${layoutlabel}-${curcon}-id]}"
i3-msg [con_id=${trgid}] split v, layout tabbed
# polyspawn...
done
}
losplit(){
# ? helper function for loapply
# ? losplit tosplit:string
# > configget
# # merge with loapply
local sx=$1 sy=$2 ex=$3 ey=$4 lolbl=$5
local spltdir="h" spltpos=
local width=$(((ex-sx)+1)) height=$(((ey-sy)+1))
local lowidth=${lyzed["${lolbl}-width"]}
local loheight=${lyzed["${lolbl}-height"]}
local sx1=0 sy1=0 ex1=0 ey1=0 sx2=0 sy2=0 ex2=0 ey2=0
local startchar=${lyzed["${lolbl}-${sy}-${sx}"]}
local endchar=${lyzed["${lolbl}-${ey}-${ex}"]}
local parnt= child= dirre= perca=
local resiss= zdir= grw= trg= splittish=
declare -A lajnuz=()
for (( h=$sy; h<$((sy+height)); h++ )); do
for (( w=$sx; w<$((sx+width)); w++ )); do
[[ ${h} -lt $((height+sy-1)) ]] \
&& lajnuz["B${h}"]=$((lajnuz["B${h}"]+lyzed["${lolbl}-B${w}-${h}"]))
[[ ${w} -lt $((sx+width-1)) ]] \
&& lajnuz["L${w}"]=$((lajnuz["L${w}"]+lyzed["${lolbl}-L${h}-${w}"]))
done
done
for key in "${!lajnuz[@]}"; do
[[ ${lajnuz["$key"]} -eq $width ]] && [[ ${key:0:1} = "B" ]] \
&& spltdir="v" && spltpos="${key:1}" && break
[[ ${lajnuz["$key"]} -eq $height ]] && [[ ${key:0:1} = "L" ]] \
&& spltdir="h" && spltpos="${key:1}" && break
done
[[ -z $spltpos ]] && return
sx1=${sx}; sy1=${sy}
ex2=${ex}; ey2=${ey}
[[ ${spltdir} = "v" ]] && ex1=${ex} \
&& ey1=${spltpos} && sx2=${sx} && sy2=$((${spltpos}+1))
[[ ${spltdir} = "h" ]] && ex1=${spltpos} \
&& ey1=${ey} && sx2=$((${spltpos}+1)) && sy2=${sy}
# notify-send "1: $ex1 2: $ex2"
parnt="${lyzed["${lolbl}-${sy1}-${sx1}"]}"
child="${lyzed["${lolbl}-${sy2}-${sx2}"]}"
dirre="${spltdir}"
[[ ${spltdir} = "v" ]] && \
perca=$( echo "scale=2;${lyzed["${lolbl}-${parnt}-height"]}/$height"*100 | bc )
[[ ${spltdir} = "h" ]] && \
perca=$( echo "scale=2;${lyzed["${lolbl}-${parnt}-width"]}/$width"*100 | bc )
resiss=$((${perca%.*}-50))
parntid=${lyzed["${lolbl}-${parnt}-id"]}
childid=${lyzed["${lolbl}-${child}-id"]}
[[ $optws ]] && trgws=$optws \
|| [[ $(configget "global-settings-sidebarlayout") = "${lolbl}" ]] && trgws=0 \
|| trgws=${tre:=$(wsget)}
local papp="$(configget "container-${parnt}-spawn")"
local capp="$(configget "container-${child}-spawn")"
local pmrk="${trgws}_${lolbl}_${parnt}_${papp}_${parntid}_#"
local cmrk="${trgws}_${lolbl}_${child}_${capp}_${childid}_#"
# if parnt is first container on layout
if [[ $width -eq $lowidth ]] && [[ $height -eq $loheight ]]; then
[[ $optws ]] && i3-msg [con_id=${parntid}] \
move to workspace ${optws} > /dev/null 2>&1
i3-msg [con_id=${parntid}] floating disable, \
mark "${pmrk}", border pixel 1 > /dev/null 2>&1
[[ $optmark ]] && i3-msg [con_id=${parntid}] \
move to mark ${optmark} > /dev/null 2>&1
fi
i3-msg [con_id=${parntid}] split $dirre > /dev/null 2>&1
i3-msg [con_id=${childid}] floating disable, \
move to mark "${pmrk}", \
mark "${cmrk}", border pixel 1 > /dev/null 2>&1
if [[ $resiss != 0 ]]; then
if [[ ${spltdir} = "v" ]]; then
zdir="down" grw="grow" trg="${parntid}"
[[ $resiss -lt 0 ]] && zdir="up" \
&& resiss=$((resiss*-1)) && trg="${childid}"
else
zdir="right" grw="grow" trg="${parntid}"
[[ $resiss -lt 0 ]] && zdir="left" \
&& resiss=$((resiss*-1)) && trg="${childid}"
fi
i3-msg [con_id=${trg}] \
resize ${grw} ${zdir} ${resiss} px or ${resiss} ppt > /dev/null 2>&1
fi
splittish="@@@${sx1} ${sy1} ${ex1} ${ey1}@@@
@@@${sx2} ${sy2} ${ex2} ${ey2}@@@
"
echo "$splittish"
}
# ---- setters and getters -----
treeset(){
# ? sets global var tre
# < init
local treg=$(i3-msg -t get_tree | sed 's/,/\n/g')
tre=$(echo -e "${treg}" | grep -v window_role | grep -v marks)
}
tabget(){
# ? return focused tab
# > treeset
# < tabswitch desktop
# # add function for ordered list
local option= crit= ret= tmp= mark= cwin= mrks=
[[ -z $tre ]] && treeset
OPTIND=1
getopts :of option
ret=${option}
[[ $ret = "?" ]] && ret=f
OPTIND=1
if [[ $ret = f ]]; then
while getopts :n:d:c:i:a option; do
case "${option}" in
i) crit='"instance":"'${OPTARG};;
c) crit='"window_properties":{"class":"'${OPTARG};;
n) crit='"id":'${OPTARG};;
d) crit='"window":'${OPTARG};;
a) crit='"focused":true';;
esac
done
crit=${crit:-'"focused":true'}
# local tmptre=${tre#*$crit}
tmp=$(printf "${tre}" \
| grep -A1984 -m1 $crit \
| grep -E -m1 -A15 '"focus":(\[[0-9]|true)')
tmp=${tmp#*'['}
echo ${tmp%%']'*}
else
while getopts :n:d:c:i:a option; do
case "${option}" in
i) crit="-i ${OPTARG}" ;;
c) crit="-c ${OPTARG}" ;;
n) cwin="${OPTARG}" ;;
d) crit="-d ${OPTARG}" ;;
a) crit="-a" ;;
esac
done
crit=${crit:--a}
cwin=${cwin:-$(treeget ${crit})}
mrks=$(getmarks)
declare -A famark
for mark in ${mrks}; do
amark=(${mark//_/' '})
[[ ${amark[4]} = $cwin ]] && hit=${amark[1]}
famark[${amark[1]}]+="${amark[4]} "
amark=""
done
echo ${famark[$hit]:0:-1}
fi
}
listapps(){
# ? returns string of windows defined in config
# ! rewrite gla doesn't exist.
# ! add criteria, for container or layout
# < none, used by external scripts
for key in "${!gla[@]}"; do
[[ ! "${key%%-*}" == "window" ]] && continue
app="${key#window-}" app="${app%-*}"
[[ ! $applist =~ "$app" ]] && applist+="$app\n"
done
echo -e "${applist:0:-2}"
}
getmarks(){
# ? returns marks
# < wsinit sbtoggle
# # add criteria and return request
local marks=$(i3-msg -t get_marks)
[[ $marks = '[]' ]] && marks="--nomarks--"
marks="${marks:2:-2}"
marks="${marks//"\",\""/ }"
echo $marks
}
configset(){
# ? sets the global var cnf
# < init
cnf='
global settings:
sidebarlayout = sidebar
sidebarwidth = 205
main = A
container A:
windows = luakit,sublime,htop,qbittorrent,inoreader
spawn = sublime
container G:
windows = irssi,thunar,term3,winspy,pcmanfm,spacefm,ncmpcpp
spawn = irssi
layout dev:
A
layout sidebar:
G
G
G
G
G
F
container F:
windows = term2
spawn = term2
window qutebrowser:
title = \- qutebrowser
command = qutebrowser --backend webengine
window vivaldi:
class = Vivaldi-stable
command = vivaldi
icon = 
window conky:
class = conky
command = conky
window ncmpcpp:
instance = ncmpcpp
command = urxvt -name ncmpcpp -e ncmpcpp
x = 108
y = 23
width = 366
height = 400
window irssi:
instance = irssi
command = urxvt -name irssi -e irssi
window kyokusen:
title = kyokusen
command = fehlet
window htop:
instance = htop
command = urxvt -name htop -e htop
window winspy:
instance = winspy
command = urxvt -name winspy -e devilspie2 --debug
window term1:
instance = term1
command = urxvt -name term1
position = 20,20,400,100
window term2:
instance = term2
command = urxvt -name term2
window term3:
instance = term3
command = urxvt -name term3
window firefox:
title = ::: firefox :::
command = firefox
window sublime:
instance = sublime_text
command = subl
icon = 
window spacefm:
class = Spacefm
command = spacefm
window qbittorrent:
class = qBittorrent
command = qbittorrent
icon = 
window gcolor2:
title = gcolor2
command = gcolor2
window luakit:
instance = luakit
command = luakit
window splonk:
title = splonk
command = splonk'
}
configget(){
# ? returns setting from cnf
# ? synopsid configget setting:string
# ! last entry of config is hard to get, needs splonk
# # store found values in global array
# # test if big difference in speed grep in file
local action=${1:?"No setting to search for."}
[[ -z $cnf ]] && [[ -n $optfile ]] && cnf=$(<${optfile})
[[ -z $cnf ]] && [[ -z $optfile ]] && configset
local sect=${action%%-*}
local valc=${action##*-}
local kelk=${action#*-}
local fnd
kelk=${kelk%-*}
if [[ $valc = "$kelk" ]]; then
fnd=$(echo -e "$cnf" | grep -A9 "$sect $kelk.")
fnd=${fnd#*\:}
local char= cnts=
for char in ${fnd//'\n'/' '}; do
[[ -z $char ]] && continue
[[ ${#char} -gt 1 ]] && break
cnts+=$char,
done
echo "$cnts"
else
fnd=$(echo -e "$cnf" | grep -m1 -A5 "$sect $kelk." | tail -5)
fnd=$(echo -e "${fnd%$sect*}" | grep -m1 $valc)
fnd="${fnd#*\=+([[:space:]])}"
echo "${fnd%+([[:space:]])}"
fi
}
wsget(){
# ? returns current workspace
# < init
# # change behaviour to set global var cws
local kurt="\},\{"
local kurt2="num\":"
local rslt=$(i3-msg -t get_workspaces)
acws=(${rslt//$kurt/ })
for (( i=0; i<${#acws[*]}; i++ )); do
[[ ! ${acws[$i]} =~ "focused\":true" ]] && continue
rslt=${acws[$i]#*$kurt2}
rslt=${rslt%%\,*}
break
done
echo "$rslt"
}
treeget(){
# ? search tre for window and return results
# ? synopsis treeget [-criterium argument] [-r string]
# > treeset
# # polycriterium
# # title search, works from command line
# # when quoted, needs more testing.
# # also test behaviour of returned title...
# # best run: 0.085/0.15
# # two windows no ws request, test with big layout..
[[ -z $tre ]] && treeset
local crit= cnum= summ= cur= i= ts_ret=
local grepopt= toss= line= option= rets=
OPTIND=1
while getopts :d:i:c:t:r:n:a option
do
case "${option}" in
t) crit="\"name\":\".*${OPTARG}.*" cnum=31;;
i) crit="\"instance\":\"${OPTARG}\"" cnum=34;;
c) crit="\"window_properties\":{\"class\":\"${OPTARG}\"" cnum=33;;
n) crit='"id":'${OPTARG} cnum=2;;
d) crit="\"window\":${OPTARG}" cnum=32;;
a) crit='"focused":true' cnum=8;;
r) ts_ret="${OPTARG}";;
esac
done
ts_ret=${ts_ret:-n}
for (( i=0; i<${#ts_ret}; i++ )); do
cur="${ts_ret:$i:1}"
case $cur in
t) summ="$((31-cnum)) ";;
i) summ="$((34-cnum)) ";;
c) summ="$((33-cnum)) ";;
d) summ="$((32-cnum)) ";;
a) summ="$((8-cnum)) " ;;
f) summ="$((42-cnum)) ";;
n) summ="$((2-cnum)) " ;;
esac
if [[ $cur != w ]]; then
if [[ $summ -lt 0 ]]; then
summ=$((summ*-1))
grepopt="-B$summ ${crit}"
toss="head -1"
else
grepopt="-A$summ ${crit}"
toss="tail -1"
fi
line="$(printf "${tre}" | grep -m1 ${grepopt} | ${toss})"
fi
case $cur in
t) rets+="\"${line:8:-1}\" ";;
i) rets+="${line:12:-1} ";;
c) rets+="${line:30:-1} ";;
n) rets+="${line: -14} ";;
d) rets+="${line:9} ";;
a) rets+="${line:10} ";;
f) rets+="${line:12:-1} ";;
w)
local wors=
local wfnd="$(printf "${tre}" | grep -n '"num":' | sort -nr)"
local gres="$(printf "${tre}" | grep -n -m1 $crit)"
for wors in $wfnd; do
[[ ${gres%%:*} -lt ${wors%%:*} ]] && continue
rets+="${wors##*:} "
break
done
;;
esac
done
echo ${rets:0:-1}
}
# -------- applaunching --------
winget(){
# ? returns id and status of app
# ? synopsis winget app:string
# > getmarks treeget configget treeset
# < loapply wsinit applaunch winmove
local win=${1:?$0 - please specify window}
local wac= wfl= wmr= wid= wws= wct= fnd= hit= crit=
local sts="exist" sbs=visible
for mark in $(getmarks); do
amark=(${mark//_/' '})
[[ ${amark[3]} = $win ]] && hit=$mark
[[ ${amark[1]} = "sidus" ]] && sbs="hidden"
done
# if win is marked, be happy
if [[ -n $hit ]]; then
amark=(${hit//_/' '})
wfl=0
[[ ${amark[1]} = floating ]] && wfl=1 \
&& [[ $(treeget -n ${amark[4]} -r a) = "true" ]] \
&& sts=active
wid=${amark[4]}
wws=${amark[0]}
wct=${amark[1]}
[[ $wct = "sidebar" ]] && [[ $sbs = "hidden" ]] && sts=$sbs
else
for crit in title instance class; do
fnd=$(configget "window-${win}-$crit")
[[ -n $fnd ]] && break
done
# if window is not marked, assume float
wfl=1
[[ -z $tre ]] && treeset
wininfo=($(treeget -r naw "-${crit:0:1}" "${fnd}"))
if [[ -n $wininfo ]]; then
wid=${wininfo[0]}
[[ ${wininfo[1]} = "true" ]] && sts=active
wws=${wininfo[2]}
wct=unknown
else
# window not found, launch it
local cmd=$(configget "window-${win}-command")
local cnt=0
${cmd} > /dev/null 2>&1 &
while [[ ! $(i3-msg -t get_tree) =~ "${fnd}" ]]; do
sleep 0.1
((++cnt))
[[ $cnt -gt 200 ]] && return 1
done
treeset
wininfo=($(treeget "-${crit:0:1}" "${fnd}" -r nw))
wid=${wininfo[0]}
wws=${wininfo[1]}
sts=launch
wct=unknown
fi
fi
echo "${wid} ${wfl} ${wws} ${wct} ${sts}"
}
applaunch(){
# ? run or raise app
# ? sunopsis applaunch app:string
# > winget wsget lowants sbtoggle winmove
# < wsinit
local app="$1"
ids=($(winget $app))
local appstatus=${ids[4]}
local appcont=${ids[3]}
local appid=${ids[0]}
local appfloat=${ids[1]}
local wanted="0"
# if unknown and not launch, mark before focus.
# also check if it's tiled
if [[ $appfloat -ne 1 ]]; then
[[ $appstatus = "exist" ]] \
&& i3-msg [con_id=$appid] focus && return
[[ $appstatus = "hidden" ]] && [[ $appcont = "sidebar" ]] \
&& sbtoggle show && i3-msg [con_id=$appid] focus && return
[[ $appstatus = "active" ]] && return
else
[[ $appstatus = "active" ]] \
&& i3-msg [con_id=$appid] focus, unmark, \
mark "-1_floating_legalizeweed_${app}_${appid}_#", \
move scratchpad && return
cws=${cws:=$(wsget)}
if [[ $appstatus = "hidden" ]]; then
i3-msg [con_id=$appid] move to workspace $cws
winmove "$appid" $app
i3-msg [con_id=$appid] focus, \
mark "${cws}_floating_legalizeweed_${app}_${appid}_#", \
unmark "-1_floating_legalizeweed_${app}_${appid}_#"
return
fi
local appws=${ids[2]}
[[ $appstatus = "launch" ]] && treeset
[[ $appws -ne $cws ]] \
&& i3-msg [con_id=$appid] focus, \
move window to workspace $cws, workspace $cws
[[ $appws -ne $cws ]] || [[ $appstatus = "launch" ]] \
&& wanted=$(lowants $app $appid)
[[ $wanted = "0" ]] && [[ $appstatus = "launch" ]] \
&& i3-msg [con_id=$appid] \
mark "${cws}_floating_legalizeweed_${app}_${appid}_#" \
&& winmove $appid $app
fi
i3-msg [con_id=$appid] focus
}
conkylaunch(){
local pos=${1:?"loroot: Argument missing: no layout"}
local style=${2:-blank}
local fcnf= cnt=0 rid=
# create root, create tmpconfig
[[ $style = blank ]] && fcnf="
update_interval 30000
total_run_times 0
own_window yes
own_window_colour 111313
own_window_class ${pos}_root
minimum_size 50 50
TEXT
" || fcnf="
update_interval 30
total_run_times 0
own_window yes
own_window_transparent yes
own_window_class ${pos}_root
minimum_size 50 50
double_buffer yes
TEXT
"
rm -f /tmp/conky_${pos} \
&& printf "${fcnf}" > /tmp/conky_${pos}
conky -c /tmp/conky_${pos} > /dev/null 2>&1 &
while [[ ! $(i3-msg -t get_tree) =~ ${pos}_root ]]; do
sleep 0.1
((++cnt))
[[ $cnt -gt 200 ]] && return 1
done
treeset
rid=$(treeget "-c" "${pos}_root" -r n)
i3-msg [con_id=$rid] mark "${pos}_root_${rid}_#" > /dev/null 2>&1 &
echo $rid
}
winghost(){
# ? creates ghost windows
# ? synopsis winghost [option:lmpwk] name:string
# ? options synopsis:
# -l layout [vhts]
# -m move-to-mark mark:string
# -p mark-parent mark:string
# -k kill
# -w workspace workspace:number
# > wsget
# < sbinit wsinit
# ! correct synopsis
cws=${cws:=$(wsget)}
OPTIND=1
while getopts :l:m:p:w:k option
do
case "${option}" in
l) local optlot=${OPTARG};;
m) local optmrk=${OPTARG};;
p) local optpar=${OPTARG};;
w) local optws=${OPTARG};;
k) local optkil=1;;
esac
done
shift $((--OPTIND))
echo "${@}"
local optnam=${1:?please enter a name for the window.}
[[ -n $optkil ]] && \
i3-msg "[con_mark=$optnam]" kill && \
echo "killed $optnam" && return
[[ -n $optpar ]] && \
i3-msg [con_mark=$optnam] focus, focus parent && \
i3-msg mark $optpar && \
echo "marked parnet of $optnam: $optpar" && return
optlot=${optlot:-h}
case "$optlot" in
v) layout="splitv" ;;
h) layout="splith" ;;
t) layout="tabbed" ;;
s) layout="stacked" ;;
esac
gw=$(i3-msg open)
gwid=${gw#*'id":'} gwid=${gwid:0:-2}
i3-msg [con_id=$gwid] floating disable, border none
[[ -n $optws ]] && [[ ! $optws = "$cws" ]] && \
i3-msg [con_id=$gwid] move to workspace "$optws" && \
echo "gw: moved $optnam to $optws"
[[ -n $optmrk ]] && \
i3-msg [con_id=$gwid] move to mark "$optmrk" && \
echo "gw: moved $optnam to $optmrk"
i3-msg [con_id=$gwid] mark $optnam, layout $layout && \
echo "gw: $optnam layout $layout"
}
lowants(){
# ? checks if app is wanted by a tabbed container
# ? synopsis lowants app:string
# > wsget configset configget getmarks
# < applaunch
# # might not be needed if i3-cnf-rewriting is succesfull
cws=${cws:=$(wsget)}
local app=$1 appid=$2 status= hit= sbwants=
[[ -z $cnf ]] && configset
local maincont=$(configget "global-settings-main")
local mainwins=$(configget "container-${maincont}-windows")
local mainwins=${mainwins//\,/" "}
for win in $mainwins; do
[[ $win != "$app" ]] && continue
winfloat ${appid} ${app} 2>&1
echo 1
return
done
for win in $(sbwants); do
if [[ $win = "$app" ]]; then
local sb_status=visible
for mark in $(getmarks); do
[[ ${mark#*-} = "sidus" ]] && sb_status=hidden && break
done
[[ $sb_status = "hidden" ]] && sbtoggle show
sb_wants=1
break
fi
done
for mark in $(getmarks); do
amark=(${mark//_/' '})
local cumaws=${amark[0]}
[[ -n $sb_wants ]] && [[ $cumaws != "0" ]] && continue
[[ -z $sb_wants ]] && [[ $cumaws != "$cws" ]] && continue
local cumalo=${amark[1]}
[[ $cumalo =~ space|sajja|sidus|alfa|root|main ]] && continue
local cumact=${amark[2]}
[[ $(configget "container-${cumact}-windows") =~ "$app" ]] \
&& hit="$mark" && break
done
if [[ -n $hit ]]; then
[[ -n $sb_wants ]] && cws="0"
local newmrk="${cws}_${cumalo}_${cumact}_${app}_${appid}_#"
i3-msg [con_id=$appid] floating disable, \
move to mark "$hit", mark "$newmrk"
echo 1
else
echo 0
fi
}
# ---- window manipulation -----
desktop(){
# ? toggles root window of main and last focused of main
# > treeget tabget
# # search marks instead of hardcode main_A
cws=${cws:=$(wsget)}
local rootid=$(treeget -c ${cws}_main_A_root)
local tabsinmain=($(tabget -n $rootid))
[[ ${tabsinmain[0]} = $rootid ]] && [[ ${#tabsinmain[@]} -gt 1 ]] \
&& i3-msg [con_id=${tabsinmain[1]}] focus && return
i3-msg [con_id=$rootid] focus
}
# winfocus(){
# # ? shift focus
# # ? synpsis winfocus direction:left|right|up|down
# local dir=$1
# winmove -b foc -d ${dir}
# }
tabswitch(){
# ? switch tab in active container
# > tabget
# > !!! treeson2
# ! tabswitch next in main cont works badly.
local dirre=${1:-prev}
declare -i ntabs
local am=${2:-$(treeson2 -a -r m)}
local ai=0
local flt=
if [[ -n $am ]]; then
local ac=${am%\-*\-*\-*}
ac=${ac/main\-*/root}
[[ ${ac%\-*} =~ space$ ]] && i3-msg focus left && return
atabs=($(tabget -fa $ac))
else
atabs=($(tabget -fa root))
fi
# number of tabs
ntabs=${#atabs[@]}
# if no tabs, do nothing go right if main, go left if sidebar or spacer
if [[ $ntabs -le 1 ]]; then
[[ $ac =~ root$ ]] && i3-msg focus parent, focus right
[[ ${ac%\-*} =~ sidebar$ ]] \
&& i3-msg focus parent, focus left
return
fi
if [[ $ac =~ root$ ]]; then
# get root con
local rcon=$(treeson2 -m root -r n)
# if only one tab in main, switch if root is active, else do nothing
if [[ $ntabs -eq 2 ]]; then
[[ ${atabs[0]} = "$rcon" ]] \
&& i3-msg [con_id="${atabs[1]}"] focus && return
i3-msg focus parent, focus right
fi
# if root is active, switch to previous tab
[[ ${atabs[0]} = "$rcon" ]] \
&& i3-msg [con_id="${atabs[1]}"] focus && return
[[ $dirre = prev ]] && for (( i = 1; i < ((ntabs-1)); i++ )); do
[[ ${atabs[$i]} = "$rcon" ]] && continue
i3-msg [con_id="${atabs[$i]}"] focus
return
done
for (( i = ((ntabs-1)); i > 1; i-- )); do
[[ ${atabs[$i]} = "$rcon" ]] && continue
i3-msg [con_id="${atabs[$i]}"] focus
return
done
else
[[ $ntabs -eq 2 ]] || [[ $dirre = prev ]] \
&& i3-msg [con_id="${atabs[1]}"] focus && return
i3-msg [con_id=${atabs[$((ntabs-1))]}] focus
fi
}
winfloat(){
# ? toggles floating state of window
# > getmarks
# < lowants
# time 0.250
local mark= newmrk= mnmrk= romrk=
[[ -z $tre ]] && treeset
cws=${cws:-$(wsget)}
local appid=${1:-$(treeget -a -r n)}
local app=${2:-unknown}
local appfl=$(treeget -n $appid -r f)
# if app is floating, move to main
if [[ $appfl =~ "on" ]]; then
mnmrk="${cws}_main_$(configget global-settings-main)"
for mark in $(getmarks); do
amark=(${mark//_/' '})
[[ ${amark[4]} = "$appid" ]] && [[ $app = unknown ]] \
&& app=${amark[3]}
[[ $mark =~ "${mnmrk}_root" ]] && romrk=$mark
done
newmrk="${mnmrk}_${app}_${appid}_#"
i3-msg [con_id=$appid] unmark, floating disable, \
move to mark $romrk, mark $newmrk, focus
return
fi
for mark in $(getmarks); do
amark=(${mark//_/' '})
[[ ${amark[4]} != "$appid" ]] && continue
[[ ${amark[1]} =~ sidebar|space|alfa|sajja ]] && return
[[ ${amark[3]} = root ]] && return
app=${amark[3]}
newmrk="${cws}_floating_legalizeweed_${app}_${appid}_#" \
&& i3-msg [con_id=$appid] unmark, floating enable, \
mark "$newmrk"
done
}
winsplit(){
# ? move window
# > getmarks winfloat treeset wsget treeget tabget
# # currently only moves window from split to main or float
# # approve other alternatives
# # split in other directions then right
cws=${cws:=$(wsget)}
[[ -z $tre ]] && treeset
local mark= wcnt= wpos= wapp= sex= spos= sapp= spid= nmrk=
local focinf=$(treeget -a -r nf)
local focid=${focinf%' '*}
local focfl=${focinf#*' '}
for mark in $(getmarks); do
amark=(${mark//_/' '})
[[ ${amark[1]} = "split" ]] && sex=$mark
[[ ${amark[4]} != $focid ]] && continue
wcnt=${amark[1]}
wpos=${amark[2]}
wapp=${amark[3]}
done
wapp=${wapp:-unknown}
if [[ $wcnt = "split" ]]; then
winfloat $focid $wapp
[[ $wpos != floating ]] && winfloat $focid $wapp
return
fi
if [[ -n $sex ]]; then
samark=(${sex//_/' '})
spos=${samark[2]}
sapp=${samark[3]}
spid=${samark[4]}
winfloat $spid $sapp
[[ $spos != floating ]] && winfloat $spid $sapp
fi
local tabsinmain=($(tabget -c conky))
if [[ $focfl =~ "on" ]]; then
[[ ${#tabsinmain[@]} -le 1 ]] && winfloat $focid $wapp && return
nmrk="${cws}_split_floating_${wapp}_${focid}_#"
i3-msg [con_id=$focid] unmark, mark $nmrk, \
floating disable, move to mark "${cws}_alfa", focus
echo kukuk
return
fi
[[ ${#tabsinmain[@]} -le 2 ]] && [[ $wcnt = main ]] && return
nmrk="${cws}_split_${wcnt}_${wapp}_${focid}_#"
i3-msg [con_id=$focid] unmark, mark $nmrk, \
move to mark "${cws}-alfa", focus
}
sbinit(){
# ? creates sidebar
# > configget winghost loapply
# < init
# # error if sidebar already exist
local line= mark= rootid=
local sblabel=$(configget "global-settings-sidebarlayout")
local sblayout=$(configget "layout-$sblabel")
local sbmrk="0_${sblabel}_${sblayout:0:1}"
local wrks=$(i3-msg -t get_workspaces)
# get width and height of screen
for line in ${wrks//,/' '}; do
[[ ! $line =~ width|height ]] && continue
[[ $line =~ width ]] && local scrnw=${line:8}
[[ $line =~ height ]] && local scrnh=${line:9:-1} && break
done
local sidew=$(configget "global-settings-sidebarwidth")
local sideh=$((scrnh-20))
local sidex=$((scrnw-(sidew+0)))
local sidey=20
winghost -l t snoris
i3-msg [con_mark=snoris] focus parent
loapply $sblabel -m snoris
rootid=$(conkylaunch ${sbmrk})
for mark in $(getmarks); do
amark=(${mark//_/' '})
[[ ${amark[3]} != root ]] && [[ ${amark[2]} = "${sblayout:0:1}" ]] \
&& [[ ${amark[1]} = $sblabel ]] && hit=$mark
done
i3-msg [con_mark="${sbmrk}_root_${rootid}_#"] floating disable, move to mark ${hit}
i3-msg [con_mark=$hit] focus, focus parent, focus parent
i3-msg mark 0_sidus
i3-msg [con_mark=0_sidus] floating enable
winghost -k snoris
i3-msg [con_mark=0_sidus] move absolute position $sidex px $sidey px, \
focus parent, resize set $sidew px $sideh px, \
move scratchpad
return
}
sbwants(){
# ? return list of windows wanted by sidebar
# > configset configget
# < lowants
[[ -z $cnf ]] && configset
sblabel="$(configget "global-settings-sidebarlayout")"
local sblayou="$(configget "layout-$sblabel")"
local sb_wants_cont=$(echo ${sblayou//\,} | LC_ALL=C tr -s '\0-\255')
local sb_wants= sb_windows=
for (( i=0; i<${#sb_wants_cont}; i++ )); do
sb_windows="$(configget "container-${sb_wants_cont:$i:1}-windows")"
sb_wants+="${sb_windows//\,/' '}"
sb_wants+=" "
done
sb_wants=${sb_wants:0:-1}
echo $sb_wants
}
sbtoggle(){
# ? toggles visibility of sidebar
# ? synopsis sbtoggle [toggle|show|hide]
# > getmarks
# < applaunch
# ! size option in sidebar show, remember size
# ! check - when toggle sidebar show, focus child
# ! ncmpcpp dies on hide
cws=${cws:-$(wsget)}
local sb_action=${1:-toggle}
local sb_status=visible
for mark in $(getmarks); do
[[ ${mark#*_} = "sidus" ]] && sb_status=hidden && break
done
[[ $sb_action = "toggle" ]] && sb_action="hide" && \
[[ $sb_status = "hidden" ]] && sb_action="show"
case "$sb_action" in
show)
# time 0.3
# when toggle sidebar show, focus child
i3-msg [con_mark=${cws}_alfa] focus
i3-msg [con_mark=0_sidus] floating enable, \
focus parent, move to workspace ${cws}
i3-msg [con_mark=0_sidus] focus parent, \
floating disable, move to mark ${cws}_space
i3-msg [con_mark=0_sidus] focus parent, \
resize shrink left 35 px or 35 ppt, \
focus, mark ${cws}_sajja, unmark 0_sidus, \
focus child
;;
hide)
# time 0.177
i3-msg [con_mark=${cws}_sajja] focus, \
mark 0_sidus, unmark ${cws}_sajja
i3-msg [con_mark=0_sidus] focus parent, \
floating enable, move scratchpad
;;
esac
}
winmove(){
# ? move window
# ? synopsis winmove appid app
# > configset configget
# < applaunch
# ! merge with winsplit, this function for floaters, winsplit for tilers
# ! new function winsize can be used before this one to calculate new size
# for floaters, tilers get resized normally.
#
# add option -name -id -dir -pos
# default window active, default action pos
#
[[ -z $tree ]] && treeset
local app= wid= pos= drt= wfl= spd= hit=
local ncrsplt= dcrsplt= oppdir= mod=
OPTIND=1
while getopts :w:n:p:s:d:b:a option; do
case "${option}" in
w) app=${OPTARG} ;;
n) wid=${OPTARG} ;;
p) pos=${OPTARG} ;;
s) spd=${OPTARG} ;;
d) drt=${OPTARG} ;;
b) mod=${OPTARG} ;;
a) wid=active ;;
esac
done
OPTIND=$((--OPTIND))
# check whether window is floating or tiled.
wid=${wid:-active}
[[ -n $app ]] && wid=$(winget $app) && wid=${wid%%' '*}
[[ $wid = active ]] && wid=$(treeget -a)
wfl=$(treeget -n $wid -r f)
mod=${mod:=mov}
if [[ $wfl =~ "on" ]]; then
if [[ -z $drt ]] && [[ -z $pos ]]; then
[[ $mod = foc ]] && return
[[ -z $app ]] && for mark in $(getmarks); do
amark=(${mark//_/' '})
[[ ${amark[4]} = $wid ]] && app=${amark[3]} \
&& break
done
[[ -z $app ]] && return
pos=$(configget window-$app-position)
fi
[[ -z $drt ]] && [[ -z $pos ]] && return
if [[ -n $drt ]]; then
if [[ $mod = mov ]]; then
spd=${spd:-100}
i3-msg [con_id=$wid] move $drt $spd
else
i3-msg focus $drt
# !! check if any windows left in drt, if not toggle_mode
fi
else
pos=(${pos//,/' '})
[[ ${#pos[@]} -ne 4 ]] && return
i3-msg [con_id=$wid] move absolute \
position ${pos[0]} px ${pos[1]} px, \
resize set ${pos[2]} px ${pos[3]} px
fi
else
[[ -z $drt ]] && return
declare -A cnts
local sbroot= maroot= mpnt= opnt= sbex= line= scrnw= scrnh=
local mepos= mapos= mapp= markro= nmrk= mcnt= sbmrk=
for mark in $(getmarks); do
amark=(${mark//_/' '})
[[ ${amark[4]} = $wid ]] && hit=${amark[1]} && mapp=${amark[3]}
[[ ! ${amark[1]} =~ space|alfa|sajja|sidebar|sidus ]] \
&& cnts[${amark[1]}]+="$mark "
[[ ${amark[3]} = root ]] && [[ ${amark[1]} = main ]] \
&& maroot=${amark[4]} && markro=$mark
[[ ${amark[3]} = root ]] && [[ ${amark[1]} = sidebar ]] \
&& sbroot=${amark[4]}
[[ ${amark[1]} = sajja ]] && sbex=1
done
# fix
[[ $mod = mov ]] && [[ $hit = sidebar ]] && return
[[ $wid = $maroot ]] && return
# target window is in split
if [[ $hit =~ "split" ]]; then
acrsplt=(${cnts[$hit]:0:-1})
ncrsplt=${#acrsplt[@]}
dcrsplt=${hit#split}
adir1=("left" "down" "right" "up")
adir2=("right" "up" "left" "down")
# get width and height of screen
local wrks=$(i3-msg -t get_workspaces)
for line in ${wrks//,/' '}; do
[[ ! $line =~ width|height ]] && continue
[[ $line =~ width ]] && local scrnw=${line:8}
[[ $line =~ height ]] && local scrnh=${line:9:-1} && break
done
for i in ${!adir1[@]}; do
[[ $dcrsplt = ${adir1[$i]} ]] && oppdir=${adir2[$i]}
done
# only one container in split cont, only legal drt is opp/main
if [[ $ncrsplt -eq 1 ]]; then
if [[ $mod = mov ]]; then
[[ $drt != $oppdir ]] && return
mcnt=$(configget global-settings-main)
nmrk="${cws:=$(wsget)}_main_${mcnt}_${mapp}_${wid}_#"
i3-msg [con_id=$wid] move to mark $markro, \
focus, unmark, mark $nmrk
else
if [[ $drt = $oppdir ]]; then
# focus visible tab in main
local tabsinmain=($(tabget -n $maroot))
i3-msg [con_id=${tabsinmain[0]}] focus
elif [[ $drt = right ]]; then
local tabsinside=($(tabget -n $sbroot))
i3-msg [con_id=${tabsinside[0]}] focus
fi
fi
else
mepos=$(getpos $wid)
mepos=(${mepos//,/' '})
case $drt in
left ) mpnt=${mepos[0]} ;;
right ) mpnt=$((${mepos[0]}+${mepos[2]})) ;;
up ) mpnt=${mepos[1]} ;;
down ) mpnt=$((${mepos[1]}+${mepos[3]})) ;;
esac
if [[ $drt = $oppdir ]]; then
mapos=$(getpos $maroot)
mapos=(${mapos//,/' '})
case $dcrsplt in
left ) opnt=${mapos[0]} ;;
right ) opnt=$((${mapos[0]}+${mapos[2]})) ;;
up ) opnt=${mapos[1]} ;;
down ) opnt=$((${mapos[1]}+${mapos[3]})) ;;
esac
elif [[ $drt = $dcrsplt ]] && [[ $dcrt != right ]]; then
[[ $drt =~ left|up ]] && opnt=0 || opnt=$scrnh
elif [[ $drt != $oppdir ]] && [[ $drt != $dcrsplt ]] \
&& [[ $drt != right ]] ; then
[[ $drt =~ left|up ]] && opnt=0 || opnt=$scrnh
elif [[ -n $sbex ]] && [[ $mod = mov ]]; then
opnt=$(getpos $sbroot)
opnt=${opnt%%,*}
else
opnt=$scrnw
fi
rslt=$((opnt-mpnt))
[[ $rslt -lt 0 ]] && rslt=$((rslt*-1))
if [[ $rslt -lt 20 ]] && [[ $drt = $oppdir ]]; then
if [[ $mod = mov ]]; then
mcnt=$(configget global-settings-main)
nmrk="${cws:=$(wsget)}_main_${mcnt}_${mapp}_${wid}_#"
i3-msg [con_id=$wid] move to mark $markro, \
focus, unmark, mark $nmrk
else
# focus visible tab in main
local tabsinmain=($(tabget -n $maroot))
i3-msg [con_id=${tabsinmain[0]}] focus
fi
else
[ $rslt -lt 20 ]] && return
[[ $mod = mov ]] && i3-msg [con_id=$wid] move $drt \
|| i3-msg focus $drt
fi
fi
elif [[ $hit = main ]]; then
nmrk="${cws:=$(wsget)}_split${drt}_main_${mapp}_${wid}_#"
acrsplt=(${cnts[split${drt}]:0:-1})
ncrsplt=${#acrsplt[@]}
if [[ $mod = foc ]]; then
if [[ $ncrsplt -gt 0 ]] || [[ -n $sbex ]]; then
if [[ $drt = right ]] && [[ ! $ncrsplt -gt 0 ]]; then
local tabsinside=($(tabget -n $sbroot))
i3-msg [con_id=${tabsinside[0]}] focus
fi
i3-msg [con_mark="${acrsplt[0]}"] focus
fi
return
fi
if [[ $drt =~ up|down ]]; then
i3-msg [con_mark=${cws}_alfa] split vertical
if [[ $ncrsplt -gt 0 ]]; then
i3-msg [con_id=$wid] \
move to mark ${acrsplt[0]}, unmark, \
mark $nmrk, split horizontal
i3-msg [con_mark="${acrsplt[0]}"] move to mark $nmrk
i3-msg [con_id=$wid] focus
else
i3-msg [con_id=$wid] move $drt, focus, unmark, \
mark $nmrk, split horizontal
fi
elif [[ $drt = left ]]; then
i3-msg [con_mark=${cws}_alfa] split horizontal
[[ $ncrsplt -gt 0 ]] && i3-msg [con_id=$wid] \
move to mark ${acrsplt[0]}, focus, unmark, \
mark $nmrk, split vertical \
|| i3-msg [con_id=$wid] move to mark $markro, move $drt, \
move $drt, focus, unmark, mark $nmrk, split vertical
else
i3-msg [con_mark=${cws}_alfa] split horizontal
[[ $ncrsplt -gt 0 ]] && i3-msg [con_id=$wid] \
move to mark ${acrsplt[0]}, focus, unmark, \
mark $nmrk, split vertical \
|| i3-msg [con_id=$wid] move to mark ${cws}_alfa, \
focus, unmark, mark $nmrk, split vertical
fi
i3-msg [con_mark=${cws}_space] split horizontal
elif [[ $hit = sidebar ]] && [[ $drt != right ]]; then
if [[ $drt = left ]]; then
acrsplt=(${cnts[split${drt}]:0:-1})
ncrsplt=${#acrsplt[@]}
if [[ $ncrsplt -gt 0 ]]; then
i3-msg [con_mark="${acrsplt[0]}"] focus
else
local tabsinmain=($(tabget -n $maroot))
i3-msg [con_id=${tabsinmain[0]}] focus
fi
else
i3-msg focus $drt
fi
fi
fi
}
getpos(){
[[ -z $tre ]] && treeset
local crit= line= rets= lajn=
crit='"id":'${1}
line="$(printf "${tre}" | grep -m1 -A16 ${crit} | tail -4)"
line=${line:0:-1}
for lajn in ${line}; do
rets+="${lajn##*:},"
done
echo ${rets:0:-1}
}
# ------------ misc ------------
subtree(){
# ? creates a tempfile with output from 13-msg and open it in sublime
# ? subtree [[marks|m]|[tree|t]|[workspaces|w]]
local what=${1:-tree}
case $what in
t) what=get_tree;;
w) what=get_workspaces;;
m) what=get_marks;;
*) what=get_$what;;
esac
local rslt=$(i3-msg -t $what)
rslt="${rslt:1:-1}"
[[ -n $2 ]] && echo ${rslt} && return
printf "${rslt//\,/'\n'}" \
> /tmp/testis && subl /tmp/testis
}
# :::::::::: AUTOEXECUTE ::::::::::
declare -A gla=()
declare -A lyzed=()
shopt -s extglob
cnf= tre= cws= showkeys=
while getopts :c:udhk option; do
case "${option}" in
c) optfile=${OPTARG};;
u) optdebg=1;;
d) dryrun=1;;
k) showkeys=1;;
h) about && exit ;;
esac
done
shift $((--OPTIND))
case "$1" in
help|about|info|'' ) about ;;
in ) init ;;
sb ) shift 1;
[[ -n $showkeys ]] && keydisplay "Mod + backspace" "i3ass sb" "toggle sidebar" \
|| sknk="" && sbtoggle ${@} ;;
al ) shift 1;
[[ -n $showkeys ]] && keydisplay "Mod + ${@}" "i3ass al ${@}" "launch app" \
|| sknk="" && applaunch ${@} ;;
tr ) shift 1; treeget ${@} ;;
wg ) shift 1; winget ${@} ;;
wf ) shift 1;
[[ -n $showkeys ]] && keydisplay "Mod + f" "i3ass wf" "toggle floating" \
|| sknk="" && winfloat ${@} ;;
st ) shift 1; subtree ${@} ;;
dt ) shift 1;
[[ -n $showkeys ]] && keydisplay "Mod + d" "i3ass dt" "toggle desktop" \
|| sknk="" && desktop ${@} ;;
fo ) shift 1;
[[ -n $showkeys ]] && keydisplay "Mod + ${@}" "i3ass fo ${@}" "shift focus" \
|| sknk="" && winmove -b foc -d ${@} ;;
ws ) shift 1; winsplit ${@} ;;
wm ) shift 1;
[[ -n $showkeys ]] && keydisplay "Mod + shift + ${@}" "i3ass wm ${@}" "move window" \
|| sknk="" && winmove -b mov -d ${@} ;;
ts ) shift 1; tabswitch ${@} ;;
lo ) shift 1; loapply ${@} ;;
tg ) shift 1; tabget ${@} ;;
mg ) shift 1; markget ${@} ;;
cg ) shift 1; configget ${@} ;;
gw ) shift 1; winghost ${@} ;;
la ) shift 1; listapps ${@} ;;
* ) ${@} ;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment