Does anyone know how to configure Ubuntu 14.04 so that when it starts up I have a terminal window open (at my specified x,y coordinates and specified width and height), and the Xload application also loaded and running at a certain x,y location?

  • 1
    Are you using the default desktop environment? – Gilles 'SO- stop being evil' Apr 7 '15 at 22:43
  • Yes default environment. – SeanLabs Apr 7 '15 at 23:21
  • 1
    You might get the idea from my answer here. Let me know if you want more info or details on this – Sergiy Kolodyazhnyy Apr 14 '15 at 14:14
  • @user411180 Apologizes for my tardy response, but i have been having some health issues. Answer posted, please review. Let me know if you like it and find it useful or anything requires fixing – Sergiy Kolodyazhnyy Apr 18 '15 at 6:36

Preliminary notes:

Before we even begin, you need to know the geometry of your screen. The following command achieves that part of the task:

xprop -root | awk '$1~/NET_DESKTOP_GEOMETRY/ {print }'.

Sample output from my dual screen set-up:

$ xprop -root | awk '$1~/NET_DESKTOP_GEOMETRY/ {print  }'                   

Next step would be to check out manual page for X server, i.e., man x , specifically GEOMETRY SPECIFICATIONS, according to which you can specify size and location on the screen in the following fassion WIDTHxHEIGHT+XOFF+YOFF, where XOFF and YOFF are offsets on the x-y plane of the screen.

There are two ways to tackle this task. The method number one is by specifying the geometry in the command that will run at start-up. The method number two is by using wmctrl tool in a script as show in my answer that I linked in the comments. Both achieve the task you want; first has advantage in avoiding installing additional software; second has advantage in using wmctrl that can be applied to a variety of tasks, for instance I used it for launcher script and setting title for byobu.

Method #1, native:

Open startup applications menu (which can be accessed through searching in dash), and add new start-up application for gnome-terminal and xload. For gnome-terminal you will want to have something like this:

Name (call it whatever you want)

gnome-terminal --geometry WIDTHxHEIGHT+XOFFSET+YOFFSET

Comment (optional)

enter image description here

Similarly create one entry for xload, but the command would have to be slightly different: xload -geometry WIDTHxHEIGHT+XOFF+YOFF

Also, notice that gnome-terminal sets width and height in columns and lines, while xload sets those in pixels. So in the screenshot above you see me create a startup entry for 30 colums (width) and 20 rows (height)

Here's two sample commands to start gnome-terminal in upper right of the screen and xload in lower right of the screen

gnome-terminal --geometry 50x20+2390+0

xload -geometry 200x200+2390-0

Method #2, through use of wmctrl

wmctrl is a very useful program for manipulating windows on screen through terminal. You can get it with sudo apt-get install wmctrl.

Next step, would be to write up a script that will do all the magic. Remember change the permissions on it to executable with sudo chmod +x /path/to/script.sh. Finally, create a .desktop file in your .config/autostart folder, which will actually launch the script upon your login. Refer here and here on how to write the .desktop file; or simply add path to your script as one of the startup items in startup applications window.

Perhaps a small advantage is that with wmctrl you don't have to guess rows/columns ratio for the germinal; everything is done with pixels. The formula for wmctrl is gravity, xoffset, yoffset,width,height (don't ask what gravity of the window is, since I've no idea myself, just use 0), and -r parameter implies "by reference" to a window with specific title

The Script

Notice, that for size and position parameters, I've simply recycled my old script with a few substitutions. I expect that you've read my previous notes on how wmctrl works and you should be able to substitute your own numbers. When in doubt, refer to man wmctrl.

# Author: Serg Kolo
# Date: 4/18/2015
# Description: A simple script open gnome-terminal and xload with 
#  specific size and position

sleep 1

gnome-terminal -t STARTING-WINDOW &
xload &

if [  $? -eq 0  ]

        wmctrl -r STARTING-WINDOW -e 0,1300,300,250,250
        sleep 0.5
        wmctrl -r xload -e 0,1300,0,250,250

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.