- Fixed regression caused by config not being imported when auto-HDR is toggled.

Monitor Setup:
- Log file creation.
- Increased verbosity.
- Basic config validation.
This commit is contained in:
2025-10-10 19:49:15 +01:00
parent 766ce8542d
commit dbc9afbbdf
3 changed files with 29 additions and 6 deletions
Vendored
+1
View File
@@ -0,0 +1 @@
monitor-setup.log
+3 -1
View File
@@ -148,7 +148,8 @@ import_config() {
exit -2 exit -2
fi fi
else else
echo "Error: monitor.conf file not found. Please ensure it's been properly setup." echo "Error: monitor.conf file not found. Please ensure it's been properly setup."
echo "Try running 'hdr-helper -a' to try automatically generating one."
exit -3 exit -3
fi fi
} }
@@ -172,6 +173,7 @@ elif [[ $1 == "-t" ]] || [[ $1 == "--test" ]]; then
elif [[ $1 == "-a" ]] || [[ $1 == "--auto-setup-conf-file" ]]; then elif [[ $1 == "-a" ]] || [[ $1 == "--auto-setup-conf-file" ]]; then
setup_conf_file setup_conf_file
elif [[ $# -eq 0 ]]; then # Automatically Toggle HDR | Default Behaviour elif [[ $# -eq 0 ]]; then # Automatically Toggle HDR | Default Behaviour
import_config
auto_hdr auto_hdr
else else
show_help show_help
+25 -5
View File
@@ -55,13 +55,20 @@ class MonitorSetup():
if search_output: if search_output:
self.output_name = search_output.group(1) self.output_name = search_output.group(1)
def print_display_info(self): def log_display_info(self):
print(f"Output Name: {self.output_name}") _log_file = "monitor-setup.log"
print(f"Default Mode: {self.default_mode}") with open(_log_file, "w") as file:
print(f"Alternative Rate: {self.alt_rate}") file.write(f"Output Name: {self.output_name}\n")
print(f"Alternative Resolution and Rate: {self.alt_res_and_rate}") file.write(f"Default Mode: {self.default_mode}\n")
file.write(f"Alternative Rate: {self.alt_rate}\n")
file.write(f"Alternative Resolution and Rate: {self.alt_res_and_rate}")
if os.path.isfile(_log_file):
print(f"Log file was written to {os.path.join(os.getcwd(),_log_file)}")
def edit_config_file(self): def edit_config_file(self):
_validation_check_cnt = 0
if os.path.isfile(self._stg_conf_file): if os.path.isfile(self._stg_conf_file):
with open(self._stg_conf_file, "r") as file: with open(self._stg_conf_file, "r") as file:
lines = file.readlines() lines = file.readlines()
@@ -70,18 +77,30 @@ class MonitorSetup():
for line in lines: for line in lines:
if "MONITOR=" in line: if "MONITOR=" in line:
line = line.replace("MONITOR=\n", f"MONITOR={self.output_name}\n") line = line.replace("MONITOR=\n", f"MONITOR={self.output_name}\n")
_validation_check_cnt += 1
elif "NATIVE_RES=" in line: elif "NATIVE_RES=" in line:
line = line.replace("NATIVE_RES=\n", f"NATIVE_RES={self.default_mode}\n") line = line.replace("NATIVE_RES=\n", f"NATIVE_RES={self.default_mode}\n")
_validation_check_cnt += 1
# Prefer alt_rate if available, otherwise alt_res_and_rate # Prefer alt_rate if available, otherwise alt_res_and_rate
if "TEMP_RES=" in line: if "TEMP_RES=" in line:
if self.alt_rate: if self.alt_rate:
line = line.replace("TEMP_RES=\n", f"TEMP_RES={self.alt_rate}\n") line = line.replace("TEMP_RES=\n", f"TEMP_RES={self.alt_rate}\n")
_validation_check_cnt += 1
elif self.alt_res_and_rate: elif self.alt_res_and_rate:
line = line.replace("TEMP_RES=\n", f"TEMP_RES={self.alt_res_and_rate}\n") line = line.replace("TEMP_RES=\n", f"TEMP_RES={self.alt_res_and_rate}\n")
_validation_check_cnt += 1
file.write(line) file.write(line)
if _validation_check_cnt != 3:
print("❌ Automation configuration failed, one or more settings could not be detected.")
self.log_display_info()
exit(-1)
if not os.path.isfile(self._stg_conf_file):
print("❌ Error creating configuration file.")
def copy_config_file(self): def copy_config_file(self):
if not os.path.exists(self._conf_file_dir): if not os.path.exists(self._conf_file_dir):
os.makedirs(self._conf_file_dir) os.makedirs(self._conf_file_dir)
@@ -93,6 +112,7 @@ class MonitorSetup():
# Copy staging config file to target location # Copy staging config file to target location
if os.path.isfile(self._stg_conf_file): if os.path.isfile(self._stg_conf_file):
shutil.copy(self._stg_conf_file, self._conf_file_path) shutil.copy(self._stg_conf_file, self._conf_file_path)
print(f"✅ Configuration file was copied to location: {self._conf_file_path}")
setup = MonitorSetup() setup = MonitorSetup()