
사진이 있는 폴더에서 주기적으로 무작위로 배경화면을 바꾸고 싶었습니다. 나는 "feh"라는 프로그램을 사용하고 bash를 사용하여 다음과 같은 작은 스크립트를 작성했습니다.wallpaperscript.sh:
#!/bin/bash
files=(/torellino/Dropbox/Dropbox/Sfondi/*)
feh --bg-scale ${files[RANDOM % ${#files[@]}]}
터미널에서 스크립트를 사용하면 작동하고 배경 화면이 무작위로 변경됩니다. 프로세스를 자동화하고 스크립트가 몇 분마다 실행되도록 하기 위해 systemd 타이머를 사용하기로 결정했습니다. 그래서 2개의 파일을 만들어 /etc/systemd/system/에 넣었습니다.
벽지.서비스:
[Unit]
Description=Call wallpaperscript.sh and change the wallapaper
[Service]
ExecStart="/etc/systemd/system/wallpaperscript.sh"
그리고벽지.타이머:
[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
실제로 제가 직접 만든 것은 아니지만 어딘가에서 찾았습니다. 어쨌든 wallpaper.timer를 활성화하고 시작했지만 작동하지 않았습니다. "systemctl status wallpaper.timer"를 확인하면 실제로 타이머가 작동하는 것을 볼 수 있습니다.
● 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에서 오류가 발생합니다.
● 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)
해결책을 찾았지만 아무 것도 찾지 못했습니다. 그런데 systemd를 처음 사용해서 문제를 스스로 파악할 수가 없네요.
어쨌든 도움이 될 수 있다면 i3과 함께 아치 리눅스를 사용하고 있습니다.
wallpaper.service에 대한 sderr도 얻었고 다음과 같은 결과를 얻었습니다.
"sudo 저널ctl -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'.
내가 이해할 수 있는 바로는 Jeff Schaller가 지적한 것처럼 feh는 X에 액세스할 수 없는 것 같습니다. 이 문제를 어떻게 해결할 수 있는지 아는 사람이 있나요?
답변1
StackExchange에 오신 것을 환영합니다.
출력에 feh
X 서버를 열 수 없다고 나와 있습니다. 다음에서 몇 가지 값을 설정해야 합니다.wallpaper.server
User=
배경화면을 설정하려는 사용자를 설정하세요.
Environment=DISPLAY=:0
디스플레이 섹션으로 이동해야 합니다. 이 게시물왜 둘 다 필요한지 설명합니다.