Home > FVWM, Programming & scripting > Background image in your FvwmPager

Background image in your FvwmPager

December 19th, 2006

This guide assumes you have a basic understanding about configuring FVWM. You don’t need to be an expert (I’m not) but you should at least know a little bit about what you’re doing when configuring it. The python script will probably need some editing since it is unlikely that we have the same resolutions/number of screens so knowing a bit of python helps, but I believe that the code is rather easy to read and change. This is pretty much just a guideline for how you can solve this problem and not a finished fix/program that does it for you so prepare to get your hands dirty…

It is actually rather tricky to use your actual desktop background as a background image in the FvwmPager.
I’m gonna use my own setup as an example since it uses xinerama for two monitors, which has different resolutions making it even trickier.

First lets chose some images to use as backgrounds.
For my widescreen monitor I use this one
bg1

…and for my regular monitor I use this one
bg2

The complete background would then look like this.

(thumbnailed)

The pictures are obviously resized from their original sizes, but you get the point.
Place your background(s) in a subfolder to you fvwm-config. For an example I used ~/.fvwm/img/wallp/
Then we need to code a script that creates the background for the pager.

I chose to use a pager with a 3×3 grid of pages with size (200p,100p).
That means that the picture output of the script should look like this
grid

This means that the script should

  1. Take your background images as input
  2. Merge these into a single image with the correct dimensions
  3. Produce a grid with thumbnails of this image to use as background for your pager

I wrote a script in python to do just this. If you only use one monitor and as such one background picture you can simplify this a lot. Dependencies are python and imagemagick.

#!/usr/bin/python
"""
Script used for creating a background for FvwmPager in FVWM
Created 2006 by Bjorn Kempen
http://buffis.com
bjokem-4@student.ltu.se
"""

import os, sys

wpfolder = "/home/buffi/.fvwm/img/wallp/"
bg1,bg2=(wpfolder+sys.argv[1],wpfolder+sys.argv[2])
try:
    tmp1=open(bg1,"r") # try to open first background
    tmp2=open(bg2,"r") # try to open second background
except:
    print "ERROR! Wrong filenames: (%s,%s)"%(bg1,bg2)

bg1thumb,bg2thumb=(wpfolder+"th_"+sys.argv[1].replace("jpg","png"), \\
    wpfolder+"th_"+sys.argv[2].replace("jpg","png"))
finalname,finalthumb = (wpfolder+"bg.png",wpfolder+"th_bg.png")
gridpic = wpfolder+"grid.png"
pagerw,pagerh = 200,100 #width x height
numrows, numcols = 3,3
vborder=1 #fix for vertical borders, change to tweak thumbsize
hborder=1 #fix for horizontal borders, change to tweak thumbsize

#resolution of thumb
thumbres = "%dx%d"%(pagerw/numrows-hborder,pagerh/numcols-vborder)

#first pic for wide-screen monitor, to png and resized
os.system("convert -resize 1440x900! %s %s"%(bg1,bg1thumb))

#second pic for regular monitor, to png and resized
os.system("convert -resize 1280x1024! %s %s"%(bg2,bg2thumb))

#merge to xinerama background
os.system("convert +append %s %s %s"%(bg1thumb,bg2thumb,finalname))

#create thumbnail for use with pager
os.system("convert -resize %s! %s %s"%(thumbres,finalname,finalthumb))

#Make the final grid background
os.system("montage %s -geometry +0+0 %s"%("%s "%finalthumb*9, gridpic))

Download here!

Make sure you run this script when you change your background, or run it automagically when you start X if you’re into that kind of stuff (it will take a few seconds so I wouldn’t recommend it).

Then in you .fvwm2rc configuration, let it link your desktop background aswell as pager background to the images produced by the script.
Here is a copy+paste from my config containing these rows.

Load the background image at start/restart

# The StartFunction is used at start and restart
DestroyFunc StartFunction
AddToFunc StartFunction
...unrelated stuff...
+ I Module FvwmButtons PagerButton
+ I Exec exec fvwm-root -r ~/.fvwm/img/wallp/bg.png

Used to get 3×3 grid in pager

##### General stuff ########
DeskTopSize 3x3

Set up the background for the pager

KillModule FvwmPager
...unrelated stuff...
*FvwmPager: Pixmap ~/.fvwm/img/wallp/grid.png
...unrelated stuff...

Swallow the pager into a button

DestroyModuleConfig PagerButton: *
*PagerButton: Geometry 200x100-1-1
*PagerButton: Back black
*PagerButton: Rows 1
*PagerButton: Columns 1
*PagerButton(1x1, Frame 2, Swallow "FvwmPager" "FvwmPager 0 0")

If you know what you are doing you should end up with something similar to this very basic config of mine…


(bottom right corner)

If there are any easier way to achieve this, please drop me a comment. I might have reinvented the wheel here :)

buffi FVWM, Programming & scripting

  1. No comments yet.
  1. No trackbacks yet.