;-*-lisp-*-

;;; Misc

(in-package :stumpwm)

(setf *default-package* :stumpwm)

(set-prefix-key (kbd "C-p"))

;; Variables

;(defparameter terminal "exec aterm -tr -sh 30")
(defparameter terminal "exec xterm")
(defparameter exal-emacs "exec /home/exal/repos/emacs/src/emacs")   
(defparameter exal-email "exec /home/exal/repos/emacs/src/emacs --eval '(exal-email)'")
(defparameter exal-msg "exec /home/exal/repos/emacs/src/emacs --eval '(exal-msg t)'")
(defparameter exal-irc "exec /home/exal/repos/emacs/src/emacs --eval '(exal-irc t)'")
(defparameter konqueror "exec konqueror")


(setf *debug-level*   10
      *mouse-focus-policy* :click)

;;; The Appearance

;;;; The Message Window
(set-fg-color "LightGrey")
(set-bg-color "Black")
(set-border-color "SlateGrey")
(set-msg-border-width 10)


(setf *message-window-gravity* :center
      *timeout-wait*           3
      *input-window-gravity*   :center)


;;;; The Mode Line

   (setf *mode-line-background-color* "Black"
         *mode-line-foreground-color* "white"
         *mode-line-border-color*     "white"
         *mode-line-timeout*          1
         *mode-line-screen-position* :top
         *window-format* "<%n%s%m%30t>"
         *screen-mode-line-format*  
        (list "[%w]   | "
         '(:eval (run-shell-command "ifconfig|grep inet|awk '{print $3}'|head -1 " t))))
   

;; ;; turn on/off the mode line for the current screen only.

(if (not (head-mode-line (current-head)))
     (toggle-mode-line (current-screen) (current-head)))

;;;; Windows

(set-focus-color   "DarkRed")
(set-unfocus-color "black")
(set-normal-gravity :center)

(setf *normal-border-width* 1)


(defvar *maximized-frame-size* (make-frame :number -1 :x 0 :y 0 :width 1024 :height 768))
(defvar *current-frame-size* (make-frame :number -1 :x 0 :y 0 :width 0 :height 0))
(defvar *current-maximized-frame* nil)



;;;; Applications startup

(mapcar #'run-shell-command 
        (list "xsetbg /home/exal/capo.jpg" "gnome-volume-manager" terminal exal-email
              exal-irc exal-msg konqueror "xmodmap -e 'keysym Alt_L = Meta_L Alt_L'"))


;;;; Frames

(setf *frame-number-map* "1234567890")


;; utility commands

(define-stumpwm-command "gmrun" ()
  (run-shell-command "gmrun"))

(define-stumpwm-command "conkeror" ()
  (run-shell-command "firefox"))

(define-stumpwm-command "firefox" ()
  (run-shell-command "firefox -chrome chrome://browser/content"))

(define-stumpwm-command "terminal" ()
  (run-shell-command terminal))

(define-stumpwm-command "konqueror" ()
  (run-shell-command "konqueror"))

(define-stumpwm-command "xlock" ()
  (run-shell-command "xlock"))

   (defun cat (&rest strings) "Concatenates strings, like the Unix command 'cat'. A shortcut for 
(concatenate 'string foo bar)."
          (apply 'concatenate 'string strings))

(defun shell-command (command) 
          (check-type command string)
          (echo-string (current-screen) (run-shell-command command t)))
   
 (define-stumpwm-command "shell-command" ((command :string "sh: " :string))
   (check-type command string)
    (shell-command command))
   
 ;;Ask user for a search string and search Google for it.
  (define-stumpwm-command "google" ((search-string :string "google " :string))
    (check-type search-string string)
    (run-shell-command (cat "surfraw google " search-string)))




;;Keybind stuff

(define-key *root-map* (kbd "e") exal-emacs)
(define-key *root-map* (kbd "d") "gmrun")
(define-key *root-map* (kbd "q") "conkeror")
(define-key *root-map* (kbd "y") terminal)
(define-key *root-map* (kbd "g") "google ")
(define-key *root-map* (kbd "p") "shell-command")
(define-key *root-map* (kbd "z") "konqueror")
(define-key *root-map* (kbd "l") "firefox")
(define-key *root-map* (kbd "x") "xlock")


;;; The End