#!/bin/sh

# TODO make image dmenu selectable
imageFilename="$HOME/Dropbox/learn/stenography/uni-layout.png"

if [ ! -f $noteFilename ]; then
  echo "File $imageFilename is not there, aborting."
  exit
fi

kitty +kitten icat $imageFilename &
# sxiv $imageFilename &
pid="$!"

# Wait for the window to open and grab its window ID
winid=''
while : ; do
    winid="`wmctrl -lp | awk -vpid=$pid '$3==pid {print $1; exit}'`"
    [[ -z "${winid}" ]] || break
done

# Focus the window we found
wmctrl -ia "${winid}"

# Make it float
i3-msg floating enable > /dev/null;

# Move it to the center for good measure
i3-msg move position center > /dev/null;

# Wait for the application to quit
wait "${pid}";