Archive

Archive for the ‘FVWM’ Category

Faking a quake terminal (like kuake / yakuake) in FVWM

December 20th, 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 how FvwmButton’s work.

I used KDE for a long time, and a big part of the reason for that is yakuake which is probably the best terminal available. For those who don’t know what it is, it is a terminal emulator that behaves like the quake console. That is, when you press a button it comes scrolling down/up. Very handy.

Yakuake doesn’t work very well in FVWM. It kind of works… but there are a bunch of bugs, such as text overlapping and what not.
However by editing your FVWM configuration file you can replicate the functions of yakuake rather nicely, and also add some nice extras.

The key is the Panel option in FvwmButtons. This enables you to drop down a FvwmButton from anywhere by clicking another FvwmButton. If you also would want to enabel this drop down terminal to a keyboard button, then the FakeClick method fixes that decently. It is a bit buggy if you move your mouse too much while toggling but it is good enough.

Simply create a button swallowing the terminal you want to have as a drop down console, and then make another button call the console button by Panel. Specify where it should drop down and that’s pretty much it.

Setup the button

DestroyFunc StartFunction
AddToFunc StartFunction
+ I Module FvwmButtons MenuButtons

The button calling the panel. You should add the Panel-call to any of you buttons instead of using this (but this is an example)

DestroyModuleConfig MenuButtons: *
*MenuButtons: Rows 1
*MenuButtons: Columns 1
*MenuButtons: Back black
*MenuButtons: Geometry 50x50-2-2
*MenuButtons: (1x1, Panel(down, delay 0, steps 30, position root left 0 0) \\
    SubPanel "Module FvwmButtons SubPanel")

The subpanel that holds the terminal

DestroyModuleConfig SubPanel: *
*SubPanel: Geometry 1280x350
*SubPanel: Rows 1
*SubPanel: Columns 1
*SubPanel: (1x1, Swallow(UseOld,NoHints,Respawn) "xterm" `Exec exec xterm`)

Now you have a button which you can click to get down the console holding an xterm. If you want to bind this to a button then use FakeClick like this to fool your system that you are clicking the button (ugly fix but the only one I’ve found).

The button press calls a function…

Key f12 A N press_fakebutton

The function quickly places the mouse cursor over the button, fakes a click and returns it.

DestroyFunc press_fakebutton
AddToFunc press_fakebutton
+ I SetEnv CURSOR_X $[pointer.x]
+ I SetEnv CURSOR_Y $[pointer.y]
+ I All [MenuButtons] WarpToWindow 25p 25p #middle of button
+ I FakeClick depth 0 press 1 wait 10 release 1
+ I WindowId root 1 WarpToWindow $[CURSOR_X]p $[CURSOR_Y]p

Adding styles to the SubPanel is smart. Displaying it on all pages for an example is quite nice.
Also feel free to use another terminal with tab support if you want to be able to use a tabbed console like in yakuake. Or maybe a drop down python interpreter instead? It’s of course possible to have the drop down console have more than 1 row/col and have them swallow other applications as well. The possibilities are endless ;)

Here are some screenshot of how it can look (without any style tags).
Please do not complain on this configuration as it is work in progress :)



I would love to be proven wrong and have some easier way to do this but right now this is my method of choice. Please feel free to comment.

buffi FVWM, Programming & scripting

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