Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

werewall

Like a werewolf, your wallpaper transforms depending on where it is.

Changes the KDE Plasma wallpaper based on the WiFi network you are connected to. At home you get a random wallpaper from your own folder (re-rolled every so often), everywhere else you get the stock KDE wallpaper.

Built for Plasma 6 with NetworkManager. Uses only nmcli, plasma-apply-wallpaperimage and bash, so there is nothing to install beyond what a normal Plasma system already has.

Install

./install.sh

This copies the script to ~/.local/bin, the unit to ~/.config/systemd/user, seeds ~/.config/werewall/config from config.example (existing configs are left alone), then enables and starts the service.

Configuration

Edit ~/.config/werewall/config:

Option Meaning
HOME_SSIDS Array of WiFi names that count as home
HOME_WALLPAPER_DIR Folder of wallpapers used at home (searched recursively for jpg/jpeg/png/webp)
AWAY_WALLPAPER Image file or wallpaper kpackage used away from home, default /usr/share/wallpapers/Next
ROTATE_MINUTES Minutes between random re-picks while home, 0 disables rotation
RESET_ON_STOP 1 restores the away wallpaper when the service stops, 0 leaves the current one
SET_LOCKSCREEN 1 also mirrors the wallpaper onto the lockscreen, 0 leaves the lockscreen alone (default)

After changing the config, restart the service:

systemctl --user restart werewall

Keeping the wallpaper up while idle

Plasma 6 has no classic screensaver, but you can get the same effect with two settings and no extra software. In System Settings:

  • Power Management → Energy Saving: turn off "Turn off screen" (and dimming if you like) for the On AC Power profile so the panel never blanks.
  • Screen Locking: set "Lock screen automatically after N minutes" and pick your image under Appearance. After N idle minutes the lock screen comes up and stays lit showing the image.

Set SET_LOCKSCREEN=1 so the idle image tracks the same network-based wallpaper as the desktop instead of a fixed one.

To have it wake without asking for your password again, either leave "Lock screen automatically" off and rely on the never-blank setting alone, or in Screen Locking turn off "Require password to unlock" (or set its grace period long enough to cover your idle time). One static image held for hours can risk burn-in on OLED, so "dim but don't turn off" is a safer middle ground.

How it works

The whole thing is one bash script with a single loop that does two jobs.

The event loop. nmcli monitor prints a line whenever NetworkManager state changes (connect, disconnect, roam, and plenty of noise). The script reads that stream in a while read loop and re-checks the active SSID on every line. It remembers whether the last applied state was "home" or "away" and only touches the wallpaper on a real transition between the two, which is what keeps the chatty monitor output from re-applying the wallpaper over and over. No WiFi at all (wired only, or disconnected) counts as away.

The rotation loop. The same read call uses a timeout of ROTATE_MINUTES. When no network events arrive for that long, read returns with a timeout status (>128) instead of a line, and if you are currently home the script picks a fresh random wallpaper from HOME_WALLPAPER_DIR. So rotation rides on the same loop and no separate systemd timer is needed.

If nmcli monitor ever dies the read hits end-of-file, the script exits non-zero, and systemd restarts it (Restart=on-failure).

Reset on stop. Plasma saves the current wallpaper in its own config, so a machine shut down at home would normally boot showing the home wallpaper for a second or two before the service catches up. With RESET_ON_STOP=1 the script traps the stop signal (logout, shutdown, systemctl --user stop) and puts the away wallpaper back before exiting, while the session is still alive. Plasma then saves the generic wallpaper, so the next boot starts generic no matter where you are. This only happens on a real stop, not when the service dies and gets restarted mid-session.

Lockscreen. With SET_LOCKSCREEN=1 every wallpaper change is also written to the lockscreen. Unlike the desktop there is no live "apply" command for the lockscreen, so the script writes the image into ~/.config/kscreenlockerrc with kwriteconfig6 (part of Plasma, nothing to install). Because it routes through the same code as the desktop, the lockscreen follows the home, away, rotation and reset-on-stop paths for free. The catch is that kscreenlocker only rereads that config when it locks, so a change shows up the next time the screen locks rather than instantly. If kwriteconfig6 is missing the script logs a warning once and carries on switching the desktop.

The unit hangs off graphical-session.target, so it starts once the Plasma session (and its D-Bus) is up and stops on logout.

Logs

journalctl --user -u werewall -f

Testing checklist

  1. ./install.sh, then check systemctl --user status werewall says active (running).
  2. On home WiFi, a wallpaper from HOME_WALLPAPER_DIR should be applied.
  3. nmcli radio wifi off: the wallpaper should switch to the away one within a couple of seconds, and the journal should log the transition.
  4. nmcli radio wifi on: after reconnecting, the home wallpaper comes back.
  5. Set ROTATE_MINUTES=1, restart the service, and confirm the wallpaper changes after a minute while home. Put it back afterwards.
  6. pkill -f "nmcli monitor" and confirm systemd restarts the service (the script treats a dead monitor as a failure).
  7. With RESET_ON_STOP=1 and while on home WiFi, run systemctl --user stop werewall and confirm the wallpaper switches back to the away one.

About

Location-aware KDE Plasma wallpaper switching, driven by your WiFi network.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages