restart_fluxbox with a keymapping


Forum: X and Fluxbox
Topic: restart_fluxbox with a keymapping
started by: Patrick

Posted by Patrick on Dec. 15 2004,05:32
A couple of days ago i added a keymapping to my "keys"-list (Mod1 z :restart_fluxbox) which works very well. (i do a lot of tweaking in init-files of fluxbox/xplanet and need to restart_fluxbox a lot)

BUT recentaly (on my logitech multimedia-keyboard at home) whenever i was typing in (for instance) scite and hit the z-key my fluxbox would restart (and no "z" would be shown in scite).

Therefor i have removed the "Mod1 z" but i am wondering why this is happening now (and not earlier or from the start).

Any hints?

Posted by mikshaw on Dec. 15 2004,13:51
I had a very similar thing happen to me yesterday, but it was with the menu key instead of mod1....I'd mapped "Menu M :RootMenu", but every time I pressed M by itself the menu would open.  I decided not to use the Menu key until I got it sorted.
My guess is that there is something messed up in the keymapping in X rather than Fluxbox, because you have the proper syntax in the keys file.  Did you use this same keyboard successfully before, with the same keyboard chosen at startup?  The multimedia keys on my logitech do not even register in DSL with the default keyboard chosen.

Also, instead of restarting fluxbox, try using "reconfigure" instead.  This reloads the init file rather than restarting the whole window manager.  For  style edits, try "reloadstyle".

Posted by Patrick on Dec. 15 2004,14:05
Did you use this same keyboard successfully before, with the same keyboard chosen at startup?  The multimedia keys on my logitech do not even register in DSL with the default keyboard chosen.

Like yourself my multimedia-keys on my logitech keyboard do not register in DSL. The "Mod1 0 : restart_fluxbox" has worked before on my logitech- (at home) and on my HP-keyboard (at work).

Thnx for the tip -> "reconfigure"/"reloadstyle"

How's fluxbox-0.9.11 coming along? (any problem there with keymappings?) Have you added icons to your fluxbox-menu yet? I have been snooping around for a fluxbox config application which will help me with adding xpm-files to the menu. (not found yet) All i have seen so far are: whitebox and FluxConf (screenshots that is..)

Would be nice in the future if we could add color/fonts/styles to individual lines in the fluxbox menu...

Posted by mikshaw on Dec. 15 2004,17:47
Does Mod1 work for any other key bindings?  It might be the "restart_fluxbox" thing confusing the application.  The recommended command is "restart" with the window manager as an argument:
Mod1 Z :Restart fluxbox  or  Mod1 Z :Restart restart_fluxbox or Mod1 Z :Restart
in the DSL menu it is listed as "[restart] (restart) {restart_fluxbox}" and this loads /usr/bin/fluxbox regardless of which version you are currently using.  If you're running fluxbox-devel, just using "restart" should be enough.
Of course this might not be the problem, since i don't know how fluxbox interprets its configuration files, but I can't think of any other reason why Mod1 wouldn't work.

I personally don't use icons, so haven't done much with them.  The fluxbox-generate_menu script which comes with the official fluxbox package now includes limited support for program icons.  What it does is look in ~/.fluxbox/icons/ for xpm files with the same name as the applications (e.g. firefox.xpm), and uses those.  This script isn't in the DSL extension because I'd need to incorporate the myDSL menu into it...something I just haven't wanted to bother with.
 
One thing I did do just as a test was to add submenu icons to  fluxbox-generate_menu (for my non-DSL system) by just adding an icon to the append_submenu function.  I didn't keep it, though, since the built-in arrows are enough for me.

The great thing about the way icons are used in the fluxbox menu is that they are added simply by slapping on a filename to the end of a line.  It should be very easy to write a bash script that will do this for you.  In fact, the addition to fluxbox-generate-menu could probably be ripped out and modified to work as its own self-contained script to run on the DSL menu.
I think maybe I'll try that today.

The new extension seems to work fine, better than 0.9.10 in my opinion....there's a little info about its status on the DSL Talky-Bloggy  thingy.  I'm waiting to hear from the creator of the potential wallpaper, but until then I've been spending an hour or two each day tinkering with it just to see how easy-to-use-straight-out-of-the-package I can make it .

Quote
Would be nice in the future if we could add color/fonts/styles to individual lines in the fluxbox menu...

wow...I never thought about that.  That's a really good idea.  Personally I don't know how much i'd use it, but it would be handy for some things.  
Take for example filetypes... you could have a different color for submenus and remove the arrows....or if you have a setup like mine where my menu contains some individual files, like reference material and various config files, those files could be a different color/style than the programs...also altering the color of arrows and separators could be useful.

What i don't get, though, is something I just noticed....you can't change the font of just window titles.  In other words, there is no window.label*font resource...it's just a window.font.  This might not be noticeable in most situations, but if you change the font for a window it also changes the font for the command dialog...it's really hard to read a dialog that has black text with a black shadow.

Posted by mikshaw on Dec. 15 2004,22:39
Quote
I have been snooping around for a fluxbox config application which will help me with adding xpm-files to the menu


Here's what I have so far.  It's kinda sloppy, with 4 awk commands in a single line, but I don't know much about editing text files from a script yet.  Probably should use cut instead, but I don't know that program yet.

This will create a duplicate of your menu, named icon_menu, using icons found in a specified directory.  The icons need to be named the same as the command + xpm extension, and it's case-sensitive.

Something I never thought about was terminal applications.  This first version of the script reads only the term name, so if you have a vim icon, for example, it will use an icon for whatever terminal program you are using to run vim.  You'll need to edit the proper icon in by hand until I get something better.

There's also a problem with it properly writing certain menu lines.  For example, I have one line which allows me to edit the current style and it needed a backslash in it in order to write the appropriate command:
aterm -e vim `grep styleFile ~/.fluxbox/init | awk '{ print $2 \}'`
When that line is echoed, the backslash is overlooked and the command no longer works because fluxbox thinks that last curly bracket is the end of the command.  This should not be a problem for you unless you're into making menu commands like that.


As always, keep a backup of your original menu.

Code Sample

#!/bin/bash

input_file="${HOME}/.fluxbox/menu"
output_file="${HOME}/.fluxbox/icon_menu"
icon_dir="${HOME}/.fluxbox/icons"

cat /dev/null > ${output_file}
cat "${input_file}" | while read line; do
command_name=`echo "${line}"|awk -F { '{print $2}'|awk -F } '{print $1}'|awk '{print $1}'|awk -F / '{print $NF}'`
icon_name="${icon_dir}/${command_name}.xpm"
if [ -f "${icon_name}" ]; then
echo "${line} <${icon_name}>" >> ${output_file}
else
echo "${line}" >> ${output_file}
fi
done


If you've got 16-pixel icons and they look all crunchy you can put this into your style file:
menu.itemHeight: 16 (might need to be slightly larger than 16)
It'll make your menu taller, but the icon will look better.

Posted by Patrick on Dec. 16 2004,08:36
Thnx for the script, will use it when i need to rewrite the menu (all the important icons are already in place right now). If got 32x32 pix icons (.xtdesktop) and 48x48 pix icons (Suse) so i added: menu.itemHeight: 32 (which makes the icons look great, but the menu itself becomes very large). Funny thing is: when i decreased  the fontsize (from 200 to 50) , the fonts actualy became bigger/humongous actualy!)

! ***** fonts *****
*.font: -*-lucida-small-r-*-*-*-200-*-*-*-*-*



:cool:

Posted by mikshaw on Dec. 16 2004,20:59
You may be trying a font size which is not available for a particular font.  This can be verified with xfontsel.  I just checked it on my workstation, and lucida doesn't seem to have a 200 pt size...it skips from 190 to 240.  There also isn't a "small" weight.
Posted by mikshaw on Dec. 17 2004,14:20
Update on the icons script,
It now will correctly grab the name of a terminal application.  
I haven't gotten "sudo" applications right yet.  There could be a menu command similiar to "xterm -e sudo <command>", or it could be "sudo [su -c] xterm -e <command>", so I haven't figured out how to guess which is being used in order to grab <command>.

Code Sample

#!/bin/bash
inpoot="${HOME}/.fluxbox/menu"
outpoot="${HOME}/.fluxbox/icon_menu"
icon_dir="${HOME}/.fluxbox/icons"

if [ -f "${outpoot}" ]; then
mv -f "${outpoot}" "${outpoot}.bak"
fi
cat "${inpoot}" | while read line; do
full_command=`echo "${line}"|awk -F { '{print $2}'|awk -F } '{print $1}'`
case "${full_command}" in
[aEx]term*-e*|rxvt*-e*|konsole*-e*|gnome-terminal*-e*)
command_name=`echo "${full_command}"|awk -F '-e' '{print $2}'|awk '{print $1}'|awk -F / '{print $NF}'`
;;
*)
command_name=`echo "${full_command}"|awk '{print $1}'|awk -F / '{print $NF}'`
;;
esac

icon_name="${icon_dir}/${command_name}.xpm"
if [ -f "${icon_name}" ]; then
echo "${line} <${icon_name}>" >> ${outpoot}
else
echo "${line}" >> ${outpoot}
fi
done

Posted by mikshaw on Dec. 22 2004,13:08
I've found the source of the corrupt menu item...it's in my $full_command variable.  If there is a menu item like this:
[exec] (something) {command | awk '{ print $ }'}
awk cuts at the first '}' instead of the last, so you end up with this as $full_command:
command | awk '{ print $
instead of this:
command | awk '{ print $ }'

I don't know how to fix it yet.

Powered by Ikonboard 3.1.2a
Ikonboard © 2001 Jarvis Entertainment Group, Inc.