[closed] Scratchpad (hide) any window, any X11 based wm

I have done all the above and it is working BUT no numeral is displayed in lemonbar.

I just don’t understand why the numbering of workspaces hidden is not showing up in the bar, as it working the other day. ?

Thanks for all your help.

This is now Fixed tested tested works. ( center left)
Bloody typos all me.

Thanks for everything archus.

1 Like

Well I’m finaly happy that you fixed :grinning:
And for no confusion it doesn’t indicate hidden workspaces but windows… have fun!

1 Like

I have fixed another thing with floating (windows) and i,m not sure if even you relies.
One thing DK could not do was restack a floating window Thanks to you it is now easily possible.
I have super + left mouse as my move window around, If I pull a window from the stack and it becomes a floating windows before you could not restack this window. Now you can just hind that window and unhind it then the window is restacked in the same place.

You are the Man Thanks

I might be misunderstanding what you mean by restack but if you mean change the layer it is on you can add a custom window command to your config header

int stackabove(__attribute__((unused)) char **argv)
{
	/*
	 * basic example of a new win command
	 *
	 * Stack the floating window above
	 */
	 if (FLOATING(cmdc))
	 	 setstackmode(cmdc->win, XCB_STACK_MODE_ABOVE);
	return 0;
}

Cmd wincmds[] = {
	/* command,   function */
	{ "focus",    cmdfocus    },
	{ "kill",     cmdkill     },
	{ "resize",   cmdresize   },
	{ "mvstack",  cmdmvstack  },
	{ "swap",     cmdswap     },
	{ "float",    cmdfloat    },
	{ "full",     cmdfull     },
	{ "cycle",    cmdcycle    },
	{ "stick",    cmdstick    },
	{ "fakefull", cmdfakefull },
	{ "focusm",   focusmaster },

	{ "stackabove", stackabove },

	/* don't add below the terminating null */
	{ NULL,       NULL        }
};

Then you can bind it or run dkcmd win stackabove

You could also rename it to ‘stack’ and allow passing arguments to it like ‘above’ and ‘below’. A little search through the cmd.c file of dk will show you how to check arguments in a window function.

2 Likes

Once I merge the map-unmap branch I’ve been working on you should be able to do scratchpad/hidden windows natively. Still just working out some of the kinks.

3 Likes

Sorry my terminology is shit.

https://youtu.be/uk2Rc7chK7A

I made a video of what I mean by restacking. note the hidden count 0 to 1 left of center bar.

It would be nice to have indicator that shows the order in which the hidden windows are in so you don’t have to keep unhiding windows till you get the one you want. say you have 4 hidden windows.

Awesome :+1:

Just leads to a private video, might have to public it or get the private link.

Yep, got Unavailable Video or so on my end.

Sorry about that first time ever unloaded to UT. This should work.

1 Like

I see it gets tiled after unhiding, interesting. How are you ensuring they spawn floating to begin with? I assume it’s a rule or something?

Pretty sure what is happening is that dk is actually no longer managing the window once it is hidden due to the event generated on unmap, then when showing the window it’s as if that window just opened (as far as dk is concerned) so it’s handled like any other window that just opened and being tiled.

1 Like

The floating scratchpad is a rule and I use your scratch.sh with kitty.

My rules

# rule class, instance, and title regexes (*ALWAYS* CASE INSENSITIVE)
    dkcmd rule class="^pulsemixer$" float=true x=800 y=28 w=1000 h=600
    dkcmd rule class="^gnome-calculator$" title="^calculator$" float=true
	dkcmd rule class="^yad$" title="^Logout Options$" float=true
	dkcmd rule class="^scratchpad$" float=true x=800 y=28 w=1000 h=600
    dkcmd rule class="^/home/koo/.config/dk/scripts/scratch.sh$" float=true x=800 y=28 w=1000 h=600
    dkcmd rule class="^alacritty$" float=true x=800 y=28 w=1000 h=600
	dkcmd rule class="^ncmpcpp-ueberzug$" ws=2 float=true x=492 y=38 w=1500 h=600 bw=1
	dkcmd rule class="^cava$" ws=2 float=true x=492 y=642 w=1500 h=300 bw=1
	dkcmd rule class="^firefox$" ws=1
    dkcmd rule class="^Spotify$" ws=2
	dkcmd rule class="^Tauon Music Box$" ws=2
	dkcmd rule class="^geany$" ws=3
	dkcmd rule class="^spacefm$" ws=3
    dkcmd rule class="^mpv$" ws=5
    dkcmd rule class="^tixati$" ws=6

dkrc

super + shift + d
     kitty --class ~/.config/dk/scripts/scratch.sh

Yes I help this never changers, could not ask for a better result . :grinning:

@archus

Hide unhide won’t work with Void Linux as their is no xorg-xset xorg-xprop with Void only xset , xprop.

Any advice. Thanks

It should work, just check the dependencies function at the top of the script.
On void packages are splitted: xset, xorg-xset for arch

@archus
Been testing the hide script today there is a problem. If I’m on an empty workspace with no windows open and run -h it hides windows that are not their, plus if I then run -u nothing else in scratchpad yet the counter is still on say 3.

Plus with the above say I have 3 windows hidden on an empty workspace, then open a window an hide that too it never unhides and the counter is now 4.

I have change the script few days ago, please read it and adapt it to your needs.

#!/bin/bash

# This script hide and show focused windows whithin you favorite
# window manager or DE by using xdo to proceed
# We can also use rofi to select and show back hidden windows

_Dependencies() {
    DEPS=( "polybar" "rofi" "wmctrl" "xdo" "xprop" "xset" )

    for pkg in "${DEPS[@]}"; do
        [[ -z $(which $pkg) ]] \
        && notify-send -t 0 -u critical "$pkg is not installed...exiting" \
        && exit 127
    done
}

# Place your polybar module in bar-3
BARPID=$(pgrep --full $(wmctrl -m | awk '/Name/{print $2}')-bar-3)

_Indicator() {
    case "$1" in
        off)    xset -led 3
                polybar-msg -p "$BARPID" \
                action "#scratchpad-ipc.hook.0" >/dev/null 2>&1
                notify-send 'nothing else in scratchpad'
        ;;
        on )    xset led 3
                polybar-msg -p "$BARPID" \
                action "#scratchpad-ipc.hook.1" >/dev/null 2>&1
        ;;
    esac
}

TARGET=$(xdo id ${1})
ID_LIST="$XDG_RUNTIME_DIR/scratchpad_hidden.list"
ID_LIST_ALL="$XDG_RUNTIME_DIR/scratchpad_all.list"

case "$1" in
    -h) # sending all existing windows ids/instances/classes in a file for debugging.
        _Dependencies
        wmctrl -lx | awk '{print $1" "$3}' > "$ID_LIST_ALL"
        # using lowercases will match ids in $ID_LIST_ALL
        echo "$TARGET" | tr [:upper:] [:lower:] >> "$ID_LIST"
        xdo hide "$TARGET"
        _Indicator on
    ;;
    -u) if [[ $(xprop -id $(sed -n '1p' "$ID_LIST") \
            | awk '/window state: / {print $3}') = Withdrawn ]]; then
            # show the first entry.
            xdo show "$(sed -n '1p' "$ID_LIST")"
            # remove it from the hidden list.
            sed -i '1d' "$ID_LIST"
            if (( $(grep "" -c "$ID_LIST") > 0 )); then
                _Indicator on
            else
                _Indicator off
            fi
        else
            _Indicator off
        fi
    ;;
    -r) if (( $(grep "" -c $ID_LIST) > 0 )); then
        
            HIDDEN=$(cat $ID_LIST)
            
            # making a rofi menu.
            N=$(for w in $HIDDEN; do
                NAME=$(xprop -id "$w" WM_CLASS 2>/dev/null | sed -r 's/.+ "(.+)"$/\1/')
                TITLE=$(xprop -id "$w" _NET_WM_NAME 2>/dev/null | sed -r 's/.+ "(.+)"$/\1/')
                [[ "$NAME" = "WM_CLASS" ]] && echo "$w" || echo "$NAME  \"$TITLE\""
            done | rofi -dmenu -no-custom -format i -p 'Unhide a window: ')

            [[ -n "$N" ]] && {

                ID=$(echo "$HIDDEN" | sed -n "$((N+1))p")
                # show selected.
                xdo show "$ID"
                # remove it from the hidden list.
                sed -i "/${ID}/d;/^\s*$/d" "$ID_LIST"

                if (( $(grep "" -c $ID_LIST) > 0 )); then
                    _Indicator on
                else
                    _Indicator off
                fi
            }

        else
            _Indicator off
        fi
    ;;
esac

2 Likes

Thanks for the update
quick test insisting on polybar , I have added lemonbar to the DEPS=( “lemonbar” “polybar” etc but still wants polybar… I use lemonbar.

Sorry I don’t use lemonbar, (remove polybar related lines in the script) xset will light a led on your keyboard so that’s an indicator for you to know you have hidden windows and if you want to see which ones, a rofi menu will appear if you press the keys you’ve determined in sxhkd or whatever you use so you can see them

Sorry to see you have closed the topic.

Anyway I have the script working fine now. (will keep testing) -h -u -r working
Was very lagged system & high resources before editing the script.

Removed

"polybar"  added "lemonbar"
# Place your polybar module in bar-3
BARPID=$(pgrep --full $(wmctrl -m | awk '/Name/{print $2}')-bar-3)
polybar-msg -p "$BARPID" \  And both off/on

New script but same result on empty workspaces, still hides windows when there are none to hide.

My last post on this topic. [closed]