diff options
| author | Christian Krinitsin <code@krinitsin.xyz> | 2024-06-12 20:04:26 +0200 |
|---|---|---|
| committer | Christian Krinitsin <code@krinitsin.xyz> | 2024-06-12 20:04:26 +0200 |
| commit | 82a32ab8b3e62639e4f9cf787b8967c8da1f1232 (patch) | |
| tree | 32bceec81d6c4eae722d123a592b1196361a1563 /bin/toggle_monitor_focus | |
| parent | 20d68d3de011282727f3fe9701fcce310a0c5135 (diff) | |
| download | dotfiles-82a32ab8b3e62639e4f9cf787b8967c8da1f1232.tar.gz dotfiles-82a32ab8b3e62639e4f9cf787b8967c8da1f1232.zip | |
remove waybar elements, add and modify scripts, add mult. monitor support
Diffstat (limited to 'bin/toggle_monitor_focus')
| -rwxr-xr-x | bin/toggle_monitor_focus | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/toggle_monitor_focus b/bin/toggle_monitor_focus new file mode 100755 index 0000000..790ebe2 --- /dev/null +++ b/bin/toggle_monitor_focus @@ -0,0 +1,21 @@ +#!/bin/bash + +# Get the currently focused output +current_output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name') + +# Get the list of outputs +outputs=($(swaymsg -t get_outputs | jq -r '.[].name')) + +# Find the index of the currently focused output +for i in "${!outputs[@]}"; do + if [[ "${outputs[$i]}" == "$current_output" ]]; then + current_index=$i + break + fi +done + +# Calculate the index of the next output +next_index=$(( (current_index + 1) % ${#outputs[@]} )) + +# Focus the next output +swaymsg focus output "${outputs[$next_index]}" |