Skip to content

Instantly share code, notes, and snippets.

@jjrh
Created July 31, 2016 17:00
Show Gist options
  • Save jjrh/c9ffd151302c7215a36c750e11c7b018 to your computer and use it in GitHub Desktop.
Save jjrh/c9ffd151302c7215a36c750e11c7b018 to your computer and use it in GitHub Desktop.
For swapping between a vertical config of tint2 and a horizontal config.
#!/bin/bash
getPID()
{
echo $1 | cut -f1 -d ' '
}
# create list of tint2 that are running
IFS=$'\n'
tints=( $(ps ax | grep tint2 | grep -v grep) )
# no tint2 process exists
if [ ${#tints[@]} -eq 0 ]; then
tint2 >> /dev/null 2> /dev/null &
exit
fi
# there are two running, just kill the first one.
if [ ${#tints[@]} -eq 2 ]; then
kill $(getPID ${tints[0]})
exit
fi
# okay only one is running...
# we echo/grep to get the return code for which tint2 is running.
echo ${tints[0]} | grep tint2 | grep -v tint2_verticalrc | grep -v grep >> /dev/null
if [ $? -eq 1 ]; then # tint2_verticalrc is running
getPID ${tints[0]}
kill $(getPID ${tints[0]})
tint2 >> /dev/null 2> /dev/null &
exit
else # tint2 horizontal is running
kill $(getPID ${tints[0]})
tint2 -c ~/.config/tint2/tint2_verticalrc >> /dev/null 2> /dev/null &
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment