Created
February 2, 2015 21:33
-
-
Save kalda341/6df589e0bb62fa98e66c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/bash | |
get_focus() { [[ $1 == "true" ]] && echo 1 || echo 0; } | |
# read workspace data into an associative array | |
i=0 | |
focus=0 | |
declare -A ws_data | |
prior_monitor=0 | |
while read line; do | |
[[ -z $line ]] && continue | |
if (( i%3 == 0 )); then | |
focus=$(get_focus "$line") | |
elif (( i%3 == 1 )); then | |
ws_data[$line]=$focus | |
else | |
if ["$prior_monitor" -ne "$line"]; then | |
fi | |
fi | |
((i++)) | |
done < <(i3-msg -t get_workspaces | jshon -a -e focused -u -p -e name -u -p -e output -u) | |
for name in "${!ws_data[@]}"; do | |
printf '${color%d}%s ' "${ws_data[$name]}" "$name" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment