From fc7e7ab18e5c1205727d71e0d23d080762fd27a2 Mon Sep 17 00:00:00 2001 From: klein panic Date: Tue, 22 Oct 2024 22:06:34 -0400 Subject: [PATCH] fixed git issues properly --- switch_tags | 1 - switch_tags/switch_tag.sh | 40 +++++++++++++++++++++++++++++++++++ switch_tags/switch_tag.sh.bak | 31 +++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) delete mode 160000 switch_tags create mode 100755 switch_tags/switch_tag.sh create mode 100755 switch_tags/switch_tag.sh.bak diff --git a/switch_tags b/switch_tags deleted file mode 160000 index 4eca228..0000000 --- a/switch_tags +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4eca2286682a32f266c7124715a6f279ed7bd004 diff --git a/switch_tags/switch_tag.sh b/switch_tags/switch_tag.sh new file mode 100755 index 0000000..35e6830 --- /dev/null +++ b/switch_tags/switch_tag.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Function to get the current tag (workspace) from the bitmask +get_current_tag() { + dwm-msg get_monitors | jq -r '.[0].tagset.current' +} + +# Read the current tag bitmask +current_tag_bitmask=$(get_current_tag) + +# Ensure current_tag_bitmask is a valid number +if ! [[ "$current_tag_bitmask" =~ ^[0-9]+$ ]]; then + echo "Error: Invalid current tag bitmask" + exit 1 +fi + +# Convert bitmask to actual tag number (1-9) +current_tag=$(awk 'BEGIN {for (i=1; i<=9; i++) if (2^(i-1) == '$current_tag_bitmask') print i}') + +if [[ -z "$current_tag" ]]; then + echo "Error: Could not determine current tag from bitmask" + exit 1 +fi + +echo "Current tag: $current_tag" + +if [ "$1" == "next" ]; then + next_tag=$((current_tag % 9 + 1)) # Increment tag and wrap around after 9 + echo "Switching to next tag: $next_tag" + sleep 0.1 # Small delay to ensure xdotool handles the input properly + xdotool key Super_L+$next_tag # Use xdotool to switch tags +elif [ "$1" == "prev" ]; then + prev_tag=$((current_tag == 1 ? 9 : current_tag - 1)) # Decrement tag and wrap around after 1 + echo "Switching to previous tag: $prev_tag" + sleep 0.1 # Small delay to ensure xdotool handles the input properly + xdotool key Super_L+$prev_tag # Use xdotool to switch tags +else + echo "Usage: $0 {next|prev}" + exit 1 +fi diff --git a/switch_tags/switch_tag.sh.bak b/switch_tags/switch_tag.sh.bak new file mode 100755 index 0000000..9f90f26 --- /dev/null +++ b/switch_tags/switch_tag.sh.bak @@ -0,0 +1,31 @@ +#!/bin/bash + +# Function to get the current tag (workspace) +get_current_tag() { + dwm-msg get_monitors | jq -r '.[0].tagset.current' +} + +# Read the current tag number +current_tag=$(get_current_tag) + +# Ensure current_tag is a valid number +if ! [[ "$current_tag" =~ ^[0-9]+$ ]]; then + echo "Error: Invalid current tag number" + exit 1 +fi + +echo "Current tag: $current_tag" + +if [ "$1" == "next" ]; then + next_tag=$(( (current_tag + 1) % 9 )) + next_tag=$((next_tag == 0 ? 9 : next_tag)) # Adjust for 1-based index + echo "Switching to next tag: $next_tag" + xdotool key Super_L+$next_tag # Use xdotool to switch tags +elif [ "$1" == "prev" ]; then + prev_tag=$(( (current_tag - 1 + 9 - 1) % 9 + 1 )) # Adjust for 1-based index + echo "Switching to previous tag: $prev_tag" + xdotool key Super_L+$prev_tag # Use xdotool to switch tags +else + echo "Usage: $0 {next|prev}" + exit 1 +fi