Compare commits

..

No commits in common. "incomplete" and "main" have entirely different histories.

View file

@ -24,22 +24,7 @@ class _Config:
logger.critical("The general dictionary was not found or contains errors") logger.critical("The general dictionary was not found or contains errors")
print("CRITICAL: The general dictionary was not found or contains errors") print("CRITICAL: The general dictionary was not found or contains errors")
raise ConfigError("The general dictionary was not found or contains errors") raise ConfigError("The general dictionary was not found or contains errors")
if not self._validate_fallback_wallpaper(): # Changing times
print("ERROR: Cannot use a fallback wallpaper: Incorrect type.")
logger.error("Cannot use a fallback wallpaper: Incorrect type.")
else:
logger.debug("Will use a fallback wallpaper")
if not self._validate_types():
logger.critical("Wallman encountered incompatible types in critical variables. exiting.")
print("CRITICAL: Wallman encountered incompatible types in critical variables. exiting.")
raise ConfigError("Wallman encountered incompatible types in critical variables.")
else:
logger.debug("All critical types match the required type.")
self.use_fallback_wallpaper: bool = self._validate_fallback_wallpaper():
if not self.use_fallback_wallpaper:
logger.warning("No fallback wallpaper will be used.")
else:
logger.debug(f"Using Fallback wallpaper: {self.config_fallback_wallpaper}")
valid_changing_times: bool = self._initialize_changing_times() valid_changing_times: bool = self._initialize_changing_times()
if not valid_changing_times: if not valid_changing_times:
logger.critical( logger.critical(
@ -144,12 +129,19 @@ class _Config:
return behavior return behavior
def _set_fallback_wallpaper(self) -> None: def _set_fallback_wallpaper(self) -> None:
if self.use_fallback_wallpaper: if self.config_fallback_wallpaper:
system(f"feh {self.config_behavior} --no-fehbg {self.config_fallback_wallpaper}") successfully_set: int = system(
f"feh {self.config_behavior} --no-fehbg {self.config_fallback_wallpaper}"
)
if successfully_set == 0:
logger.info("The fallback Wallpaper has been set.") logger.info("The fallback Wallpaper has been set.")
else: else:
logger.critical("An Error occured and not being used. Exiting...") logger.critical(
raise ConfigError("An Error occured and not being used.") "An Error occured and no fallback wallpaper was provided, exiting..."
)
raise ConfigError(
"An error occured and no fallback wallpaper has been set, exiting..."
)
def _initialize_general(self) -> bool: def _initialize_general(self) -> bool:
# Create Config General Dict # Create Config General Dict
@ -306,86 +298,13 @@ class _Config:
return False return False
except ConfigError: except ConfigError:
logger.critical( logger.critical(
f"Dictionary {wallpaper_set} does not have sufficient entries, exiting..." f"Dictionary {wallpaper_set} does not have sufficient entries, exciting..."
) )
print( print(
f"Dictionary {wallpaper_set} does not have sufficient entries, exiting..." f"Dictionary {wallpaper_set} does not have sufficient entries, exciting..."
) )
return False return False
def _validate_fallback_wallpaper(self) -> bool:
if not isinstance(self.config_fallback_wallpaper, str):
logger.error("The type of fallback_wallpaper in the config file is incorrect. Should be string.")
print("ERROR: The type of fallback_wallpaper in the config file is incorrect. Should be string.")
return False
if not path.isfile(self.config_fallback_wallpaper):
logger.error("No fallback wallpaper with the specified name could be found.")
print("ERROR: No fallback wallpaper with the specified name could be found.")
return False
logger.debug("The Type of the fallback wallpaper is correct and it exists.")
return True
def _validate_types(self) -> bool:
# Loglevel
if not isinstance(self.config_log_level, str) and not isinstance(self._set_log_level, int):
logger.critical("Expected type of loglevel to be int or str. Got incorrect type. Exiting...")
print("CRITICAL: Expected type of loglevel to be int or str. Got incorrect type. Exiting...")
self._set_fallback_wallpaper()
return False
else:
logger.debug("The type for loglevel in the config has a valid type.")
# Wallpapers per set
if not isinstance(self.config_wallpapers_per_set, int):
logger.critical("The type of wallpaper_per_set in the config is incorrect. Expected int.")
print("CRITICAL: The type of wallpaper_per_set in the config is incorrect. Expected int.")
return False
else:
logger.debug("The type of wallpapers_per_set is correct.")
# enable_wallpaper_sets
if not isinstance(self.config_wallpaper_sets_enabled, bool):
logger.critical("The type of enable_wallpaper_sets is incorrect. Expected bool.")
print("CRITICAL: The type of enable_wallpaper_sets is incorrect. Expected bool.")
else:
logger.debug("The type of enable_wallpaper_sets is bool.")
# used_sets
if not isinstance(self.config_used_sets, list):
logger.critical("The type of used_sets in the config is not an array, exiting.")
print("CRITICAL: The type of used_sets in the config is not an array, exiting.")
else:
logger.debug("used_sets is an array")
for i in range(self.config_wallpapers_per_set):
if not isinstance(self.config_used_sets[i], str):
print(f"CRITICAL: The type of index {i} in used_sets in the config is not str. Exiting...")
logger.critical(f"The type of index {i} in used_sets in the config is not str. Exiting...")
return False
else:
logger.debug(f"The type of index {i} of used_sets in the config is correct.")
logger.debug("used_sets is a list of strings.")
# systray
if not isinstance(self.config_systray, bool):
logger.error("The type of systray in the config is not a bool. Defaulting to true.")
print("ERROR: The type of systray in the config is not a bool. Defaulting to true.")
else:
print("The type of systray in the config is correct.")
# Wallpaper behavior
if not isinstance(self.config_behavior, str):
print("ERROR: The type of behavior in the config file is not str. Defaulting to fill.")
logger.error("The type of behavior in the config file is not str. Defaulting to fill.")
else:
logger.debug("The type of behavior in the config file is str.")
# notifications
if not isinstance(self.config_notify, bool):
logger.error("The type of notify in the config is not bool, defaulting to False")
print("ERROR: The type of notify in the config is not bool, defaulting to False")
else:
logger.debug("The type of notify in the config is bool.")
return True
# TODO: Improve modularity. See notes inside the class for more details. # TODO: Improve modularity. See notes inside the class for more details.
# TODO: Ensure functionality and if needed add handling for the 1 wallpaper per set case. # TODO: Ensure functionality and if needed add handling for the 1 wallpaper per set case.