aboutsummaryrefslogtreecommitdiff
path: root/move-qemu.sh
blob: 7583cffb2900a2c850d640f61a8a225bbaa26866 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash

#
#function move_qemu_window {
#    find_window_title() {
#        hyprctl clients | grep -q "QEMU (nixos) - noVNC — Mozilla Firefox"
#    }
#
#    # Function to move the window to workspace 3
#    move_window() {
#        local window_title="$1"
#        if [[ -n $window_title ]]; then
#            hyprctl dispatch movetoworkspace 3,title:"$window_title"
#            echo "Moved window to workspace 3."
#        else
#            echo "Failed to find window title."
#        fi
#    }
#
#    # Function to handle socket input
#    handle_socket() {
#        while read -r line; do
#            case "$line" in
#            *"QEMU (nixos) - noVNC — Mozilla Firefox"*)
#                echo "Socket message received: "$line
#                if find_window_title; then
#                    window_title="^QEMU \(.*\) - noVNC — Mozilla Firefox*"
#                    move_window ""$window_title
#                else
#                    echo "Failed to find window title."
#                fi
#                ;;
#            *)
#                echo "Ignoring socket message: "$line
#                ;;
#            esac
#        done
#    }
#
#    # Wait for the socket and handle messages
#    echo "Waiting for socket messages..."
#    socat - "UNIX-CONNECT:/tmp/hypr/"$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | handle_socket
#}
#
#move_qemu_window

function move_qemu_window {
    find_window_title() {
        hyprctl clients | grep -q "QEMU (nixos) - noVNC — Mozilla Firefox"
    }

    # Function to move the window to workspace 3
    move_window() {
        local window_title="$1"
        if [[ -n $window_title ]]; then
            hyprctl dispatch movetoworkspace 3,title:"$window_title"
            echo "Moved window to workspace 3."
        else
            echo "Failed to find window title."
        fi
    }

    # Wait for the window to appear
    echo "Waiting for window..."
    while true; do
        if find_window_title; then
            window_title="^QEMU \(.*\) - noVNC — Mozilla Firefox*"
            move_window "$window_title"
        fi
        sleep 1 # Check every second
    done
}

move_qemu_window