summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2014-06-01 17:54:41 +0200
committercos <cos>2014-06-01 17:54:41 +0200
commit56b5bdcf49cd9e8f1dd8f32aad344fc316126824 (patch)
treeacebdffe6579a2555f6d9901ad09f8d525ea2335
parent17926a34038676f3fc7e4bef77410f8cbe14b835 (diff)
parent8045f78b9c6df38dd44a665ed0619ec5dd560991 (diff)
downloadgo-webbrowser-launcher-56b5bdcf49cd9e8f1dd8f32aad344fc316126824.zip
Merge branch 'master' into debian
-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