Compare commits
3 commits
ef89547708
...
24302092df
Author | SHA1 | Date | |
---|---|---|---|
|
24302092df | ||
|
f0c32fdf0c | ||
|
58a3e1c46a |
3 changed files with 34 additions and 14 deletions
12
README.org
12
README.org
|
@ -14,10 +14,14 @@ Wallman currently has three main features:
|
||||||
+ Settings Wallpapers at a specific time of the day
|
+ Settings Wallpapers at a specific time of the day
|
||||||
|
|
||||||
* Installation
|
* Installation
|
||||||
** Requirements
|
** Depedencies
|
||||||
|
*** Alwaus Required
|
||||||
+ Python 3.11 or newer (Required because of tomllib)
|
+ Python 3.11 or newer (Required because of tomllib)
|
||||||
+ APScheduler (Install python-apscheduler or APScheduler, depending on the package manager)
|
+ APScheduler (Install python-apscheduler or APScheduler, depending on the package manager)
|
||||||
+ feh (Used for setting the wallpapers, hard dependency)
|
+ feh (Used for setting the wallpapers, hard dependency)
|
||||||
|
*** Optional
|
||||||
|
+ libnotify (for desktop notification support.)
|
||||||
|
|
||||||
|
|
||||||
** How to install it?
|
** How to install it?
|
||||||
+ Clone this git repo
|
+ Clone this git repo
|
||||||
|
@ -34,8 +38,8 @@ cp sample_config.toml ~/.config/wallman/wallman.toml
|
||||||
* Configuration
|
* Configuration
|
||||||
This is a short guide on how to correctly configure wallman. Look in the sample config for additional context.
|
This is a short guide on how to correctly configure wallman. Look in the sample config for additional context.
|
||||||
** TOML Dictionaries
|
** TOML Dictionaries
|
||||||
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.
|
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.
|
||||||
*** wallpaper_sets
|
*** general
|
||||||
In wallpaper_sets, you need to always define 3 variables:
|
In wallpaper_sets, you need to always define 3 variables:
|
||||||
+ enabled: bool
|
+ enabled: 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.
|
||||||
|
@ -43,6 +47,8 @@ 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.
|
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
|
+ wallpapers_per_set: int
|
||||||
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
|
||||||
|
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
|
*** 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.
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
# Here, define if you want to use different sets of wallpapers, and if yes,
|
# 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.
|
# what those sets are called and how many wallpapers are included per set.
|
||||||
[wallpaper_sets]
|
[general]
|
||||||
enabled = true
|
enabled = true
|
||||||
used_sets = ["anime", "nature"]
|
used_sets = ["anime", "nature"]
|
||||||
wallpapers_per_set = 5
|
wallpapers_per_set = 5
|
||||||
|
notify = False
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
|
@ -9,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())
|
||||||
|
@ -30,13 +30,17 @@ class _ConfigLib:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.config_file: dict = self._initialize_config() # Full config
|
self.config_file: dict = self._initialize_config() # Full config
|
||||||
# Dictionaries
|
# Dictionaries
|
||||||
self.config_wallpaper_sets: dict = self.config_file["wallpaper_sets"]
|
self.config_general: dict = self.config_file["general"]
|
||||||
self.config_changing_times: dict = self.config_file["changing_times"]
|
self.config_changing_times: dict = self.config_file["changing_times"]
|
||||||
# Values in Dicts
|
# Values in Dicts
|
||||||
self.config_wallpaper_sets_enabled: bool = self.config_wallpaper_sets["enabled"]
|
self.config_wallpaper_sets_enabled: bool = self.config_general["enabled"]
|
||||||
self.config_used_sets: list = self.config_wallpaper_sets["used_sets"]
|
self.config_used_sets: list = self.config_general["used_sets"]
|
||||||
self.config_wallpapers_per_set: int = self.config_wallpaper_sets["wallpapers_per_set"]
|
self.config_wallpapers_per_set: int = self.config_general["wallpapers_per_set"]
|
||||||
self.config_total_changing_times: int = len(self.config_changing_times)
|
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):
|
class ConfigValidity(_ConfigLib):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -50,10 +54,10 @@ class ConfigValidity(_ConfigLib):
|
||||||
logger.error("The amount of changing times and the amount of wallpapers per set does not match.")
|
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.")
|
raise ConfigError("Please provide an amount of changing_times equal to wallpapers_per_set.")
|
||||||
|
|
||||||
def _check_wallpaper_sets_validity(self) -> None:
|
def _check_general_validity(self) -> None:
|
||||||
if len(self.config_wallpaper_sets) != 3:
|
if len(self.config_general) < 3:
|
||||||
logger.error("An insufficient amount of parameters for wallpaper_sets has been provided, exiting...")
|
logger.error("An insufficient amount of parameters for general has been provided, exiting...")
|
||||||
raise ConfigError("wallpaper_sets should have exactly 3 elements")
|
raise ConfigError("general should have at least 3 elements")
|
||||||
|
|
||||||
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
|
||||||
|
@ -75,7 +79,7 @@ class ConfigValidity(_ConfigLib):
|
||||||
|
|
||||||
def validate_config(self) -> None:
|
def validate_config(self) -> None:
|
||||||
self._check_wallpapers_per_set_and_changing_times()
|
self._check_wallpapers_per_set_and_changing_times()
|
||||||
self._check_wallpaper_sets_validity()
|
self._check_general_validity()
|
||||||
self._check_wallpaper_dicts()
|
self._check_wallpaper_dicts()
|
||||||
self._check_wallpaper_amount()
|
self._check_wallpaper_amount()
|
||||||
logger.debug("The config file has been validated successfully (No Errors)")
|
logger.debug("The config file has been validated successfully (No Errors)")
|
||||||
|
@ -103,6 +107,10 @@ class WallpaperLogic(_ConfigLib):
|
||||||
else:
|
else:
|
||||||
return start <= x or x < end
|
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:
|
def set_wallpaper_by_time(self) -> None:
|
||||||
# Ensure use of a consistent wallpaper set
|
# Ensure use of a consistent wallpaper set
|
||||||
if self.chosen_wallpaper_set is False:
|
if self.chosen_wallpaper_set is False:
|
||||||
|
@ -113,10 +121,15 @@ 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.
|
# 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()):
|
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]}")
|
system(f"feh --bg-scale --no-fehbg {self.wallpaper_list[time_range]}")
|
||||||
|
if self.config_notify:
|
||||||
|
self._notify_user()
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
system(f"feh --bg-scale --no-fehbg {self.wallpaper_list[-1]}")
|
system(f"feh --bg-scale --no-fehbg {self.wallpaper_list[-1]}")
|
||||||
|
if self.config_notify:
|
||||||
|
self._notify_user()
|
||||||
|
|
||||||
def schedule_wallpapers(self):
|
def schedule_wallpapers(self):
|
||||||
scheduler = BlockingScheduler()
|
scheduler = BlockingScheduler()
|
||||||
|
|
Loading…
Reference in a new issue