You are not logged in.
I'd like Slim and my desktop (Xmonad) to have the same wallpaper, randomly selected from a specific directory each time I boot. The way I've thought to do this is:
1. Before Slim starts, run a script to
a. choose a random file from /home/wallpapers
b. copy the file as /tmp/wallpaper.jpg
2. link Slim's default background to /tmp/wallpaper.jpg
3. set /tmp/wallpaper.jpg as the background with feh in .xinitrc
I am having trouble with part 1. I don't know how to run a script before Slim starts, and I don't quite know how to get a script to copy a file from one directory to another with a new name.
Could anyone help? Or suggest an easier way to do this? Thanks.
Last edited by 0112358 (2013-01-03 17:15:58)
Offline
you'll want to create a systemd service file. It sounds to me like the type should be oneshot and should have before=slim.service. the ExecStart line could be something like
/bin/bash -c 'cp $(find /home/wallpaper | sort -R | head -n 1) /tmp/wallpaper'EDIT: even better, replace cp with ln -s to get a symbolic link rather than a physical copy.
Last edited by WizenedEE (2013-01-03 03:42:04)
Offline
Thanks. I'm having trouble with the service file though - I haven't gotten the knack of these yet. When I save the below as /etc/systemd/system/wallpaper.service and test it with systemctl start wallpaper.service, it just hangs. Any idea what I'm messing up?
[Unit]
Description=Sync wallpaper between Slim and Desktop
Before=slim.service
[Service]
Type=oneshot
ExecStart=/bin/bash -c 'ln -s $(find ~/Pictures/other/wallpapers/favorites | sort -R | head -n 1) /tmp/wallpaper.jpg'
[Install]
WantedBy=multi-user.targetOffline
You might be better off turning your command into a small script and running it from service file. Using full path to wallpapers as well
Last edited by heman (2013-01-03 09:14:11)
Offline
And/or include "User=<yourusername>" because, as written, the ~ will be expanded to /root/.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Got it. Thanks everyone. Using the full path and putting the command in a script worked. The working file is below.
[Unit]
Description=Sync wallpaper between Slim and desktop
Before=slim.service
[Service]
Type=oneshot
ExecStart=/home/USER/Scripts/wallpaper.sh
[Install]
WantedBy=multi-user.targetOffline