Error running redshift app as a system service on hardware resume












0















I'm running Ubuntu 18.04.1 and I'm using the redshift app to change the color temp of my monitor. Every time I resume my machine from suspend, monitor temperature has returned to it's default, so I run redshift command that I want from a terminal every time.



It's getting a bit annoying, and I can't find out why this is happening, so I tried adding a system service that will run on resume to run the redshift command automatically. The command is not running correctly though. I'm not sure if the resume procedure hasn't progressed enough to let the app do what it needs to do, or if my service config is wrong:



Here's the service config at /etc/systemd/system/start-redshift.service:



[Unit]
Description=Start redshift app
Before=sleep.target
StopWhenUnneeded=yes

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStop=/usr/bin/redshift -O 3800

[Install]
WantedBy=sleep.target


Here's the log output for a run of the service after resume:



stuff@stuff-laptop$ journalctl -u start-redshift.service 
-- Logs begin at Thu 2019-01-10 10:07:00 GMT, end at Mon 2019-02-04 09:55:55 GMT. --
Feb 04 09:55:33 stuff-laptop systemd[1]: Started Start redshift app.
Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Unit not needed anymore. Stopping.
Feb 04 09:55:46 stuff-laptop systemd[1]: Stopping Start redshift app...
Feb 04 09:55:46 stuff-laptop redshift[20046]: `RANDR Query Version' returned error -1
Feb 04 09:55:46 stuff-laptop redshift[20046]: Initialization of randr failed.
Feb 04 09:55:46 stuff-laptop redshift[20046]: Trying next method...
Feb 04 09:55:46 stuff-laptop redshift[20046]: X request failed: XOpenDisplay
Feb 04 09:55:46 stuff-laptop redshift[20046]: Initialization of vidmode failed.
Feb 04 09:55:46 stuff-laptop redshift[20046]: Trying next method...
Feb 04 09:55:46 stuff-laptop redshift[20046]: No more methods to try.
Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Control process exited, code=exited status=1
Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Failed with result 'exit-code'.
Feb 04 09:55:46 stuff-laptop systemd[1]: Stopped Start redshift app.


I've also tried putting a script at /lib/systemd/system-sleep/redshift-start:



#!/bin/sh
if [ "${1}" = "post" ]; then
echo "Resuming redshift..." > /tmp/redshift.log
/usr/bin/redshift -O 3800 >> /tmp/redshift.log 2>&1
fi


...and it runs on resume, but the output is the following:



Resuming redshift...
`RANDR Query Version' returned error -1
Initialization of randr failed.
Trying next method...
X request failed: XOpenDisplay
Initialization of vidmode failed.
Trying next method...
No more methods to try.









share|improve this question





























    0















    I'm running Ubuntu 18.04.1 and I'm using the redshift app to change the color temp of my monitor. Every time I resume my machine from suspend, monitor temperature has returned to it's default, so I run redshift command that I want from a terminal every time.



    It's getting a bit annoying, and I can't find out why this is happening, so I tried adding a system service that will run on resume to run the redshift command automatically. The command is not running correctly though. I'm not sure if the resume procedure hasn't progressed enough to let the app do what it needs to do, or if my service config is wrong:



    Here's the service config at /etc/systemd/system/start-redshift.service:



    [Unit]
    Description=Start redshift app
    Before=sleep.target
    StopWhenUnneeded=yes

    [Service]
    Type=oneshot
    RemainAfterExit=yes
    ExecStop=/usr/bin/redshift -O 3800

    [Install]
    WantedBy=sleep.target


    Here's the log output for a run of the service after resume:



    stuff@stuff-laptop$ journalctl -u start-redshift.service 
    -- Logs begin at Thu 2019-01-10 10:07:00 GMT, end at Mon 2019-02-04 09:55:55 GMT. --
    Feb 04 09:55:33 stuff-laptop systemd[1]: Started Start redshift app.
    Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Unit not needed anymore. Stopping.
    Feb 04 09:55:46 stuff-laptop systemd[1]: Stopping Start redshift app...
    Feb 04 09:55:46 stuff-laptop redshift[20046]: `RANDR Query Version' returned error -1
    Feb 04 09:55:46 stuff-laptop redshift[20046]: Initialization of randr failed.
    Feb 04 09:55:46 stuff-laptop redshift[20046]: Trying next method...
    Feb 04 09:55:46 stuff-laptop redshift[20046]: X request failed: XOpenDisplay
    Feb 04 09:55:46 stuff-laptop redshift[20046]: Initialization of vidmode failed.
    Feb 04 09:55:46 stuff-laptop redshift[20046]: Trying next method...
    Feb 04 09:55:46 stuff-laptop redshift[20046]: No more methods to try.
    Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Control process exited, code=exited status=1
    Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Failed with result 'exit-code'.
    Feb 04 09:55:46 stuff-laptop systemd[1]: Stopped Start redshift app.


    I've also tried putting a script at /lib/systemd/system-sleep/redshift-start:



    #!/bin/sh
    if [ "${1}" = "post" ]; then
    echo "Resuming redshift..." > /tmp/redshift.log
    /usr/bin/redshift -O 3800 >> /tmp/redshift.log 2>&1
    fi


    ...and it runs on resume, but the output is the following:



    Resuming redshift...
    `RANDR Query Version' returned error -1
    Initialization of randr failed.
    Trying next method...
    X request failed: XOpenDisplay
    Initialization of vidmode failed.
    Trying next method...
    No more methods to try.









    share|improve this question



























      0












      0








      0








      I'm running Ubuntu 18.04.1 and I'm using the redshift app to change the color temp of my monitor. Every time I resume my machine from suspend, monitor temperature has returned to it's default, so I run redshift command that I want from a terminal every time.



      It's getting a bit annoying, and I can't find out why this is happening, so I tried adding a system service that will run on resume to run the redshift command automatically. The command is not running correctly though. I'm not sure if the resume procedure hasn't progressed enough to let the app do what it needs to do, or if my service config is wrong:



      Here's the service config at /etc/systemd/system/start-redshift.service:



      [Unit]
      Description=Start redshift app
      Before=sleep.target
      StopWhenUnneeded=yes

      [Service]
      Type=oneshot
      RemainAfterExit=yes
      ExecStop=/usr/bin/redshift -O 3800

      [Install]
      WantedBy=sleep.target


      Here's the log output for a run of the service after resume:



      stuff@stuff-laptop$ journalctl -u start-redshift.service 
      -- Logs begin at Thu 2019-01-10 10:07:00 GMT, end at Mon 2019-02-04 09:55:55 GMT. --
      Feb 04 09:55:33 stuff-laptop systemd[1]: Started Start redshift app.
      Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Unit not needed anymore. Stopping.
      Feb 04 09:55:46 stuff-laptop systemd[1]: Stopping Start redshift app...
      Feb 04 09:55:46 stuff-laptop redshift[20046]: `RANDR Query Version' returned error -1
      Feb 04 09:55:46 stuff-laptop redshift[20046]: Initialization of randr failed.
      Feb 04 09:55:46 stuff-laptop redshift[20046]: Trying next method...
      Feb 04 09:55:46 stuff-laptop redshift[20046]: X request failed: XOpenDisplay
      Feb 04 09:55:46 stuff-laptop redshift[20046]: Initialization of vidmode failed.
      Feb 04 09:55:46 stuff-laptop redshift[20046]: Trying next method...
      Feb 04 09:55:46 stuff-laptop redshift[20046]: No more methods to try.
      Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Control process exited, code=exited status=1
      Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Failed with result 'exit-code'.
      Feb 04 09:55:46 stuff-laptop systemd[1]: Stopped Start redshift app.


      I've also tried putting a script at /lib/systemd/system-sleep/redshift-start:



      #!/bin/sh
      if [ "${1}" = "post" ]; then
      echo "Resuming redshift..." > /tmp/redshift.log
      /usr/bin/redshift -O 3800 >> /tmp/redshift.log 2>&1
      fi


      ...and it runs on resume, but the output is the following:



      Resuming redshift...
      `RANDR Query Version' returned error -1
      Initialization of randr failed.
      Trying next method...
      X request failed: XOpenDisplay
      Initialization of vidmode failed.
      Trying next method...
      No more methods to try.









      share|improve this question
















      I'm running Ubuntu 18.04.1 and I'm using the redshift app to change the color temp of my monitor. Every time I resume my machine from suspend, monitor temperature has returned to it's default, so I run redshift command that I want from a terminal every time.



      It's getting a bit annoying, and I can't find out why this is happening, so I tried adding a system service that will run on resume to run the redshift command automatically. The command is not running correctly though. I'm not sure if the resume procedure hasn't progressed enough to let the app do what it needs to do, or if my service config is wrong:



      Here's the service config at /etc/systemd/system/start-redshift.service:



      [Unit]
      Description=Start redshift app
      Before=sleep.target
      StopWhenUnneeded=yes

      [Service]
      Type=oneshot
      RemainAfterExit=yes
      ExecStop=/usr/bin/redshift -O 3800

      [Install]
      WantedBy=sleep.target


      Here's the log output for a run of the service after resume:



      stuff@stuff-laptop$ journalctl -u start-redshift.service 
      -- Logs begin at Thu 2019-01-10 10:07:00 GMT, end at Mon 2019-02-04 09:55:55 GMT. --
      Feb 04 09:55:33 stuff-laptop systemd[1]: Started Start redshift app.
      Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Unit not needed anymore. Stopping.
      Feb 04 09:55:46 stuff-laptop systemd[1]: Stopping Start redshift app...
      Feb 04 09:55:46 stuff-laptop redshift[20046]: `RANDR Query Version' returned error -1
      Feb 04 09:55:46 stuff-laptop redshift[20046]: Initialization of randr failed.
      Feb 04 09:55:46 stuff-laptop redshift[20046]: Trying next method...
      Feb 04 09:55:46 stuff-laptop redshift[20046]: X request failed: XOpenDisplay
      Feb 04 09:55:46 stuff-laptop redshift[20046]: Initialization of vidmode failed.
      Feb 04 09:55:46 stuff-laptop redshift[20046]: Trying next method...
      Feb 04 09:55:46 stuff-laptop redshift[20046]: No more methods to try.
      Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Control process exited, code=exited status=1
      Feb 04 09:55:46 stuff-laptop systemd[1]: start-redshift.service: Failed with result 'exit-code'.
      Feb 04 09:55:46 stuff-laptop systemd[1]: Stopped Start redshift app.


      I've also tried putting a script at /lib/systemd/system-sleep/redshift-start:



      #!/bin/sh
      if [ "${1}" = "post" ]; then
      echo "Resuming redshift..." > /tmp/redshift.log
      /usr/bin/redshift -O 3800 >> /tmp/redshift.log 2>&1
      fi


      ...and it runs on resume, but the output is the following:



      Resuming redshift...
      `RANDR Query Version' returned error -1
      Initialization of randr failed.
      Trying next method...
      X request failed: XOpenDisplay
      Initialization of vidmode failed.
      Trying next method...
      No more methods to try.






      18.04 services redshift






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 4 at 10:41







      RTF

















      asked Feb 4 at 10:10









      RTFRTF

      15319




      15319






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1115485%2ferror-running-redshift-app-as-a-system-service-on-hardware-resume%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1115485%2ferror-running-redshift-app-as-a-system-service-on-hardware-resume%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

          Mangá

          Eduardo VII do Reino Unido