Skip to content

Instantly share code, notes, and snippets.

@gcoda
Created October 4, 2015 05:06
Show Gist options
  • Save gcoda/8d0163e48063a868be51 to your computer and use it in GitHub Desktop.
Save gcoda/8d0163e48063a868be51 to your computer and use it in GitHub Desktop.
Summons windows from any workspace to current container, if window alredy inside current workspace just changes focus to it
#!/bin/sh
#based on https://github.com/minos-org/minos-tools/blob/master/tools/dmenu-i3-window-jumper
DMENU="rofi -dmenu -i -p Summon: "
if ! command -v "rofi" >/dev/null 2>&1; then
printf "%s\\n" "you need to install 'dmenu' to run this program" >&2
exit 1
fi
TITLE="$(i3-msg -t get_tree | egrep -o "(class.:.[a-Z]+.|title.:.[()0123456789~. -/a-Z]+)" | \
sed 's/"//g;s/class://g;s/title://g' | while read -r line; read -r line2; do printf "%s\\n" "═ $line :: $line2"; done | sed '/i3bar for/d' | ${DMENU})"
if [ -z "${TITLE}" ]; then
exit 1
else
# Escape some characters to prevent i3 to interpret them as a pattern
# "(" and ")" replace them with "\(" and "\)"
#TITLE="$(printf "%s\\n" "${TITLE}" | sed 's/\([()]\)/\\\1/g')"
TITLE="$(printf "%s\\n" "${TITLE}" | egrep -o "::.*" | sed 's/:: //g;s/\([()]\)/\\\1/g')"
i3-msg "[title=\"${TITLE}\"] move workspace current"
i3-msg "[title=\"${TITLE}\"] focus"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment