You are not logged in.
Pages: 1
I've got Lenovo W510 and the Mini Dock port replicator that has two monitors connected to it. The laptop is capable only for two monitors at once, so every time I put my laptop on the dock I have to manually go to nvidia's tool and change the monitor output. I have to do that also when I unplug my laptop from the dock, before I unplug because the laptop screen will be blank if I do not do so.
Is there any way to automate this? I move my laptop around a lot. I want to be lazy.
https://wiki.archlinux.org/index.php/ACPI_modules
There's something about docking station status module, but when I run the command to find out what modules there are for my kernel, I do not see anything about docking. Here's the output:
-rw-r--r-- 1 root root 2637 Sep 27 08:36 ac.ko.gz
-rw-r--r-- 1 root root 1763 Sep 27 08:36 acpi_i2c.ko.gz
-rw-r--r-- 1 root root 3349 Sep 27 08:36 acpi_ipmi.ko.gz
-rw-r--r-- 1 root root 5177 Sep 27 08:36 acpi_pad.ko.gz
drwxr-xr-x 2 root root 4096 Sep 27 08:37 apei
-rw-r--r-- 1 root root 5809 Sep 27 08:36 battery.ko.gz
-rw-r--r-- 1 root root 4309 Sep 27 08:36 button.ko.gz
-rw-r--r-- 1 root root 1727 Sep 27 08:36 custom_method.ko.gz
-rw-r--r-- 1 root root 2302 Sep 27 08:36 ec_sys.ko.gz
-rw-r--r-- 1 root root 2444 Sep 27 08:36 fan.ko.gz
-rw-r--r-- 1 root root 18937 Sep 27 08:36 processor.ko.gz
-rw-r--r-- 1 root root 3567 Sep 27 08:36 sbshc.ko.gz
-rw-r--r-- 1 root root 5183 Sep 27 08:36 sbs.ko.gz
-rw-r--r-- 1 root root 7056 Sep 27 08:36 thermal.ko.gz
-rw-r--r-- 1 root root 10160 Sep 27 08:36 video.ko.gzAnd even if there was, I wouldn't know how to make use of it. I know I can build some script that changes the video output whenever something (ie. dock connection/disconnection) happens, but where do I put such script?
Any help appreciated. Thanks in advance.
Offline
My friend has better google-fu than I do and he helped me out. But I still could not get the scripts to work. They work if I run them manually, so I believe the problem is in triggering the scripts.
http://www.thinkwiki.org/wiki/Docking_Solutions
There it says:
Newer series 3 docks no longer register themselves as a dock, but instead behave like a port replicator, as such the below method does not work. They do however cause a key event on dock and undock which could be used as a trigger, but for now these key events are not exposed by the thinkpad-acpi driver before kernel 3.0
So my friend googled again for me and found this: http://phihag.de/2012/thinkpad-docking.html
I did not run that script, but instead put all that stuff in place manually. So I now have these:
/e/a/events> pwd
/etc/acpi/events
/e/a/events> ls
anything lm_battery thinkpad-dock-ibm thinkpad-undock-ibm
lm_ac_adapter lm_lid thinkpad-dock-lenovo thinkpad-undock-lenovo
/e/a/events> cd ../actions/
/e/a/actions> ls
lm_ac_adapter.sh* lm_battery.sh* lm_lid.sh* thinkpad-dock.sh* thinkpad-undock.sh*
/e/a/actions>And their contents are what that script on the website was going to write in them. I changed the display configuration for xrandr to my own settings. I also tried to take off the su command, since those other events did not have them so I figured I wouldn't need them. I am also able to run the scripts without sudo, so I guess I wont need the su command anyway.
Docking / undocking still does not trigger these scripts. I have restarted acpid.service, but that does nothing.
Offline
I don't have a strong feeling for your technical prowess, so forgive me if I state the obvious.
In Linux, the script you describe might be implemented as a daemon. It is a program which runs in the background, detached from any console. It would spend most of its time asleep, would wake occasionally, check for a change in dock state, respond to change in dock state, and go back to sleep for several seconds.
Take a look at this thread on nixcraft
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
You and I were posting at the same time. In the daemon I mention, determining the state could be done by watching for changes in the journal. Come up with a way of parsing the output of :
/usr/bin/journalctl -afb (Here I make the assumption that something interesting gets added to the logs when the dock state changes)
No need for sleep, just parse the output. Journalctl will block when things are quiescent.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
I know what a daemon is, and the problem here is now that acpid does not run these scripts (two lines of xrandr commands both) when it recieves the docking related events. I am not sure if it doesn't recieve them or if it is unable to run the scripts.
Thanks for your input anyway, you are partially right. I am a programmer, not sysadmin, and when it comes me administering my system, I just tinker my way out and when it works wont touch it anymore and hope it wont break.
Offline
I think we we posting at the same time - again ![]()
What about the journal or dmesg, are there any entries created when you dock or undock? If so, post them and I'll try to come up with a script.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
Yeah we were posting at the same time. There should be some kind of ajax indicator to show when someone is typing. ![]()
Journalctl didn't tell me anything interesting regarding the docking. But heres dmesg:
~> dmesg | grep thinkpad
[586588.462766] thinkpad_acpi: EC reports that Thermal Table has changed
[586588.555076] thinkpad_acpi: undocked from hotplug port replicator
[586690.626238] thinkpad_acpi: EC reports that Thermal Table has changed
[605265.516532] thinkpad_acpi: EC reports that Thermal Table has changed
[605309.130333] thinkpad_acpi: EC reports that Thermal Table has changed
[608614.390516] thinkpad_acpi: EC reports that Thermal Table has changed
[608647.820798] thinkpad_acpi: EC reports that Thermal Table has changed
[614481.981115] thinkpad_acpi: EC reports that Thermal Table has changed
[614543.128864] thinkpad_acpi: EC reports that Thermal Table has changed
[614543.359644] thinkpad_acpi: docked into hotplug port replicator
[674262.177703] thinkpad_acpi: EC reports that Thermal Table has changed
[674262.268182] thinkpad_acpi: undocked from hotplug port replicator
[674328.504011] thinkpad_acpi: EC reports that Thermal Table has changed
[680854.455938] thinkpad_acpi: EC reports that Thermal Table has changed
[680898.048380] thinkpad_acpi: EC reports that Thermal Table has changed
[680898.384749] thinkpad_acpi: docked into hotplug port replicator
[681246.625716] thinkpad_acpi: undocked from hotplug port replicator
[681247.243935] thinkpad_acpi: EC reports that Thermal Table has changed
[681358.576663] thinkpad_acpi: EC reports that Thermal Table has changed
[681358.663324] thinkpad_acpi: docked into hotplug port replicator
[681785.827497] thinkpad_acpi: EC reports that Thermal Table has changed
[681785.919546] thinkpad_acpi: undocked from hotplug port replicator
[681800.762702] thinkpad_acpi: EC reports that Thermal Table has changed
[681800.850775] thinkpad_acpi: docked into hotplug port replicator
[682309.483674] thinkpad_acpi: EC reports that Thermal Table has changed
[682309.578145] thinkpad_acpi: undocked from hotplug port replicator
[682322.824545] thinkpad_acpi: EC reports that Thermal Table has changed
[682322.911917] thinkpad_acpi: docked into hotplug port replicator
[684104.204379] thinkpad_acpi: EC reports that Thermal Table has changed
[684104.295977] thinkpad_acpi: undocked from hotplug port replicator
[684109.770536] thinkpad_acpi: EC reports that Thermal Table has changed
[684109.855664] thinkpad_acpi: docked into hotplug port replicator
[684110.567179] thinkpad_acpi: docked into hotplug port replicator
[684111.279567] thinkpad_acpi: docked into hotplug port replicatorLast edited by Lazzu (2013-10-04 16:10:31)
Offline
https://wiki.archlinux.org/index.php/AC … figuration
When I undock and dock back in, acpi_listen command shows me this:
ac_adapter ACPI0003:00 00000080 00000000
processor LNXCPU:00 00000080 00000001
processor LNXCPU:01 00000080 00000001
processor LNXCPU:02 00000080 00000001
processor LNXCPU:03 00000080 00000001
processor LNXCPU:04 00000080 00000001
processor LNXCPU:05 00000080 00000001
processor LNXCPU:06 00000080 00000001
processor LNXCPU:07 00000080 00000001
ibm/hotkey IBM0068:00 00000080 00006030
thermal_zone LNXTHERM:00 00000081 00000000
ibm/hotkey IBM0068:00 00000080 00004011
battery PNP0C0A:00 00000080 00000001
processor LNXCPU:00 00000080 00000002
processor LNXCPU:01 00000080 00000002
processor LNXCPU:02 00000080 00000002
processor LNXCPU:03 00000080 00000002
processor LNXCPU:04 00000080 00000002
processor LNXCPU:05 00000080 00000002
processor LNXCPU:06 00000080 00000002
processor LNXCPU:07 00000080 00000002
ibm/hotkey IBM0068:00 00000080 00004010
ac_adapter ACPI0003:00 00000080 00000001
processor LNXCPU:00 00000080 00000001
processor LNXCPU:01 00000080 00000001
processor LNXCPU:02 00000080 00000001
processor LNXCPU:03 00000080 00000001
processor LNXCPU:04 00000080 00000001
processor LNXCPU:05 00000080 00000001
processor LNXCPU:06 00000080 00000001
processor LNXCPU:07 00000080 00000001
processor LNXCPU:00 00000080 00000000
processor LNXCPU:01 00000080 00000000
processor LNXCPU:02 00000080 00000000
processor LNXCPU:03 00000080 00000000
processor LNXCPU:04 00000080 00000000
processor LNXCPU:05 00000080 00000000
processor LNXCPU:06 00000080 00000000
processor LNXCPU:07 00000080 00000000
ibm/hotkey IBM0068:00 00000080 00006030
thermal_zone LNXTHERM:00 00000081 00000000
battery PNP0C0A:00 00000080 00000001Offline
I am going to need to step away for a couple hours, but here is how I would approach it.
Create a script that pipes the output of dmesg -w | grep thinkpad_acpi into an awk or bash script that then looks for "docked" versus "undocked". Whenever it sees a line with one of those two words in it, it executes the appropriate command, otherwise it ignores the line.
I'll get back later this afternoon.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
Yeah I was thinking about that, too. But it seems a bit too hacky for me, but perhaps I'll have to do that if I could not get the more correct way to work.
Offline
Just an update. I am now going for the hacky solution. I created this script:
#!/bin/bash
if [[ "$@" == *4010* ]]
then
echo "dock";
# /etc/acpi/thinkpad-dock.sh
elif [[ "$@" == *4011* ]]
then
echo "undock";
# /etc/acpi/thinkpad-undock.sh
fiAnd it works so far, but I am stuck with bash not behaving.
~> acpi_listen | grep "ibm\/hotkey"
ibm/hotkey IBM0068:00 00000080 00006030
ibm/hotkey IBM0068:00 00000080 00004011
ibm/hotkey IBM0068:00 00000080 00006030
ibm/hotkey IBM0068:00 00000080 00004010But when I try to split the output lines up with xargs, it stops working.
~> acpi_listen | grep "ibm\/hotkey" | xargs echoThat does not output anything. Working on that now..
Offline
I don't think you need to escape the '/' buried inside double quotes.
ewaller$@$odin ~ 1004 %echo "This is a test"
This is a test
ewaller$@$odin ~ 1005 %echo "This is a \test"
This is a est
ewaller$@$odin ~ 1006 %echo "This is a /test"
This is a /test
ewaller$@$odin ~ 1007 %echo "This is a \/ test"
This is a \/ test
ewaller$@$odin ~ 1008 Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way
Offline
Internet told me I needed to escape it with grep, while I was searching for another problem, but now that I tried it myself you are correct:
~> echo "test/test" | grep "test/test"
test/testI got it now "working" with this:
acpi_listen | grep --line-buffered "ibm/hotkey" | xargs -L1 ./dock.shThere still is a problem. The behaviour is buggy when I dock the laptop. It works fine if I undock, I think. For some reason the xrandr commands fail when I dock the laptop. But the original problem is now solved anyway. ![]()
I'll just leave it here for now, since I've used almost a day for this already. I'ts funny how people work hard to be lazy. Anyway, I'll come back at this in future.
Last edited by Lazzu (2013-10-04 20:06:07)
Offline
What about using a udev rule to execute the command when the monitors are plugged in?
https://bbs.archlinux.org/viewtopic.php?id=170294
https://wiki.archlinux.org/index.php/Udev
Last edited by teateawhy (2013-10-04 21:08:16)
Offline
Pages: 1