jonls / redshift

Redshift adjusts the color temperature of your screen according to your surroundings. This may help your eyes hurt less if you are working in front of the screen at night.
http://jonls.dk/redshift
GNU General Public License v3.0
5.85k stars 424 forks source link

Unable to connect to GeoClue. Unable to get location from provider. #318

Open DimitriPapadopoulos opened 8 years ago

DimitriPapadopoulos commented 8 years ago

Unable to start redshift 1.11 on Fedora 23 since yesterday:

$ redshift
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Unable to start GeoClue client: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: Geolocation disabled for UID 1000.
Unable to connect to GeoClue.
Unable to get location from provider.
$ 

This is similar to #158 but the proper fix - having both redshift.desktop and redshift-gtk.desktop files - doesn't help any more. Indeed both files are available in Fedora since #1309177 was closed:

$ rpm -qf /usr/share/applications/redshift.desktop
redshift-1.11-1.fc23.x86_64
$ rpm -qf /usr/share/applications/redshift-gtk.desktop
redshift-gtk-1.11-1.fc23.x86_64
$ 

Both alternative solutions work although they are supposed to be bad solutions:

  1. Run as sudo redshift-gtk
  2. Add to /etc/geoclue/geoclue.conf:
[redshift]
allowed=true
system=false
users=
DimitriPapadopoulos commented 8 years ago

I've found location services had been turned off. After turning on location services redshift runs smoothly.

It makes sense that redshift needs a location. However instead of exiting with a cryptic error message, redshift could display a dialog to manually set a location or turn on location services.

For example gnome-maps doesn't crash when location services are not running:

See attached screen capture of gnome-maps: gnome-maps

mikeatlas commented 8 years ago

@DimitriPapadopoulos where can I "turn on location services" setting you are describing... gnome-maps doesn't work on 14.04. I presume there's an underlying package and not something inherently required about gnome-maps being installed to fix redshift's geoclue2 problems.

DimitriPapadopoulos commented 8 years ago

Gnome maps is just an example of an alternative way to handle missing location services. Other than that it is totally unrelated to redshift. I don't know about Ubuntu 14.04, I have Fedora 23 here and location services can be enabled/disabled from Settings.

DimitriPapadopoulos commented 8 years ago

As far as I can tell it is quite difficult to disable intrusive services like geoclue (location service) in Ubuntu: http://askubuntu.com/questions/106916/how-do-i-stop-geoip-from-connecting-to-the-internet-every-time-i-boot

My guess is that location services are not disabled on your Ubuntu computer. Also I have just tried an Ubuntu 14.04 workstation and gnome-maps works pretty well once installed. Something might be broken on your computer.

mikeatlas commented 8 years ago

I decided to just install the latest build 1.11 from source and specify my lat:lon manually in the config. Personally I don't travel with my workstation across time zones .... Like ever. So dynamic geoclue calls every time redshift starts aren't really worth the struggle to resolve. Thanks for the reply @DimitriPapadopoulos

clayzermk1 commented 7 years ago

Was encountering this and have a clean fix. Currently using redshift 1.10-5ubuntu on Linux Mint 18 Sarah (straight from repo).

Installed redshift and redshift-gtk packages. Attempted to run redshift-gtk and encountered this issue. Ran redshift from command line and got:

$ redshift
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Unable to connect to GeoClue.
Unable to get location from provider.

Installed geoclue-2.0 sudo apt-get install geoclue-2.0. Ran another time from the terminal. Started no problems. Exited the terminal process and started redshift-gtk, no problems.

Hope this helps someone else :beers:

eadebayo commented 7 years ago

@clayzermk1 Thanks for the post. Worked for me. Mint 18, MATE.

clayzermk1 commented 7 years ago

At least in the .deb, it seems like geoclue-2.0 should be a requirement of the package if it's required. It seems like the .rpm could also use a dependency based on @DimitriPapadopoulos's original post. Can anyone on a .rpm distro comment as to the minimum set of packages they had to install to get redshift to work?

mrschaal commented 7 years ago

@clayzermk1 thank you very much, helped me a lot. Worked perfectly for me, using Linux Mint 18 KDE

vbsteja commented 7 years ago

@clayzermk1 it solved for me. thanks so much.

artforlife commented 6 years ago

I am still having this issue on Ubuntu 16.04. I have tried every solution advised in this thread to no avail. Any idea how I can troubleshoot this?

imflash217 commented 6 years ago

Based on the original post, the geo2 location provider is already installed. So there are two solutions to this:

  1. Run Redshift from command line as root sudo redshift
  2. Turn on Location services: Goto Settings --> Privacy --> Location Services (ON/OFF)
sodomak commented 6 years ago

Ok, so it is not possible to run Redshift without location services? It would be nice to be able to set the location manualy (I think I know where I am:) ). I see it as the privacy issue.

helo9 commented 6 years ago

No you don't need any location service, simply pass -l LAT:LON as option on command line.

saif-ellafi commented 6 years ago

On Fedora 28 KDE, only thing that worked was redshift-gtk -l 0:0

navoytak commented 6 years ago

On Fedora 28 Cinammon, the command redshift-gtk -l 0:0 also works Seems like recent update breaks the app.

ElijahLynn commented 6 years ago

I had this issue as well, my environment is Fish > Tmux > Guake. I had to exit Tmux within Guake and run redshift outside of Tmux. I had tried creating a new window (shell session) inside Tmux but that didn't work.

rmlrml commented 6 years ago

Getting almost the same error message in Debian too. geoclue-2.0 is installed. Error popup on startup:

Failed to run Redshift
Trying location provider `geoclue2'...
Unable to start GeoClue client:
GDBus.Error:org.freedesktop.DBus.Error.AccessDenied:
'redshift' disallowed, no agent for UID 1000.
Unable to connect to GeoClue.
Unable to get location from provider.

In the terminal, no gtk:

ryan@pocketwee:~$ redshift
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Unable to start GeoClue client: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: 'redshift' disallowed, no agent for UID 1000.
Unable to connect to GeoClue.
Unable to get location from provider.

sudo same:

ryan@pocketwee:~$ sudo redshift
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Unable to start GeoClue client: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: 'redshift' disallowed, no agent for UID 0.
Unable to connect to GeoClue.
Unable to get location from provider.

Was suggested to start service, no go:

ryan@pocketwee:~$ systemctl --user start redshift.service
ryan@pocketwee:~$ redshift
Trying location provider `geoclue2'...
Using provider `geoclue2'.
Unable to start GeoClue client: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: 'redshift' disallowed, no agent for UID 1000.
Unable to connect to GeoClue.
Unable to get location from provider.
akostadinov commented 6 years ago

What version was merge request 6 merged into? Perhaps it will resolve the issue.

FYI for Fedora 28 issue is 1585970.

DrDoctor13 commented 6 years ago

I'm getting this issue on KDE 5.13.3. When I log in, I get prompted to allow location access (not something I knew KDE did) but it doesn't seem to do anything.

Trying location provider `geoclue2'...
Using provider `geoclue2'.
Using method `randr'.
Waiting for initial location to become available...
Unable to start GeoClue client: GDBus.Error:org.freedesktop.DBus.Error.AccessDenied: 'redshift' disallowed, no agent for UID 1000.
Access to the current location was denied by GeoClue!
Make sure that location services are enabled and that Redshift is permitted
to use location services. See https://github.com/jonls/redshift#faq for more
information.
Unable to get location from provider.
ElijahLynn commented 6 years ago

This seems like an issue with connectivity with the external server. The error handling needs to be better around refused connections.

sbrl commented 6 years ago

I'm using an Arch-based distro (Artix Linux actually - it uses OpenRC instead of SystemD) with XFCE4, and I get a prompt every time I sign in asking me whether I want redshift to be allowed to access my location. I found a notify_location preference under xfce4-notifyd in the Xfconf settings editor - and its set to 2, but I'm currently unsure if this is the right setting I'm after - and, indeed, what to set it to to auto-approve location access for redshift if it is.

Skatox commented 6 years ago

I have the same problem on Arch inside KDE, I don't know how to enable location from KDE, since it seems like it's a GNOME thing.

akostadinov commented 6 years ago

You need patched geoclue, and make sure geoclue demo agent is running. Agent will start geoclue on demand.

Jeremytho2050 commented 6 years ago

I'm new to GitHub and I do not know how to post the error

I have a problem starting Redshitf in Konsole: redshift -o. And I get this:

Waiting for the current location to be available ... Unable to start GeoClue client: GDBus.Error: org.freedesktop.DBus.Error.AccessDenied: 'redshift' disallowed, no agent for UID 1000. Access to the current location was denied by GeoClue! Make sure that location services are enabled and that Redshift is permitted to use location services. See https://github.com/jonls/redshift#faq for more information. The location of the provider could not be obtained.

Help me please :'v

sbrl commented 6 years ago

@akostadinov:

You need patched geoclue, and make sure geoclue demo agent is running. Agent will start geoclue on demand.

Where can I find this patched geoclue?

Also, I'm unsure as to what you mean by geoclue demo agent.

akostadinov commented 6 years ago

@sbrl , read my last comment about bug fix. You need a version with the merge request applied. On Fedora 28 I'm using Fedora 29 latest Koji builds, see the bugzilla issue.

The demo agent that is part of the GeoClue distribution needs to be started unless you are running Gnome. On Fedora 28 XFCE starts it automatically. No idea about other distros and/or DEs.

ghost commented 6 years ago

Hello. In my case I think it has been solved for me by making a symbolic link of the file: /etc/xdg/autostart/geoclue-demo-agent.desktop, into the directory: ~/.config/autostart. Hope it works for other people. Also, I use Plasma as my Desktop Environment and Arch Linux as my Linux distribution.

Portergos commented 6 years ago

/etc/xdg/autostart/geoclue-demo-agent.desktop

Nice! So i added (/usr/lib/geoclue-2.0/demos/agent| redshift-gtk) & to my i3-wm startup and geoclue2 is working fine. Thanks!

akostadinov commented 6 years ago

@Portergos , I assume you'd better change | to && or something. The | is sending agent stdout to redshift which doesn't do any good and is a potential source of trouble.

Portergos commented 6 years ago

@akostadinov Ok, i just saw that previous version didn't come with /usr/lib/geoclue-2.0/demos/agent there was only /usr/lib/geoclue-2.0/demos/where-am-i so i don't think it's a geoclue bug but redshift need to invoke the library (with a new update i hope)

sbrl commented 6 years ago

I ended up writing a one-liner that I've added to my startup applications:

redshift -l $(curl ipinfo.io | jq -j .loc | tr ',' ':')

This downloaded my approximate location, based on my IP address, from ipinfo.io and passes it as a 'manual' location to redshift. When I move around enough for it to become an issue, I usually have to shut my laptop down to get off a train, go through airport security, etc - and I don't have an inbuilt GPS sensor (as far as I know, anyway :P), so I don't think it really matters.

Furthermore, I don't turn my device on and off enough for the rate limit of ipinfo.io to take effect either :P

Note that it requires that both curl and jq be installed.

lf- commented 6 years ago

I fixed my issue by adding a quick systemd user service to enable the geoclue agent service.

Put something like the following at ~/.config/systemd/user/geoclue-agent.service, then enable/start it with systemctl --user enable --now geoclue-agent

[Unit]
Description=redshift needs to get a (geo)clue

[Service]
ExecStart=/usr/lib/geoclue-2.0/demos/agent

[Install]
WantedBy=default.target
stpeters00 commented 6 years ago

For Fedora and perhaps other distros, the path to the agent is /usr/libexec/geoclue-2.0/demos/agent (/usr/lib -> /usr/libexec)

fictionic commented 6 years ago

@lf- That works for me! Except I can't start redshift or redshift-gtk as a systemd service. Any ideas on why? I've followed the instructions on the Arch Wiki here without success

jerbob commented 6 years ago

Quick note for people using Arch: If you get an ImportError from running redshift-gtk:

Traceback (most recent call last):
  File "/usr/bin/redshift-gtk", line 26, in <module>
    from redshift_gtk.statusicon import run
  File "/usr/lib/python3.7/site-packages/redshift_gtk/statusicon.py", line 30, in <module>
    import gi
  File "/usr/lib/python3.7/site-packages/gi/__init__.py", line 42, in <module>
    from . import _gi
ImportError: cannot import name '_gi'

you might have to run it with python2: python2 /usr/bin/redshift-gtk

jonls commented 6 years ago

@AnonGuy Please don't run it with python 2, it will break. Please ask you distribution to fix the packaging if there's an issue. You may need to fix your install of python gobject.

jerbob commented 6 years ago

@jonls Ah, my bad. A reinstall of python-gobject: sudo pacman -S python-gobject fixes the issue.

It seems that I had the global Python interpreter switched to a different version with pyenv during the original installation, so I had to switch to the system version with pyenv global system before reinstalling.

httpsgithu commented 6 years ago

resolution for archlinux systemctl --user enable redshift.service

lukehinds commented 5 years ago

@PowerOlive That's not really a resolution, the problem is geoclue2 denying redshift access, not enabling the systemd wrapper service for redshift.

The fix for Arch is to upgrade to geoclue-2.4.11 or >

See here https://github.com/jonls/redshift/issues/636#issuecomment-407802240

Raptime commented 5 years ago

Using debian even with latest geoclue and redshift the issue is still here, unless I manually star the demo agent prior to starting redshift

EDIT: it looks like I get a notification asking me to allow redshift to access location (I'm using XFCE), it works when I accept. I must have missed the notification earlier.

qazip commented 5 years ago

@lukehinds, you mean downgrade right? Because I have geoclue-2.4.12-1 and I am still having this problem.

alx-a commented 5 years ago

not using geolocation here, Debian buster/sid. as suggested in the archwiki, https://wiki.archlinux.org/index.php/Redshift#Manual_setup I solved by launching redshift -l 59.33258:18 For your location, you can use http://www.geonames.org/ or an online map serive. May i suggest that after the GEO permission error message the user is prompted/given the option to enter location manually.

razor-x commented 5 years ago

I have it working now on systemd using:

fictionic commented 5 years ago

@razor-x I also needed to add this to redshift-gtk.service

Environment=DISPLAY=:0

Also, what is xresources.service? I don't think I have that.

Once we get this all sorted out, can we make sure some version of these instructions are put in the installation section of the readme, or in the man page, or both?

razor-x commented 5 years ago

@fictionic It loads my custom Xresources. I put that so all the x11 based stuff that I start with systemd runs after the xresources are loaded. If you don't load your own xresources, then that's not needed.

That Environment option is not needed for me, but it might be depending on how you are using systemd to start X11 apps. Note I am using (systemctl--user).

Anyway, the key is that the /usr/lib/geoclue-2.0/demos/agent starts before redshift-gtk.service.

dacresni commented 5 years ago

considering that the plasmid for KDE communicates with Geoclue via DBus, I doubt redshift-gtk is necessary for the fix to work. I think you just need to add redshift to geoclue's config.

ghost commented 5 years ago

@lf-

I'd like to try your solution (on Linux Mint) but I cannot find any demos folder containing a file called agent. Could you advice? which agent yields nothing. I do have /usr/libexec/geoclue-2.0/demos/ but it has no agent file in it.

sbrl commented 5 years ago

Looks like this issue is spreading. It's now occurring on Ubuntu 18.10.

pastet89 commented 5 years ago

@sbrl I love your solution. For some reason the jq command had to be slightly modified to get it working. I ended up writing a simple bash patch which first tries to get the coordinates from ipinfo.io and if fails, starts the script with 0:0 coordinates.