Skip to content

Instantly share code, notes, and snippets.

@untoreh
Created April 10, 2017 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save untoreh/24e36b14137556e90dd1613086aa4e0b to your computer and use it in GitHub Desktop.
Save untoreh/24e36b14137556e90dd1613086aa4e0b to your computer and use it in GitHub Desktop.
incremental steps i3wm window move command
#!/bin/sh
verse=$1
stu=20
tapf=/tmp/i3-tap
stepf=/tmp/i3-step
verf=/tmp/i3-verse
if [ ! -f $tapf ] ; then
echo `date +%s` > $tapf
fi
if [ ! -f $verf ] ; then
echo $verse > $verf
lverse=$verse
else
lverse=`cat $verf`
echo $verse > $verf
fi
last=`cat $tapf`
current=`date +%s`
if [ ! -f $stepf ] ; then
echo $stu > $stepf
step=$stu
else
cstep=`cat $stepf`
step=$(( cstep + $stu )) > $stepf
fi
if [ "$verse" = "$lverse" -a $(( current - last )) -lt 2 ] ; then
i3-msg move $verse $step
echo $step > $stepf
else
i3-msg move $verse $stu
echo $stu > $stepf
fi
echo $current > $tapf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment