Skip to content

Instantly share code, notes, and snippets.

@floffy-f
Last active August 26, 2024 10:53
Show Gist options
  • Select an option

  • Save floffy-f/62d08d2a32194d39e02bed815ffa00fe to your computer and use it in GitHub Desktop.

Select an option

Save floffy-f/62d08d2a32194d39e02bed815ffa00fe to your computer and use it in GitHub Desktop.
#!/bin/bash
# Put thins in your i3 block:
# workspace_command /usr/local/bin/custom_zellij_bar.sh
# Output readale by i3-bar
RESULT="[{
\"id\": 1,
\"num\": 1,
\"name\": \"<flag>\",
\"focused\": true,
\"output\": \"eDP-1\",
\"urgent\": false
}]"
PATTERN=#Fill the pattern your i3 displays after the Zellij session name. For me something like <myusername@machine-somedigits>:cdir
i3-msg -t subscribe -m '["window"]' | {
while read p; do
NAME=$(echo $p | jq -r .container.name | sed -n /Zellij/p | sed 's/Zellij (\(.\+\)) - $PATTERN:\(.\+\)/\1 - (\2)/g' | sed 's/\//\\\//g')
echo $RESULT | sed "s/<flag>/$NAME/g"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment