summaryrefslogtreecommitdiff
path: root/.scripts/togglecaps
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-06-25 12:53:26 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-06-25 12:53:26 +0530
commitab60bbbf1b19bae28f7302d2299ca14dd64a7bc5 (patch)
tree9ff52105f5309a1120ae06c7dff8114f0532bf83 /.scripts/togglecaps
parent2a08b80ecdedea6b198d777ecea5db1a1b8e42f2 (diff)
hypr+script: togglecaps sh to avoid emacspinky
Diffstat (limited to '.scripts/togglecaps')
-rwxr-xr-x.scripts/togglecaps16
1 files changed, 16 insertions, 0 deletions
diff --git a/.scripts/togglecaps b/.scripts/togglecaps
new file mode 100755
index 0000000..09dd90c
--- /dev/null
+++ b/.scripts/togglecaps
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+hyprland_cfg="$HOME/.config/hypr/hyprland.conf"
+
+line1=$(grep "kb_options" "$hyprland_cfg" | head -n 1)
+line2=$(grep "kb_options" "$hyprland_cfg" | tail -n 1)
+
+if [ "${line1:0:1}" = "#" ]; then
+ # If first line is commented, uncomment it and comment the second line
+ sed -i 's/^#\s*kb_options=caps:escape/kb_options=caps:escape/' "$hyprland_cfg"
+ sed -i 's/^kb_options=ctrl:nocaps/# kb_options=ctrl:nocaps/' "$hyprland_cfg"
+elif [ "${line2:0:1}" = "#" ]; then
+ # If second line is commented, uncomment it and comment the first line
+ sed -i 's/^#\s*kb_options=ctrl:nocaps/kb_options=ctrl:nocaps/' "$hyprland_cfg"
+ sed -i 's/^kb_options=caps:escape/# kb_options=caps:escape/' "$hyprland_cfg"
+fi