summaryrefslogtreecommitdiff
path: root/enforce-configurations
diff options
context:
space:
mode:
Diffstat (limited to 'enforce-configurations')
-rwxr-xr-xenforce-configurations53
1 files changed, 53 insertions, 0 deletions
diff --git a/enforce-configurations b/enforce-configurations
new file mode 100755
index 0000000..d1c4051
--- /dev/null
+++ b/enforce-configurations
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+set -e
+
+VERBOSE=0
+
+is_profile()
+{
+ local directory=$1
+
+ [ -f "$directory/bookmarks" ]
+}
+
+echo_debug()
+{
+ if [ $VERBOSE != 0 ]
+ then
+ echo $@
+ fi
+}
+
+for dir in ${XDG_CONFIG_HOME:-~/.config/dwb}/*
+do
+ profile=`basename "$dir"`
+ if is_profile $dir
+ then
+ echo_debug "Enforcing configuration for dwb profile $profile."
+ existing_config=`awk < ${XDG_CONFIG_HOME:-~/.config/dwb/}/settings \
+ "/\[$profile\]/ { print ; while (/./ && getline) { print } }"`
+ echo_debug " "existing_config: `echo "$existing_config"|wc -l` \
+ `echo "$existing_config"|head -1`
+
+ dwb_execute=""
+ for config_option in `cat ~/.go/config|cut -d= -f1`
+ do
+ config_value=`cat ~/.go/config|sed --silent "s/$config_option=//p"`
+ if (echo "$existing_config"|
+ grep -q "`echo $config_option=$config_value`")
+ then
+ :
+ else
+ dwb_execute="${dwb_execute:+$dwb_execute;; }set $config_option $config_value"
+ fi
+ done
+ if ps xaf|grep dwb|grep --quiet =$profile
+ then
+ echo "A browser using the $profile profile seems to be running. Skipping it."
+ else
+ echo_debug " config command: $dwb_execute"
+ [ -z "$dwb_execute" ] || dwb --profile="$profile" --execute="$dwb_execute;; quit" &
+ fi
+ fi
+done