You are not logged in.

#1 2022-09-03 20:54:30

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

xfce4-terminal detect currently geometry? [SOLVED]

Is anyone aware of a way to get xfce4-terminal to detect the geometry of the currently open process of itself?  Best I can do is resize with the mouse and observe the geometry in a overlay window.  The goal is to pass the geometry to a script automatically.  Been through the man page and google but found nothing.

Last edited by graysky (2022-09-04 09:06:57)

Offline

#2 2022-09-03 21:52:39

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,223

Re: xfce4-terminal detect currently geometry? [SOLVED]

Does it export the WINDOWID ?

xwininfo -id $WINDOWID

Do you need the geometry in pixels or the terminal size?
=> https://stackoverflow.com/questions/263 … nal-window

Offline

#3 2022-09-03 22:09:17

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Re: xfce4-terminal detect currently geometry? [SOLVED]

Nice, thanks.  Piping into a nasty hack gives the desired effect:

 xwininfo -id $WINDOWID | grep geome | awk '{print $2}' | sed 's/+.*$//'
128x36

In my .zshrc

dup() {
  local _here=$(pwd)
  local _geo=$(xwininfo -id $WINDOWID | grep geome | awk '{print $2}' | sed 's/+.*$//')
  xfce4-terminal --geometry "$_geo" --working-directory="$_here"
}

Last edited by graysky (2022-09-03 22:10:36)

Offline

#4 2022-09-03 22:20:07

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,496
Website

Re: xfce4-terminal detect currently geometry? [SOLVED]

Are you trying to give me a heart attack?  Really, grep plus awk plus sed in a pipeline?!  You do know that any one of those three would be perfectly capable of acheiving the same goal on their own.  If you want examples, post the raw output of the xwininfo command (I don't have X installed to check).  Additionally you'll almost certainly want to use the -size or -shape (and perhaps -frame) flags for xwininfo before even throwing it into the text processing tool of choice.

Last edited by Trilby (2022-09-03 22:22:17)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2022-09-03 22:24:37

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: xfce4-terminal detect currently geometry? [SOLVED]

Trilby wrote:

Are you trying to give me a heart attack?

I was hoping that the lack of oxygen would turn you avatar back into more interesting colours...


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#6 2022-09-03 22:25:23

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: xfce4-terminal detect currently geometry? [SOLVED]

Can do it all with just awk:

xwininfo -id $WINDOWID | awk '/geome/ {sub(/\+.*/,""); print $2}'

Offline

#7 2022-09-03 22:31:14

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,223

Re: xfce4-terminal detect currently geometry? [SOLVED]

Now that we've the pigeon at our mercy, that's also the terminal char-size,

echo ${LINES}x${COLUMNS}

will do the same (hopefully. If in a script, make sure to invoke bash -i)
The xwininfo should also hold the pixel geometry and position (pretty much at the top)

Offline

#8 2022-09-04 01:23:56

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,496
Website

Re: xfce4-terminal detect currently geometry? [SOLVED]

Oh dear - if it is just character size it is much easier.  The LINES and COLUMNS variables are a bashism, though (and as noted only in an interactive shell).  But tput is much more portable:

tput lines cols

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2022-09-04 06:40:57

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,223

Re: xfce4-terminal detect currently geometry? [SOLVED]

The stackoverflow link in #2 also has "stty size" and a bunch of more or less clumsy ways to utilize the command outputs wink
Ftr, even fish supports $LINES and $COLUMNS
Geee. I really wonder which shell might not tongue

Offline

#10 2022-09-04 09:04:58

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,734
Website

Re: xfce4-terminal detect currently geometry? [SOLVED]

Thanks again, all.  Lots of cleaner ways.  I like seth's for my use case and it works as a simple one-line alias now:

alias dup='xfce4-terminal --geometry "${COLUMNS}x${LINES}" --working-directory="$(pwd)"'

Offline

#11 2022-09-04 12:35:55

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,496
Website

Re: xfce4-terminal detect currently geometry? [SOLVED]

If someone doesn't care about portability, then whether or not fish has the variable is irrelevant.  If one does care about portability, then whether or not fish has the variable is irrelevant.

So overall, fish is irrelevant.

EDIT for clarity this is not about fish.  No single shell is relevant to portability discussions.  Portability comes not from attempting to check with various current implementations, but rather with sticking to a standard.  Which shell does not define LINES and COLUMNS... well, as noted even bash doesn't in scripts!

Last edited by Trilby (2022-09-04 12:40:42)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB