A button that raises and lowers a window

I have made a bar of buttons which bring up panels that contain things like an xterm, a volume control app, etc. I wanted to make a button that controls the print manager. The print manager raises itself when somebody prints, and I wanted to keep this behavior. In order to do that, I need a different sort of button, one that acts more like an icon manager button. Is there a way to create this button? I searched through the manual but can’t figure out how I can send the RaiseLower command to a certain window. I had the idea of swallowing an instance of FVWMIconMan that only manages one window, though that seems like an overly complex approach. What is the best way to do this?

Be more specific if you can. But what you’re asking for is this:

Next (SomeApplicationClass) RaiseLower

– Thomas Adam

That seems to be just what I needed—it’s working just like I wanted. The whole button bar is as shown below. It would be nice if I could find a pulseaudio volume control program that doesn’t require such a huge window, but other than that I think I’m happy with how it is working. (Note that “blankshell” is a script that invokes the tcsh shell with an environment variable to create a short prompt. Is there a way to pass an environment variable in from fvwm without needing a wrapper script?)

Style FvwmButtons !Title, !Handles, CirculateSkip, NeverFocus, Sticky, \
      WindowListSkip
Style *bar*   !Handles, !Borders, SloppyFocus
Style units NoTitle, NoHandles, !Borders, SloppyFocus
Style termbutton NoTitle, NoHandles, !Borders, SloppyFocus

DestroyModuleConfig termbutton: *
*termbutton: Rows 1
*termbutton: Columns 1
*termbutton: (1x1 swallow(UseOld,NoHints,Respawn) "button_term" \
                     "Exec xterm -T button_term -bg lightcyan +sb -e tcsh")

DestroyModuleConfig units: *
*units: Rows 1
*units: Columns 1
*units: (1x1 swallow(UseOld,NoHints,Respawn) "unitswindow" \
           "Exec xterm -T unitswindow -bg '#FED8A7' +sb -e units")

DestroyModuleConfig soundcontrol: *
*soundcontrol: Rows 1
*soundcontrol: Columns 1
*soundcontrol: (1x1 swallow(UseOld,Respawn) "Volume Control" \
                        "Exec pavucontrol")

DestroyModuleConfig buttonbar: *
*buttonbar: Rows 1
*buttonbar: Columns 12
*buttonbar: Back thistle
*buttonbar: (8x1 swallow (UseOld,NoHints,Respawn) "singleterm" \
          "Exec xterm -T singleterm -bg thistle  -fg black +sb -e blankshell")
*buttonbar: (Panel(steps 0,down,indicator,position button right) termbutton \
                        "Module FvwmButtons -g 300x150 termbutton")
*buttonbar: (Panel(steps 0,down,indicator,position button left) units \
                        "Module FvwmButtons -g 300x150 units")
*buttonbar: (Padding 0 0,Icon /home/adrian/.fvwm/notes.png,\
                   Panel(steps 0,down) soundcontrol \
                  "Module FvwmButtons -g 600x900 soundcontrol")
*buttonbar: (Padding 0 0, Icon /home/adrian/.fvwm/printer.png) \
    Action (Mouse 1) "Next (Turboprint-monitor) RaiseLower"

FvwmButtons -g 300x22+800+0 buttonbar

Actually I encountered puzzling behavior. I wanted to make the print manager window always cover all other windows and I wanted it sticky. I used the following:

Style "turboprint-monitor"  !Title, !Handles, Sticky, StaysOnTop, WindowListSkip

This works fine for xclock and xbuffy and the pager. But it doesn’t work for the print monitor. I tried changing StaysOnTop to “Layer 8” but that didn’t work either. I know that the window is getting the style because I observe it to vanish from the window list, lose its title, and turn sticky. But I can cover it with other ordinary windows. What could explain the failure of StaysOnTop?

This will depend when the value of the environment variable is set, and whose responsibility it is to set it. Basic process management knowledge will tell you that exporting variables from the shell is not a shared memory environment – children cannot update their parent’s knowledge of environment variables, in the same way that processes started from FVWM which set environment variables won’t be seen by FVWM.

If this is a more general thing though, Adrian, do have a look at FVWM’s SetEnv command.

Use !Title and !Handles throughout.

– Thomas Adam

It’s probably a problem between the keyboard and the chair, but post your entire FVWM config somewhere and I can take a look.

– Thomas Adam

I restarted X, rather than just restarting FVWM, and now the window is behaving as expected. I’m not sure why that should matter, but I guess that means the problem is solved.

No, it means something else entirely. Don’t be so presumptuous.

– Thomas Adam

Ah, so what does it mean?

That there might be something in your config, hence why I asked for it before.

Please don’t drag me round in circles, it’s irritating.

– Thomas Adam

### BUTTONS & CURSORS

#ButtonStyle 3 Vector 9 50x25@0 67x33@0 75x50@0 67x67@0 50x75@0 33x67@0 25x50@0 33x33@1 50x25@1
#ButtonStyle 4 Vector 9 50x25@0 67x33@0 75x50@0 67x67@0 50x75@0 33x67@0 25x50@0 33x33@0 50x25@0
#ButtonStyle 5 Vector 7 70x0@0 70x70@0 0x70@0 0x40@0 40x40@0 40x0@0 70x0@0
#ButtonStyle 6 Vector 8 40x20@1 40x50@1 20x50@1 50x80@1 80x50@0 60x50@0 60x20@0 40x20@1

ButtonStyle 1  Vector 4 50x75@1 25x25@1 75x25@1 50x75@0
ButtonStyle 2  Vector 7 70x0@0 70x70@0 0x70@0 0x40@1 40x40@1 40x0@1 70x0@1

### OPTIONS

DeskTopSize	2x2
EdgeScroll	100 100 wrap
EdgeResistance  500
Style * EdgeMoveDelay 50
Style * EdgeMoveResistance 50

Style * SnapAttraction  5

#old WindowFont	-*-lucida-medium-r-*-*-12-*-*-*-*-*-*-*
#WindowFont      -adobe-times-bold-r-normal--14-140-75-75-p-77-iso8859-1


#MenuStyle	white grey SlateGrey 9x15 fvwm
MenuStyle * "fvwm", Foreground "white", Background "grey", Greyed "SlateGrey", Font "9x15", "AnimationOff"
OpaqueMoveSize	0
ClickTime       200

#CursorStyle TITLE 0
#CursorStyle RIGHT 24
#CursorStyle Root 0

### STYLES

TitleStyle LeftJustified 
TitleStyle -- Flat
ButtonStyle All -- Flat
BorderStyle Active -- HiddenHandles, NoInset


Style * HilightFore black
Style * HilightBack PowderBlue
Style * IconFont -*-lucida-medium-r-*-*-14-*-*-*-*-*-*-*
Style * Font -adobe-times-bold-r-normal--14-140-75-75-p-77-iso8859-1
Style *	Color black/grey
Style *	!Handles, BorderWidth 4, NoIcon
Style *	DecorateTransient, NoPPosition, HintOverride
Style *	TileCascadePlacement, SloppyFocus
Style * RaiseTransient, LowerTransient


Style "Fvwm*"	!Title, !Handles, Sticky, WindowListSkip, StaysOnTop
Style "Fvwm*"	BorderWidth 1
Style "FvwmForm-Talk" Title, Slippery, WindowListHit, BorderWidth 4, StaysPut
Style "xbiff"   !Title, !Handles, Sticky, StaysOnTop, WindowListSkip
Style "xbuffy"   !Title, !Handles, Sticky, StaysOnTop, WindowListSkip
Style "myxclock" !Title, !Handles, Sticky, StaysOnTop, WindowListSkip
Style "xload"	!Title, !Handles, Sticky
Style "turboprint-monitor"  Sticky, StaysOnTop, WindowListSkip,!Closable

Read /etc/X11/fvwm/menudefs.hook

### POPUP MENUS

DestroyMenu     RootMenu
AddToMenu       RootMenu
+ "Root Menu"         Title
+ "xterm"           Exec xterm &
+ "Applications"    PopUp Apps
+ "X functions"     PopUp XStuff
+ "All Programs"    PopUp "/Debian"
+ "Desktop"         PopUp Desk_Ops
+ "Lock"            Exec xtrlock &
# + "Log out"         PopUp Logout_Menu


DestroyMenu Apps
AddToMenu     Apps
+ "firefox"       Exec firefox &
+ "mail"          Exec xterm -geometry 80x60 -e mutt & 
+ "gnucash"       Exec gnucash &
+ "top"		  Exec xterm -T top -n top -geometry 80x60 -e top &
+ "emacs"         Exec emacs &

#+ "console"       Exec /xterm -geometry 80x7+1+1 -C -T `hostname` &


DestroyMenu XStuff
AddToMenu XStuff
+ "editres"	Exec editres &
+ "X colors"     Exec xcolors &
+ "X events"     Exec /usr/bin/xterm -e xev &
+ "X cut buffers" Exec xcb &

DestroyMenu	"Bar_Ops"
AddToMenu	"Bar_Ops"
+	"Hide"		Iconify
+       "Lower"         Lower
+       ""              Nop
+       "Move"          Move
+       "Resize"        Resize
+	""		Nop
+	"Big"		Maximize 
+	"Tall"		Maximize 0 100
+	"Wide"		Maximize 100 0
+       "Medium"        Maximize 700p 800p
+	""		Nop
+	"Stick"		Stick
+	"Identify"	Module FvwmIdent
+       ""              Nop
+	"Close"		Close


DestroyMenu     "Logout_Menu"
AddToMenu       "Logout_Menu"
+       "Log Out Menu"  Title
+       "Log Out"       Quit
+       "Don't Log Out" Nop
+       ""              Nop
+       "Suspend"       Exec /usr/sbin/s2ram


DestroyMenu	"Desk_Ops"
AddToMenu	"Desk_Ops"
+	"Refresh"	Refresh
+	"Reload Resources"	Exec xrdb $HOME/.Xresources &
+	""		Nop
+	"Show Pager"	Module FvwmPager 0 0
+	"Hide Pager"	KillModule FvwmPager
+       ""              Nop
+       "Show Icon Mgr" Module FvwmIconMan
+       "Hide Icon Mgr" KillModule FvwmIconMan   
+       ""              Nop
+       "Print selection" Exec xcb -p 0 | enscript -2Gr -Plp600 2>/dev/null
+       "Print window"    Exec xwd | xwdtopnm 2>/dev/null | lpr
+       ""              Nop
+       "Mouse speed"   PopUp Set_Mouse
+	""		Nop
+	"Talk to Fvwm"	Module FvwmTalk
+	"Restart Fvwm"	Restart
+       "Destroy window" Destroy

DestroyMenu	"Set_Mouse"
AddToMenu	"Set_Mouse"
+ "Very Fast"   Exec xset m 7 10
+ "Fast"        Exec xset m 3 10
+ "Default"     Exec xset m default
+ "Glacial"     Exec xset m 0 10


### MOUSE BINDINGS

# Window bar button actions

Mouse 0		1	a	Iconify
Mouse 0		2	a	Resize

# Window bar and border actions

Mouse 1         fst     a       Move-or-Raise
Mouse 2         fst     a       Resize
Mouse 3         fst     a       Menu "Bar_Ops" Nop

# root window actions
IgnoreModifiers L2
Mouse 1         r       a       XtermOrMenu
Mouse 2		r    	a      	Windowlist
Mouse 3         r       n       Menu "RootMenu" Nop
#Mouse 3         r       n2      Menu "RootMenu" Nop
Mouse 3         r       c       Menu "LogOut_Menu" Nop
#Mouse 3         r       c2      Menu "LogOut_Menu" Nop

DestroyFunc XtermOrMenu
AddToFunc   XtermOrMenu
+ C Exec xterm &
+ H Menu Apps Nop


### MODULES

*FvwmPagerGeometry	60x40-0+0
*FvwmPagerRows		1
*FvwmPagerColumns       1
*FvwmPagerFont		none
*FvwmPagerFore		black
*FvwmPagerBack		grey
*FvwmPagerHilight	DeepSkyBlue4
#
# With bigger pager, can get name of window on little copies:
#  *FvwmPagerSmallFont	-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso8859-1

*FvwmIconMan*background thistle
*FvwmIconMan*foreground black
*FvwmIconMan*plainbutton up
*FvwmIconMan*followfocus true
*FvwmIconMan*selectbutton flat magenta thistle
*FvwmIconMan*iconbutton up
*FvwmIconMan*focusbutton up blue thistle
*FvwmIconMan*managergeometry 1x0-1+42
*FvwmIconMan*buttongeometry 150x0
*FvwmIconMan*format "%t"
*FvwmIconMan*font -adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1
*FvwmIconMan*resolution global
*FvwmIconMan*action Mouse 1 a sendcommand Iconify
*FvwmIconMan*action Mouse 2 a sendcommand "Move pointer"
*FvwmIconMan*action Mouse 3 a sendcommand "Module FvwmIdent"

 
*FvwmIdentBack		grey


DestroyModuleConfig mpdbar: *
*mpdbar: Back darkgrey
*mpdbar: Columns 5
*mpdbar: Rows 2 
*mpdbar: (1x1, Action (Mouse 1) 'Exec mpc play &>/dev/null', Icon \
          $[HOME]/.fvwm/icons/play.png)
*mpdbar: (1x1, Action (Mouse 1) 'Exec mpc pause &>/dev/null', Icon \
          $[HOME]/.fvwm/icons/pause.png)
*mpdbar: (1x1, Action (Mouse 1) 'Exec mpc stop &>/dev/null', Icon \
          $[HOME]/.fvwm/icons/stop.png)
*mpdbar: (1x1, Action (Mouse 1) 'Exec mpc prev &>/dev/null', Icon \
          $[HOME]/.fvwm/icons/prev.png)
*mpdbar: (1x1, Action (Mouse 1) 'Exec mpc next &>/dev/null', Icon \
          $[HOME]/.fvwm/icons/next.png)
*mpdbar: (5x1)


Style FvwmButtons !Title, !Handles, CirculateSkip, NeverFocus, Sticky, \
      WindowListSkip
Style *bar*   !Handles, !Borders, SloppyFocus
Style units !Title, !Handles, !Borders, SloppyFocus
Style termbutton !Title, !Handles, !Borders, SloppyFocus

DestroyModuleConfig termbutton: *
*termbutton: Rows 1
*termbutton: Columns 1
*termbutton: (1x1 swallow(UseOld,NoHints,Respawn) "button_term" \
                     "Exec xterm -T button_term -bg lightcyan +sb -e tcsh")

DestroyModuleConfig units: *
*units: Rows 1
*units: Columns 1
*units: (1x1 swallow(UseOld,NoHints,Respawn) "unitswindow" \
           "Exec xterm -T unitswindow -bg '#FED8A7' +sb -e units")

DestroyModuleConfig soundcontrol: *
*soundcontrol: Rows 1
*soundcontrol: Columns 1
*soundcontrol: (1x1 swallow(UseOld,Respawn) "Volume Control" \
                        "Exec pavucontrol")

DestroyModuleConfig buttonbar: *
*buttonbar: Rows 1
*buttonbar: Columns 12
*buttonbar: Back thistle
*buttonbar: (8x1 swallow (UseOld,NoHints,Respawn) "singleterm" \
          "Exec xterm -T singleterm -bg thistle  -fg black +sb -e blankshell")
*buttonbar: (Panel(steps 0,down,indicator,position button right) termbutton \
                        "Module FvwmButtons -g 300x150 termbutton")
*buttonbar: (Panel(steps 0,down,indicator,position button left) units \
                        "Module FvwmButtons -g 300x150 units")
*buttonbar: (Padding 0 0,Icon /home/adrian/.fvwm/notes.png,\
                   Panel(steps 0,down) soundcontrol \
                  "Module FvwmButtons -g 600x900 soundcontrol")
*buttonbar: (Padding 0 0, Icon /home/adrian/.fvwm/printer.png) \
    Action (Mouse 1) "Next (Turboprint-monitor) Iconify"


AddToFunc Move-or-Raise		"C" Raise
+				"M" Move

AddToFunc PrintFunction         "I" Raise
+                               "I" Exec xwd -silent -id $w | xwdtopnm | lpr


Key Print  W  N  PrintFunction

Key F1 W C Destroy
Key F12 W A Maximize 800p 900p


### INIT

AddToFunc InitFunction 
+ I Exec /usr/local/bin/myxclock -padding 3 -geometry -113+1 -d \
       -font '-adobe-courier-bold-r-normal-*-20-*-100-100-m-*-iso8859-1' &
+ I Exec /usr/bin/xbuffy -g 44x27-61+0 -horiz -boxfile ~/.mailboxes
+ I Exec xterm -geometry 80x62+1-1 &
+ I Exec xconsole -file /dev/xconsole -geometry 480x96+0+0 &
+ I Exec turboprint-monitor -iconic &
+ I Exec xsetroot -solid gray35 -def
+ I Exec xhost +
+ I Exec /usr/local/bin/argyll/dispwin -I /etc/calibration/data.icc

DestroyFunc StartFunction
AddToFunc StartFunction
+ I Module FvwmPager 0 0
+ I Module FvwmButtons -g 300x22+800+0 buttonbar
+ I Module FvwmIconMan