Skip to content

Instantly share code, notes, and snippets.

@rc2dev
Last active August 18, 2022 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rc2dev/d45379a7beb2540af04524ebea77c555 to your computer and use it in GitHub Desktop.
Save rc2dev/d45379a7beb2540af04524ebea77c555 to your computer and use it in GitHub Desktop.
Wrapper for nitrogen, so LightDM wallpaper is synced (https://rafaelc.org/posts/sync-wm-wallpaper-with-lightdm-on-linux-mint/). Previously tracked on my dotfiles repository.
#!/usr/bin/env bash
#
# Wrapper for nitrogen, so LightDM wallpaper is synced.
#
# Copyright (C) 2021 Rafael Cavalcanti <https://rafaelc.org/dev>
# Licensed under GPLv3
set -euo pipefail
/usr/bin/nitrogen "$@"
# We could exit here in the case of `nitrogen --restore` (to bypass setting
# LightDM's wallpaper again in that case). This would work fine if we don't
# login into other DEs where the wallpaper is managed by other software.
# However, if we login into Cinnamon, for example, it will overwrite LightDM's
# wallpaper with the one set there. So, upon calling `nitrogen --restore`, it
# also makes sense to set the LightDM wallpaper.
readonly bg_path="$(awk -F '=' '/file/{print $2}' "$HOME/.config/nitrogen/bg-saved.cfg")"
dbus-send \
--print-reply \
--system \
--dest=org.freedesktop.Accounts \
/org/freedesktop/Accounts/User$(id -u) \
org.freedesktop.DBus.Properties.Set \
string:org.freedesktop.DisplayManager.AccountsService \
string:BackgroundFile \
variant:string:"$bg_path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment