Open ihtruelsen opened 2 years ago
小严同学已收到您的邮件,
Ubuntu22.04 GNOME
sudo nano /home/xxx/himawaripy.sh crontab -e /10 * /home/xxx/himawaripy.sh
${HOME}/.local/bin/himawaripy --auto-offset --dont-change
sleep 15
dir="${HOME}/.cache/himawaripy/"
PID=$(pgrep gnome-session|head -n1) export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
wallpaper=find "${dir}" -type f | shuf -n1
/usr/bin/gsettings set org.gnome.desktop.background picture-options "scaled" /usr/bin/gsettings set org.gnome.desktop.background picture-uri "file://${wallpaper}" `
I can run it from terminal with the following output:
ian@ian-MS-7C84:~$ /home/ian/.local/bin/himawaripy --auto-offset himawaripy 2.2.0 Updating... Latest version: 2021/11/17 22:20:00 GMT. Detected offset: UTC-08:00 Offset version: 2021/11/17 04:20:00 GMT. Downloading tiles... Downloading tiles: 1/16 completed... Downloading tiles: 2/16 completed... Downloading tiles: 3/16 completed... Downloading tiles: 4/16 completed... Downloading tiles: 5/16 completed... Downloading tiles: 6/16 completed... Downloading tiles: 7/16 completed... Downloading tiles: 8/16 completed... Downloading tiles: 9/16 completed... Downloading tiles: 10/16 completed... Downloading tiles: 11/16 completed... Downloading tiles: 12/16 completed... Downloading tiles: 13/16 completed... Downloading tiles: 14/16 completed... Downloading tiles: 15/16 completed... Downloading tiles: completed. Saving to '/home/ian/.cache/himawaripy/himawari-20211117T042000.png'... No such key “draw-background” No such key “draw-background” Exception in thread himawaripy-main-thread: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/home/ian/.local/lib/python3.9/site-packages/himawaripy/main.py", line 214, in thread_main r = set_background(output_file) File "/home/ian/.local/lib/python3.9/site-packages/himawaripy/utils.py", line 36, in set_background assert os.system('bash -c "gsettings set org.gnome.desktop.background draw-background true"') == 0 AssertionError
This produces an image as expected.
This is my crontab line: 5 /home/ian/.local/bin/himawaripy --auto-offset >> /home/ian/log/cron.log 2>&1
This is the output of my cron.log:
himawaripy 2.2.0 Updating... Latest version: 2021/11/17 21:40:00 GMT. Detected offset: UTC-08:00 Offset version: 2021/11/17 03:40:00 GMT. Downloading tiles... Downloading tiles: 1/16 completed... Downloading tiles: 2/16 completed... Downloading tiles: 3/16 completed... Downloading tiles: 4/16 completed... Downloading tiles: 5/16 completed... Downloading tiles: 6/16 completed... Downloading tiles: 7/16 completed... Downloading tiles: 8/16 completed... Downloading tiles: 9/16 completed... Downloading tiles: 10/16 completed... Downloading tiles: 11/16 completed... Downloading tiles: 12/16 completed... Downloading tiles: 13/16 completed... Downloading tiles: 14/16 completed... Downloading tiles: 15/16 completed... Downloading tiles: completed. Saving to '/home/ian/.cache/himawaripy/himawari-20211117T034000.png'... Could NOT retrieve env. var. DESKTOP_SESSION Could NOT retrieve env. var. KDE_FULL_SESSION Could NOT retrieve env. var. GNOME_DESKTOP_SESSION_ID Could NOT retrieve env. var. XDG_CURRENT_DESKTOP Fetched env. var. DBUS_SESSION_BUS_ADDRESS as
unix:path=/run/user/1000/bus
Could NOT retrieve env. var. DISPLAY Could NOT retrieve env. var. DESKTOP_SESSION Could NOT retrieve env. var. KDE_FULL_SESSION Could NOT retrieve env. var. GNOME_DESKTOP_SESSION_ID Could NOT retrieve env. var. XDG_CURRENT_DESKTOPAnd the background is black.
I am running Ubuntu 21.10 with gnome-shell version 40.5