/lib/udev/tlp-rdw-udev is in tlp-rdw 1.1-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | #!/bin/sh
# tlp-rdw - handle dock/undock events
#
# Copyright (c) 2018 Thomas Koch <linrunner at gmx.net>
# This software is licensed under the GPL v2 or later.
# --- Constants
readonly LIBDIR="/usr/share/tlp"
readonly LIBS="tlp-functions tlp-rf-func"
# --- Source libraries
for lib in $LIBS; do
if [ ! -f $LIBDIR/$lib ]; then
echo "Error: missing function library \'$LIBDIR/$lib\'." 1>&2
exit 1
fi
. $LIBDIR/$lib
done
# --- MAIN
read_defaults
check_tlp_enabled || exit 0
add_sbin2path
# get power source
get_sys_power_supply
# get device/type
ddev=/sys$1
devtype=$2
case $devtype in
dock)
# check if type is "dock_station", exit if not
type=$(cat $ddev/type 2> /dev/null)
[ "$type" = "dock_station" ] || exit 0
docked=$(cat $ddev/docked 2> /dev/null)
action=$EVENT
echo_debug "udev" "+++ rdw_udev($devtype).$action dev=$ddev type=$type docked=$docked syspwr=$syspwr"
;;
usb_dock)
case $ACTION in
add) action="dock" ;;
remove) action="undock" ;;
esac
echo_debug "udev" "+++ rdw_udev($devtype).$action dev=$ddev syspwr=$syspwr"
;;
*) exit 0 ;; # unknown device type
esac
# quit if timed lock in progress
if check_timed_lock $RDW_DOCK_LOCK ; then
echo_debug "udev" "rdw_udev.locked"
exit 0
fi
case $action in
dock) # laptop was docked
# lock for 2 seconds in case dock has multiple devices
set_timed_lock $RDW_DOCK_LOCK $RDW_LOCKTIME
# enable configured radios (obey rdw nm locks too)
for dev in $DEVICES_TO_ENABLE_ON_DOCK; do
[ -n "$dev" ] && ! check_timed_lock "${RDW_NM_LOCK}_${dev}" \
&& device_switch $dev on "${RDW_NM_LOCK}_${dev}" $RDW_LOCKTIME
done
# disable configured radios (obey rdw nm locks too)
for dev in $DEVICES_TO_DISABLE_ON_DOCK; do
[ -n "$dev" ] && ! check_timed_lock "${RDW_NM_LOCK}_${dev}" \
&& device_switch $dev off "${RDW_NM_LOCK}_${dev}" $RDW_LOCKTIME
done
;;
undock) # laptop was undocked
# lock for 2 seconds in case dock has multiple devices
set_timed_lock $RDW_DOCK_LOCK $RDW_LOCKTIME
# enable configured radios (obey rdw nm locks too)
for dev in $DEVICES_TO_ENABLE_ON_UNDOCK; do
[ -n "$dev" ] && ! check_timed_lock "${RDW_NM_LOCK}_${dev}" \
&& device_switch $dev on "${RDW_NM_LOCK}_${dev}" $RDW_LOCKTIME
done
# disable configured radios (obey rdw nm locks too)
for dev in $DEVICES_TO_DISABLE_ON_UNDOCK; do
[ -n "$dev" ] && ! check_timed_lock "${RDW_NM_LOCK}_${dev}" \
&& device_switch $dev off "${RDW_NM_LOCK}_${dev}" $RDW_LOCKTIME
done
;;
*) ;; # unknown action -> do nothing
esac
exit 0
|