3.8 KiB
Parsing the KDE Lockscreen Configuration and setting x11 root BG
fehbg
is a script which selects a random image file and sets it as the X11 root bgfehbg
is installed and automated in home-manager and My NixOS configuration
When I am using i3wm it doesn't reliably create KDE Plasma workspaces for each workspace. This script extracts the list of images used in the Screen Locker → Appearance → Slideshow
wallpaper type and chooses one at random to set to the root image.
fehbg
is a script which selects a random image file and sets it as the X11 root bg
Grab all files in paths selected paths:
kreadconfig5 --file ~/.config/kscreenlockerrc \
--group Greeter --group Wallpaper --group org.kde.slideshow --group General \
--key SlidePaths \
| sed -s 's|,|\n|g' | xargs -I{} find "{}" -type f
You can un-check individual files from the folders, this kreadconfig5
call lists those and normalizes the paths.
kreadconfig5 --file ~/.config/kscreenlockerrc \
--group Greeter --group Wallpaper --group org.kde.slideshow --group General \
--key UncheckedSlides \
| sed -E -s 's|,?file://|\n|g' | sed -E "s|/media/pictures/|/home/rrix/Pictures/|"
These are inserted in to a script – this uses some under-used BASh-isms and noweb syntax to weave it all together:
<(CMD)
creates a process substitution – bash will replace that with something like /dev/fd/100
,create a sub-process which writes to that file descriptor (also referred to as a named pipe) and then the process being scripted, grep
in this case, will read from those "files" which are just the output of multiple other programs. This uses two named pipes and particular grep options
-F
matches fixed strings instead of regular expressions-x
matches an entire line-v
filters for exclusion rather than inclusion, unchecked from all-files-f
specifies to use theunchecked
files process substitution as a list of line-expressions to filter- The two
grep -v
call filter the text files and tarballs and other stuff out
grep -Fx -v <( \
<<all-files>>
) -f <(
<<unchecked>>
) \
| grep -v "txt$" | grep -v "tar.gz$" \
| shuf -n1 | xargs -I{} feh --bg-fill "{}"
fehbg
is installed and automated in home-manager and My NixOS configuration
It can be installed in to home-manager with a roam:SystemD timer, too
{pkgs, ... }:
let fehbg = pkgs.writeShellApplication {
name = "fehbg";
runtimeInputs = with pkgs; [ feh gnugrep libsForQt5.kconfig ];
text = builtins.readFile ../files/fehbg.sh;
};
in {
home.packages = [ fehbg ];
systemd.user.services.fehbg = {
Unit.Description = "Change the X11 rootbg.";
Unit.After = "graphical-session.target";
Service.ExecStart = "${fehbg}/bin/fehbg";
Service.Type = "oneshot";
};
systemd.user.timers.fehbg = {
Unit.Description = "Change the X11 rootbg every half hour.";
Install.WantedBy = ["graphical-session.target"];
# one minute after login
Timer.OnActiveSec = 60;
# every 30 minutes there after
Timer.OnUnitActiveSec = (30 * 60);
Timer.OnStartupSec = 30;
Timer.Unit = "fehbg";
};
}