Issues while creating a custom special-workspace (scratchpad workflow) function

I just wanna say I’m very new to linux (hyprland) and editing scripts/code/configs in general most of the stuff I gathered from internet and put it in AI chatbots to create me script as I couldn’t find any guide on what I wanted to achieve.

I wanted something like this, create a special-workspace then toggle on/off (hide-unhide) and then if need be movetoworkspace, I used three moving things to get this 1. Toggle script 2. promotion script 3. A window rule in config.

What’s happening: I can as per my preferences open the spcial-window (scratchpad workflow) but when I try to move it to workspace it is still keeping float and center values, i want it to behave as a normal window after being moved to workspace. From what I gathered float and center are static and that’s why this is happening. Is there anyway to resolve this

Toggle Script

#!/usr/bin/env bash


SCRATCH="term"

CLASS="scratchpad-term"

CMD="kitty --class scratchpad-term"


SCRATCH_ADDR=$(hyprctl clients -j | jq -r \

".[] | select(.initialClass == \"$CLASS\" and .workspace.name == \"special:$SCRATCH\") | .address" \

| head -n1)

if [[ -z "$SCRATCH_ADDR" ]]; then

$CMD &

attempt=0

while [[ -z "$SCRATCH_ADDR" ]]; do

sleep 0.1

        ((attempt++))

        [[ $attempt -ge 20 ]] && exit 1

SCRATCH_ADDR=$(hyprctl clients -j | jq -r \

".[] | select(.initialClass == \"$CLASS\" and .workspace.name == \"special:$SCRATCH\") | .address" \

| head -n1)

done

hyprctl dispatch setfloating "address:$SCRATCH_ADDR"

hyprctl dispatch centerwindow "address:$SCRATCH_ADDR"

hyprctl dispatch tagwindow +utility "address:$SCRATCH_ADDR"

hyprctl dispatch tagwindow +scratchpad "address:$SCRATCH_ADDR"


exit 0

fi

VISIBLE=$(hyprctl monitors -j | jq -r \

".[] | select(.specialWorkspace.name == \"special:$SCRATCH\" and .specialWorkspace.visible == true)")




if [[ -z "$VISIBLE" ]]; then

hyprctl dispatch togglespecialworkspace "$SCRATCH"

exit 0

fi

ACTIVE_ADDR=$(hyprctl activewindow -j | jq -r '.address')




if [[ "$ACTIVE_ADDR" == "$SCRATCH_ADDR" ]]; then

hyprctl dispatch togglespecialworkspace "$SCRATCH"

else

hyprctl dispatch focuswindow "address:$SCRATCH_ADDR"

fi 

Promotion Script

#!/usr/bin/env bash

CLASS="scratchpad-term"
SCRATCH="term"

WINDOW=$(hyprctl activewindow -j)
ADDR=$(echo "$WINDOW" | jq -r '.address')
ACTIVE_CLASS=$(echo "$WINDOW" | jq -r '.initialClass')
ACTIVE_WS=$(echo "$WINDOW" | jq -r '.workspace.name')

# Exit if not our scratchpad
if [[ "$ACTIVE_CLASS" != "$CLASS" || "$ACTIVE_WS" != "special:$SCRATCH" ]]; then
    exit 0
fi

hyprctl dispatch togglespecialworkspace "$SCRATCH"
hyprctl dispatch movetoworkspacesilent "emptynm,address:$ADDR"
hyprctl dispatch setfloating 0 "address:$ADDR"
hyprctl dispatch focuswindow "address:$ADDR"


Hyprland version 0.53.0
PASTE YOUR HYPRLAND VERSION HERE (hyprctl version), BETWEEN THE BACKTICKS. DO NOT REMOVE ANY FORMATTING.

I don’t quite understand what you are trying to accomplish here.

open a program (say kitty) in special window. use the same key bind to toggle it (hide/show), that way I can run some minor thing in there, and if need be move the window to a workspace for proper working. ** I want to us this same functionality to other programs such as obsidian or cider later.

So what you want is something like this?

bind = ctrl, o, togglespecialworkspace, special_kitty
workspace = special:special_kitty, on-created-empty: kitty --class special_kitty
bind = ctrl, p, movetoworkspace, e+0

# what should be doable.

windowrule = float on, center on, match:workspace s[true], match:class special_kitty
windowrule = tile on, match:workspace s[false], match:class special_kitty

# but what we have to do instead.

bind = ctrl, p, settiled

or are you going to send all the apps you start to the same special ws?

I want only specific apps mainly {terminal (kitty), music(cider) and notes(obsidian)} to have their own separate special workplace, bind to their own key map. and yes i was looking for something similar to this indeed.

So as per your suggestion I added “ hyprctl dispatch settiled “address:$ADDR” “ to the promotion script. and now it works as intended.THANK YOU so much for that.

Sorry to bother you further with this but do you think all these actions can be done just via .conf and scripts can be made redundant for this whole thing ? I’ll try own my own just want to know if it can be done.

Thank you once again for this. Cheers :champagne: