LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook
User Name
Password
Linux - Laptop and Netbook Having a problem installing or configuring Linux on your laptop? Need help running Linux on your netbook? This forum is for you. This forum is for any topics relating to Linux and either traditional laptops or netbooks (such as the Asus EEE PC, Everex CloudBook or MSI Wind).

Notices


Reply
  Search this Thread
Old 12-28-2018, 10:00 AM   #1
polytropos
LQ Newbie
 
Registered: Jun 2003
Posts: 26

Rep: Reputation: 0
`xset dpms force off' fails when called from a script


Hi all

I am trying to run xset dpms force off when a keyboard button is pressed. The button generates video/switchmode ACPI event, and I have put the following code in /etc/acpi/default to trigger the command:

Code:
case "$group" in
	video)
		case "$action" in
			switchmode)
				DISPLAY=:0 xset dpms force off ;;
				 *)	log_unhandled $* ;;
		esac
		;;

	*)	log_unhandled $* ;;
esac
Here is what I know:
(i) The match works fine, for when I run `/etc/acpi/default.sh "video/switchmode"', my monitor switches off.
(ii) Acpid is working fine too, for if I replace
Code:
DISPLAY=:0 xset dpms force off ;;
with
Code:
touch /home/niku/test ;;
and restart acpid and then press the button, the file ~/test gets updated.
(iii) I tried prefixing `DISPLAY=:0' after the suggestion here but it didn't work!
(iv) Acpid runs as root. The command in (i) switches off the monitor both as normal user and root.
(v) Providing full path of xset (/usr/bin/xset) in the script doesn't help either.

What else should I try? The above link mentions checking other environment variables too, but I couldn't find any information about it xset's or acpid's manpage.

Edit: It is clearly a problem with getting xset to work. In the log files, in (ii), when using touch command, the script exits with 0. When using xset, the script exits with 1. I read somewhere (forgotten where), that 1 means that there is some "minor error".

Thanks!

Last edited by polytropos; 12-30-2018 at 07:28 PM.
 
Old 12-29-2018, 07:21 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
Try giving the full path to xset in the command. PATH may not be set the same when running the script.
 
Old 12-29-2018, 08:29 PM   #3
polytropos
LQ Newbie
 
Registered: Jun 2003
Posts: 26

Original Poster
Rep: Reputation: 0
Thanks smallpond, but it doesn't help. (I tried it already, and had later updated my original post to mention it!)
 
Old 12-30-2018, 08:30 PM   #4
polytropos
LQ Newbie
 
Registered: Jun 2003
Posts: 26

Original Poster
Rep: Reputation: 0
Solved!

I got it working after allowing every user directly logged on the local machine (including the root) to access the display by running as the non-privileged user (the one who started the X server):
Code:
xhost +local:
For persistence, I added the command to my .xinitrc, but adding it to .bashrc should work fine too.
See this for a little more detail.

---

How I discovered the problem:
I got the xset error message into a file by changing the xset line to
Code:
xset -display :0 dpms force off > /home/niku/test 2>&1 ;;
The xset error messages said "No protocol specified", etc, for which I did a www search, which led to the above solution.

-

The curious question which remains is: why is xset able to access the display as root when run on the command line, but not when run by the acpid. (I verified that acpid runs as the root by adding logger "`whoami`" to the code at the top {logger sends the output to syslog}).

Last edited by polytropos; 12-30-2018 at 10:19 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] xset dmps force off doesn't work in cron howandsen Linux - Desktop 3 08-15-2016 01:07 PM
[SOLVED] How to make xset dpms force off work with gnome-power-manager nokangaroo Linux - Software 6 05-18-2011 04:23 AM
xset dpms force off does'nt turn off screen anirudh.iitm Linux - General 3 02-24-2007 01:54 PM
getting xscreensaver/dmps to ignore screen 0.1? lurko Linux - Newbie 1 07-13-2006 01:30 PM
xset -dpms and xset s off ericcarlson Fedora 1 10-01-2004 07:45 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Laptop and Netbook

All times are GMT -5. The time now is 01:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration