A simple wallpaper changer for Ubuntu that chooses a wallpaper based on configurable randomized policy.
Just run mkdir ./build; bash ./.git-hooks/run_build.sh.
This will compile the source code and run all tests. An executable will be created in ./build directory.
Tested on Ubuntu 18.04, 20.04 and 22.04; cmake: 3.16.3 and 3.25.1; make: 4.2.1 and 4.3; gcc: 9.3.0, 10.3.0 and 12.1.0.
A configuration file - config.cfg - must be created in the same directory as the executable. It is loaded on start, so any configuration changes made during runtime will be loaded the next time the application is started.
The file should look like this:
# Path to the wallpapers, subdirectories will be traversed.
path=path/to/wallpapers
# Seconds before change, integer.
seconds_before_change=30
# Allowed extensions, case sensitive.
file_allowed_extensions=.png,.jpg,.jpeg,.PNG,.JPG,.JPEG
# Directories that should be skipped, comma-separated.
directory_exclusions=Dir1,Dir2
# Relative frequency for choosing the listed directories.
directory_priorities = Nature:3,Abstract:2,Arts:10
# Seconds before change if wallpaper from the configured directory is selected.
directory_seconds = Nature:45,Abstract:20
# Scale options for the configured directories. Defaults to `zoom`.
directory_pic_options = Nature:scaled, Abstract:scaled
# Randomization policy. Choose from {uniform, weighted}.
policy=weighted
Some notes on the policies:
uniformwill choose a random file underpathor its subdirectories; it uses cache, so new files (added in the directories during runtime) will be ignored.weightedwill traverse the directories, where on each level it will randomly choose a directory, e.g.: if there are two directories undermain:dir1anddir2, as the algorithm entersmainit will selectdir1with probability 1/3,dir2with probability 1/3 and.with probability 1/3. The last thing is useful if there are both files and subdirectories in the same directory (mainin this case).- this can be overriden by configuring the
directory_priorities. E.g., ifdir1is prioritized with "3" (others default to 1), thendir1will be selected with probability 3/5,dir2with probability 1/5 and.with probability 1/5. - new files will be eligible for selection as soon as the next wallpaper change.
- this can be overriden by configuring the
Having built the application and set the configuration, just execute the compiled file (preferably with nohup). The application will create a log file (log.txt), where the full path to each chosen wallpaper will be stored.
- Consider supporting both light and dark themes for GNOME. Currently the command is different and the application needs to be recompiled on theme change.
- Consider not using system calls for wallpaper switching.