Compare commits

..

No commits in common. "24302092dfacd13a39feebbcc606d4bffbcf18be" and "ef8954770855077bc4d5e55d5221f22d136f0235" have entirely different histories.

3 changed files with 14 additions and 34 deletions

View file

@ -14,14 +14,10 @@ Wallman currently has three main features:
+ Settings Wallpapers at a specific time of the day
* Installation
** Depedencies
*** Alwaus Required
** Requirements
+ Python 3.11 or newer (Required because of tomllib)
+ APScheduler (Install python-apscheduler or APScheduler, depending on the package manager)
+ feh (Used for setting the wallpapers, hard dependency)
*** Optional
+ libnotify (for desktop notification support.)
** How to install it?
+ Clone this git repo
@ -38,8 +34,8 @@ cp sample_config.toml ~/.config/wallman/wallman.toml
* Configuration
This is a short guide on how to correctly configure wallman. Look in the sample config for additional context.
** 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.
*** general
First of all, the config file is structured via different TOML dictionaries. There are two TOML dictionaries: wallpaper_sets 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.
*** wallpaper_sets
In wallpaper_sets, you need to always define 3 variables:
+ enabled: bool
A simple switch that states if you want to use different sets of wallpapers or not.
@ -47,8 +43,6 @@ In wallpaper_sets, you need to always define 3 variables:
A list that includes the names of the wallpaper sets you want to use. If you want to use only one, the list should have one entry.
+ wallpapers_per_set: int
The amount of wallpapers that you use in each set. It should be an integer.
+ 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.
*** 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.

View file

@ -1,10 +1,9 @@
# Here, define if you want to use different sets of wallpapers, and if yes,
# what those sets are called and how many wallpapers are included per set.
[general]
[wallpaper_sets]
enabled = true
used_sets = ["anime", "nature"]
wallpapers_per_set = 5
notify = False
# 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.

View file

@ -9,7 +9,7 @@ from apscheduler.triggers.cron import CronTrigger
# setup logging
chdir(str(getenv("HOME")) + "/.local/share/wallman/")
logger = logging.getLogger(__name__)
logging.basicConfig(filename="wallman.log", encoding="utf-8", level=logging.DEBUG)
logging.basicConfig(filename="wallman.log", encoding="utf-8", level=logging.WARNING)
# read config
# a = list(data["changing_times"].values())
@ -30,17 +30,13 @@ class _ConfigLib:
def __init__(self):
self.config_file: dict = self._initialize_config() # Full config
# Dictionaries
self.config_general: dict = self.config_file["general"]
self.config_wallpaper_sets: dict = self.config_file["wallpaper_sets"]
self.config_changing_times: dict = self.config_file["changing_times"]
# Values in Dicts
self.config_wallpaper_sets_enabled: bool = self.config_general["enabled"]
self.config_used_sets: list = self.config_general["used_sets"]
self.config_wallpapers_per_set: int = self.config_general["wallpapers_per_set"]
self.config_wallpaper_sets_enabled: bool = self.config_wallpaper_sets["enabled"]
self.config_used_sets: list = self.config_wallpaper_sets["used_sets"]
self.config_wallpapers_per_set: int = self.config_wallpaper_sets["wallpapers_per_set"]
self.config_total_changing_times: int = len(self.config_changing_times)
try:
self.config_notify = self.config_general["notify"]
except KeyError:
self.config_notify = False
class ConfigValidity(_ConfigLib):
def __init__(self):
@ -54,10 +50,10 @@ class ConfigValidity(_ConfigLib):
logger.error("The amount of changing times and the amount of wallpapers per set does not match.")
raise ConfigError("Please provide an amount of changing_times equal to wallpapers_per_set.")
def _check_general_validity(self) -> None:
if len(self.config_general) < 3:
logger.error("An insufficient amount of parameters for general has been provided, exiting...")
raise ConfigError("general should have at least 3 elements")
def _check_wallpaper_sets_validity(self) -> None:
if len(self.config_wallpaper_sets) != 3:
logger.error("An insufficient amount of parameters for wallpaper_sets has been provided, exiting...")
raise ConfigError("wallpaper_sets should have exactly 3 elements")
def _check_wallpaper_dicts(self)-> None:
# This block checks if a dictionary for each wallpaper set exists
@ -79,7 +75,7 @@ class ConfigValidity(_ConfigLib):
def validate_config(self) -> None:
self._check_wallpapers_per_set_and_changing_times()
self._check_general_validity()
self._check_wallpaper_sets_validity()
self._check_wallpaper_dicts()
self._check_wallpaper_amount()
logger.debug("The config file has been validated successfully (No Errors)")
@ -107,10 +103,6 @@ class WallpaperLogic(_ConfigLib):
else:
return start <= x or x < end
def _notify_user(self):
system("notify-send 'Wallman' 'A new Wallpaper has been set.'")
logger.debug("Sent desktop notification.")
def set_wallpaper_by_time(self) -> None:
# Ensure use of a consistent wallpaper set
if self.chosen_wallpaper_set is False:
@ -121,15 +113,10 @@ class WallpaperLogic(_ConfigLib):
# Check if the current time is between a given and the following changing time and if so, set that wallpaper. If not, keep trying.
if self._time_in_range(time(int(clean_time[0]), int(clean_time[1]), int(clean_time[2])), time(int(clean_time_two[0]), int(clean_time_two[1]), int(clean_time_two[2])), datetime.now().time()):
system(f"feh --bg-scale --no-fehbg {self.wallpaper_list[time_range]}")
if self.config_notify:
self._notify_user()
return
else:
continue
system(f"feh --bg-scale --no-fehbg {self.wallpaper_list[-1]}")
if self.config_notify:
self._notify_user()
def schedule_wallpapers(self):
scheduler = BlockingScheduler()