#!/bin/bash
# launch labwc-tweaks-gtk, then after exit
# run ptheme_gtk if dconf file has changed

dconffile=$HOME/.config/dconf/user
md51=$(md5sum "$dconffile" | cut -d' ' -f1)
/usr/bin/labwc-tweaks-gtk
sync
sleep 2
md52=$(md5sum "$dconffile" | cut -d' ' -f1)
LABWC_XKB_LAYOUT="`grep 'XKB_DEFAULT_LAYOUT' $HOME/.config/labwc/environment 2>/dev/null | cut -f2 -d'='`"
XKBRC_XKB_LAYOUT="`grep 'XKB_DEFAULT_LAYOUT' $HOME/.xkbrc 2>/dev/null | cut -f2 -d'='`"
if [ "$md52" != "$md51" ] || [ "$LABWC_XKB_LAYOUT" != "$XKBRC_XKB_LAYOUT" ]; then
   /usr/bin/ptheme_gtk
   labwc -r
   killall -SIGHUP sfwbar &
fi
