1

Is there an argument that would start the terminal with a certain window size - like the geometry argument (-geometry in xterm, --geometry= in Terminator and --geometry in Gnome Terminal) when I run a command that needs a very small window?

~ I want to use a shortcut to run the command scrot -s -d 5 -c and I need to run it in terminal. It will capture a region with a delay of 5 seconds while displaying a countdown; the window shouldn't be in the way, so it would be better to make it very small in such a case, while keeping the normal size of the terminal for other purposes. I know how to use for this the other mentioned terminals, I was wandering if I could use the default one.

4 Answers 4

1

There is no command line switch to support this in pantheon-terminal.

You might want to try the workaround as suggested in the other answers, however, it might not always work as expected if other terminal windows are open as well.

pantheon-terminal-width-height script (use pantheon-terminal-width-height WIDTH HEIGHT):

#!/bin/bash
NEW_WIDTH=$1
NEW_HEIGHT=$2    
OLD_WIDTH=$(gsettings get org.pantheon.terminal.saved-state window-width)
OLD_HEIGHT=$(gsettings get org.pantheon.terminal.saved-state window-height)    
gsettings set org.pantheon.terminal.saved-state window-width $NEW_WIDTH
gsettings set org.pantheon.terminal.saved-state window-height $NEW_HEIGHT
pantheon-terminal &
sleep 1
gsettings set org.pantheon.terminal.saved-state window-width $OLD_WIDTH
gsettings set org.pantheon.terminal.saved-state window-height $OLD_HEIGHT
2

You can change the dconf settings just before opening the terminal like this

gsettings set org.pantheon.terminal.saved-state window-width 400;
gsettings set org.pantheon.terminal.saved-state window-height 400;
pantheon-terminal

There are also opening-x and opening-y properties you can change that you might find useful.

1

Install sudo apt-get install dconf-toolsand run it.

Then go to org>pantheon>terminal>settings

Find here settings for windows width and height and set it.

If you want, you can change other preferences. :)

1
  • The terminal remembers the last window size anyway. What I want is an argument (if available: I'll make that more clear in the question) that would allow me to start it sometimes with a very small window (when running a command that involves displaying a countdown: scrot -s -d 5 -c).
    – user170
    Commented Jan 24, 2017 at 9:38
0

I understand it's a bit late maybe with this kind of reply. But I think it can still be useful for someone. If I understand the original question right, by Cipricus, he wanted to change the size of a running terminal. Not open a 2th terminal from terminal 1 and change the size of the 2th terminal window afterwards. The big issue, a running bash script will stop the script after opening the 2th terminal window, which is not what a bash developer wants.

I have frustrated myself today while trying to use your replies for this question in combination with a large bash script. Doesn't work. And even if you try to make it work you probably don't want to open a second terminal while running a bash script.

Most important, before I will show you my trick, a short message;

Dear gentlemen elementary developers,

Please don't let us find endless workarounds for functions that anyone would expect to be available to work when needed. Changing a terminal window size should be a matter of one terminal command that is supplied by default after installing the o.s. on a computer. Please provide this for other people like me, not wanting to install another terminal application and keep elementary os as original as possible.

Ok. Having said that, here is what I found.

In your bash script use these lines to change the size of your terminal while running a script:

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' wmctrl|grep "install ok installed")
echo Checking for wmctrl: $PKG_OK
if [ "" == "$PKG_OK" ]; then
clear   
echo "Please Wait a moment....."
sudo apt-get install --yes wmctrl > /dev/null 2>&1;
fi
wmctrl -r script.sh -e 0,-1,-1,1400,800;

In the last line you need to change the name of the script (script.sh) to the filename of your running bash script and adjust the size values "1400,800" to your wish. That should be enough to use it. It will probably work after that.

What it does:

PKG_OK=$(dpkg-query -W --showformat='${Status}\n' wmctrl|grep "install ok installed")
echo Checking for wmctrl: $PKG_OK
if [ "" == "$PKG_OK" ]; then

In this part the script is checking for a package named "wmctrl" whether it is installed or not. then,

clear 
echo "Please Wait a moment....."
sudo apt-get install --yes wmctrl > /dev/null 2>&1;
fi

if it doesn't find the package installed, it will install the package, but it will not confuse the user with terminal output of the installation process. This hiding is done by: > /dev/null 2>&1; The user will only see an empty screen with a message "Please wait a moment" while waiting 10 seconds for the installation.

If there is no installation needed, the better. The script will end the boolean with fi and go to the last line;

wmctrl -r script.sh -e 0,-1,-1,1400,800;

Where it will actually use the command to adjust the terminal window. It is handy to do a #wmctrl -l to examine the names of the windows in the list. Probably you will see the name of your running sh script in the list. Only the "exact" name of your script should be enough for wmctrl to find the right window. (Because that is what is does, it finds the right window among the list of all open windows and change it)

The last numbers are the ones to adjust the window settings. In my example I only wanted to change the size of the running terminal window (last 2 values, 1400 and 800) and not the position (value 2 and 3 in the line) -1 -1

For all options take a look at : wmctrl -h

Pfew...! And all that to avoid one missing logical terminal command... Works for me, hope you can use it!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.