boramalper / himawaripy

Set near-realtime picture of Earth as your desktop background
http://labs.boramalper.org/himawaripy
MIT License
1.62k stars 239 forks source link

Image not showing up in Ubuntu 16.04 #83

Closed relentless-coder closed 5 years ago

relentless-coder commented 7 years ago

I followed every step as described in the installation process, but nothing happened. The is installed, I have looked into the directory, but the desktop background didn't change.

soohyunc commented 7 years ago

yup, this is true. the background image did not change automatically with crontab configuration, but only worked with manual run on terminal. why?

ngrande commented 7 years ago

cron only has access to a very restricted set of environment variables - the python script here makes use of one that is not available in that case.

see SO answer here: https://stackoverflow.com/questions/10374520/gsettings-with-cron/19666729#19666729

boramalper commented 7 years ago

Hey,

I tried and experienced the problem myself as well, although I didn't encounter it before (not sure if they changed the behaviour of services [if not, then how did it work for so long?]).

Anyway, not only the script makes use of environment variables but also gsettinngs (on $DISPLAY) which himawaripy heavily relies on. I'm trying to find a way without hard-coding environment variables, but it might be our last resort.

soohyunc commented 7 years ago

i have managed to fix this issue as a walk-around approach. basically, the link that @ngrande shared above helped a lot.

that is, i have created a separate shell script as the below, and added in my crontab with the same period as the himawaripy executable file. this seemed to work very well so far.

#!/bin/bash
# http://bit.ly/2ines3u

# Wallpaper's directory.
dir="${HOME}/.cache/himawaripy/"

# export DBUS_SESSION_BUS_ADDRESS environment variable
PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ | cut -d= -f2-)

# Random wallpaper.
wallpaper=`find "${dir}" -type f | shuf -n1`

# Change wallpaper.
# http://bit.ly/HYEU9H
gsettings set org.gnome.desktop.background picture-options "spanned"
gsettings set org.gnome.desktop.background picture-uri "file://${wallpaper}"
zenithyr commented 6 years ago

above approach by @soohyunc is totally working. One suggestion is to change the "spanned" to "scaled" in order to center the image.

Thanks!

raphaelbs commented 5 years ago

@soohyunc answer should be in README. Thank you!

boramalper commented 5 years ago

Fixed! You should now be able to use it as described in the README without any additional scripts. Let me know if you have any further questions. =)

zzbajie commented 2 years ago

OR PID=$(pgrep gnome-session | head -n1)