LinuxQuestions.org
Visit Jeremy's Blog.
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 08-26-2011, 07:46 PM   #1
jlacroix
Member
 
Registered: Nov 2003
Posts: 187

Rep: Reputation: 15
Help With Docking Station Script, and Udev rules


Hello everyone, I am hoping someone can help me with a script as well as udev rules. I am also hoping the solution to this can be helpful others, since docking stations can be a pain.

Anyway, here is a script I wrote after Googling for a while:

Code:
#!/bin/sh
xrandr --current | grep "VGA1 connected "
if [ $? -eq 0 ]; then
	sleep 5s
	xrandr --output LVDS1 --off --output VGA1 --auto
else
	xrandr --output LVDS1 --auto --output VGA1 --off
fi
That script will switch my laptop to the appropriate monitor. If I'm docked, it will go to the external monitor, otherwise it will direct output to the laptops display. I set up a keyboard shortcut in XFCE (ALT+CTRL+=) and whenever I press that, it switches video to the appropriate place. So far, so good.

I also wrote a udev rule, hoping that I can automate this:

Code:
# Rules for docking / undocking

KERNEL=="dock.0", ATTR{docked}=="1", RUN+="/usr/local/bin/dock"
KERNEL=="dock.0", ATTR{docked}=="0", RUN+="/usr/local/bin/dock"
I saved that in /etc/udev/rules.d/81-docking.rules.

Unfortunately, that does not work. I still have to switch the output manually. Any idea what I may have done wrong? I never wrote a udev rule before.

Edit: I totally forgot to mention, this is on a Latitude D630. I'll be setting this type of thing up on a Latitude E6410 when I get it sorted out.

Last edited by jlacroix; 08-26-2011 at 07:47 PM.
 
Old 08-27-2011, 12:08 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
I have no personal experience with this, but to hazard a guess, I believe udev scripts run as root, which is generally not the user that owns the x session. Perhaps some use of su/sudo would help.

Another possibility may be to use something like halevt instead.

http://www.nongnu.org/halevt/

There are probably better ways to do it though.
 
Old 09-07-2011, 04:57 PM   #3
Karl Godt
Member
 
Registered: Mar 2010
Location: Kiel , Germany
Distribution: once:SuSE6.2,Debian3.1, aurox9.2+3,Mandrake?,DSL? then:W7st,WVHB, #!8.10.02,PUPPY4.3.1 now:Macpup
Posts: 314

Rep: Reputation: 45
udev responds to entries somewhere in the /sys directory .

You could need to have to `echo 'dock' > /sys/path/of/driver/uevent` .

The Puppy boot script /etc/rc.d/rc.sysinit uses `echo 'ADD'` to load the autodetected drivers at boot .

As far as I could observe this , the /sys/.../uevent file gets automatically restored afterwards .

If you add a `cat /sys/.../uevent` before and after the `echo 'ADD' > /sys/.../uevent` you would see no difference .
 
  


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
Docking station Augustino Linux - Hardware 1 06-26-2007 03:57 AM
How do I use my USB Docking station? TheMusicGuy Linux - Hardware 4 06-24-2007 07:06 PM
XF86Config-4 and docking station Cons Linux - Laptop and Netbook 1 06-21-2007 03:32 PM
udev rules - running script OllieGator Linux - Software 4 03-29-2007 06:44 AM
Docking Station + X WIndows kzablonski Linux - Laptop and Netbook 2 01-04-2005 03:47 PM

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

All times are GMT -5. The time now is 04:50 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