aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README5
-rwxr-xr-xsrc/check_docked.sh3
-rwxr-xr-xsrc/dock_checker.sh34
-rwxr-xr-xsrc/sh/docked.sh7
-rwxr-xr-xsrc/sh/docked/_docked_polybar.sh4
-rwxr-xr-xsrc/sh/docked/docked_00layout.sh4
-rwxr-xr-xsrc/sh/docked/docked_10feh.sh3
-rwxr-xr-xsrc/sh/docked/docked_20polybar.sh6
-rwxr-xr-xsrc/sh/undocked.sh7
-rwxr-xr-xsrc/sh/undocked/_undocked_polybar.sh3
-rwxr-xr-xsrc/sh/undocked/undocked_00layout.sh2
-rwxr-xr-xsrc/sh/undocked/undocked_10feh.sh3
-rwxr-xr-xsrc/sh/undocked/undocked_20polybar.sh6
13 files changed, 87 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..dd54d3c
--- /dev/null
+++ b/README
@@ -0,0 +1,5 @@
+# dockd
+
+mein klein dockd
+
+poll usb for thinkpad ultra dock, run scripts in folder when status changes.
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