GithubHelp home page GithubHelp logo

SHOWHIDDEN error about tabbed-hjc HOT 8 CLOSED

Barbaross93 avatar Barbaross93 commented on September 15, 2024
SHOWHIDDEN error

from tabbed-hjc.

Comments (8)

huijunchen9260 avatar huijunchen9260 commented on September 15, 2024

My bad. the code should be

cwin="$(xwininfo -children -id $XEMBED | grep '^     0x' | sed -e 's@^ *\(0x[0-9a-f]*\) "\([^"]*\)".*@\1 \2@')" 
echo $cwin

and

IFS=':' &&
for win in $(printf '%s' "$cwin" | tr '\n' ':'); do unset IFS &&
cwid=$(printf '%s' "$win" | cut -d ' ' -f 1) &&
xwininfo -id $cwid -stats |
grep -q 'IsUnMapped' &&
printf '%s\n' "$win"; done

and also try to pipe the above output to dmenu / rofi to see whether the prompt opened

from tabbed-hjc.

Barbaross93 avatar Barbaross93 commented on September 15, 2024

Hmmm, I'm still getting xwininfo: error: -id requires argument after the first command. The second block after piping into rofi -dmenu -i -l 5 worked fine, however, I can see the out put for win in $(printf '%s' "$cwin" | tr '\n' ' followed by the string that was typed into rofi. So if I typed "spaghett" in the rofi prompt I get: for win in $(printf '%s' "$cwin" | tr '\n' 'spaghett

from tabbed-hjc.

huijunchen9260 avatar huijunchen9260 commented on September 15, 2024

You should open a terminal embedded into tab, and the first code will work. If still not work, then

cwin="$(xwininfo -children -id $(xdotool getactivewindow) | grep '^     0x' | sed -e 's@^ *\(0x[0-9a-f]*\) "\([^"]*\)".*@\1 \2@')" 
echo $cwin

Let's say you have three tabs open and hide two tabs.

xwininfo -children -id $XEMBED is to get a list of the child windows in tabbed, which id is represented by $XEMBED. The rest of the code is just manipulating the standard output so that only child windows' windows id and windows name appears. We store the output to cwin variable in the form winid winname (e.g. 0x520000a urxvt)

After you run the first command, your terminal should have a cwin variable. We use the following for loop to find which one is hidden.

Note that by default shell script has the IFS (internal field separator) set as space, tab and newline three characters, If we just use cwin into for loop, we will have six rather than three input for for loop since shell treat both winid and winname as different field.

To overcome the above difficulty, I set IFS as : to avoid such problem. Thus, when we put cwin into for loop, we also need to transform (tr) the newline character (\n) into colon (:) so that the for loop precisely based on colon. That is to say, the output of printf '%s' "$cwin" | tr '\n' ':' should be

0x2e0000a urxvt:0x3e0000a urxvt:0x520000a urxvt

, and each for loop will only accept a pair of winid winname.

After that, we unset IFS to default state to prevent any possible error.

We isolate only the windows id, pipe that windows id into xwininfo to retrieve the status of hidden. If hidden, we output the hidden pair of winid winname into standard output. Then pipe to rofi or dmenu to show a prompt for user to choose which hidden window to show.

Hope my explanation will help you understand what is happening in the SHOWHIDDEN function. If above code works for you, to further debug, you can try to remap the SHOWHIDDEN function into other keybinding that does not comflict to any other keybind existing in your system, and tell me the result.

from tabbed-hjc.

Barbaross93 avatar Barbaross93 commented on September 15, 2024

I think I've figured out the problem. The command did indeed work, but only if I made a new terminal using one of the commands you have to add a terminal to tabbed (and then executing that code in the new terminal). I'm using a bspwm specific script to achieve tabbing and what I was doing was taking your functions and putting them into my version of tabbed. Clearly there was a discrepancy there in the way you handled adding windows to tabbed versus the way my script does it. I'll go ahead and mark this closed since this is technically not a problem on your end

from tabbed-hjc.

huijunchen9260 avatar huijunchen9260 commented on September 15, 2024

Btw, in your screencast, https://imgur.com/a/N0661Hg, how do you let your PS1 appear on the tab?

from tabbed-hjc.

Barbaross93 avatar Barbaross93 commented on September 15, 2024

from tabbed-hjc.

huijunchen9260 avatar huijunchen9260 commented on September 15, 2024

Yeah, that is exactly what I am asking. Could you please explain the code a bit so that it is easier for me to understand the code?

from tabbed-hjc.

Barbaross93 avatar Barbaross93 commented on September 15, 2024

from tabbed-hjc.

Related Issues (2)

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.