aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts/specialworkspace_mover.sh
blob: 7e94d0361dc8436812021685c039d0498afba92d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash

# Fetch all clients' information using hyprctl
clients_output=$(hyprctl clients)

# Extract window classes for workspace -99
special_windows=$(echo "$clients_output" | awk '
  BEGIN { RS="Window "; FS="\n" }
  /workspace: -99/ {
    for (i=1; i<=NF; i++) {
      if ($i ~ /class:/) {
        class = $i
        sub("class: ", "", class)
        print class
      }
    }
  }
')

# Check if there are any windows in the special workspace
if [[ -z "$special_windows" ]]; then
  echo "No windows found in the special workspace."
  exit 0
fi

# Display the window classes in wofi and get the selected window class
selected_class=$(echo "$special_windows" | wofi --dmenu -p "Select a window to move:" | awk '{$1=$1};1')

# Exit if no selection was made
if [[ -z "$selected_class" ]]; then
  echo "No selection made."
  exit 0
fi

window_title=$(hyprctl clients | grep -i -E "Window .* $selected_class" | sed "s/Window.*-> \(.*\):/\1/I")

echo "Special windows: $special_windows"
echo "Selected class: $selected_class"
echo "Window title: $window_title"

current_workspace=$(hyprctl activeworkspace | head -n1 | cut -d' ' -f3)

echo "Curspace: $current_workspace"
# hyprctl dispatch movetoworkspacesilent 1,title:"Thinking in Systems - volty - Obsidian v1.7.7"

# Move the selected window to the current workspace
if [[ -n "$window_title" ]]; then
  hyprctl dispatch movetoworkspacesilent "$current_workspace",title:"$window_title"
  echo "Moved $selected_class to the current workspace."
else
  echo "Failed to find window ID for $selected_class."
fi