Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Dual Monitor Tricks with Fluxbox
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
yogipsu
Tux's lil' helper
Tux's lil' helper


Joined: 30 Aug 2003
Posts: 98

PostPosted: Thu Nov 09, 2006 4:31 am    Post subject: Dual Monitor Tricks with Fluxbox Reply with quote

After buying a second monitor with a different size and resolution than my first, I realized that xinerama and twinview wouldn't work all that well for me. So I configured Xorg to support two separate screens. The following steps are those I took to make the environment more usable:

1. Modifed my ~/.fluxbox/init file to account for screen1 in addition to screen0. Copying all the values works nicely to encourage uniformity.
2. Installed switchscreen from here: http://users.tkk.fi/~spniskan/switchscreen/, which allows one to easily swap the mouse pointer from one screen to the next. However, this doesn't get around the problem of changing the keyboard focus, so I modified the resulting togglescreen script.

Code:

#!/bin/bash

STOREFILE=~/.fluxbox/screen
SWITCHSCREEN=~/.fluxbox/switchscreen


CURRENT="`$SWITCHSCREEN -P`"
CURSCR=`echo "$CURRENT" | gawk '{ print $2 }'`
CURPOS=`echo "$CURRENT" | gawk '{ print $4 }'`

echo $CURPOS > $STOREFILE.$CURSCR

if [ "$CURSCR" = "0" ]; then
    NEWSCR=1
else
    NEWSCR=0
fi

NEWPOS="`cat $STOREFILE.$NEWSCR 2>/dev/null`"
if [ "$NEWPOS" ]; then
    POSOPT="-c $NEWPOS"
else
    POSOPT=""
fi

$SWITCHSCREEN -q $POSOPT $NEWSCR

if [ "$DISPLAY" = ":0.0" ]; then
    export DISPLAY=:0.1
    xterm -geometry 1x1 &
    export DISPLAY=:0.0
else
    export DISPLAY=:0.0
    xterm -geometry 1x1 &
    export DISPLAY=:0.1
fi
sleep .015
ps aux|grep xterm|grep -v defunct|grep -v yeahconsole|grep -v grep|awk '{print $2}'|xargs kill -9


(What this does is open a pixel-sized xterm on the screen your mouse is getting switched to, then immediately closes it, so the keyboard focuses along with it. But we're not done yet, because we need to modify the ~/.fluxbox/apps file - and how it's structured.)

3. Created two files in your ~/.fluxbox directory: apps.screen0 and apps.screen1. We'll be taking advantage of this in a launcher shell script - because fluxbox doesn't allow for separate apps files for different screens.

4. Created the following script, and ran chmod +x on it:

Code:

#!/bin/bash

if [ `readlink ~/.fluxbox/apps | cut -c32` = `echo $DISPLAY | cut -c4` ] ;
        then
                $1
        else
                rm ~/.fluxbox/apps
                if [ "$DISPLAY" = ":0.0" ] ; then
                        ln -s ~/.fluxbox/apps.screen0 ~/.fluxbox/apps
                else
                        ln -s ~/.fluxbox/apps.screen1 ~/.fluxbox/apps
                fi

                xterm -geometry 1x1 &
                sleep .015
                ps aux|grep xterm|grep -v defunct|grep -v yeahconsole|grep -v grep|awk '{print $2}'|xargs kill -9
                $1
fi


The script handles screen-specific apps. But for some reason, fluxbox doesn't automatically take the new symlink into account until a program's opened. So, to alleviate that problem, we'll rely on our invisible xterm again.

5. Added this to my apps.screen0 and apps.screen1 files:

Code:

[app] (xterm)
  [Dimensions]  {1 1}
  [Position]    (UPPERLEFT)     {0 0}
  [Deco]        {NONE}
  [Hidden]      {yes}


It makes xterm invisible (save for a single pixel), and it doesn't clutter up the iconbar either!

6. Finally, I added proper support for the launch script in my ~/.fluxbox/keys and ~/.fluxbox/menu files:

Code:

# apps
Mod1 3 :execcommand xfe
Mod4 E :execcommand Eterm --buttonbar=0 --scrollbar=0
Mod4 F :execcommand ~/.fluxbox/launch.sh firefox
Mod4 G :execcommand gaim
Mod4 T :execcommand ~/.fluxbox/launch.sh thunderbird
Mod4 A :execcommand audacious


Let me know if you've got any problems with the above.
Back to top
View user's profile Send private message
Centinul
Apprentice
Apprentice


Joined: 28 Jul 2005
Posts: 232

PostPosted: Thu Nov 09, 2006 9:27 pm    Post subject: Reply with quote

I run Fluxbox with two different sized LCD monitors with Twinview and I haven't noticed any adverse side effects. What were your reasons for not using it? Just curious. Nice HowTo BTW :)
Back to top
View user's profile Send private message
yogipsu
Tux's lil' helper
Tux's lil' helper


Joined: 30 Aug 2003
Posts: 98

PostPosted: Thu Nov 09, 2006 9:52 pm    Post subject: Reply with quote

The only problem that I had, really, was the fact that my background didn't display properly because of the different resolutions of the monitors. I ran one in 1440x900 and the other in 1280x1024. Does yours work properly?

But really, I also liked the idea of having two separate screens, each with their own independent workspaces. And thanks for the comment. :D
Back to top
View user's profile Send private message
feystorm
Tux's lil' helper
Tux's lil' helper


Joined: 29 Jan 2004
Posts: 95

PostPosted: Thu Jan 04, 2007 6:35 am    Post subject: Reply with quote

for the background thing, just use gimp, make an image the combined width of the 2 monitors, and the hight of the tallest (ex: for 1600x1200 & 1280x1024, the image would be 2880x1200), put the desired background in the gimp image twice, and stretch/shrink each accordingly so it will show up on each monitor.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum