Compare commits
No commits in common. "9ba75569c9c644ad66fbedbf0cb1cf5ab25d8826" and "e38d61cf5cf5be5c8704c1d21b66df8d7beb3a75" have entirely different histories.
9ba75569c9
...
e38d61cf5c
3 changed files with 10 additions and 53 deletions
|
@ -41,7 +41,7 @@ This is a short guide on how to correctly configure wallman. Look in the sample
|
||||||
** TOML Dictionaries
|
** TOML Dictionaries
|
||||||
First of all, the config file is structured via different TOML dictionaries. There are two TOML dictionaries: general and changing_times that must be present in every config. Aside from that, further dictionaries are needed depending on how wallman is configured. You need to create a dictionary with the name of each wallpaper set defined in the used_sets list (more on that later). You should probably just configure wallman by editing the sample config as it is by far the easiest way to do it.
|
First of all, the config file is structured via different TOML dictionaries. There are two TOML dictionaries: general and changing_times that must be present in every config. Aside from that, further dictionaries are needed depending on how wallman is configured. You need to create a dictionary with the name of each wallpaper set defined in the used_sets list (more on that later). You should probably just configure wallman by editing the sample config as it is by far the easiest way to do it.
|
||||||
*** general
|
*** general
|
||||||
In general, you need to always define 3 variables and you can optionally add two more:
|
In general, you need to always define 3 variables and you can optionally add one more:
|
||||||
+ enable_wallpaper_sets: bool
|
+ enable_wallpaper_sets: bool
|
||||||
A simple switch that states if you want to use different sets of wallpapers or not.
|
A simple switch that states if you want to use different sets of wallpapers or not.
|
||||||
+ used_sets: list
|
+ used_sets: list
|
||||||
|
@ -50,8 +50,6 @@ In general, you need to always define 3 variables and you can optionally add two
|
||||||
The amount of wallpapers that you use in each set. It should be an integer.
|
The amount of wallpapers that you use in each set. It should be an integer.
|
||||||
+ Optional: notify: bool
|
+ Optional: notify: bool
|
||||||
This defaults to "false". Enable to set send a desktop notification when the wallpaper is changed. The program will still work correctly, even if this option is not defined at all.
|
This defaults to "false". Enable to set send a desktop notification when the wallpaper is changed. The program will still work correctly, even if this option is not defined at all.
|
||||||
+ Optional: fallback_wallpaper: bool
|
|
||||||
Wallpaper to be set if an error is found in the config. Defaults to None. If none is set and the config is written incorrectly, a ConfigError is raised and the program is exited. If an error in the config occurs but the fallback wallpaper has been defined, it will be set and wallman will exit with Code 1.
|
|
||||||
|
|
||||||
*** changing_times
|
*** changing_times
|
||||||
The changing_times dictionary is used to specify the times of the day when your wallpaper is switched. The names of the keys do not matter here, the values must always be strings in the "XX:YY:ZZ" 24 hour time system. use 00:00:00 for midnight. Note that XX should be in the range of 00-23 and YY and ZZ should be in the range of 00-59.
|
The changing_times dictionary is used to specify the times of the day when your wallpaper is switched. The names of the keys do not matter here, the values must always be strings in the "XX:YY:ZZ" 24 hour time system. use 00:00:00 for midnight. Note that XX should be in the range of 00-23 and YY and ZZ should be in the range of 00-59.
|
||||||
|
|
|
@ -5,7 +5,6 @@ enable_wallpaper_sets = true
|
||||||
used_sets = ["anime", "nature"]
|
used_sets = ["anime", "nature"]
|
||||||
wallpapers_per_set = 5
|
wallpapers_per_set = 5
|
||||||
notify = False
|
notify = False
|
||||||
fallback_wallpaper = "/path/to/paper"
|
|
||||||
|
|
||||||
# Enter the hours at which you want the wallpaper to change.
|
# Enter the hours at which you want the wallpaper to change.
|
||||||
# If the script is called between one of this times, it will go back to the previous time.
|
# If the script is called between one of this times, it will go back to the previous time.
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from sys import exit
|
|
||||||
from os import chdir, getenv, system
|
from os import chdir, getenv, system
|
||||||
import logging
|
import logging
|
||||||
import tomllib
|
import tomllib
|
||||||
|
@ -10,7 +9,7 @@ from apscheduler.triggers.cron import CronTrigger
|
||||||
# setup logging
|
# setup logging
|
||||||
chdir(str(getenv("HOME")) + "/.local/share/wallman/")
|
chdir(str(getenv("HOME")) + "/.local/share/wallman/")
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(filename="wallman.log", encoding="utf-8", level=logging.WARNING)
|
logging.basicConfig(filename="wallman.log", encoding="utf-8", level=logging.DEBUG)
|
||||||
|
|
||||||
# read config
|
# read config
|
||||||
# a = list(data["changing_times"].values())
|
# a = list(data["changing_times"].values())
|
||||||
|
@ -44,48 +43,22 @@ class _ConfigLib:
|
||||||
self.config_notify = False
|
self.config_notify = False
|
||||||
logger.warning("'notify' is not set in dictionary general in the config file, defaulting to 'false'.")
|
logger.warning("'notify' is not set in dictionary general in the config file, defaulting to 'false'.")
|
||||||
|
|
||||||
def _set_fallback_wallpaper(self):
|
|
||||||
if self.config_general["fallback_wallpaper"]:
|
|
||||||
system(f"feh --bg-fill --no-fehbg {self.config_general['fallback_wallpaper']}")
|
|
||||||
logger.info("The fallback Wallpaper has been set.")
|
|
||||||
else:
|
|
||||||
logger.critical("An Error occured and no fallback wallpaper was provided, exiting...")
|
|
||||||
raise ConfigError("An error occured and no fallback wallpaper has been set, exiting...")
|
|
||||||
|
|
||||||
class ConfigValidity(_ConfigLib):
|
class ConfigValidity(_ConfigLib):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def _check_fallback_wallpaper(self):
|
|
||||||
if self.config_general["fallback_wallpaper"]:
|
|
||||||
logger.debug("A fallback wallpaper has been defined.")
|
|
||||||
else:
|
|
||||||
logger.warning("No fallback wallpaper has been provided. If the config is written incorrectly, the program will not be able to be executed.")
|
|
||||||
|
|
||||||
def _check_wallpapers_per_set_and_changing_times(self) -> None:
|
def _check_wallpapers_per_set_and_changing_times(self) -> None:
|
||||||
# Check if the amount of wallpapers_per_set and given changing times match
|
# Check if the amount of wallpapers_per_set and given changing times match
|
||||||
if self.config_total_changing_times == self.config_wallpapers_per_set:
|
if self.config_total_changing_times == self.config_wallpapers_per_set:
|
||||||
logger.debug("The amount of changing times and wallpapers per set is set correctly")
|
logger.debug("The amount of changing times and wallpapers per set is set correctly")
|
||||||
else:
|
else:
|
||||||
try:
|
logger.error("The amount of changing times and the amount of wallpapers per set does not match.")
|
||||||
self._set_fallback_wallpaper()
|
raise ConfigError("Please provide an amount of changing_times equal to wallpapers_per_set.")
|
||||||
logger.error("The amount of changing_times and the amount of wallpapers_per_set does not much, the fallback wallpaper has been set.")
|
|
||||||
print("ERROR: The amount of changing_times and the amount of wallpapers_per_set does not much, the fallback wallpaper has been set.")
|
|
||||||
exit(1)
|
|
||||||
except ConfigError:
|
|
||||||
logger.critical("The amount of changing times and the amount of wallpapers per set does not match, exiting...")
|
|
||||||
raise ConfigError("Please provide an amount of changing_times equal to wallpapers_per_set, exiting...")
|
|
||||||
|
|
||||||
def _check_general_validity(self) -> None:
|
def _check_general_validity(self) -> None:
|
||||||
if len(self.config_general) < 3:
|
if len(self.config_general) < 3:
|
||||||
try:
|
logger.error("An insufficient amount of parameters for general has been provided, exiting...")
|
||||||
self._set_fallback_wallpaper()
|
raise ConfigError("general should have at least 3 elements")
|
||||||
logger.error("An insufficient amount of elements has been provided for general, the fallback wallpaper has been set.")
|
|
||||||
print("ERROR: An insufficient amount of wallpapers has been provided for general, the fallback wallpaper has been set.")
|
|
||||||
exit(1)
|
|
||||||
except ConfigError:
|
|
||||||
logger.critical("An insufficient amount of elements for general has been provided, exiting...")
|
|
||||||
raise ConfigError("general should have at least 3 elements, exiting...")
|
|
||||||
|
|
||||||
def _check_wallpaper_dicts(self)-> None:
|
def _check_wallpaper_dicts(self)-> None:
|
||||||
# This block checks if a dictionary for each wallpaper set exists
|
# This block checks if a dictionary for each wallpaper set exists
|
||||||
|
@ -93,14 +66,8 @@ class ConfigValidity(_ConfigLib):
|
||||||
if wallpaper_set in self.config_file:
|
if wallpaper_set in self.config_file:
|
||||||
logger.debug(f"The dictionary {wallpaper_set} has been found in config.")
|
logger.debug(f"The dictionary {wallpaper_set} has been found in config.")
|
||||||
else:
|
else:
|
||||||
try:
|
logger.error(f"No dictionary {wallpaper_set} has been found in the config.")
|
||||||
self._set_fallback_wallpaper()
|
raise ConfigError(f"The dictionary {wallpaper_set} has not been found in the config")
|
||||||
logger.error(f"The dictionary {wallpaper_set} has not been found in the config, the fallback wallpaper has been set.")
|
|
||||||
print(f"ERROR: The dictionary {wallpaper_set} has not been found in the config, the fallback wallpaper has been set.")
|
|
||||||
exit(1)
|
|
||||||
except ConfigError:
|
|
||||||
logger.critical(f"No dictionary {wallpaper_set} has been found in the config exiting...")
|
|
||||||
raise ConfigError(f"The dictionary {wallpaper_set} has not been found in the config, exiting...")
|
|
||||||
|
|
||||||
def _check_wallpaper_amount(self) -> None:
|
def _check_wallpaper_amount(self) -> None:
|
||||||
# This block checks if if each wallpaper set dictionary provides enough wallpapers to satisfy wallpapers_per_set
|
# This block checks if if each wallpaper set dictionary provides enough wallpapers to satisfy wallpapers_per_set
|
||||||
|
@ -108,17 +75,10 @@ class ConfigValidity(_ConfigLib):
|
||||||
if len(self.config_file[wallpaper_set]) == self.config_wallpapers_per_set:
|
if len(self.config_file[wallpaper_set]) == self.config_wallpapers_per_set:
|
||||||
logger.debug(f"Dictionary {wallpaper_set} has sufficient values.")
|
logger.debug(f"Dictionary {wallpaper_set} has sufficient values.")
|
||||||
else:
|
else:
|
||||||
try:
|
logger.error(f"Dictionary {wallpaper_set} does not have sufficient entries")
|
||||||
self._set_fallback_wallpaper()
|
raise ConfigError(f"Dictionary {wallpaper_set} does not have the correct amount of entries")
|
||||||
logger.error(f"The Dictionary {wallpaper_set} does not have sufficient entries, the fallback wallpaper has been set.")
|
|
||||||
print(f"ERROR: The Dictionaty {wallpaper_set} does not have sufficient entries, the fallback wallpaper has been set.")
|
|
||||||
exit(1)
|
|
||||||
except ConfigError:
|
|
||||||
logger.critical(f"Dictionary {wallpaper_set} does not have sufficient entries, exciting...")
|
|
||||||
raise ConfigError(f"Dictionary {wallpaper_set} does not have the correct amount of entries, exciting...")
|
|
||||||
|
|
||||||
def validate_config(self) -> None:
|
def validate_config(self) -> None:
|
||||||
self._check_fallback_wallpaper()
|
|
||||||
self._check_wallpapers_per_set_and_changing_times()
|
self._check_wallpapers_per_set_and_changing_times()
|
||||||
self._check_general_validity()
|
self._check_general_validity()
|
||||||
self._check_wallpaper_dicts()
|
self._check_wallpaper_dicts()
|
||||||
|
|
Loading…
Reference in a new issue