changing resolution from /etc/acpi/power.sh

Questions about hardware,drivers and peripherals
Forum rules
Before you post please read this

changing resolution from /etc/acpi/power.sh

Postby yhtomitwebb on Fri Aug 01, 2008 10:10 pm

Hi
I am trying to setup my system so that when I put my laptop onto the docking station if automatically enables my external monitor ( which is plugged into the docking station), the way that I am trying to do this is to add these lines to /etc/acpi/power.sh
Code: Select all
if xrandr -q | grep -q  "TMDS-1 connected"; then
   echo "enabling external display";
   exec xrandr --output LVDS --mode 1280x800 --output TMDS-1 --mode 1680x1050 --pos 0x0
else
   echo "disabling external display";
   exec xrandr --output LVDS --mode 1280x800 --pos 0x0 --output TMDS-1 --off
fi

This basically checks if the monitor is plugged in and if so enables it.
If I put those lines into a script and run the script manually, it works fine, but if I put those lines into /etc/acpi/power.sh it doesn't do anything at all.

I have checked that that /etc/acpi/power.sh actually gets run when power is plugged in or removed by adding this line to the file:
Code: Select all
echo "test" >> /home/timothy/Desktop/test.txt

and that works.

So has anyone got any idea on why this doesn't work?
Or how I could do it that does work?

thanks
Tim
yhtomitwebb
Level 1
Level 1
 
Posts: 27
Joined: Sun Feb 03, 2008 7:43 am

Linux Mint is funded by ads and donations.
 

Re: changing resolution from /etc/acpi/power.sh

Postby Husse on Mon Aug 04, 2008 1:54 pm

Can't test so a bit of guesswork
First off - I hope you have avoided getting it inside a function :)
Does it matter if it's added at the beginning or at the end?
It's not unusual however that scripts behave like this.
The separate script that works is that a bash script?
I don't really know what to look for in this case
And I hope you have a copy of the original file...
Image
Don't fix it if it ain't broken, don't break it if you can't fix it
Husse
Level 21
Level 21
 
Posts: 19703
Joined: Sun Feb 11, 2007 7:22 am
Location: Near Borås Sweden

Re: changing resolution from /etc/acpi/power.sh

Postby yhtomitwebb on Thu Mar 12, 2009 1:59 am

Sorry I haven't replied.
For all of those that have the same problem, this is how I fixed it (months later)

The problem it that the ACPI scripts do not have a connection to the X server and they are run as root, which by default is not allowed access to the X server.
I fixed it by making a script:
Code: Select all
#!/bin/bash
 
if xrandr -d :0 --screen 0 -q | grep -q  "TMDS-1 connected"; then
   exec xrandr -d :0 --screen 0 --output LVDS --off --output TMDS-1 --mode 1680x1050 --pos 0x0
else
   exec xrandr -d :0 --screen 0 --output LVDS --mode 1280x800 --pos 0x0 --output TMDS-1 --off
fi

and then putting into /etc/acpi/power.sh

Code: Select all
su [USER] -c [path to above script]

This then enables and disables my external monitor as it should

Hope this helps some one!
Tim
yhtomitwebb
Level 1
Level 1
 
Posts: 27
Joined: Sun Feb 03, 2008 7:43 am


Return to Hardware Support

Who is online

Users browsing this forum: Google [Bot] and 15 guests