Giter Site home page Giter Site logo

Comments (4)

luravoid avatar luravoid commented on June 12, 2024 1

Works great. Thank you

from pyprland.

fdev31 avatar fdev31 commented on June 12, 2024

This looks a bit fragile, what if the user manipulates the window without using the plugin ?
It should reset I guess...
it would only work well for very controlled sequences... but maybe that's fine.
I may have a look at it but with a low priority.

from pyprland.

luravoid avatar luravoid commented on June 12, 2024

If the user manipulates the window, such as moving it to another workspace without using a plugin, then I think it doesn't matter. The saved workspace location will only reset the next time using fetch-client-menu or when window is sent back. So even after manipulating the window without using the plugin, the window will still return to the same place from which it was moved, if the keybinding was used. User just won't send the window back if he doesn't need it.

Please take a look at my script that I created today and see how I implemented saving workspace of the window before moving.
This script kinda replicate dwm/awesome tags behaviour so I can very easily toggle windows from all the workspaces into the single view.

#!/bin/bash

if [ $# -eq 0 ]; then
    echo "Usage: $0 <window_class>"
    exit 1
fi

WINDOW_CLASS="$1"

STORE_FILE="$HOME/.config/hypr/.win_store"

if [ ! -f "$STORE_FILE" ]; then
    touch "$STORE_FILE"
fi

CURRENT_WORKSPACE=$(hyprctl activeworkspace -j | jq '.id')

WINDOWS_INFO=$(hyprctl -j clients | jq --arg CLASS "$WINDOW_CLASS" -c '.[] | select(.class == $CLASS)')

echo "$WINDOWS_INFO" | while IFS= read -r WINDOW; do
    WINDOW_ADDRESS=$(echo "$WINDOW" | jq -r '.address')
    WINDOW_WORKSPACE=$(echo "$WINDOW" | jq '.workspace.id')

    if grep -q "$WINDOW_ADDRESS" "$STORE_FILE"; then
        ORIGINAL_WORKSPACE=$(grep "$WINDOW_ADDRESS" "$STORE_FILE" | cut -d ' ' -f 2)
        if [ "$WINDOW_WORKSPACE" -eq "$CURRENT_WORKSPACE" ]; then
            hyprctl dispatch movetoworkspacesilent "$ORIGINAL_WORKSPACE","address:$WINDOW_ADDRESS"
            sed -i "/$WINDOW_ADDRESS/d" "$STORE_FILE"
        else
            hyprctl dispatch movetoworkspace "$CURRENT_WORKSPACE","address:$WINDOW_ADDRESS"
        fi
    else
        echo "$WINDOW_ADDRESS $WINDOW_WORKSPACE" >> "$STORE_FILE"
        hyprctl dispatch movetoworkspace "$CURRENT_WORKSPACE","address:$WINDOW_ADDRESS"
    fi
done

And my keybindings:

bind = $mainMod CTRL, 1, exec, ~/.config/hypr/scripts/toggle-window neovim
bind = $mainMod CTRL, 2, exec, ~/.config/hypr/scripts/toggle-window Brave-browser
bind = $mainMod CTRL, 3, exec, ~/.config/hypr/scripts/toggle-window VSCodium
bind = $mainMod CTRL, 4, exec, ~/.config/hypr/scripts/toggle-window discord
bind = $mainMod CTRL, 5, exec, ~/.config/hypr/scripts/toggle-window obsidian

from pyprland.

fdev31 avatar fdev31 commented on June 12, 2024

Are you able to test the git version to see if you are happy with the "unfetch_client" command ?

from pyprland.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.