;; menurc.scm
;; This file contains specification of your popup menus

(primitive-load-path "popups")

;; Add names on computers for the login menu to this list
(defvar machine-list
        '()
        "List of machines that can be logged in to." 'list)

(defvar command-pop-list
        `(("Xterm" ,(lambda (h) (list "xterm" "-r" "-n" (machine-name h))))
          ("Aterm" ,(lambda (h) (list "aterm" "-cr" "red")))
          ("Administrador" "aterm" "-e" "su" "-")
          ("Exp. Archivos" "rox")
          ("Gestor procesos" "mxkill")
          #t
          "qupzilla"
          "opera"
          ("Reprod. música" "herrie_unicode")
          ("Calendario" "plan"))
        "List of shell commands to have in the menu." 'list)

(defvar root-pop-list
        `(("Configurar" ,(lambda (x) (custom-menu)))
          ("Decorar todas" ,(lambda (x) (redecorate-all)))
          ("Restaurar todas" ,(lambda (x) (deiconify-all)))
          ("Desenfocar" ,(lambda (x) (focus-window #f)))
          #t
          ("Reiniciar GWM" ,(lambda (x) (restart)))
          ("Salir" ,(lambda (x) (end))))
        "Items for the root menu." 'list)

(defvar window-pop-list
        `(("Elevar" ,raise-window)
          ("Bajar" ,lower-window)
          ("Mover" ,(lambda (w) (user-move-window w #f)))
          ("Tamaño..." ,(lambda (w) (user-resize-window w #f)))
          ("Minimizar" ,toggle-iconify-window)
          ("Sombrear" ,(lambda (w e) toggle-shade-window w))
          ("Ampliar" ,(lambda (w) (zoom-window w)))
          ("Pegajosa" ,(lambda (w) (virtual-toggle-nail w)))
          ("Enfocar" ,focus-window)
          ("Redecorar" ,redecorate-window)
          ("Matar apl." ,(lambda (w) (or (delete-window w)
                                     (kill-window w)))))
        "Items for the window menu." 'list)

(make-screen-var root-pop #f)
(make-screen-var window-pop #f)
(make-screen-var login-pop #f)
(make-screen-var command-pop #f)

(define (update-menus)
  (root-pop (make-popup "Opciones GWM" root-pop-list))
  (window-pop (make-popup "Opciones Ventana" window-pop-list))
  (login-pop (make-machine-popup "Login" 
                                 (lambda (h) (list "xterm" "-n" (machine-name h)))
                                 machine-list))
  (command-pop (make-command-popup "Aplicaciones" command-pop-list)))

;; Delay creation of menus until screen opening (of the first screen)
(add-hook! screen-opening
           (lambda (s) (if (eq? s (car (list-of-screens))) (update-menus))))

(custom-menu-install-hook "Menurc" update-menus)
