#!/bin/bash

thunar -q

# step 2: add our files to code tree #normaly a diff file merge is used
mkdir $HOME/thunar-dev/examples/menuplugin/
cp --verbose $HOME/menuplugin/plugin/menu-plugin.c $HOME/thunar-dev/examples/menuplugin/
cp --verbose $HOME/menuplugin/plugin/menu.c $HOME/thunar-dev/examples/menuplugin/
cp --verbose $HOME/menuplugin/plugin/menu.h $HOME/thunar-dev/examples/menuplugin/
cp --verbose $HOME/menuplugin/plugin/Makefile.am $HOME/thunar-dev/examples/menuplugin/

# step 3: append string "foo-plugin" as sub-dir
#patch --strip=4 --directory=$HOME/thunar-dev/ --input=$HOME/menuplugin/patches/Makefile.am.patch

# step 4: onder the line: 'examples/tex-open-terminal/Makefile' append the following: 'examples/foo/Makefile'
#patch --strip=4 --directory=$HOME/thunar-dev/ --input=$HOME/menuplugin/patches/configure.in.patch

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"

# step 6: check for the following files
ls -hal $HOME/thunar-dev/examples/menuplugin/
[ -e $HOME/thunar-dev/examples/menuplugin/menu.la ] && echo exist
[ -e $HOME/thunar-dev/examples/menuplugin/menu_la-foo.lo ] &&  echo exist
[ -e $HOME/thunar-dev/examples/menuplugin/menu_la-foo-plugin.lo ] &&  echo exist
[ -e $HOME/thunar-dev/examples/menuplugin/Makefile.in ]  && echo exist

cd  $HOME/thunar-dev/examples/menuplugin/
sudo make install-extensionsLTLIBRARIES
thunar -q
# step 8: run thunar and right click a directory and watch the output
bash -e $HOME/thunar-dev/thunar/Thunar
