You are not logged in.
Hello and Happy new year to everyone !
I made differents high-resolution pictures of the earth and I'd like to display them each 2hours.
I tried to launch a script in a crontab to display these pictures but I did something wrong and it's doing nothing.
I begin 9 scripts one for example this one for 8 o'clock (the second one for 10, third for 12 etc...):
#!/bin/bash
feh --bg-scale ~/.xplanet/images/Earth_HD/earth-hd/HPH-MAPS/easteeuropa-1920-8h.jpg
done
I'm really bad with maths and codes, I only got ideas and need a little help to realize this, help will be much apreciated.
In advance thanks
Offline
Simple one-liner that shows a random selection of images:
while true ; do feh --bg-scale --randomize "$HOME"/.xplanet/images/Earth_HD/earth-hd ; sleep 7200 ; done
A bit more is needed to show the images in order:
[non-working code redacted]
Untested and I'm sure there is a much better way of doing that
EDIT: to clarify, simply call those from ~/.config/openbox/autostart
No need for cronjobs or anything
EDIT2: ha! the second one doesn't work at all
Sorry OP, give me a minute...
Last edited by Head_on_a_Stick (2017-01-12 15:13:43)
Offline
thank you ! I'll try that, and yes the pics must be displayed in order of "time" each 2hrs.
Offline
Working, tested version:
#!/bin/sh
for i in "$HOME"/.xplanet/images/Earth_HD/earth-hd/* ; do
feh --bg-scale "$i" 2>/dev/null && sleep 7200 || continue
done
Last edited by Head_on_a_Stick (2017-01-12 15:17:07)
Offline
oops I miss the post or something ... I can wait a little
EDIT
The script "knows" what time it is for launching the picture of the moment of the day... (sorry for my english)?
For example if it's 3pm it will launch the 4pm one ?
big thanks !
Last edited by ragamatrix (2017-01-12 15:31:08)
Offline
I tweaked the script a bit (forgot to full-quote the variables, ahem), to alter the interval change the "sleep" command, it measures in seconds
Offline
The script "knows" what time it is for launching the picture of the moment of the day... (sorry for my english)?
For example if it's 3pm it will launch the 4pm one ?
Sorry, I missed this.
Well, the lines I posted will simply go through all of the files in the ~/.xplanet/images/Earth_HD/earth-hd/ folder and attempt to set them as a wallpaper then wait 7200 seconds (`sleep 7200`) and go to the next file in the list and try again.
To have specific wallpapers show at particular times would require a more complicated script.
Last edited by Head_on_a_Stick (2017-01-12 16:50:51)
Offline
No problem, thanks for these clear explanations, I'll have to search how to do what I would... for example if it's 9am I'd like that the script displays the 10am picture and continues with 12am, 14pm,16pm,18pm,20pm... Thank you for your help.
Offline
OK, so with a systemd .timer:
First, create the directories needed to run --user units:
mkdir -p ~/.config/systemd/user
Then create ~/.config/systemd/user/wallchanger.timer (as your normal user):
[Unit]
Description=Change wallpaper at set times.
[Timer]
OnCalendar=*-*-* 2,4,6,8,10,12,14,16,18,20,22:00:00
Persistent=true
[Install]
WantedBy=timers.target
With the matching ~/.config/systemd/user/wallchanger.service
[Unit]
Description=Change wallpaper at set times.
[Service]
Type=oneshot
Environment=DISPLAY=:0
ExecStart=/bin/sh -c "for i in $(/bin/date | /usr/bin/awk -F '[ :]' '{print $4}') ; do /usr/bin/feh --bg-scale $HOME/.xplanet/images/Earth_HD/earth-hd/$i.png 2>/dev/null ; done"
This requires that the wallpaper pictures be named 10.jpg, 12.jpg, 14.jpg, etc.
Enable the .timer (to start at the next and sunsequent boots) with:
systemctl --user enable wallchanger.timer
Start the .timer immediately with:
systemctl --user start wallchanger.timer
Check the status with:
systemctl --user list-timers
EDIT2: changed "Type=" from "oneshot" to "simple", maybe more changes to come...
I'm awful, I know
Last edited by Head_on_a_Stick (2017-01-12 20:41:15)
Offline
The final working version is posted above, no need for separate scripts, just ~/.config/systemd/user/wallchanger.{service,timer}
Offline
morning'
Just launched the 2 scripts to test, waiting for 10:00 to know if it's working, then I'll post an archive with the pictures to share it for everybody. Thanks again Head_on_Stick !
Offline
don't know why, nothing happened:
raphix@debian:~$ systemctl --user list-timers
NEXT LEFT LAST PASSED UNIT ACTIVATES
ven 2017-01-13 12:00:00 +02 1h 56min left ven 2017-01-13 10:00:46 +02 2min 38s ago wallchanger.timer wallchanger.service
1 timers listed.
Pass --all to see loaded but inactive timers, too.
raphix@debian:~$
Offline
don't know why, nothing happened:
Maybe I'm wrong...
the service would have to be supplemented?
With the matching ~/.config/systemd/user/wallchanger.service
[Unit] Description=Change wallpaper at set times. [Service] Type=oneshot Environment=DISPLAY=:0 ExecStart=/bin/sh -c "for i in $(/bin/date | /usr/bin/awk -F '[ :]' '{print $4}') ; do /usr/bin/feh --bg-scale $HOME/.xplanet/images/Earth_HD/earth-hd/$i.png 2>/dev/null ; done" [Install] <--- WantedBy=graphical.target <---
Offline
Offline
^ at 2 pm I had not yet installed feh ... :8
at 16.00 clock I was not at home and the computer slept ...
now at 18.00 systemd changes me the background image!
Wow HoaS, it works as you thought.
My service:
[Unit]
Description=Change wallpaper at set times.
[Service]
Type=simple
Environment=DISPLAY=:0
ExecStart=/bin/sh -c "for i in $(/bin/date | /usr/bin/awk -F '[ :]' '{print $4}') ; do /usr/bin/feh --bg-scale $HOME/tmp/$i.png 2>/dev/null ; done"
[Install]
WantedBy=graphical.target
at 20.00 clock your wallpaper - ragamatrix - would be the turn.
I'm curious.
Offline
Thanks for testing unklar
Do you actually need that [Install] section in wallchanger.service?
The .timer works fine in my BunsenLabs system without that section and that stanza would only be parsed if `systemctl --user {enable,start} wallchanger.service` was used and that is not the command that should be used.
These commands should be used instead:
systemctl --user start wallchanger.timer # starts .timer immediately
systemctl --user enable wallchanger.timer # starts .timer automatically from the next boot
@Ragamatrix: I'm happy to troubleshoot this if you are
Can you confirm how exactly you have set things up?
What is the output of:
systemctl --user list-timers
systemctl --user status wallchanger.{timer,service}
Also, does my ExecStart command actually work on your system?
Try running it from a terminal:
/bin/sh -c "for i in $(/bin/date | /usr/bin/awk -F '[ :]' '{print $4}') ; do /usr/bin/feh --bg-scale $HOME/tmp/$i.png 2>/dev/null ; done"
Check if the full paths to the commands are correct with `which {sh,date,awk,feh}` and change if needed.
Last edited by Head_on_a_Stick (2017-01-13 19:01:50)
Offline
At first, the background image also changes at 8 pm
Do you actually need that [Install] section in wallchanger.service?
$ systemctl status --user wallchanger.service
● wallchanger.service - Change wallpaper at set times.
Loaded: loaded (/home/unklar/.config/systemd/user/wallchanger.service; disabled)
Active: inactive (dead) since Fr 2017-01-13 20:00:42 CET; 18min ago
Process: 14840 ExecStart=/bin/sh -c for i in $(/bin/date | /usr/bin/awk -F '[ :]' '{print $4}') ; do /usr/bin/feh --bg-scale $HOME/tmp/$i.png 2>/dev/null ; done (code=exited, status=0/SUCCESS)
Main PID: 14840 (code=exited, status=0/SUCCESS)
Without the [Install] section I have not tried yet, because it did not work at @ragamatrix ...
$ systemctl status --user wallchanger.timer
● wallchanger.timer - Change wallpaper at set times.
Loaded: loaded (/home/unklar/.config/systemd/user/wallchanger.timer; enabled)
Active: active (waiting) since Fr 2017-01-13 13:00:10 CET; 7h ago
Last edited by unklar (2017-01-13 19:35:46)
Offline
^ ok HoaS, it is 22.00 clock and he makes the change also without the [Install] statement.
But I did not understand it yet.
systemctl status --user wallchanger.service
● wallchanger.service - Change wallpaper at set times.
Loaded: loaded (/home/unklar/.config/systemd/user/wallchanger.service; static)
Active: inactive (dead) since Fr 2017-01-13 22:00:54 CET; 2min 54s ago
Process: 2743 ExecStart=/bin/sh -c for i in $(/bin/date | /usr/bin/awk -F '[ :]' '{print $4}') ; do /usr/bin/feh --bg-scale $HOME/tmp/$i.png 2>/dev/null ; done (code=exited, status=0/SUCCESS)
Main PID: 2743 (code=exited, status=0/SUCCESS)
systemctl status --user wallchanger.timer
● wallchanger.timer - Change wallpaper at set times.
Loaded: loaded (/home/unklar/.config/systemd/user/wallchanger.timer; enabled)
Active: active (waiting) since Fr 2017-01-13 21:10:23 CET; 53min ago
[Unit]
Description=Change wallpaper at set times.
[Service]
Type=simple
Environment=DISPLAY=:0
ExecStart=/bin/sh -c "for i in $(/bin/date | /usr/bin/awk -F '[ :]' '{print $4}') ; do /usr/bin/feh --bg-scale $HOME/tmp/$i.png 2>/dev/null ; done"
Difference:
The service is now marked as * static * = * disabled *.
Last edited by unklar (2017-01-14 09:32:44)
Offline
Thanks again unklar, the "static" type is correct for wallchanger.service — we don't want to enable that .service directly anyway.
Last edited by Head_on_a_Stick (2017-01-13 22:48:08)
Offline
^ You are welcome.
Offline