From 5eb78c5fc8ee50707f3c18ab60b57fd89f1d489e Mon Sep 17 00:00:00 2001 From: spv Date: Thu, 2 Oct 2025 18:47:49 -0400 Subject: mein klein dockd --- src/check_docked.sh | 3 +++ src/dock_checker.sh | 34 ++++++++++++++++++++++++++++++++++ src/sh/docked.sh | 7 +++++++ src/sh/docked/_docked_polybar.sh | 4 ++++ src/sh/docked/docked_00layout.sh | 4 ++++ src/sh/docked/docked_10feh.sh | 3 +++ src/sh/docked/docked_20polybar.sh | 6 ++++++ src/sh/undocked.sh | 7 +++++++ src/sh/undocked/_undocked_polybar.sh | 3 +++ src/sh/undocked/undocked_00layout.sh | 2 ++ src/sh/undocked/undocked_10feh.sh | 3 +++ src/sh/undocked/undocked_20polybar.sh | 6 ++++++ 12 files changed, 82 insertions(+) create mode 100755 src/check_docked.sh create mode 100755 src/dock_checker.sh create mode 100755 src/sh/docked.sh create mode 100755 src/sh/docked/_docked_polybar.sh create mode 100755 src/sh/docked/docked_00layout.sh create mode 100755 src/sh/docked/docked_10feh.sh create mode 100755 src/sh/docked/docked_20polybar.sh create mode 100755 src/sh/undocked.sh create mode 100755 src/sh/undocked/_undocked_polybar.sh create mode 100755 src/sh/undocked/undocked_00layout.sh create mode 100755 src/sh/undocked/undocked_10feh.sh create mode 100755 src/sh/undocked/undocked_20polybar.sh (limited to 'src') diff --git a/src/check_docked.sh b/src/check_docked.sh new file mode 100755 index 0000000..81019dc --- /dev/null +++ b/src/check_docked.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env zsh + +lsusb | grep -q "ThinkPad Ultra Dock" && echo docked || echo undocked diff --git a/src/dock_checker.sh b/src/dock_checker.sh new file mode 100755 index 0000000..5b4f1f8 --- /dev/null +++ b/src/dock_checker.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env zsh + +SCRIPT_DIR=$(dirname $(realpath $0)) +cd $SCRIPT_DIR + +rm .{un,}docked + +while true; do + if [ "$(./check_docked.sh)" = "docked" ]; then + if [ -e .docked ]; then + continue + fi + + echo docking... + + rm -f .undocked + sh/docked.sh + + touch .docked + else + if [ -e .undocked ]; then + continue + fi + + echo undocking... + + rm -f .docked + sh/undocked.sh + + touch .undocked + fi + + sleep 5 +done diff --git a/src/sh/docked.sh b/src/sh/docked.sh new file mode 100755 index 0000000..944cc05 --- /dev/null +++ b/src/sh/docked.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh + +SCRIPT_DIR=$(dirname $(realpath $0))/docked + +for script in $SCRIPT_DIR/docked_*.sh; do + $script +done diff --git a/src/sh/docked/_docked_polybar.sh b/src/sh/docked/_docked_polybar.sh new file mode 100755 index 0000000..d45dd03 --- /dev/null +++ b/src/sh/docked/_docked_polybar.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env zsh + +polybar bar & +MONITOR=DP-2-1 polybar bar diff --git a/src/sh/docked/docked_00layout.sh b/src/sh/docked/docked_00layout.sh new file mode 100755 index 0000000..5c473b1 --- /dev/null +++ b/src/sh/docked/docked_00layout.sh @@ -0,0 +1,4 @@ +#!/bin/sh +xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output VGA-1 --off --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --off --output DP-2-1 --mode 1920x1080 --pos 1920x0 --rotate normal --output DP-2-2 --off --output DP-2-3 --off + +sleep 5 diff --git a/src/sh/docked/docked_10feh.sh b/src/sh/docked/docked_10feh.sh new file mode 100755 index 0000000..2f13c02 --- /dev/null +++ b/src/sh/docked/docked_10feh.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env zsh + +feh --bg-scale ~/.local/share/backgrounds/bg.png diff --git a/src/sh/docked/docked_20polybar.sh b/src/sh/docked/docked_20polybar.sh new file mode 100755 index 0000000..c59cf0c --- /dev/null +++ b/src/sh/docked/docked_20polybar.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env zsh + +SCRIPT_DIR=$(dirname $(realpath $0)) + +pkill -9 polybar +i3-msg exec $SCRIPT_DIR/_docked_polybar.sh # _ prevents from running in loop diff --git a/src/sh/undocked.sh b/src/sh/undocked.sh new file mode 100755 index 0000000..ec7ca10 --- /dev/null +++ b/src/sh/undocked.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh + +SCRIPT_DIR=$(dirname $(realpath $0))/undocked + +for script in $SCRIPT_DIR/undocked_*.sh; do + $script +done diff --git a/src/sh/undocked/_undocked_polybar.sh b/src/sh/undocked/_undocked_polybar.sh new file mode 100755 index 0000000..639fd70 --- /dev/null +++ b/src/sh/undocked/_undocked_polybar.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env zsh + +polybar bar diff --git a/src/sh/undocked/undocked_00layout.sh b/src/sh/undocked/undocked_00layout.sh new file mode 100755 index 0000000..fdc7b0b --- /dev/null +++ b/src/sh/undocked/undocked_00layout.sh @@ -0,0 +1,2 @@ +#!/bin/sh +xrandr --output eDP-1 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output VGA-1 --off --output DP-1 --off --output HDMI-1 --off --output DP-2 --off --output HDMI-2 --off --output DP-2-1 --off --output DP-2-2 --off --output DP-2-3 --off diff --git a/src/sh/undocked/undocked_10feh.sh b/src/sh/undocked/undocked_10feh.sh new file mode 100755 index 0000000..2f13c02 --- /dev/null +++ b/src/sh/undocked/undocked_10feh.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env zsh + +feh --bg-scale ~/.local/share/backgrounds/bg.png diff --git a/src/sh/undocked/undocked_20polybar.sh b/src/sh/undocked/undocked_20polybar.sh new file mode 100755 index 0000000..aeaced5 --- /dev/null +++ b/src/sh/undocked/undocked_20polybar.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env zsh + +SCRIPT_DIR=$(dirname $(realpath $0)) + +pkill -9 polybar +i3-msg exec $SCRIPT_DIR/_undocked_polybar.sh # _ prevents from running in loop -- cgit v1.2.3