You are not logged in.
Pages: 1
I use Arch and openbox for my laptop. Unfortunately, when I dock/undock to my dual screens, I often end up with windows left out of reach.
I could not find a tool that solved the problem (although one probably exists), so I put one together using wmctrl and xdpyinfo.
I've posted the script here: http://lmbrt.com/a/63
It's also attached to this post. I hope someone finds it useful.
#!/usr/bin/perl
#
# Copyright 2011 Dustin Lambert
#
# This script is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# This script is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with this script.
# If not, see http://www.gnu.org/licenses/.
#
my $lines = `wmctrl -G -l`;
my $res = `xdpyinfo | grep dimensions`;
$res =~ /^\s+dimensions:\s+(\d+)x(\d+)/;
my $screenWidth = $1;
my $screenHeight = $2;
print "Screen size: $screenWidth x $screenHeight\n";
foreach my $line(split(/\n/, $lines))
{
$line =~ s/\s+/ /g;
my($windowID, $level, $posX, $posY, $width, $height)=split(/ /, $line);
if ($level ne -1)
{
$doMove = 0;
# resize windows if they are currently larger than screen
if ($width > $screenWidth)
{
$width = $screenWidth - 5;
$doMove = 1;
}
if ($height > $screenHeight)
{
$height = $screenHeight - 5;
$doMove = 1;
}
# if they are off the screen, move them
if (($posX + $width) > $screenWidth)
{
$posX = $screenWidth - $width;
$doMove = 1;
}
if (($posY + $height) > $screenHeight)
{
$posY = $screenHeight - $height;
$doMove = 1;
}
# might have gotten into negative areas with moving... also windows will be in the negative if they are above the screen
# move them to pos 1
if ($posX < 1)
{
$doMove = 1;
$posX = 1;
}
if ($posY < 1)
{
$doMove = 1;
$posY = 1;
}
# our calcs are not perfect... only rearrange if there was a problem
if ($doMove eq 1)
{
system("wmctrl -i -r $windowID -e 0,$posX,$posY,$width,$height");
}
}
}
Offline
Good idea! It's one of those "gah, why didn't I think of that?" ideas.
I most often run into off-screen windows in Twinview mode when there is no second monitor though, so they're technically "on-screen" as far as the system is concerned and wouldn't be caught by this script (at least I don't think they would, from a cursory examination). It did however inspire me to write something with xdotool to move the active window to the mouse location with an Openbox keybind: http://xyne.archlinux.ca/scripts/openbox/#winhere
Until now I've been focusing the window, maximizing it, then dragging it onto the visible screen.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Pages: 1