Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a --split-horizontal-height=XX and --split-vertical-width=XX #1931

Closed
Lowrida opened this issue Oct 15, 2021 · 7 comments
Closed

Add a --split-horizontal-height=XX and --split-vertical-width=XX #1931

Lowrida opened this issue Oct 15, 2021 · 7 comments

Comments

@Lowrida
Copy link

Lowrida commented Oct 15, 2021

A suggestion

Add a --split-horizontal-height=XX (XX= lines) for max height of new terminal
Add a --split-vertical-width=XX (XX= cols) for max width of new terminal

I use a script to open a new tab that opens 2 horizontal splits (3 terminals).
First one is just 1 line and shows clock, cpu, mem etc info every second.
Second one runs midnight commander in it with output to third terminal (exec 1>/dev/pts/xx).
Third one is the output of the second terminal.

But i have to drag the size of the terminals manually every time i open an new tab, because the first split is halve of the screen while terminal 1 output is just a one liner.

I couldn't find anything on the net to set this on the cli.

Screenshots:
guake-split-a
.
guake-split-b

@Lowrida
Copy link
Author

Lowrida commented Oct 16, 2021

I made a quick&dirty script to do what i want, but xdotool is slow as F#! :/ I still hope these options will be implemented in an upcoming release.. btw the xdotool keys are my own shortcut keys, you have to implement your own shortcut keys to resize the terminal.

Maybe usable for anyone with the same problem..?

`#!/bin/sh
######################################################################################################################

This script opens a new tab, splits it in three, resizes each terminal and starts a program in each terminal.

The values of the sleep timers depends on the speed of your system. Untill there is an option to set the size

of the new split, this is a slow&dirty solution. Feel free to (ab)use it as you like!

######################################################################################################################

Open new tab and terminal

guake -new-tab=/home/admin -e 'echo "Terminal0: 0" >/tmp/guake_terminal.tmp; c0=$(tty); echo "Console0: $c0" >>/tmp/guake_terminal.tmp; lines0=$(tput lines); echo "Lines0: $lines0" >>/tmp/guake_terminal.tmp'

Open second terminal find out number and tty

guake --split-horizontal -e 't1=$(guake --selected-terminal); echo "Terminal1: $t1" >>/tmp/guake_terminal.tmp; c1=$(tty); echo "Console1: $c1" >>/tmp/guake_terminal.tmp; lines1=$(tput lines); echo "Lines1: $lines1" >>/tmp/guake_terminal.tmp'
sleep .1

Open third terminal find out number and tty

guake --split-horizontal -e 't2=$(guake --selected-terminal); echo "Terminal2: $t2" >>/tmp/guake_terminal.tmp; c2=$(tty); echo "Console2: $c2" >>/tmp/guake_terminal.tmp; lines2=$(tput lines); echo "Lines2: $lines2" >>/tmp/guake_terminal.tmp'

sleep .1

Put terminal and tty into variables

terminal0=$(cat /tmp/guake_terminal.tmp | grep "Terminal0" | awk -F "Terminal0: " '{print $2}')
console0=$(cat /tmp/guake_terminal.tmp | grep "Console0" | awk -F "Console0: " '{print $2}')
lines0=$(cat /tmp/guake_terminal.tmp | grep "Lines0" | awk -F "Lines0: " '{print $2}')
sleep .1
terminal1=$(cat /tmp/guake_terminal.tmp | grep "Terminal1" | awk -F "Terminal1: " '{print $2}')
console1=$(cat /tmp/guake_terminal.tmp | grep "Console1" | awk -F "Console1: " '{print $2}')
lines1=$(cat /tmp/guake_terminal.tmp | grep "Lines1" | awk -F "Lines1: " '{print $2}')
sleep .1
terminal2=$(cat /tmp/guake_terminal.tmp | grep "Terminal2" | awk -F "Terminal2: " '{print $2}')
console2=$(cat /tmp/guake_terminal.tmp | grep "Console2" | awk -F "Console2: " '{print $2}')
lines2=$(cat /tmp/guake_terminal.tmp | grep "Lines2" | awk -F "Lines2: " '{print $2}')

Select first terminal and resize

guake --select-terminal=$terminal0 -e 'while [ "$lines0" -gt 5 ]; do xdotool keydown -delay 0 ctrl+shift+super Up keyup ctrl+shift+super Up; lines0=$((lines0-1)); tput clear; printf "$lines0"; done'
sleep 3
guake --select-terminal=$terminal0 -e /home/admin/bin/mctime.sh

Select second terminal and resize

guake --select-terminal=$terminal1 -e 'while [ "$lines1" -lt 65 ]; do xdotool keydown -delay 0 ctrl+shift+super Down keyup ctrl+shift+super Down; lines1=$((lines1+1)); tput clear; printf "$lines1"; done'
sleep 2
guake --select-terminal=$terminal2 -e "tput clear"
guake --select-terminal=$terminal1 -e mc
guake --select-terminal=$terminal1 -e "exec 1>$console2"
`

@Davidy22
Copy link
Collaborator

Could possibly just make width/height optional parameters to the existing split commands. Cut back on the amount to learn a little bit.

@Lowrida
Copy link
Author

Lowrida commented Oct 18, 2021

I would be very pleased with any option to set height and width with a cli command!
The script i made is a temporary solution, but xdotool is just too slow for this.. costs me more coffee than acceptable! ;)

@Lowrida
Copy link
Author

Lowrida commented Oct 19, 2021

And maybe an idea to choose if you want number of lines/columns or a percent of the screen?
I noticed that when i split in fullscreen and go back to normal the split is not adjusting to the window size.. some terminals are complete outside of the windows size.
I my case my upper terminal always has to be 1 line, so i could set that with a line number. But the middel and botom terminal i would have them always 60%-40%

@Davidy22
Copy link
Collaborator

Eh probably just throw an error when you try to make a split larger than the window.

@Lowrida
Copy link
Author

Lowrida commented Oct 19, 2021

?

@Davidy22
Copy link
Collaborator

Resolved by #2208

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants