wallpaper: replace lua timer by a systemd timer

This commit is contained in:
Vincent Bernat 2020-02-05 08:16:27 +01:00
parent 66d130e702
commit a528e2f242
6 changed files with 25 additions and 27 deletions

1
rc.lua
View file

@ -63,7 +63,6 @@ loadrc("appearance") -- theme and appearance settings
loadrc("debug") -- debugging primitive `dbg()`
loadrc("bindings") -- keybindings
loadrc("wallpaper") -- wallpaper settings
loadrc("widgets") -- widgets configuration
loadrc("tags") -- tags handling
loadrc("xlock") -- lock screen

View file

@ -1,25 +0,0 @@
-- Change wallpaper
local wtimer = timer { timeout = 0 }
config.wallpaper = {}
config.wallpaper.directory = awful.util.getdir("config") .. "/wallpapers"
config.wallpaper.current = awful.util.getdir("cache") .. "/current-wallpaper.png"
-- We use fvwm-root because default backend for awsetbg does not seem
-- to accept to set multiscreen wallpapers.
local change = function()
awful.util.spawn_with_shell(
awful.util.getdir("config") .. "/bin/build-wallpaper " ..
"--crop --directory " .. config.wallpaper.directory ..
" --target " .. config.wallpaper.current ..
"&& fvwm-root -r " .. config.wallpaper.current)
end
wtimer:add_signal("timeout", function()
change()
wtimer:stop()
wtimer.timeout = math.random(3000, 3600)
wtimer:start()
end)
wtimer:start()

View file

@ -6,6 +6,7 @@ After=compton@%i.service
After=xsettingsd@%i.service
After=tmux.service
Before=nm-applet@%i.service
Before=wallpaper@%i.service
[Service]
Environment=DISPLAY=%I

View file

@ -1,14 +1,16 @@
[Unit]
Description=Graphical user session for %I
StopWhenUnneeded=yes
Wants=awesome@%i.service
Wants=autorandr@%i.service
Wants=awesome@%i.service
Wants=compton@%i.service
Wants=inputplug@%i.service
Wants=misc-x@%i.service
Wants=nm-applet@%i.service
Wants=policykit-agent@%i.service
Wants=redshift@%i.service
Wants=wallpaper@%i.service
Wants=wallpaper@%i.timer
Wants=xiccd@%i.service
Wants=xsettingsd@%i.service
Wants=xss-lock@%i.service

View file

@ -0,0 +1,14 @@
[Unit]
Description=Build a wallpaper for %I
PartOf=graphical-session@%i.target
[Service]
Environment=DISPLAY=%I
Environment=WALLPAPER_DIRECTORY=%h/.config/awesome/wallpapers
Environment=WALLPAPER_OUTPUT=%h/.cache/awesome/current-wallpaper.png
ExecStart=%h/.config/awesome/bin/build-wallpaper --crop \
--directory $WALLPAPER_DIRECTORY \
--target $WALLPAPER_OUTPUT
ExecStart=/usr/bin/fvwm-root -r $WALLPAPER_OUTPUT
Type=oneshot
RemainAfterExit=false

7
systemd/wallpaper@.timer Normal file
View file

@ -0,0 +1,7 @@
[Unit]
Description=Wallpaper rotation for %I
PartOf=graphical-session@%i.target
[Timer]
OnUnitActiveSec=1h
RandomizedDelaySec=10m