Let's start with some itches in need scratching:
Icons: I've not added any key or mouse bindings to icons yet. Clicking on them does nothing, and with the taskbar to restore an iconified window, the icon itself is just a waste of space.
- Code: Select all
Style * NoIcon
solves the problem.
XMMS appears with a titlebar and looks weird. Unintentionally so.
- Code: Select all
Style "xmms" NoTitle
Don't use caps ("XMMS") or it won't work. You can't match on the window title, because XMMS will change that with each track it plays. You can match on the resource id though, but that's in lower case. QED.
Transient windows don't have a titlebar. If things go wrong, that's often the only way to close them.
- Code: Select all
Style * "DecorateTransient"
Onto the busines of the day. The last post left us with a config that's pretty much usable, even if it needs a fewmore apps added to the toolbox. So today, I think I might play with a few less essential things.
Like for example making the panel titlebar control XMMS. The plan is to have two buttons. One of them is going to play/pause/stop depending on the mouse button used. The other will FF or REW the track with the middle mouse button unhiding the XMMS window so you can set playlists and the like. I'll also look at desiging some vector buttons to reflect the changed functionality.
First thing to do is emerge xmmsctrl. Then remove NoButton 1 and NoButton 2 from the Panel style settings. You can either reload FVWM or set the Button 1 and Button 2 styles in the console to see the changes. Note that I've changed the name of the panel again to "Klix" since "KlikKlik" isn't going to fit.
- Code: Select all
Style "Klix" Button 1, Button 2
Next we'll define a function to handle most of the XMMS operations we'll need.
- Code: Select all
DestroyFunc XMMS
AddToFunc XMMS
+ I exec exec xmmsctrl launch
+ I exec xmmsctrl main 0
+ I exec exec xmmsctrl $0 $1
We're going to lauch the player each time because it has no effect if an instance is already running, and if xmms crashes for any reason, pressing play will restart it. The second line will hides the main xmms window if it appears, and the third one sends the function parameters to XMMS. We've allowed two params ($0 and $1) so we can set flags as well as issue commands.
In a window decor button number one is the leftmost button. That's the one that's going to handle PLAY (mouse 1), PAUSE (mouse 3) or QUIT (mouse 2). The quit operation is in there because some of my games won't run right if XMMS grabs the soundcard.
- Code: Select all
Mouse (Klix) 1 1 N XMMS play # mouse 1, window button 1
Mouse (Klix) 2 1 N XMMS quit # mouse 2, window button 1
Mouse (Klix) 3 1 N XMMS pause # mouse 3, window button 1
Window button 2 is the rightmost one. That is going select the NEXT track on button 1, the PREVIOUS track on button 3 or toggle the main XMMS window on button 2.
- Code: Select all
Mouse (Klix) 1 2 N XMMS next
Mouse (Klix) 2 2 N exec exec xmms_toggle
Mouse (Klix) 3 2 N XMMS previous
The xmms_toggle script is a little shell script I wrote rather than try to couldn't figure out how to quote the if-then-else construct to work all on one line. It looks like this:
- Code: Select all
#! /bin/bash
if xmmsctrl is_main
then
xmmsctrl main 0
else
xmmsctrl main 1
fi
Bascially, it checks to see if the xmms main window is displayed. If it is, the script hides it. If not, the window is unhidden.
And just so we don't need to hunt throught 9 pages to find the unhidden window:
- Code: Select all
style "xmms" NoTitle, Sticky, StaysOnTop
OK. Our titlebar works, but the buttons are saying "close" and "maximise". Actually the "close" button says "menu" to me, but I'll get to that later. For now, we want to change those buttons for the panel only. That means defining a new decor.
Like everything else in FVWM, decors are additive. This means we start by destroying the old one.
- Code: Select all
DestroyDecor PanelDecor
Now we can add button definitions - this is the scary looking part.
- Code: Select all
AddToDecor PanelDecor
+ ButtonStyle 1 9 25x25@4 25x75@1 75x75@0 75x25@0 25x25@1 \
35x25@4 35x75@1 65x50@0 35x25@1
+ ButtonStyle 2 12 10x50@1 35x25@1 35x40@1 65x40@1 65x25@1
90x50@1 65x75@0 65x60@0 35x60@0 35x75@0 10x50@0 10x50@1
The first argument to ButtonStyle is the titlebar button number. The next one tells it how many lines to expect in the definition to follow. All the arguments after that represent lines to draw on the icon. If you paste that into a console window, you may find you need to type "recapture" before the changes show up.
For button one, I want something to remind me that the button does "play/pause". I'm going for a mixture of the standard tape deck play and pause buttons: a square with a triangle on top of it. What we need to do is work out where the points at each end of the lines are going to be. We specify these on an imaginary grid of 100x100 points.
The top left hand corner of the square I'm going to place at 25 across and 25 down. We write that as "25x25@4", where the "@4" bit the color to use when drawing the line. Usually, for each point like this, FVWM will draw a line from the previous point to this one. In this case there is no previous point, so I don't think FVWM will draw anything, but just to be sure, I've chosen colour 4 which means "don't traw anything - just move".
The Next point we choose is 25,75@1. This draws a line from the last point (35,35) to the new one (25,25). We choose colour 1 for this, because that's specifies the hilight colour. This is going to be the left side of the square, and that should look as if light was falling up it if its going to match the other icons.
The Next three points complete the square, finishing back where we started out: 75x75@0 75x25@0 25x25@1. The @0 lines are being drawn in the shade color to make them look like they're in shadow and preserve the illusion three-dimensonality for the icons.
After that we use another move-only point to move the cursor inside the square, and from there we draw the triangle in the same way.
See? That wasn't so bad after all :)
For the second icon I used a double headed arrow. There was a nice one on the FVWM vectorbuttons page, so I pinched that. That was even easier :D
The last thing to do use make the "Klix" window use the new decor:
- Code: Select all
Style "Klix" UseDecor PanelDecor
Et,
voila! Ok, the triangle is a little pixelated, but no more so than the "pro" version. I think I can live with that. I've also got a slight problem with the player stated up un-hidden. Anyone know a reliable way to make XMMS start off hidden? I'd like to know about ut.
One thing I've been putting off until we talked about decors: I'm not mad keen on the default buttons either. The close button is on the wrong side of the bar ffor me, and the icon itself makes me thing I'm using Windows 3.1.1. I keep clicking it expecting a menu. It can be a nasty surprise when the window vanishes.
So, I think I'll have close icon on the right where I expect it, and on the left, I fancy a combined min/max button. I also think I'll make the close icon only operate on a double click (never thought I'd feel nostalgic for Win 3.1.1!) with probably a menu there for a single click to stop me forgetting and thinking the config is broken.
Let's define another decor:
- Code: Select all
DestroyDecor DefaultDecor
AddToDecor DefaultDecor
+ ButtonStyle 1 16 60x40@1 60x80@0 15x80@0 15x40@1 60x40@1 \
40x40@1 40x25@1 75x25@1 75x60@0 60x60@0 \
75x60@0 75x40@0 85x40@0 85x15@0 60x15@1 \
60x25@1
+ ButtonStyle 2 8 35x15@1 20x50@1 40x50@0 30x80@1 75x40@0 \
50x40@1 75x15@0 35x15@1
I snaged both of these from the FVWM page. Why re-invient the wheel? That's assuming the current defacto industry standard isn't triangular or something, obviously ;)
- Code: Select all
Mouse 1 1 N Iconify # iconify on mouse 1
Mouse 3 1 N Maximize # max it on mouse 3
Mouse 1 2 N CloseOrMenu # Call a function on mouse 1
The reson for the function call is that the "D" modifier doesn't work for mouse actions in this context. But it does in functions so we pass the click to the function, and then the function decides what sort of click it was passed:
- Code: Select all
DestroyFunc CloseOrMenu
AddToFunc CloseOrMenu
+ C Menu FvwmMenu # if single click, display menu
+ D Close # close on double click
Anyone why ever accidentally clicked on a window and lost several hours work knows where I'm coming from with this one.
- Code: Select all
Style "*" UseDecor DefaultDecor
Make sure you add the system wide stuff before you do the app specific code. Otherwise the above UseDecor will blot out the custom one and you'll wonder where your XMMS controls went. If you do this from the console line you may need to add NoButton 4 to the style command to shift the now superfluous button.
The
config file stands at 334 lines and looks like
this. Next installment, some more oddball pager tricks.