# Menu for different ways to run away ;)
# Created by: Pawel "NEMO" Drygas <nemo@braxis.org>
# Modified by Dominique Michel <dominique_libre@sourceforge.net> for use with
# session managers as gnome-session

DestroyFunc KillAutoHibernate
AddToFunc KillAutoHibernate
+ I Piperead 'for i in /tmp/crystal_autohibernate_* ; do kill `echo $i | sed s:/tmp/crystal_autohibernate_::`; done'

DestroyFunc EndAutoHibernate
AddToFunc EndAutoHibernate
+ I KillAutoHibernate
+ I SavePreferences AutoHibernation Nop

DestroyMenu /AutoHibernateValue
AddToMenu /AutoHibernateValue
+ "$[gt. 1 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 1
+ "$[gt. 2 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 2
+ "$[gt. 3 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 3
+ "$[gt. 5 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 5
+ "$[gt.10 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 10
+ "$[gt.15 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 15
+ "$[gt.20 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 20
+ "$[gt.25 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 25
+ "$[gt.50 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 50
+ "$[gt.75 %]" Exec exec $[FVWM_SYSTEMDIR]/scripts/AutoHibernate 75

DestroyFunc AutoHibernate-generator
AddToFunc AutoHibernate-generator
+ I DestroyMenu recreate /AutoHibernate
+ I Piperead "if ls /tmp/crystal_autohibernate_* 1>2 2>/dev/null; \
	then echo Test \\\(x /usr/sbin/pm-hibernate\\\) AddToMenu /AutoHibernate \\'$[gt.Stop]\\' EndAutoHibernate; \
	else echo Test \\\(x /usr/sbin/pm-hibernate\\\) AddToMenu /AutoHibernate \\'$[gt.Start when battery is as low as]\\' Popup /AutoHibernateValue; fi"

DestroyMenu /AutoHibernate
AddToMenu /AutoHibernate
+ DynamicPopupAction Function AutoHibernate-generator

DestroyMenu /Exit
AddToMenu /Exit 
+ '%22x22/fvwm-crystal/view-refresh.png%$[gt.Restart]' Restart
Test (x xscreensaver) + '%22x22/fvwm-crystal/system-lock-screen.png%$[gt.Lock screen]' X xscreensaver-command -lock
Test (EnvIsSet SESSION_MANAGER) + '%22x22/fvwm-crystal/system-log-out.png%$[gt.Logout]' QuitSession
Test (!EnvIsSet SESSION_MANAGER) + '%22x22/fvwm-crystal/system-log-out.png%$[gt.Logout]' Quit
Test (x /usr/sbin/pm-hibernate) + '' Nop
Test (x /usr/sbin/pm-hibernate) + '%22x22/fvwm-crystal/gdm.png%$[gt.Automatic suspend to disk]' Popup /AutoHibernate
Test (x /usr/sbin/pm-suspend) + '' Nop
Test (x /usr/sbin/pm-suspend) + '%22x22/fvwm-crystal/gdm.png%$[gt.Resume to RAM]' S pm-suspend
Test (x /usr/sbin/pm-suspend-hybrid) + '%22x22/fvwm-crystal/gdm.png%$[gt.Resume hybride]' S pm-suspend-hybrid
Test (x /usr/sbin/pm-hibernate) + '%22x22/fvwm-crystal/gdm.png%$[gt.Suspend to disk]' S pm-hibernate
Test (x /usr/sbin/pm-powersave) + '%22x22/fvwm-crystal/gdm.png%$[gt.Powersave]' S pm-powersave
Test (EnvIsSet SESSION_MANAGER) + '' Nop
Test (EnvIsSet SESSION_MANAGER) + '%22x22/fvwm-crystal/gdm.png%$[gt.Save session]' Exec exec gnome-session-save --gui
Test (EnvIsSet SESSION_MANAGER) + '%22x22/fvwm-crystal/gdm.png%$[gt.Manage session]' Exec exec gnome-session-properties

DestroyFunc Exit-SelectLoginManager
AddToFunc Exit-SelectLoginManager
+ I Test (x gdmflexiserver) PipeRead 'pidof gdm > /dev/null && echo "Include components/functions/Exit-gdm" || echo "Test (x sudo) Include components/functions/Exit-sudo"'
+ I TestRc (NoMatch) Include components/functions/Exit-sudo

Exit-SelectLoginManager
Test (x /usr/sbin/pm-hibernate) AddToFunc ExitFunction I Test (ToRestart) KillAutoHibernate

# vim:ft=fvwm
