Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

This is one of those things that looks like it might have a simple solution but is rather time consuming once you start investigating PyTile, Xnee and the likes.

I know, I should just use a tiling window manager etc., but I suppose it can be done in an EWMH compliant window manager (like OpenBox), and I am just hoping somebody already has a working solution.

Ok, so I want to press a key combination while I am in an OpenBox session (Lubuntu LXDE to be more precise) and have my terminal appear below my then resized Chromium window (say ~60% Chromium and ~40% Terminal).

share|improve this question

1 Answer 1

up vote 1 down vote accepted
+50

I have written a small script that puts Chromium at 60% of the screen, launches a terminal, and puts it under Chromium:

#!/bin/bash

screen_width=` wmctrl -d | awk '{print $9}' | cut -d x -f 1`
screen_height=`wmctrl -d | awk '{print $9}' | cut -d x -f 2`
titlebar=51
browser="Chromium"
terminal_cmd="xterm"

browser_height=$[$screen_height * 60 / 100 - $titlebar]
# unmaximize browser
wmctrl -b remove,maximized_vert,maximized_horz -r "$browser"
wmctrl -r "$browser" -e "0,0,0,$screen_width,$browser_height"

# start terminal and wait till its window has appeared
$terminal_cmd &
sleep 1

# put terminal under browser
terminal_top=$[$screen_height * 60 / 100 + $titlebar]
terminal_height=$[$screen_height * 40 / 100]
wmctrl -r :ACTIVE: -e "0,0,$terminal_top,$screen_width,$terminal_height"

You can change some properties (like the terminal and browser used, and the height of the window titlebar). Note that $browser is (a part of) the browser (window) title (like "Chromium", "Google Chrome" or "Firefox"), not the command to launch the browser.

In case you don't want Chromium to resize, it gets a little trickier, but it can be done by getting the window coordinates with wmctrl -G -l.

I don't know how to assign keybindings in OpenBox, and whether it works in that WM, but at least it works in Unity when I run it on the command line.

share|improve this answer
    
Excellent answer, thank you. –  Erik Sep 17 '12 at 17:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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