Set window size linux

From Command Line to Advanced Settings: How to Set Window Size in GNU Screen on Linux

GNU Screen is a popular terminal multiplexer that allows multiple terminal sessions to run within a single terminal window. This makes it an efficient tool for managing multiple tasks and working on remote servers. One of the useful features of GNU Screen is the ability to set window size.

By default, GNU Screen sets the window size to 80 columns and 24 rows. However, this can be easily changed using command-line options or by modifying the ~/.screenrc file.

Setting Window Size Using Command-Line Options

To set the window size using command-line options, you need to use the following syntax:

$ screen -S sessionname -X eval 'resize 80 24' 

Replace sessionname with the name of your session, and 80 and 24 with the number of columns and rows, respectively.

For example, to set the window size to 100 columns and 30 rows, you can use the following command:

$ screen -S mysession -X eval 'resize 100 30' 

This will resize the window of the mysession session to 100 columns and 30 rows.

You can also set the window size interactively from within the GNU Screen session by pressing the key combination Ctrl-a : and typing the following command:

Replace 80 and 24 with the desired number of columns and rows.

Setting Window Size Using ~/.screenrc

To set the default window size for all GNU Screen sessions, you can modify the ~/.screenrc file. This file is a configuration file used by GNU Screen to set various options, including the window size.

To set the window size in ~/.screenrc , add the following lines to the file:

# Set the default window size defhsize 100 defvsize 30 

These lines set the default horizontal size to 100 and the default vertical size to 30.

Save the file and restart GNU Screen for the changes to take effect.

Conclusion

Setting window size in GNU Screen is an easy task. You can do it from the command-line using options, or you can set the default size in the ~/.screenrc file for all sessions. With the ability to set the window size, you can make GNU Screen more efficient and comfortable to use.

Читайте также:  Linux write bash script

Источник

Set window size in graphics.h on Ubuntu

initwindow() doesn’t seem to work, nor does initgraph() . How do I set the width and height of the window?

Did you read the documentation ? A quick google search showed up this: askubuntu.com/questions/525051/…

4 Answers 4

This seems like graphics.h has a defined DETECT variable that I would assume would detect your default width / height. Look into that and I think you may find your answer.

Don’t do this.

This library is ancient. I wouldn’t be surprised if you found a system that doesn’t support it.
Use any of:

The BGI library is very old. But it was very good, convenient, and useful. Consequently, there are quite a few working versions floating around.

Some versions let you set any arbitrary window size.
Some versions only permit some window sizes.
Some versions don’t let you choose.

Hence, you absolutely must read the documentation that came with whatever version you are using to see how to properly initialize the window, and which function to call.

initwindow(1000, 1000); /* (size X, size Y) */ setactivepage(0); 

Hot Network Questions

Subscribe to RSS

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Site design / logo © 2023 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2023.7.12.43529

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.

Источник

How to set window size and location of an application on screen via command line?

I want Firefox window to be opened in a specific size, and location on screen using a shell command, for example:

firefox myfile.html size 800x600 location bottom-left 

I managed to do this (with the help of this forum), although if you find any other solution, please tell me as it will probably be more robust: unix.stackexchange.com/questions/40209/…

6 Answers 6

Here is a community version of the answer by Yokai that incorporates examples offered by Rudolf Olah.

You can use the tool called xdotool to control window size and location. Not only that, any script you write in bash , using xdotool , can be setup to work with a fully maximized window and it can be scripted to set the window size and x:y coordinates by manipulating the mousemove and click commands.

xdotool search --onlyvisible --name firefox 
xdotool windowsize $WINDOW_ID_GOES_HERE $WIDTH $HEIGHT 
xdotool windowmove $WINDOW_ID_GOES_HERE $X $Y 

For example, if the window id for firefox is 123 you would do this:

xdotool windowsize 123 800 600 xdotool windowmove 123 0 1080 

The bottom-left positioning will have to be figured out based on your screen resolution.

There’s a bug with xdotool , wmctrl etc.. and Ubuntu, XFCE (that I have): if the window has already launched in full screen mode, you can’t move it anymore: bugs.launchpad.net/ubuntu/+source/unity/+bug/971147

Читайте также:  Linux свободно на разделе

I don’t see this bug in Ubuntu 19.10. It’s interesting that the other answer, which says that it’s impossible, has 20 upvotes.

xdotool allows you to chain several commands together. so you could do: xdootool search —onlyvisible —name firefox windowmove 100 100

This still works well enough, but, if a window has a decoration (like firefox has) it is being treated as part of the window, leaving you with a window slightly smaller than intended.

Is there a way to move the window such that the client area of the window starts at the given coordinates, not the window border?

As far as I know, this is not possible as Firefox does not accept commands to control the window. That’s also (mostly) the responsibility of the window manager, so I doubt that there ever will be parameters to do that. However, you can control the window with wmctrl, but that’s going to be a little bit difficult:

#!/usr/bin/env bash firefox -new-instance -new-window "http://www.reddit.org" & # Process ID of the process we just launched PID=$! # Window ID of the process. pray that there's # only one window! Otherwise this might break. # We also need to wait for the process to spawn # a window. while [ "$WID" == "" ]; do WID=$(wmctrl -lp | grep $PID | cut "-d " -f1) done # Set the size and location of the window # See man wmctrl for more info wmctrl -i -r $WID -e 0,50,50,250,250 

There might be more clever ways to do it, and there are some interoperability issues with Firefox (e.g. that no other instance is running) but it should get you going.

Just a little note. The resizing won’t work if the window is maximized. So you have to deactivate this property first with: wmctrl -i -r $WID -b remove,maximized_vert; wmctrl -i -r $WID -b remove,maximized_horz; After that I was able to resize the Firefox window.

Thanks for your answer! On Ubuntu 18.04.3 I had an error with the code; suggest shebang #!/bin/bash at beginning of code for concerned users.

This doesn’t solve the problem of the position, but at least you can set dimensions :

firefox -width 200 -height 500 

In the past I have created an HTML document that would set the window size with Javascript then redirect to the page I wanted. It’s a stupid hack but, hey, it works.

Looks like this doesn’t work anymore. Apparently, window.resizeTo only has an effect if the window is a popup created via window.open.

I do this all the time. I use DevilsPie2, however, because it’s more robust. It uses the LUA scripting language, which isn’t very difficult.

Here’s my lua script for Thunderbird, which I want to open on the far left monitor (laptop screen) when it opens:

if (get_window_name()=="Mozilla Thunderbird") then pin_window() set_window_geometry( 50, 10, 1220, 780 ) end where 50 = X coordinate (for upper-left corner of the window) 10 = Y coordinate ( " " ) 1220 = window width 780 = window height 

To set this up, you create a directory in your home configuration (on Ubuntu-like distributions) named devilspie2, eg /home/$USERNAME/.config/devilspie2

Читайте также:  Linux open 443 port

For Thunderbird, I created thunderbird.lua, though the filename doesn’t matter. I have a different filename for each application though you can put everything into one script file if you wish. Set devilspie2 to start automatically when you login, eg /home/$USERNAME/.config/autostart/devilspie2.desktop

Here’s a link to a good page about various options available to your lua script: https://github.com/gusnan/devilspie2/blob/master/README

One note: The scripts don’t have to be executable. Mine are 664 and work fine. A few of the other programs I control are openconnect, pidgin, RecordMyDesktop, timeshift, xeyes, xload, & yad. I use pin_window on them so they appear on all desktops, plus other commands depending on the application.

Источник

How to set a specific window size and placement for all windows that open to default

I want my windows to be a specific size (not full screen) and to be in the middle of the screen by default. When I close the application and re-open it, it will be the dimensions I want it to be by default. Is there an easy way to do that? I’m using Ubuntu 11.10 and the Unity desktop enviroment.

4 Answers 4

I don’t know if you can simply make all windows behave the same, but you can individually. We’ll use Thunderbird as an example.

Make sure you have ccsm installed: Open a terminal (Press Control — Alt — T ) and enter

sudo apt-get install compizconfig-settings-manager

Open ccsm. You’ll be using the Place Windows and Windows Rules plugins in the Window Management section.

Compiz Window Managment

First, go into Place Windows, select the Fixed Window Placement tab and Select New.

Fixed Window Placement screen

Enter the program name (class=xxxx) and set the starting X and Y coordinates. The coordinates start from the top left corner of the screen. This tells the program where to open on the screen.

Enter placement rules

Next go to the Windows Rules plugin and select the Size Rules tab and new.

Window Rules screen

Enter the program name (class=xxxx) and set the X and Y size. This tells the program what size to open the program in pixels (pixels wide x pixels high).

Enter size rules

Open your program

Now, open the program you just did this for and it should open where and how big you want it to everytime.

Note that you will have to do this for every program you want to open in a specific place and a specific size. You can also use one without the other, for instance always having a program open in a specific place but not having it’s size defined.

Источник

Оцените статью
Adblock
detector