Eu queria mudar meu papel de parede periodicamente e aleatoriamente de uma pasta com fotos.
Eu usei o programa "feh" e escrevi um pequeno script com o bash chamado wallpaperscript.sh :
#!/bin/bash
files=(/torellino/Dropbox/Dropbox/Sfondi/*)
feh --bg-scale ${files[RANDOM % ${#files[@]}]}
Quando eu uso o script em um terminal, ele funciona e o papel de parede é alterado aleatoriamente.
Para automatizar o processo e deixar o script executar a cada poucos minutos, decidi usar o timer systemd. Então eu criei 2 arquivos e os coloquei em / etc / systemd / system /:
wallpaper.service :
[Unit]
Description=Call wallpaperscript.sh and change the wallapaper
[Service]
ExecStart="/etc/systemd/system/wallpaperscript.sh"
e wallpaper.timer :
[Unit]
Description=Runs wallpaperscript every 10 minutes
[Timer]
# Time to wait after booting before we run first time
OnBootSec=1min
# Time between running each consecutive time
OnUnitActiveSec=10min
Unit=wallpaper.service
[Install]
WantedBy=multi-user.target
Na verdade, eu não criei esses, mas os encontrei em algum lugar. De qualquer forma eu habilitei e comecei wallpaper.timer mas não funcionou. Se eu verificar "systemctl status wallpaper.timer", posso ver que o cronômetro está funcionando:
● wallpaper.timer - Runs wallpaperscript every 10 minutes
Loaded: loaded (/etc/systemd/system/wallpaper.timer; enabled; vendor preset: disabled)
Active: active (waiting) since Fri 2018-06-01 19:42:40 CEST; 16min ago
Trigger: Fri 2018-06-01 20:03:47 CEST; 4min 14s left
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
wallpaper.service do outro lado me dá um erro:
● wallpaper.service - Call wallpaperscript.sh and change the wallapaper
Loaded: loaded (/etc/systemd/system/wallpaper.service; static; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2018-06-01 19:53:47 CEST; 7min ago
Process: 919 ExecStart=/etc/systemd/system/wallpaperscript.sh (code=exited, status=2)
Main PID: 919 (code=exited, status=2)
Pesquisei soluções, mas não encontrei nenhuma. Aliás, é a primeira vez que estou usando systemd, então eu realmente não consigo descobrir o problema sozinho.
Estou usando o arch-linux com o i3 se isso puder ajudar de qualquer maneira
Eu também tenho o sderr para wallpaper.service e eu tenho isso:
"sudo journalctl -u wallpaper.service"
giu 01 19:43:38 placobravo systemd[1]: Started Call wallpaperscript.sh and change the wallapaper.
giu 01 19:43:39 placobravo wallpaperscript.sh[452]: feh WARNING: You have no HOME, cannot read configuration
giu 01 19:43:39 placobravo wallpaperscript.sh[452]: feh ERROR: Can't open X display. It *is* running, yeah?
giu 01 19:43:39 placobravo systemd[1]: wallpaper.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
giu 01 19:43:39 placobravo systemd[1]: wallpaper.service: Failed with result 'exit-code'.
giu 01 19:53:47 placobravo systemd[1]: Started Call wallpaperscript.sh and change the wallapaper.
giu 01 19:53:47 placobravo wallpaperscript.sh[919]: feh WARNING: You have no HOME, cannot read configuration
giu 01 19:53:47 placobravo wallpaperscript.sh[919]: feh ERROR: Can't open X display. It *is* running, yeah?
giu 01 19:53:47 placobravo systemd[1]: wallpaper.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
giu 01 19:53:47 placobravo systemd[1]: wallpaper.service: Failed with result 'exit-code'.
giu 01 20:04:47 placobravo systemd[1]: Started Call wallpaperscript.sh and change the wallapaper.
giu 01 20:04:47 placobravo wallpaperscript.sh[1108]: feh WARNING: You have no HOME, cannot read configuration
giu 01 20:04:47 placobravo wallpaperscript.sh[1108]: feh ERROR: Can't open X display. It *is* running, yeah?
giu 01 20:04:47 placobravo systemd[1]: wallpaper.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
giu 01 20:04:47 placobravo systemd[1]: wallpaper.service: Failed with result 'exit-code'.
giu 01 20:15:47 placobravo systemd[1]: Started Call wallpaperscript.sh and change the wallapaper.
giu 01 20:15:47 placobravo wallpaperscript.sh[1343]: feh WARNING: You have no HOME, cannot read configuration
giu 01 20:15:47 placobravo wallpaperscript.sh[1343]: feh WARNING: /torellino/Dropbox/Dropbox/Sfondi/the does not exist - skipping
giu 01 20:15:47 placobravo wallpaperscript.sh[1343]: feh WARNING: witcher3.jpg does not exist - skipping
giu 01 20:15:47 placobravo wallpaperscript.sh[1343]: feh: No loadable images specified.
giu 01 20:15:47 placobravo wallpaperscript.sh[1343]: See 'feh --help' or 'man feh' for detailed usage information
giu 01 20:15:47 placobravo systemd[1]: wallpaper.service: Main process exited, code=exited, status=1/FAILURE
giu 01 20:15:47 placobravo systemd[1]: wallpaper.service: Failed with result 'exit-code'.
giu 01 20:26:47 placobravo systemd[1]: Started Call wallpaperscript.sh and change the wallapaper.
giu 01 20:26:47 placobravo wallpaperscript.sh[1388]: feh WARNING: You have no HOME, cannot read configuration
giu 01 20:26:47 placobravo wallpaperscript.sh[1388]: feh ERROR: Can't open X display. It *is* running, yeah?
giu 01 20:26:47 placobravo systemd[1]: wallpaper.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
giu 01 20:26:47 placobravo systemd[1]: wallpaper.service: Failed with result 'exit-code'.
giu 01 20:37:47 placobravo systemd[1]: Started Call wallpaperscript.sh and change the wallapaper.
giu 01 20:37:47 placobravo wallpaperscript.sh[1579]: feh WARNING: You have no HOME, cannot read configuration
giu 01 20:37:47 placobravo wallpaperscript.sh[1579]: feh ERROR: Can't open X display. It *is* running, yeah?
giu 01 20:37:47 placobravo systemd[1]: wallpaper.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
giu 01 20:37:47 placobravo systemd[1]: wallpaper.service: Failed with result 'exit-code'.
Pelo que eu entendo, parece que o feh não pode acessar o X como Jeff Schaller apontou.
Alguém tem ideia de como eu poderia resolver isso?