I am a new user of swaywm and fairly new with creating my own custom systemd services. I previously used Openbox, feh and systemd to created a scripted wallpaper change every 30 min. The below is a foo.service which functions fine in openbox:
[Unit]
Description=wallpaper rotate service
RefuseManualStart=no
RefuseManualStop=no
[Service]
Type=oneshot
User=trentonknight
ExecStart=/bin/sh -c 'DISPLAY=:0.0 feh --recursive --randomize --bg-fill /home/trentonknight/Pictures/Wallpaper/*'
This is the timer which runs it every 30 min:
[Unit]
Description=wallpaper rotate timer
RefuseManualStart=no
RefuseManualStop=no
[Timer]
Persistent=false
OnCalendar=*:0/30
Unit=wrotate.service
[Install]
WantedBy=default.target
Swaywm uses the Wayland compositer and is fantastic. However, feh only works with X. Without feh I can easily change my wallpaper with this simple command native to swaywm:
swaymsg output DP-3 bg foo_background.png
DP-3 is a result of runing this command prior:
swaymsg -t get_outputs
Using the above output command in a bash script I can automate the random selection of images for wallpapers in a directory. This works when run from command line without an issue:
#!/bin/bash
NEW=$(ls ~/Pictures/Wallpaper/ | shuf -n 1)
NEW_SWAY_BACK="~/Pictures/Wallpaper/"$NEW
swaymsg output DP-3 bg $NEW_SWAY_BACK fill
However, if I attempt to call this bash script from the following custom service it fails. Here is the service first:
[Unit]
Description=swaymsg output rotate wallpaper service
RefuseManualStart=no
RefuseManualStop=no
[Service]
WorkingDirectory=/usr/share/backgrounds/sway/
Type=forking
User=trentonknight
ExecStart=/usr/bin/bash sway_backgroud_changer.sh
KillMode=process
This is one of many versions I have attempted but they all have the same status after atempting to start:
[trentonknight@archboX system]$ sudo systemctl status swaywallr.service
* swaywallr.service - swaymsg output rotate wallpaper service
Loaded: loaded (/etc/systemd/system/swaywallr.service; disabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2018-05-12 18:37:17 EDT; 5s ago
Process: 30491 ExecStart=/usr/bin/bash sway_backgroud_changer.sh (code=exited, status=1/FAILURE)
May 12 18:37:17 archboX systemd[1]: Starting swaymsg output rotate wallpaper service...
May 12 18:37:17 archboX bash[30491]: sway socket not detected.
May 12 18:37:17 archboX bash[30491]: E: 05/12/18 18:37:17 - [ipc-client.c:37] Unable to connect to
May 12 18:37:17 archboX systemd[1]: swaywallr.service: Control process exited, code=exited status=1
May 12 18:37:17 archboX systemd[1]: swaywallr.service: Failed with result 'exit-code'.
May 12 18:37:17 archboX systemd[1]: Failed to start swaymsg output rotate wallpaper service.
[Install]
WantedBy=multi-user.target
I see that the SWAYSOCK is as follows:
[trentonknight@archboX system]$ echo $SWAYSOCK
/run/user/1000/sway-ipc.1000.527.sock
I'm clueless how to call it properly. Or even if that the problem? Additionally, I am running the following:
[trentonknight@archboX system]$ uname -a
Linux archboX 4.16.8-1-ARCH #1 SMP PREEMPT Wed May 9 11:25:02 UTC 2018 x86_64 GNU/Linux
I'm open to alternative approaches as well. I see there is a swaybg but running give the following printout and the man page does not include swaybg at all:
[trentonknight@archboX sway]$ swaybg
05/12/18 18:43:26 - [main.c:63] Do not run this program manually. See man 5 sway and look for output options.
My guess is its still in development.