You are not logged in.

#1 2016-07-29 21:28:57

Tallix
Member
From: Arizona, USA
Registered: 2013-06-02
Posts: 20

Make Redshift Fall Back to Manual Location

Hi all!

I use Redshift to avoid eye strain while using my computers in the evening. However, I often start up my computer when I don't have internet access. I like that Redshift automatically fetches my location using Geoclue when it starts up, because this means that if I'm travelling or I am otherwise not in my usual location the screen will shift according to the lighting conditions of the current area. However, the fact that Redshift just quits/doesn't work when I don't have internet access is somewhat problematic. Is there some way, using only the Redshift configuration file, that I can make Redshift first try to fetch my location from the internet, and if that fails to fall back to a manually set location? I read through the Redshift wiki article and there doesn't seem to be an obvious way to do this.

It probably wouldn't be hard to achieve this if I launched Redshift using a custom Bash script, but I would prefer to keep things as clean as possible by doing it through the configuration file.

Thank you!

Offline

#2 2016-07-29 22:59:00

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Make Redshift Fall Back to Manual Location

Redshift 1.10 Release Announcement wrote:

In the future, this will be fixed by a fallback to a cached location from a previous run or to a manually set location.

source

I guess the future hasn't arrived yet. roll


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#3 2016-07-29 23:22:11

Tallix
Member
From: Arizona, USA
Registered: 2013-06-02
Posts: 20

Re: Make Redshift Fall Back to Manual Location

Ah, thank you very much. I think I'll hack together that script and post it here then.

Offline

#4 2016-07-29 23:52:02

Tallix
Member
From: Arizona, USA
Registered: 2013-06-02
Posts: 20

Re: Make Redshift Fall Back to Manual Location

Okay, here's what I came up with:

#!/bin/bash

#custom startup for Redshift that tests whether geoclue is working, and if not falls back to manually set coordinates

sleep 60    #give the machine time to connect to an available network

if [ "$(/usr/lib/geoclue2/geoclue-2.0/demos/where-am-i)" = "" ]; then
	redshift-gtk -l LAT:LON    #make sure to set your own fallback coordinates here
else
	redshift-gtk
fi

The only problem I see right now is that /usr/lib/geoclue2/geoclue-2.0/demos/where-am-i takes a long time to actually produce an output. Otherwise, adding this script to start up with the desktop environment seems to implement this feature.

If anybody has suggestions for improvements/fixes to this script or overall implementation, I would love to hear them! If I think of anything for myself I'll post it here as well.

Last edited by Tallix (2016-07-30 00:06:12)

Offline

#5 2016-08-02 15:19:40

alphaniner
Member
From: Ancapistan
Registered: 2010-07-12
Posts: 2,810

Re: Make Redshift Fall Back to Manual Location

It seems this would be an ideal situation to leverage systemd. The first thing that comes to mind is having one redshift service ("redshift-network") dependent on networking and use

OnFailure=

    A space-separated list of one or more units that are activated when this unit enters the "failed" state.

to have it start a non-networked redshift service upon failure. That's just an off-the-cuff suggestion and is probably not the best solution. You might also be able to configure "redshift-network" to start if networking comes up after init in which case

Conflicts=

    A space-separated list of unit names. Configures negative requirement dependencies. If a unit has a Conflicts= setting on another unit, starting the former will stop the latter and vice versa.

would be useful. Actually, it would probably be a good idea to use Conflicts= in any case.


But whether the Constitution really be one thing, or another, this much is certain - that it has either authorized such a government as we have had, or has been powerless to prevent it. In either case, it is unfit to exist.
-Lysander Spooner

Offline

#6 2016-08-05 08:47:43

Tallix
Member
From: Arizona, USA
Registered: 2013-06-02
Posts: 20

Re: Make Redshift Fall Back to Manual Location

Well I admit that I'm not too familiar with systemd, but it does sound like it carries interesting potential for a solution.

Offline

Board footer

Powered by FluxBB