Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

systemd-sleep wakeup script

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
hajder
Posts: 19
Joined: 2009-10-10 09:02

systemd-sleep wakeup script

#1 Post by hajder »

Hello

I'm trying to setup my monitors after waking up from systemctl suspend. I can see that my script is executed but xrandr is reporting a 'Can't open display' error.
The idea is to shutdown my laptop output if I have an external monitor plugged in already, the script is working well as it's used when I start my WM.

Code: Select all

3683 Jun 18 08:30:54 hajder systemd-sleep[13117]: Doing some stuff for monitor setup
3684 Jun 18 08:30:54 hajder systemd-sleep[13117]: Has DP1, shutting down laptop monitor
3685 Jun 18 08:30:54 hajder systemd-sleep[13117]: Can't open display

Code: Select all

1 #!/bin/bash
  2 
  3 #Second argument will either be pre or post.
  4 
  5 #if [ $1 == "post" ];
  6 xrandr -q | grep -q -w DP1
  7 echo "Doing some stuff for monitor setup"
  8 case $1/$2 in
  9     pre/*)
 10         echo "Going to sleep";
 11         ;;
 12     post/*)
 13         if [ $? -eq 0 ];
 14         then
 15             echo 'Has DP1, shutting down laptop monitor';
 16             xrandr --auto
 17             sleep 5; #Tried putting a sleep but didn't work either....
 18             xrandr --output eDP1 --off
 19         else
 20             echo 'No DP1 detected, only laptop screen activated';
 21         fi
 22 esac

User avatar
phenest
Posts: 1702
Joined: 2010-03-09 09:38
Location: The Matrix

Re: systemd-sleep wakeup script

#2 Post by phenest »

Exactly how are you implementing this script?
ASRock H77 Pro4-M i7 3770K - 32GB RAM - Pioneer BDR-209D

Post Reply