Compare commits

..

5 commits

Author SHA1 Message Date
Emma Nora Theuer
391d60822a Add loglevel option to sample config 2024-06-09 21:26:00 +02:00
Emma Nora Theuer
5fa2446830 Add support for defining the loglevel in the config. 2024-06-09 21:25:26 +02:00
Emma Nora Theuer
c4aa64fdd9 Update Version number 2024-06-09 21:24:40 +02:00
Emma Nora Theuer
155aad6fb7 Update to reflect changes in README.org 2024-06-09 21:23:06 +02:00
Emma Nora Theuer
93c5d7c938 Add documentation for new feature, remove done TODO. 2024-06-09 21:22:37 +02:00
5 changed files with 71 additions and 65 deletions

View file

@ -35,7 +35,7 @@ doas eselect repository create wallman
doas cp -rf Wallman/distfiles/Gentoo/wallman /var/db/repos/ doas cp -rf Wallman/distfiles/Gentoo/wallman /var/db/repos/
doas emerge -av wallman doas emerge -av wallman
#+END_SRC #+END_SRC
A proper portage overlay will be created soon so that updates can be handled automatically. A proper portage overlay will be created soon, so that updates can be handled automatically.
*** Arch Linux *** Arch Linux
Support for Arch Linux will be added soon. Support for Arch Linux will be added soon.
@ -62,7 +62,6 @@ doas cp src/wallman_lib.py /usr/bin/wallman_lib.py
doas chmod +x /usr/bin/wallman doas chmod +x /usr/bin/wallman
#+END_SRC #+END_SRC
+ Edit the sample config + Edit the sample config
+ (Optional): Adjust the loglevel in Source Code to your liking.
+ Profit + Profit
* Configuration * Configuration
@ -70,7 +69,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 three 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
@ -80,7 +79,9 @@ In general, you need to always define 3 variables and you can optionally add two
+ 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 + Optional: fallback_wallpaper: bool
Wallpaper to be set if an error is found in the config or the wallpaper intended to be set cannot be found. Defaults to None. If none is set and the config has been 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. Wallpaper to be set if an error is found in the config or the wallpaper intended to be set cannot be found. Defaults to None. If none is set and the config has been 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. If The config is written correctly but the wallpaper intended to be set can't be found, wallman will set the fallback wallpaper and continue to try setting future wallpapers.
+ Optional: loglevel: string
Loglevel to be used by wallman. Defaults to WARNING. Choices MUST be DEBUG, INFO, WARNING, ERROR or CRITICAL. Using any capitalization is valid, all caps is reccomended. Wallman will crash if a value is specified that is not one of the specified ones.
*** 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.
@ -98,7 +99,6 @@ The keys in the dictionary once again do not matter, the names of the keys in ea
** Technical Details ** Technical Details
+ Improve Modularity + Improve Modularity
+ Make the enabled flag in wallpaper_sets actually useful by making the used_sets field optional + Make the enabled flag in wallpaper_sets actually useful by making the used_sets field optional
+ Add support for different loglevels in the config file or as a command line argument
+ Drop the feh dependecy and set wallpapers using pywlroots or python-xlib + Drop the feh dependecy and set wallpapers using pywlroots or python-xlib
** Features ** Features

View file

@ -1,38 +1,38 @@
# Table of Contents # Table of Contents
1. [Overwiev](#org38008e5) 1. [Overwiev](#org2a35117)
1. [What is this?](#orgbf0d867) 1. [What is this?](#orge3a5d17)
2. [What can it do?](#orga6b51ae) 2. [What can it do?](#org5bd5faf)
2. [Installation](#orgf8cb7f4) 2. [Installation](#org2245116)
1. [Depedencies](#orgdcf9c12) 1. [Depedencies](#orgb307c2f)
1. [Always Required](#org6db51f1) 1. [Always Required](#orgcb51d2a)
2. [Optional](#orgd486e75) 2. [Optional](#org93a250c)
3. [Build dependencies](#orgb137ff2) 3. [Build dependencies](#orgde9f3fb)
2. [Installing with package Manager](#org7130917) 2. [Installing with package Manager](#org6bc369b)
1. [Gentoo](#org12416b9) 1. [Gentoo](#org2270777)
2. [Arch Linux](#org839518f) 2. [Arch Linux](#orgdc87765)
3. [Others](#orgc43c06f) 3. [Others](#org4807bf8)
3. [Installing with pip](#org09d87ac) 3. [Installing with pip](#org0923c8c)
4. [Installing manually](#org978c6b3) 4. [Installing manually](#org4cc688d)
3. [Configuration](#org67eaff5) 3. [Configuration](#orge297365)
1. [TOML Dictionaries](#orgf398b60) 1. [TOML Dictionaries](#orge759420)
1. [general](#org8cc8089) 1. [general](#orgc027496)
2. [changing<sub>times</sub>](#orgb5c4a76) 2. [changing<sub>times</sub>](#orge3910dc)
3. [The other dictionaries](#org9066447) 3. [The other dictionaries](#orgaede4d5)
4. [TODOs](#org2f22e63) 4. [TODOs](#orgf082abd)
1. [Structuring](#orgee9e8f9) 1. [Structuring](#org20c5864)
2. [Technical Details](#org9af492c) 2. [Technical Details](#orga6a55f9)
3. [Features](#org58d4a35) 3. [Features](#org32767d2)
<a id="org38008e5"></a> <a id="org2a35117"></a>
# Overwiev # Overwiev
<a id="orgbf0d867"></a> <a id="orge3a5d17"></a>
## What is this? ## What is this?
@ -41,7 +41,7 @@ This version is an early Alpha. As of now, it supports the most important featur
As such, please make absolutely sure you follow the instructions on how to write the config file very closely. I will implement better config handling with more meaningful error output in the future. For now, follow everything really closely and read the logs if needed. If you do that, it *should* work. As such, please make absolutely sure you follow the instructions on how to write the config file very closely. I will implement better config handling with more meaningful error output in the future. For now, follow everything really closely and read the logs if needed. If you do that, it *should* work.
<a id="orga6b51ae"></a> <a id="org5bd5faf"></a>
## What can it do? ## What can it do?
@ -52,17 +52,17 @@ Wallman currently has three main features:
- Settings Wallpapers at a specific time of the day - Settings Wallpapers at a specific time of the day
<a id="orgf8cb7f4"></a> <a id="org2245116"></a>
# Installation # Installation
<a id="orgdcf9c12"></a> <a id="orgb307c2f"></a>
## Depedencies ## Depedencies
<a id="org6db51f1"></a> <a id="orgcb51d2a"></a>
### Always Required ### Always Required
@ -71,14 +71,14 @@ Wallman currently has three main features:
- feh (Used for setting the wallpapers, hard dependency) - feh (Used for setting the wallpapers, hard dependency)
<a id="orgd486e75"></a> <a id="org93a250c"></a>
### Optional ### Optional
- libnotify (for desktop notification support) - libnotify (for desktop notification support)
<a id="orgb137ff2"></a> <a id="orgde9f3fb"></a>
### Build dependencies ### Build dependencies
@ -86,12 +86,12 @@ Wallman currently has three main features:
- build - build
<a id="org7130917"></a> <a id="org6bc369b"></a>
## Installing with package Manager ## Installing with package Manager
<a id="org12416b9"></a> <a id="org2270777"></a>
### Gentoo ### Gentoo
@ -102,24 +102,24 @@ This program, as of now, can be installed very easily on gentoo. Just follow the
doas cp -rf Wallman/distfiles/Gentoo/wallman /var/db/repos/ doas cp -rf Wallman/distfiles/Gentoo/wallman /var/db/repos/
doas emerge -av wallman doas emerge -av wallman
A proper portage overlay will be created soon so that updates can be handled automatically. A proper portage overlay will be created soon, so that updates can be handled automatically.
<a id="org839518f"></a> <a id="orgdc87765"></a>
### Arch Linux ### Arch Linux
Support for Arch Linux will be added soon. Support for Arch Linux will be added soon.
<a id="orgc43c06f"></a> <a id="org4807bf8"></a>
### Others ### Others
I will potentially write a version for nixpkgs and will also bundle wallman as a flatpak. I will potentially write a version for nixpkgs and will also bundle wallman as a flatpak.
<a id="org09d87ac"></a> <a id="org0923c8c"></a>
## Installing with pip ## Installing with pip
@ -128,7 +128,7 @@ Wallman is available on PyPI. Simply run:
pip install wallman pip install wallman
<a id="org978c6b3"></a> <a id="org4cc688d"></a>
## Installing manually ## Installing manually
@ -143,29 +143,28 @@ Wallman is available on PyPI. Simply run:
doas chmod +x /usr/bin/wallman doas chmod +x /usr/bin/wallman
- Edit the sample config - Edit the sample config
- (Optional): Adjust the loglevel in Source Code to your liking.
- Profit - Profit
<a id="org67eaff5"></a> <a id="orge297365"></a>
# 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.
<a id="orgf398b60"></a> <a id="orge759420"></a>
## TOML Dictionaries ## TOML Dictionaries
First of all, the config file is structured via different TOML dictionaries. There are two TOML dictionaries: general and changing<sub>times</sub> 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<sub>sets</sub> 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<sub>times</sub> 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<sub>sets</sub> 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.
<a id="org8cc8089"></a> <a id="orgc027496"></a>
### 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 three more:
- enable<sub>wallpaper</sub><sub>sets</sub>: bool - enable<sub>wallpaper</sub><sub>sets</sub>: 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.
@ -176,17 +175,19 @@ In general, you need to always define 3 variables and you can optionally add two
- Optional: notify: bool - Optional: notify: bool
This defaults to &ldquo;false&rdquo;. 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 &ldquo;false&rdquo;. 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<sub>wallpaper</sub>: bool - Optional: fallback<sub>wallpaper</sub>: bool
Wallpaper to be set if an error is found in the config or the wallpaper intended to be set cannot be found. Defaults to None. If none is set and the config has been 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. Wallpaper to be set if an error is found in the config or the wallpaper intended to be set cannot be found. Defaults to None. If none is set and the config has been 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. If The config is written correctly but the wallpaper intended to be set can&rsquo;t be found, wallman will set the fallback wallpaper and continue to try setting future wallpapers.
- Optional: loglevel: string
Loglevel to be used by wallman. Defaults to WARNING. Choices MUST be DEBUG, INFO, WARNING, ERROR or CRITICAL. Using any capitalization is valid, all caps is reccomended. Wallman will crash if a value is specified that is not one of the specified ones.
<a id="orgb5c4a76"></a> <a id="orge3910dc"></a>
### changing<sub>times</sub> ### changing<sub>times</sub>
The changing<sub>times</sub> 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 &ldquo;XX:YY:ZZ&rdquo; 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<sub>times</sub> 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 &ldquo;XX:YY:ZZ&rdquo; 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.
<a id="org9066447"></a> <a id="orgaede4d5"></a>
### The other dictionaries ### The other dictionaries
@ -194,12 +195,12 @@ The other dictionaries must always have the names of the wallpaper sets from use
The keys in the dictionary once again do not matter, the names of the keys in each dictionary must be strings and be absolute paths. They should not include spaces unless prefaced by a backslash. The keys in the dictionary once again do not matter, the names of the keys in each dictionary must be strings and be absolute paths. They should not include spaces unless prefaced by a backslash.
<a id="org2f22e63"></a> <a id="orgf082abd"></a>
# TODOs # TODOs
<a id="orgee9e8f9"></a> <a id="org20c5864"></a>
## Structuring ## Structuring
@ -207,17 +208,16 @@ The keys in the dictionary once again do not matter, the names of the keys in ea
- Add documentation for developers - Add documentation for developers
<a id="org9af492c"></a> <a id="orga6a55f9"></a>
## Technical Details ## Technical Details
- Improve Modularity - Improve Modularity
- Make the enabled flag in wallpaper<sub>sets</sub> actually useful by making the used<sub>sets</sub> field optional - Make the enabled flag in wallpaper<sub>sets</sub> actually useful by making the used<sub>sets</sub> field optional
- Add support for different loglevels in the config file or as a command line argument
- Drop the feh dependecy and set wallpapers using pywlroots or python-xlib - Drop the feh dependecy and set wallpapers using pywlroots or python-xlib
<a id="org58d4a35"></a> <a id="org32767d2"></a>
## Features ## Features

View file

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "wallman" name = "wallman"
version = "1.3.2.3" version = "1.3.3.0"
authors = [ authors = [
{name = "Emma Nora Theuer", email = "wallman@entheuer.de"}, {name = "Emma Nora Theuer", email = "wallman@entheuer.de"},
] ]

View file

@ -6,6 +6,7 @@ used_sets = ["anime", "nature"]
wallpapers_per_set = 5 wallpapers_per_set = 5
notify = False notify = False
fallback_wallpaper = "/path/to/paper" fallback_wallpaper = "/path/to/paper"
loglevel = "WARNING"
# 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.

View file

@ -8,13 +8,7 @@ from apscheduler.schedulers.blocking import BlockingScheduler
from apscheduler.triggers.cron import CronTrigger from apscheduler.triggers.cron import CronTrigger
# setup logging # setup logging
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)
# read config
# a = list(data["changing_times"].values())
# print(a[0])
class ConfigError(Exception): class ConfigError(Exception):
pass pass
@ -38,12 +32,23 @@ class _ConfigLib:
self.config_used_sets: list = self.config_general["used_sets"] self.config_used_sets: list = self.config_general["used_sets"]
self.config_wallpapers_per_set: int = self.config_general["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)
self.config_log_level: str = self.config_general.get("loglevel", "WARNING").upper()
try: try:
self.config_notify = self.config_general["notify"] self.config_notify: bool = self.config_general["notify"]
except KeyError: except KeyError:
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'.")
self._set_log_level()
def _set_log_level(self):
global logging
global logger
chdir(str(getenv("HOME")) + "/.local/share/wallman/")
numeric_level = getattr(logging, self.config_log_level, logging.WARNING)
logger.setLevel(numeric_level)
logging.basicConfig(filename="wallman.log", encoding="utf-8", level=numeric_level)
def _set_fallback_wallpaper(self): def _set_fallback_wallpaper(self):
if self.config_general["fallback_wallpaper"]: if self.config_general["fallback_wallpaper"]:
system(f"feh --bg-fill --no-fehbg {self.config_general['fallback_wallpaper']}") system(f"feh --bg-fill --no-fehbg {self.config_general['fallback_wallpaper']}")
@ -175,7 +180,7 @@ class WallpaperLogic(_ConfigLib):
print(f"ERROR: The wallpaper {self.wallpaper_list[self.current_time_range]} has not been found and no fallback wallpaper has been set. Future wallpapers will still attempted to be set.") print(f"ERROR: The wallpaper {self.wallpaper_list[self.current_time_range]} has not been found and no fallback wallpaper has been set. Future wallpapers will still attempted to be set.")
return False return False
else: else:
logger.debug(f"The wallpaper {self.wallpaper_list[self.current_time_range]} has been set.") logger.info(f"The wallpaper {self.wallpaper_list[self.current_time_range]} has been set.")
return True return True