You are not logged in.

#1 2009-10-06 16:19:30

coubeatczech
Member
From: Prague, CZ
Registered: 2009-02-04
Posts: 18

Running command during every startx

Hi, I want to run a command during every startx.
Where do I need to place this command? I can't use it in ~/.xinitrc, because I need to be root for that, I can't put it in /etc/X11/xinitrc, beacuse it is overwriten by the ~/.xinitrc file.
Thanks
By the way, the issue is that my notebook freezed when I closed the lid. The remedy I foud is to run
# echo 1 > /proc/acpi/video/C098/DOS.
But this file doesn't exist at the time when /etc/profile is ran.

Offline

#2 2009-10-06 17:31:42

Steve`
Member
From: Buchholz / Germany
Registered: 2005-04-16
Posts: 15
Website

Re: Running command during every startx

What about using sudo for an entry in ~/.xinitrc?

Offline

#3 2009-10-06 17:37:03

SamC
Member
From: Calgary
Registered: 2008-05-13
Posts: 611
Website

Re: Running command during every startx

If you set up that command not to need a password, this should work.

Offline

#4 2009-10-06 17:43:35

brisbin33
Member
From: boston, ma
Registered: 2008-07-24
Posts: 1,796
Website

Re: Running command during every startx

coubeatczech wrote:

By the way, the issue is that my notebook freezed when I closed the lid. The remedy I foud is to run
# echo 1 > /proc/acpi/video/C098/DOS.

add this command to /etc/rc.local and it will be run by root at every boot.  much better IMHO.

Offline

#5 2009-10-06 21:09:00

coubeatczech
Member
From: Prague, CZ
Registered: 2009-02-04
Posts: 18

Re: Running command during every startx

actually, when I try to run this command with sudo

coub ~  $ sudo echo 1 > /proc/acpi/video/C098/DOS
bash: /proc/acpi/video/C098/DOS: Permission denied

this happens.
It works just as a root.
Don't know why,

cat /etc/sudoers
# User privilege specification
root    ALL=(ALL) ALL

# Uncomment to allow people in group wheel to run all commands
 %wheel ALL=(ALL) ALL

And I am in the wheel group.

Offline

#6 2009-10-06 21:09:31

coubeatczech
Member
From: Prague, CZ
Registered: 2009-02-04
Posts: 18

Re: Running command during every startx

brisbin33 wrote:
coubeatczech wrote:

By the way, the issue is that my notebook freezed when I closed the lid. The remedy I foud is to run
# echo 1 > /proc/acpi/video/C098/DOS.

add this command to /etc/rc.local and it will be run by root at every boot.  much better IMHO.

I found out that the file /proc/acpi/video/C098/DOS doesn't exist at time there is no X server ran, so I think putting it in /etc/rc.local wouldn't solve that.

Offline

#7 2009-10-06 21:59:24

Misfit138
Misfit Emeritus
From: USA
Registered: 2006-11-27
Posts: 4,189

Re: Running command during every startx

Create a daemon script under /etc/rc.d/ and call it from ~/.xinitrc ?

Offline

#8 2009-10-06 22:12:27

lucke
Member
From: Poland
Registered: 2004-11-30
Posts: 4,018

Re: Running command during every startx

Create a shell script in /usr/sbin and call it from ~/.xprofile.

Offline

#9 2009-10-06 23:22:57

tavianator
Member
From: Waterloo, ON, Canada
Registered: 2007-08-21
Posts: 858
Website

Re: Running command during every startx

coubeatczech wrote:

actually, when I try to run this command with sudo

coub ~  $ sudo echo 1 > /proc/acpi/video/C098/DOS
bash: /proc/acpi/video/C098/DOS: Permission denied

this happens.
It works just as a root.
Don't know why,

That's because the shell interprets that as

(sudo echo 1) > /proc/acpi/video/C098/DOS

I.e. runs "sudo echo 1" and then tries to output that to a file it doesn't have write access to.

Try

sudo sh -c "echo 1 > /proc/acpi/video/C098/DOS"

instead.  Also see EXAMPLES in man sudo.

Offline

#10 2009-10-07 11:20:58

coubeatczech
Member
From: Prague, CZ
Registered: 2009-02-04
Posts: 18

Re: Running command during every startx

tavianator wrote:
coubeatczech wrote:

actually, when I try to run this command with sudo

coub ~  $ sudo echo 1 > /proc/acpi/video/C098/DOS
bash: /proc/acpi/video/C098/DOS: Permission denied

this happens.
It works just as a root.
Don't know why,

That's because the shell interprets that as

(sudo echo 1) > /proc/acpi/video/C098/DOS

I.e. runs "sudo echo 1" and then tries to output that to a file it doesn't have write access to.

Try

sudo sh -c "echo 1 > /proc/acpi/video/C098/DOS"

instead.  Also see EXAMPLES in man sudo.

Thanks for explanation, it works now.

Offline

Board footer

Powered by FluxBB