aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2023-05-14 17:43:45 +0200
committerSébastien Dailly <sebastien@dailly.me>2023-05-14 17:43:45 +0200
commitb8fdecd901122d3e20b7479f44f3a82d71948566 (patch)
tree27d3c8d5acdaed3daea5266ad7246b1ff39b6823
parent87589048a3d52d93103cc60585a154710ff2961a (diff)
BSPWM: Add the macropad script on startup
-rwxr-xr-xbspwm/.config/bspwm/bspwmrc3
-rwxr-xr-xbspwm/scripts/bspwm/macropad.sh32
2 files changed, 34 insertions, 1 deletions
diff --git a/bspwm/.config/bspwm/bspwmrc b/bspwm/.config/bspwm/bspwmrc
index a7eaef2..72e9184 100755
--- a/bspwm/.config/bspwm/bspwmrc
+++ b/bspwm/.config/bspwm/bspwmrc
@@ -11,7 +11,8 @@ run sxhkd
run polybar bspwm
run ~/scripts/bspwm/desktops.sh
run ~/scripts/bspwm/border_colors.sh
-~/scripts/bspwm/wallpaper.sh
+run ~/scripts/bspwm/wallpaper.sh
+run ~/scripts/bspwm/macropad.sh
#compton -i .8 --focus-exclude '_NET_WM_NAME@:s = "rofi"' --blur-background --blur-kern '3,3,0.1,1,1,1,1,1,1,1' &
diff --git a/bspwm/scripts/bspwm/macropad.sh b/bspwm/scripts/bspwm/macropad.sh
new file mode 100755
index 0000000..0dcf843
--- /dev/null
+++ b/bspwm/scripts/bspwm/macropad.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+# This script listen the events from BSPWM and report to the macropad the
+# layout to use.
+
+# The script only listen the events from switching one desktop to another one,
+# and do not report the events specific for a window.
+
+# Send to the macropad the appropriate layout depending of the desktop.
+send_layout() {
+ echo $1 | socat - TCP4:localhost:9999
+}
+
+bspc subscribe desktop | while read -r event monitor_id desktop_id name;
+do
+ case $event in
+ desktop_focus)
+ name=$(bspc query -D -d --names)
+ echo $name;
+ case $name in
+ Web)
+ send_layout "Firefox"
+ ;;
+ 6-girl)
+ send_layout "Num pad"
+ ;;
+ *)
+ #echo Num pad | socat - TCP4:localhost:9999;
+ ;;
+ esac;
+ esac;
+done