From 06616836d10b10b5c78d517d3d212187d6e2f130 Mon Sep 17 00:00:00 2001
From: sinanmohd <pcmsinan@gmail.com>
Date: Sat, 18 Feb 2023 16:23:48 +0530
Subject: configs: game profiles can now override soibox configs the proper
 precedence order is listed below in descending order * command line arguments
 * game profiles * ~/.config/soibox/soibox.conf * /etc/soibox/soibox.conf

---
 example/example.sb | 10 +++++-----
 soibox             | 14 +++++++-------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/example/example.sb b/example/example.sb
index 87b9956..4417fc7 100644
--- a/example/example.sb
+++ b/example/example.sb
@@ -3,12 +3,14 @@
 #    acording to the game profile location
 # 2) if an option is specified in the soibox config
 #    its ignored from game profiles unless specified
-# 3) soibox config is located at ~/.config/soibox/soibox.conf, this applies
-#    to all games, game profiles are specific to each game
+# 3) soibox config is located at /etc/soibox/soibox.conf and ~/.config/soibox/soibox.conf,
+#    this applies to all games, game profiles are specific to each game
+# 4) command line arguments overrides game profiles overrides ~/.config/soibox/soibox.conf
+#    overrides /etc/soibox/soibox.conf
 
 # use mangohud perfomance overlay, the value can either be on, 1,2,3,4 or path to
 # a mangohud config. 1 being just the fps and 4 being the most verbose option,
-# mangohud : 3
+# mangohud : 2
 
 # 4 options 0,1,2,3. 1 outputs just progress bars and banners, 3 being the most verbose
 # loglevel : 1
@@ -48,8 +50,6 @@
 # path to wine prefix
 # wine_prefix : path/to/wine/prefix
 
-# note: this does not ignore game profile if specified in the soibox config
-# but appends game profile version to the config
 # WINEDLLOVERRIDES
 # winedll_ovrids : mshtml=d
 
diff --git a/soibox b/soibox
index 381be5b..2c931d0 100755
--- a/soibox
+++ b/soibox
@@ -108,7 +108,7 @@ parse_config()
 			: "${wine:=$val}"
 			;;
 		winedll_ovrids)
-			winedll_ovrids="${winedll_ovrids:+${winedll_ovrids};}${val}"
+			: "${winedll_ovrids:=$val}"
 			;;
 		wine_tag)
 			: "${wine_tag:=$val}"
@@ -473,7 +473,6 @@ setup_mangohud()
         : "${1:?setup_mangohud: empty \$1}"
 
 	MANGOHUD_CONFIG=
-	mangohud=on
 	dep_check "mangohud"
 
 	case "$1" in
@@ -498,8 +497,7 @@ setup_mangohud()
 			MANGOHUD_CONFIGFILE="$(absolute_path "$mangohud" "$local_config" )"
 			export MANGOHUD_CONFIGFILE
 		else
-			warn "config, mangohud, ${1}, invalid option"
-			mangohud=off
+			warn "config, mangohud, ${1}, invalid option, falling back to default layout"
 		fi
 		;;
 	esac
@@ -578,9 +576,11 @@ main()
 
 	# parse input
 	parse_opts "$@"
-	[ -f "$config_dir/soibox.conf" ] && [ "$ignore_globalconf" != true ]
-		parse_config "$config_dir/soibox.conf"
 	parse_config "$local_config"
+	[ -f "$config_dir/soibox.conf" ] && [ "$ignore_globalconf" != true ] &&
+		parse_config "$config_dir/soibox.conf"
+	[ -f "/etc/soibox/soibox.conf" ] && [ "$ignore_globalconf" != true ] &&
+		parse_config "/etc/soibox/soibox.conf"
 	: "${loglevel:=1}"
 
 	# validate input
@@ -649,7 +649,7 @@ main()
 
 	[ -n "$wine" ] &&
 		cmd="${wine_exe} ${cmd}"
-	[ "$mangohud" = on ] &&
+	[ -n "$mangohud" ] &&
 		cmd="mangohud ${cmd}"
 	[ "$gamemode" = on ] && dep_check "gamemoderun" &&
 		cmd="gamemoderun ${cmd}"
-- 
cgit v1.2.3