You are not logged in.
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
Does it export the WINDOWID ?
xwininfo -id $WINDOWIDDo you need the geometry in pixels or the terminal size?
=> https://stackoverflow.com/questions/263 … nal-window
Offline
Nice, thanks. Piping into a nasty hack gives the desired effect:
xwininfo -id $WINDOWID | grep geome | awk '{print $2}' | sed 's/+.*$//'
128x36In 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
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
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...
Offline
Can do it all with just awk:
xwininfo -id $WINDOWID | awk '/geome/ {sub(/\+.*/,""); print $2}'Offline
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
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
The stackoverflow link in #2 also has "stty size" and a bunch of more or less clumsy ways to utilize the command outputs ![]()
Ftr, even fish supports $LINES and $COLUMNS
Geee. I really wonder which shell might not ![]()
Offline
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
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