You are not logged in.

#1 2018-02-04 02:47:55

olocin
Member
Registered: 2018-01-03
Posts: 171

is it possible to cat the docking status on modern thinkpads?

I use a thinkpad t460s.
I'd like to modifiy my .xinitrc with something like

cat /proc/acpi....
if (status=docked) then do something

but it appears that docking with modern thinkpads is treated more like an event.
Is it still possible to read somewhere the docked/undocked status?

Offline

#2 2018-02-04 03:04:32

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: is it possible to cat the docking status on modern thinkpads?

I doubt you'd find anything in /proc/.  I'm pretty sure there'd be some changes in /sys/, but personally I'd take the stupid simple approach.  In the case of my x200s and their docking stations:

if [ -e /dev/sr0 ]; then
   # ...
fi

This works for the x200s as sr0 is the optical drive present on the dock but not on the laptop itself.  The device node is created when/while docked.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2018-02-04 03:54:59

progandy
Member
Registered: 2012-05-17
Posts: 5,322

Re: is it possible to cat the docking status on modern thinkpads?

thinkwiki should have most of the relevant information.
http://www.thinkwiki.org/wiki/Docking_Solutions
https://phihag.de/2012/thinkpad-docking.html
You could write a status file when you receive the events.

Last edited by progandy (2018-02-04 03:56:11)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#4 2018-02-04 04:11:49

olocin
Member
Registered: 2018-01-03
Posts: 171

Re: is it possible to cat the docking status on modern thinkpads?

I had looked into the thinkwiki, but I prefer the stupid simple approach.
Could you guys point to some places where I may look (like /sys /dev ..) in the case of my t460s with ultra dock?

Offline

#5 2018-02-04 04:17:28

olocin
Member
Registered: 2018-01-03
Posts: 171

Re: is it possible to cat the docking status on modern thinkpads?

the one (probably too stupid) I could think of is

xrandr | grep -o 'DP-2-2 connected' | grep -o connected

with 'if' command.

Offline

#6 2018-02-04 12:09:06

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: is it possible to cat the docking status on modern thinkpads?

Are there no devices on the docking station such that my x200 solution wouldn't work?  If you want to use xrandr, don't use 2 greps, and don't use a separate conditional:

if $(xrandr | grep -q 'DP-2-2 connected'); then
   # ...
fi

As for telling you what's difference under /sys with and without the dock, I doubt anyone here can unless you find someone with exactly the same model.  But you're sitting at the right model now, explore.  Or just diff and `ls /dev/` from docked and not to use the device node solution I already posted.

Last edited by Trilby (2018-02-04 12:12:08)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2018-02-04 15:09:09

olocin
Member
Registered: 2018-01-03
Posts: 171

Re: is it possible to cat the docking status on modern thinkpads?

Thanks, I will do some experiments, but already a solution with if and xrandr should do the dirty job smile

Offline

#8 2018-02-05 02:52:57

olocin
Member
Registered: 2018-01-03
Posts: 171

Re: is it possible to cat the docking status on modern thinkpads?

Ok, so right now this is my .xinitrc file: does it look fine to you guys?

#!/bin/sh
rm ~/.config/chromium-flags.conf
touch ~/.config/chromium-flags.conf
echo '--password-store=gnome' >> ~/.config/chromium-flags.conf

if $(xrandr | grep -q 'DP-2-2 connected'); then
	xrandr --output eDP-1 --off
	nmcli radio wifi off
else
	xrandr --dpi 216
	echo '--force-device-scale-factor=2' >> ~/.config/chromium-flags.conf
	nmcli radio wifi on
fi

eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
export SSH_AUTH_SOCK
~/Projects/suckless/dropbox.py start &> dropbox.log
~/Projects/suckless/dwm_status.sh &
udiskie &
feh --bg-center ~/Pictures/m1.jpg
xautolock -time 20 -locker slock &

usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"
fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

exec dwm

Offline

#9 2018-02-05 03:34:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,543
Website

Re: is it possible to cat the docking status on modern thinkpads?

rm, touch, and echo are all redundant, the last echo is sufficient if you use a single `>` rather than `>>` (or a `>|` if you have 'noclobber' set).


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB