Last active
December 19, 2023 14:38
-
-
Save mschmitt/5fbbe043ba0f0e1f39ea517f1aae85ab to your computer and use it in GitHub Desktop.
Gnome wallpaper changer in native systemd user units
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ansible-playbook | |
--- | |
- hosts: localhost | |
become: false | |
gather_facts: false | |
connection: local | |
tasks: | |
- name: Systemd user config location | |
file: | |
path: ~/.config/systemd/user/ | |
state: directory | |
- name: Wallpaper service | |
copy: | |
src: wallpaper.service | |
dest: ~/.config/systemd/user/ | |
- name: Wallpaper timer | |
copy: | |
src: wallpaper.timer | |
dest: ~/.config/systemd/user/ | |
- name: Enable wallpaper timer | |
systemd: | |
name: wallpaper.timer | |
scope: user | |
enabled: yes | |
state: started | |
# vim: filetype=yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.config/systemd/user/wallpaper.service | |
[Unit] | |
Description=Wallpaper Change | |
StartLimitIntervalSec=0 | |
[Service] | |
Type=oneshot | |
Environment=wpdir=%h/Nextcloud/Wallpapers | |
ExecStart=/usr/bin/env sh -c 'gsettings set org.gnome.desktop.background picture-uri "file://$(find "${wpdir}" -type f | shuf | head -1)"' | |
ExecStart=/usr/bin/env sh -c 'gsettings set org.gnome.desktop.background picture-uri-dark "$(gsettings get org.gnome.desktop.background picture-uri)"' | |
ExecStartPost=/usr/bin/env gsettings get org.gnome.desktop.background picture-uri |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ~/.config/systemd/user/wallpaper.timer | |
[Unit] | |
Description=Wallpaper Change Timer | |
[Timer] | |
OnStartupSec=60 | |
OnUnitInactiveSec=900 | |
[Install] | |
WantedBy=default.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment