3

Environment: Red Hat Enterprise Linux, C language , Eclipse IDE for C/C++ Developers

Question: I'm programming a typing tutor which run on GNOME terminal, i want to maximize terminal when run the program(on GNOME). How can i realize it, does anyone have suggestions or any possible clues.

2
  • gnome-terminal --full-screen might help
    – Taylor Bioniks
    Oct 25, 2012 at 16:14
  • I really think this belongs on unix.stackexchange.com.
    – john-jones
    Nov 17, 2018 at 13:47

4 Answers 4

3
$ gnome-terminal --maximize

Should do.

Take a look at

$ gnome-terminal --help
$ gnome-terminal --help-window-options

etc. to see what else you can do.


So you want to run your application inside a maximized GNOME terminal? The easiest way is to seperate launching the application from the code itself.

Write a shellscript wrapper which runs gnome-terminal --maximize -x my_typing_tutorial. Then set up the shortcut (or whatever) to run this script, instead of your binary.

Note this gives you a chance to detect if gnome-terminal isn't installed, and try starting konsole or xterm instead. It also means that a user can edit the start script if it doesn't work on their system, without having to re-compile your binary.

Note that I'm not addressing the question of how to maximize an existing terminal - if I were the user, I'd hate a program that messed up my window geometry without asking.

4
  • Thank for your graciously help. But seems like doesn't work, maybe i haven't described my problem clearly.As u may know, i'm using C language to program. What i expected is to maximum GNOME terminal when starting typing tutor(by pressing an START/OK button), not maximum terminal by Initialization. Which means if i can write some C language code to realize it, like by calling "system("clear)";" to clear terminal screen. Thank u again.
    – Takechiyocn
    Oct 25, 2012 at 22:13
  • yeah, that's what i exactly wanted-the solutions & suggestions. u r right, i should consider about the protability and maximize my GNOME without user's permission is not a good idea, though the program is just a demo that my leader ask me to try. Thank you again. In the end, how can i change my text to a new line like u did... it's ugly without a proper new-line just as what i did...
    – moku
    Oct 28, 2012 at 9:45
  • If you mean the formatting, you have only limited control in comments. In questions and answers, just look at the help to see what you can do.
    – Useless
    Oct 28, 2012 at 18:01
  • Here in 2021, that switch is not even listed in the man page; had to find it with gnome-terminal --help-all. Aug 26, 2021 at 20:14
3

You can use wmctrl, to get current window id use $WINDOWID environment variable, to get current window geometry use xwinfo -id $WINDOWID

so after something like sudo aptitude install wmctrl :

  • wmctrl -i -r $WINDOWID -b toggle,fullscreen #toggle fullscreen
  • wmctrl -i -r $WINDOWID -b add,fullscreen #force fullscreen
  • wmctrl -i -r $WINDOWID -b remove,fullscreen #force remove fullscreen

Also wmctrl have own way to handle current window:

wmctrl -r :ACTIVE: -b toggle,fullscreen
10
  • well, thank u for ur help, i just tried as told, but seems nothing changed except "xwinfo -id $WINDOWID" shows my window information.Since i have installed wmctrl1.7, i don't know what happened though.
    – moku
    Oct 28, 2012 at 9:51
  • what you using gnome or kde ? in kde all works even for xterm my wmctrl version is 1.07
    – zb'
    Oct 28, 2012 at 10:24
  • eh, i'm using gnome, my vmctrl is also 1.07. but when tried : wmctrl -i -r $WINDOWID -b toggle,fullscreen - toggle fullscreen wmctrl -i -r $WINDOWID -b add,fullscreen - force fullscreen wmctrl -i -r $WINDOWID -b remove,fullscreen - force remove fullscree nothingh happened, i dont know why...
    – moku
    Oct 28, 2012 at 14:32
  • did you tried just wmctrl -i -r $WINDOWID -b toggle,fullscreen ?
    – zb'
    Oct 28, 2012 at 17:24
  • 1
    On Ubuntu 13.10 in a gnome terminal this works perfectly. wmctrl -l shows the available windows. And e.g. wmctrl -i -r 0x05000682 -b toggle,fullscreen makes the window full screen. The :ACTIVE: handle does not work though. Ah, I see it DOES work, but then the -i flag has to be removed. Feb 21, 2014 at 9:26
0

You could create a launcher called it "Gnome Terminal Maximized" for your desktop and double-click on it. This is how to do it:

cat /usr/share/applications/gnome-terminal.desktop|sed 's/gnome-terminal/gnome-terminal --maximize/;s/Name=Terminal/& Maximized/' > ~/Desktop/gnome-terminal-maximized.desktop
1
  • thank u for the same. Actually i did't get u properly, well , i'm just a newbie about LINUX, people here are really enthusastic. Thk u all.
    – moku
    Oct 28, 2012 at 9:57
0

You can use the xdotool utility.

You can run xdotool code that automatically moves the mouse to the upper left corner of the active window, double clicks and the moves back, in a fraction of a second. The code is the following:

#get the active windows id.
active_window_id=$(xdotool getactivewindow)
#get current x and y mouse locations.
cx=$(xdotool getmouselocation --shell | grep X | sed s/X=//gi);
cy=$(xdotool getmouselocation --shell | grep Y | sed s/Y=//gi);

#move to upper left corner of current window.
xdotool mousemove --window ${active_window_id} 50 -10;
#double click.
xdotool click 1;
xdotool click 1;
#move back to original location with the mouse.
xdotool mousemove ${cx} ${cy};

You can then put this code into a start_script and then run that file by putting the following in your ~/.bashrc:

start(){
    /path/your_start_script
    }

The when you run this start command the terminal becomes maximized. You can also insert whatever other commands you want to happen when you start a terminal.

You can install xdotool with:
sudo apt-install xdotool;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .