on windows I used AutoHotkey and a little script combined with a keyboard shortcut so that I could make the active programs gui go to one half of the screen. There is no AutoHotkey for Linux so I wonder if instead I could use two different bash scripts that I could link to keyboard shortucts to call them. I would like one script to put the active window at the left half of the screen and one to put it to the right. Basically what I want is to be able to see two windows side by side with each one occupying half the screen.
any one got a bash script that can do this? I dont know bash at all.
how to make a window occupy half the screen?
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
how to make a window occupy half the screen?
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Re: how to make a window occupy half the screen?
Why can't you just drag it there? - it happens automatically for me.
Re: how to make a window occupy half the screen?
I don't know about going to 1/2 screen but, if you click on the System menu button then Preferences -> Keyboard Shortcuts. Scroll down to Window Management, there you can Toggle maximization state, vertical and horizontal maximization states from the keyboard. Since I do a lot of scripting, I use these shortcuts very extensively.
It may not be exactly what you want, but it should be useful.
Regards,
MPH
It may not be exactly what you want, but it should be useful.
Regards,
MPH
Re: how to make a window occupy half the screen?
You can probably program that, once you know a little bash, using wmctrl or xdotool. I've used both in the past to automatically make applications start on a specific workspace. Documentation on these is available, but perhaps search for some examples to get you started easier.
Perhaps if this is your workflow (having windows occupy half the screen), a tiling window manager would be more to your liking. Something like xmonad, but there are lots of others.
Perhaps if this is your workflow (having windows occupy half the screen), a tiling window manager would be more to your liking. Something like xmonad, but there are lots of others.
Re: how to make a window occupy half the screen?
Vincent,
Excellent source of info. I installed wmctrl this morning. Very nice, I wish I'd of found this years ago. THANKS!
ChickenPie4Tea,
I threw this script together fairly hastily this morning, but it might suit your purposes. I does mine.
It's not quite right but close enough for now. Now all I need to do is set it up to some keyboard short cuts.
NOTE: The window's maximized state toggle will override this. I.E. If the window is already toggled maximized this won't work in whatever direction the window is maximized.
Excellent source of info. I installed wmctrl this morning. Very nice, I wish I'd of found this years ago. THANKS!
ChickenPie4Tea,
I threw this script together fairly hastily this morning, but it might suit your purposes. I does mine.
It's not quite right but close enough for now. Now all I need to do is set it up to some keyboard short cuts.
NOTE: The window's maximized state toggle will override this. I.E. If the window is already toggled maximized this won't work in whatever direction the window is maximized.
Code: Select all
#! /bin/ksh
#
# wm_ctrl.sh MPH (2011/03/15)
#
###########################################################################
# Vars
###########################################################################
wm_size=`wmctrl -d | head -1 | awk '{print $9}'`
wm_wd=`echo "$wm_size" | awk -F"x" '{print $1}'`
wm_hi=`echo "$wm_size" | awk -F"x" '{print $2}'`
hh=`echo "scale=0; $wm_hi/2" | bc -l`
hw=`echo "scale=0; $wm_wd/2" | bc -l`
vpos="-1"
hpos="-1"
wd="-1"
ht="-1"
type=":ACTIVE:"
###########################################################################
# Functions
###########################################################################
# usage: A brief explanation.
usage(){
echo
echo "Usage:"
echo `basename "$0"` " [Option(s)] [window]"
echo
echo "Options:"
echo " -a Manipulate the active window."
echo " -s Forces the user to select a window to manipulate."
echo " -d Forces window to full width."
echo " -f Forces window to full height."
echo " -b When resizing a window's height specify that it is to use"
echo " the bottom half of the screen, top is the default."
echo " -t Resize a window to half the height of the current desktop."
echo " -w Resize a window to half the width of the current desktop."
echo " -b When resizing a window send it to the bottom. Top is the default."
echo " Most usefull when halfing a window."
echo " -h This help."
exit 0
}
###########################################################################
# Main
###########################################################################
while getopts abdfhlrstw opt
do
case "$opt" in
a) type=":ACTIVE:";;
b) hpos="$hh";;
f) ht="$wm_hi";;
d) wd="$wm_wd";;
l) vpos="0";;
r) vpos="$hw";;
s) type=":SELECT:";;
t) ht="$hh";;
w) wd="$hw";;
h) usage;;
*) usage;;
esac
done
wmctrl -r "$type" -e 0,"$vpos","$hpos","$wd","$ht"