Tiny Core Linux

Tiny Core Base => TCB Q&A Forum => Topic started by: KHarvey on December 24, 2011, 05:26:22 PM

Title: Dual Monitor Backgrounds
Post by: KHarvey on December 24, 2011, 05:26:22 PM
I have been running Tiny Core for a couple of months now, and I have had a working dual monitor setup.  But I want to know if there is a way for me to specify a background image for a specific monitor?

I have a couple of python scripts that cycle through my backgrounds, and they work pretty well in Tiny Core, except that the backgrounds are centered between the two monitors, which means I have a physical gap in the actual background.  Is there a way for me to specify which monitor the background shows up on?  Or is there a way for me to justify the background left or right?

In the past I used gconftool in Ubuntu, or xfconf in Solaris.  Currently I am using hsetroot -full in Tiny Core.
Title: Re: Dual Monitor Backgrounds
Post by: curaga on December 25, 2011, 09:02:27 AM
Depends on how you set up the multihead; if automatic/xrandr/xinerama, you'd need an xrandr/xinerama-aware wm/bg-setter. I'm not sure if hsetroot has that capability.

If they are different screens/zaphod, it is quite easy to say:
DISPLAY=:0.0 hsetroot ....
DISPLAY=:0.1 hsetroot ....
Title: Re: Dual Monitor Backgrounds
Post by: KHarvey on December 25, 2011, 09:51:17 AM
Thanks for the response curaga.

I am actually using the NVidia X Server settings with XOrg and have configured Twinview.

Looking at the settings inside the NVidia X Server it only shows that I have one Display Name of tc:0.0
So I was able to build a command:
DISPLAY=tc:0.0 hsetroot /mnt/sdb2/Wallpaper/Random.jpg
And it sets the wallpaper but it still splits it between the two monitors.  When I try using tc:0.1 I get a Segmentation Fault.  I think that maybe I built my dual monitors incorrectly?

By the way Merry Christmas  :D
Title: Re: Dual Monitor Backgrounds
Post by: curaga on December 25, 2011, 11:30:32 AM
Twinview is xinerama-compatible IIRC.

hsetroot doesn't check its display argument, which seems somewhat common practise. Unrelated to your display setup.
Title: Re: Dual Monitor Backgrounds
Post by: KHarvey on December 25, 2011, 01:06:08 PM
Okay, so I have been playing with this for the last couple of hours, and I made a little progress I think.

So I turned off TwinView and changed to Separate X screen and enabled Xinerama.  I found as you stated that Xinerama and TwinView run pretty much the same.
So then I left it on Separate X Screen and turned off Xinerama, and now I am able to set the background and it shows up on both screens.  Meaning that I have to exact copies of the background, which is perfectly fine.  The problem that I have now, is since I am not using Xinerama or TwinView, I am unable to move any windows between the screens.  Even if I try to start an application (DISPLAY=:0.1 chromium-browser) it always starts on screen 0.0.  At least I am not getting the segmentation fault errors any more.  But as it stands now my second monitor is pretty much useless other than looking at my background.

Also I realized that no matter what setting I choose when I do an echo $DISPLAY it always only says 0.0

I did find that I can use Nitrogen to set the background on a screen, but I am only able to do that through the GUI.  I did not find a CLI option for Nitrogen to specify the monitor.

I didn't think this would be that complicated, but I guess I was mistaken.  I think that I am close, but I don't know what to do now.

Do you have any more suggestions, or maybe a website that I could go read through?
Title: Re: Dual Monitor Backgrounds
Post by: curaga on December 26, 2011, 05:10:32 AM
Sorry, multi-screen on linux is a bit of a mess. It's by design that you can't move windows with separate screens.
Title: Re: Dual Monitor Backgrounds
Post by: KHarvey on December 26, 2011, 03:34:37 PM
Thank you for your help with this curaga.

Since I could not find a native way of doing this I decided that I would script a way of doing this.
I am using ImageMagick to do the conversions and build the backgrounds automatically.

This is done in Python, but if anyone is interested.
Code: [Select]
import os, random

objWallpaper = "/mnt/sdb2/Wallpaper/"
strWallpaper = os.listdir(objWallpaper)[random.randrange(1, len(os.listdir(objWallpaper)))]

os.system('convert "' + objWallpaper + strWallpaper + '" -resize "1680x1050" /tmp/WP1.png')
os.system('convert /opt/backgrounds/Black.png /tmp/WP1.png +append /tmp/WP.png')
os.system('hsetroot -full /tmp/WP.png')

So what I am doing is pulling a random image from a directory.  I then convert the image to a PNG as it has better color depth and resolution compared to a JPG, at least from my tests.  I also change the resolution of the picture to 1680x1050 which is the resolution of my monitors.  Now I am not hard changing the resolution, meaning that I am maintaining the original aspect ratio of the picture.
I then add Black.png to the left of my background image.  Now Black.png is a 1680x1050 pure black image that I created in GIMP. 
Now I could use my image twice, but I found that I have to continue to reset my WBAR for it to become transparent, I would also need to configure my conky a little better.  So I opted to just use a plain black background on my left monitor.  I will probably fix this later though.  I will probably also change the script a bit to where it pulls the resolution automatically from the OS rather than having it hard coded.

From there I just created a SH that executes my Python script, and created a 48x48 .img file and put them in /mnt/sda1/tce/ondemand and voila.  This gives me a button that I can change the background on randomly when I want, or I could configure using cron.  This seems to be working well with Xinerama.  I haven't tested it with TwinView but I am pretty sure it would work with that.

Hopefully this will help someone else.  If anyone needs more info on what I'm doing or how it works just let me know.