summary refs log tree commit diff
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2023-09-22 14:35:33 -0400
committerZach DeCook <zachdecook@librem.one>2023-09-22 14:35:33 -0400
commit78ca26a8e9b59129bb8b9b258376d81257bc40b2 (patch)
tree8e350c5e8f8268a5dbf904cee8c4d179e55b2ede
parent30f7f9ed42822fb11f0d641d3eae294b177f3af3 (diff)
downloaddotfiles-78ca26a8e9b59129bb8b9b258376d81257bc40b2.tar.gz
Switch: Change sxmo options with 3-position switch
-rwxr-xr-x.local/bin/switch.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/.local/bin/switch.sh b/.local/bin/switch.sh
new file mode 100755
index 0000000..89b832a
--- /dev/null
+++ b/.local/bin/switch.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+#Misc script for oneplus 6 until sway supports this device
+noise() {
+	rm -f "$XDG_CONFIG_HOME"/sxmo/.noring
+	notify-send -t 1000 -a switch noise
+}
+rumble() {
+	rm -f "$XDG_CONFIG_HOME"/sxmo/.novibrate
+	touch "$XDG_CONFIG_HOME"/sxmo/.noring
+	sxmo_vibrate 50 15000
+	notify-send -t 1000 -a switch rumble
+}
+silent() {
+	touch "$XDG_CONFIG_HOME"/sxmo/.noring
+	touch "$XDG_CONFIG_HOME"/sxmo/.novibrate
+	notify-send -t 1000 -a switch silent
+}
+evtest /dev/input/event1 |stdbuf -o L grep -i -o 'Value *\d' | while read -r line; do
+	if echo "$line" | grep -q '0'; then
+		noise
+	elif echo "$line" | grep -q '1'; then
+		rumble
+	elif echo "$line" | grep -q '2'; then
+		silent
+	fi
+done