94 lines
3.8 KiB
Org Mode
94 lines
3.8 KiB
Org Mode
:PROPERTIES:
|
|
:ID: 20220222T091934.288233
|
|
:ROAM_ALIASES: fehbg
|
|
:END:
|
|
#+title: Parsing the KDE Lockscreen Configuration and setting x11 root BG
|
|
#+FILETAGS: :CCE:
|
|
#+ARCOLOGY_KEY: cce/kde-lockscreen-fehbg
|
|
#+ARCOLOGY_ALLOW_CRAWL: t
|
|
|
|
When I am using [[id:20211206T133651.674012][i3wm]] it doesn't reliably create [[id:cce/kde_is_a_base_for_my_emacs_desktop][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:
|
|
|
|
#+NAME: all-files
|
|
#+begin_src shell
|
|
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
|
|
#+end_src
|
|
|
|
You can un-check individual files from the folders, this =kreadconfig5= call lists those and normalizes the paths.
|
|
|
|
#+NAME: unchecked
|
|
#+begin_src shell
|
|
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/|"
|
|
#+end_src
|
|
|
|
These are inserted in to a script -- this uses some under-used BASh-isms and [[id:09779ac0-4d5f-40db-a340-49595c717e03][noweb syntax]] to weave it all together:
|
|
=<(CMD)= creates a [[https://www.gnu.org/software/bash/manual/html_node/Process-Substitution.html][*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 the =unchecked= 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
|
|
|
|
#+begin_src shell :noweb yes :session *shell* :shebang #! /usr/bin/env nix-shell :tangle ~/arroyo-nix/files/fehbg.sh :comments no
|
|
grep -Fx -v <( \
|
|
<<all-files>>
|
|
) -f <(
|
|
<<unchecked>>
|
|
) \
|
|
| grep -v "txt$" | grep -v "tar.gz$" \
|
|
| shuf -n1 | xargs -I{} feh --bg-fill "{}"
|
|
#+end_src
|
|
|
|
* =fehbg= is installed and automated in [[id:cce/home-manager][home-manager]] and [[id:cce/my_nixos_configuration][My NixOS configuration]]
|
|
|
|
It can be installed in to [[id:cce/home-manager][home-manager]] with a [[roam:SystemD]] timer, too
|
|
|
|
#+ARROYO_SYSTEM_ROLE: endpoint
|
|
#+ARROYO_HOME_MODULE: hm/fehbg.nix
|
|
#+AUTO_TANGLE: t
|
|
|
|
#+begin_src nix :tangle ~/arroyo-nix/hm/fehbg.nix :noweb yes
|
|
{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";
|
|
};
|
|
}
|
|
#+end_src
|