Skip to content

Instantly share code, notes, and snippets.

@DanielFGray
Last active August 19, 2016 19:50
Show Gist options
  • Save DanielFGray/22d19a913ee3ab1725202731d8278e28 to your computer and use it in GitHub Desktop.
Save DanielFGray/22d19a913ee3ab1725202731d8278e28 to your computer and use it in GitHub Desktop.
wm agnostic workspace indicator
#!/usr/bin/env bash
declare activeWorkspace="*%s"
declare inactiveWorkspace=" %s"
declare separator=" │ "
xprop -spy -root |
awk -v inactiveWorkspace="$inactiveWorkspace" \
-v activeWorkspace="$activeWorkspace" \
-v separator="$separator" -F' = ' '
function printWorkspace(current, names) {
++current;
gsub("\"", "", names);
n = split(names, a, ", ");
printf "\n";
for(i = 0; ++i <= n;) {
if(current == i) {
printf activeWorkspace, a[i];
} else {
printf inactiveWorkspace, a[i];
}
if(i != n) printf separator;
}
system("");
}
BEGIN { active=0; workspaces=""; }
"_NET_CURRENT_DESKTOP(CARDINAL)" == $1 { if($2 != active) { active=$2; printWorkspace(active, workspaces); } }
"_NET_DESKTOP_NAMES(UTF8_STRING)" == $1 { if($2 != workspaces) { workspaces=$2; printWorkspace(active, workspaces); } }
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment