Skip to content

Commit

Permalink
Fix laptop docking scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lindhe committed Aug 8, 2023
1 parent 74a0a38 commit 54a4fa3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions laptop/check_for_dock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,19 @@ if ${missing_dependencies}; then
fail 'Please install the missing dependencies!'
fi

docked=false

# If the dock ethernet interface is available, we are probably docked.
ip link show eth0 2>&1 /dev/null
declare -r eth_if="${?}"
if ip link show eth0 &> /dev/null; then
docked=true
fi

# If a monitor is connected to DP-1-1 (or variants), we are probably docked.
monitors=$(xrandr --query | grep -E 'DP-?[1-2]-[1-2] connected')
if xrandr --query | grep -q -E 'DP-?[1-2]-[1-2] connected'; then
docked=true
fi

if [[ "${eth_if}" == "0" ]] || [[ -n "${monitors}" ]]; then
if [[ "${docked}" == "true" ]]; then
echo "Connected to dock"
true
else
Expand Down
2 changes: 1 addition & 1 deletion laptop/toggle_dock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if "${SCRIPTS_LOCATION}"/laptop/check_for_dock.sh; then
"${SCRIPTS_LOCATION}"/laptop/monman.py -a ${IAMAT:+~/.config/monitors/${IAMAT}.json} \
&& LOG_LINE='Docking successful!' || LOG_LINE='Docking failed!';
else
"${SCRIPTS_LOCATION}"/dock/monman.py -d \
"${SCRIPTS_LOCATION}"/laptop/monman.py -d \
&& LOG_LINE='Undocking sucessful!' || LOG_LINE='Undocking failed!';
fi

Expand Down

0 comments on commit 54a4fa3

Please sign in to comment.