Mnemovore

Posts Tagged ‘window manager

Updating stumpwmrc

leave a comment »

Posting the stumpwm configuration that I’m using for about a year now. It’s located also in the downloads section. My only task now is to find a way to use the conky configuration i have in musca along with the modeline to get rid some of its weird bugs.

;;Aperturefever/gammalyrae stump config
;;;;;;;;;;;;
;;  Misc  ;;
;;;;;;;;;;;;

(in-package :stumpwm)

(setf *default-package* :stumpwm)

;(set-font "-xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-7")
(set-font "-xos4-terminus-medium-r-normal--0-0-72-72-c-0-iso8859-7")
;(set-font "-*-dina-medium-r-normal-*-*-*-*-*-*-*-*-*")
;(set-font "-lispm-fixed-medium-r-normal-*-13-*-*-*-*-*-*-*")
;(set-font "-artwiz-smoothansi-medium-r-normal--13-130-75-75-m-60-iso8859-1")

;; Set up X cursor and colors.
(stumpwm:run-shell-command "xsetroot -cursor_name left_ptr -fg  white  -bg black")
;(stumpwm:run-shell-command "setxkbmap dvorak && xmodmap -e \'keycode 115 = F20\'")
;(stumpwm:run-shell-command "stumpbar")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;   Lisp monitoring Scripts   ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(load "/home/shevek/progs/stumpwm/contrib/battery.lisp")
(load "/home/shevek/progs/stumpwm/contrib/cpu.lisp")
(load "/home/shevek/progs/stumpwm/contrib/net.lisp")
(load "/home/shevek/progs/stumpwm/contrib/mem.lisp")
;(load "/home/shevek/progs/stumpwm/contrib/wifi.lisp")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;        Eye Candy         ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;; STARTUP MESSAGE

(setf *startup-message* nil)
(setf *startup-message* " ^2 ^b Hello George!^B Welcome to Stumpwm!^b ~& ^n Don't forget to check your ^8* TODO ^n list!!")

;;;; EXEC INPUT BAR NAMING

(defcommand my-shell-command (command) ((:string "sh$ "))
(check-type command string)
(shell-command command))

;;;; FRAMENUMBERING - check keybindings george---notifier

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

;;;; MESSAGE WINDOW

(set-bg-color "grey20")
;(set-fg-color "#97b26b")
;(set-fg-color "#20CBFE")
(set-fg-color "#a1b5cd")
;(set-fg-color "orange")
(set-border-color "grey10")
(set-msg-border-width 1)

(setf *message-window-gravity* :top-right
*timeout-wait*           6
*input-window-gravity*   :bottom-right)

;;;; SET THE TWO REMAINING COLOR SLOTS

(setf *colors* (append *colors*
(list "cyan" ;;"lightskyblue"
"coral")))
(update-color-map (current-screen))

;;;; MODE-LINE

(setf *mode-line-background-color* "grey20"
*mode-line-foreground-color* "#a1b5cd"
*mode-line-border-color*  "grey10"
*mode-line-border-width* 1
*mode-line-timeout*       5
*mode-line-position* :top
;*window-format* "< %n%s%m%30t >"
*window-format* "^B%m%n^b %15t"
*group-format*  "^8*%t%s  "

*screen-mode-line-format*
(list "^6*::^n  %g  ^6*::^n%w^6* :: ^8*CPU: ^n%f %C ^3*%t ^6*:: ^n^r%M ^6*:: ^n%b ^6*:: ^n %l ^6*::^8* - "
'(:eval (run-shell-command "date +\"%T %d-%m-%Y\" | tr -d '[:cntrl:]'" t))))

;; turn on/off the mode line for the current screen only.
(enable-mode-line (current-screen) (current-head) t)

;;;; WINDOWS
(setf *maxsize-border-width* 3)
(set-frame-outline-width 1)
(set-focus-color   "dimgray")
(set-unfocus-color "grey10")
(set-normal-gravity :center)
(setf *normal-border-width* 3)
(setf *window-border-style* :thin)  ; thick,thin,none,tight

;;;; Display Keybinding - My version...

(defun key-press-hook (key key-seq cmd)
(declare (ignore key))
(unless (eq *top-map* *resize-map*)
(let ((*message-window-gravity* :bottom-right))
(message "Key sequence: ~A - "
(print-key-seq (reverse key-seq)) cmd))))

;; Give 'em time to read it.
(sleep 0.5)

(defmacro replace-hook (hook fn)
`(remove-hook ,hook ,fn)
`(add-hook ,hook ,fn))

(replace-hook *key-press-hook* 'key-press-hook)

;;;; Code by Male ---- Original...
;;;; Display the keysequence in progress
;;(defun key-press-hook (key key-seq cmd)
;;  (declare (ignore key))
;;  (unless (eq *top-map* *resize-map*)
;;    (let ((*message-window-gravity* :bottom-right))
;;      (message "Key sequence: ~A" (print-key-seq (reverse key-seq))))
;;    (when (stringp cmd)
;;      ;; Give 'em time to read it.
;;      (sleep 0.5))))

;;(defmacro replace-hook (hook fn)
;; `(remove-hook ,hook ,fn)
;; `(add-hook ,hook ,fn))

;;(replace-hook *key-press-hook* 'key-press-hook)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;       Keybindings      ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; change the prefix key to something else
(run-shell-command "xmodmap -e \'keycode 133 = F20\'" t)
(set-prefix-key (kbd "F20"))

(message "Loading stumpwmrc..")

(define-key *root-map* (kbd "Return") "exec urxvt")
(define-key *root-map* (kbd "b") "exec firefox")
(define-key *root-map* (kbd "a") "exec vup")
(define-key *root-map* (kbd "z") "exec vdown")
(define-key *root-map* (kbd "x") "exec vmute")
(define-key *root-map* (kbd "quoteleft") "gnext")
(define-key *root-map* (kbd "w") "windowlist")
(define-key *root-map* (kbd "M-g") "google")
(define-key *root-map* (kbd "M-w") "wikipedia")
(define-key *root-map* (kbd "M-i") "imdb")
;; Dirty ;(define-key *root-map*  (kbd "M-9") "exec setxkbmap us && xmodmap -e 'keycode 115 = F20' -e 'clear Lock'")
;; Dirty ;(define-key *root-map*  (kbd "M-0") "exec setxkbmap dvorak && xmodmap -e 'keycode 115 = F20' -e 'clear Lock'")
(define-key *root-map* (kbd "M-a") "exec qiv /mnt/mercury/dvorak.gif")
(define-key *root-map* (kbd "M-x") "exec ratmenu")
(define-key *root-map* (kbd "m") "fclear")

;(define-key *root-map* (kbd "1") "fselect 1")
;(define-key *root-map* (kbd "2") "fselect 2")
;(define-key *root-map* (kbd "3") "fselect 3")
;(define-key *root-map* (kbd "4") "fselect 4")
;(define-key *root-map* (kbd "5") "fselect 5")
;(define-key *root-map* (kbd "6") "fselect 6")
;(define-key *root-map* (kbd "7") "fselect 7")
;(define-key *root-map* (kbd "8") "fselect 8")
;(define-key *root-map* (kbd "9") "fselect 9")
;(define-key *root-map* (kbd "0") "fselect 0")

;;;;;;;;;;;;;;;;;;
;;    Groups    ;;
;;;;;;;;;;;;;;;;;;

;; Rename the first group to Main
(setf (group-name (first (screen-groups (current-screen)))) "Main")
;; Create the other groups.
(run-commands "gnewbg www" "gnewbg devel" "gnewbg media" "gnewbg chat")
;;;;;;;;;;;;;;;;;;;;;;;
;;  Custom Commands  ;;
;;;;;;;;;;;;;;;;;;;;;;;

(defun shell-command (command)
"Stumpwm might hang here :/"
(check-type command string)
(echo-string (current-screen) (run-shell-command command t)))

(defcommand weatherget () ()
"Display weather info in Greece."
(shell-command "weatherget -s GRXX0004 --metric"))

(defcommand dfh () ()
"Disk"
(shell-command "df -h"))

(defcommand moon () ()
"Moon Info"
(shell-command "less ~/sources/stumpwm/astroinfo/moon"))

(defcommand mocpinfo () ()
"MOC info"
(shell-command "mocpinfo"))

(defcommand mocosd () ()
"MOC info"
(shell-command "mocosd"))

(defcommand monitoroff () ()
"Monitor Off"
(shell-command "sleep 1 && xset dpms force off"))

(defcommand dmenu () ()
(run-shell-command "dmenu_run -nb grey20 -nf orange -fn '-windows-dina-medium-r-normal--13-80-96-96-c-70-microsoft-cp1252'"))
(define-key *root-map* (kbd "[") "dmenu")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;    Web jump (works for Google, Wikipedia and Imdb)    ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defmacro make-web-jump (name url-prefix)
`(defcommand ,name (search) ((:rest ,(string-capitalize (string-downcase (concatenate 'string (symbol-name name) ": ")))))
(run-shell-command (format nil "firefox '~A=~A'"
,url-prefix (substitute #\+ #\Space search)))))

(make-web-jump imdb "http://www.imdb.com/find?q")
(make-web-jump google "http://www.google.com/search?q")
(make-web-jump wikipedia "http://en.wikipedia.org/wiki/Special:Search?search")

;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  Qwerty - Dvorak  ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;

;; keyboard layout
(defvar *keyboard-layout* :qwerty)
;(run-shell-command "setxkbmap us")
;(run-shell-command "xmodmap -e \'clear Lock\' && xmodmap -e \'keycode 66 = Tab\'")

(defcommand toggle-keyboard-layout () ()
(cond ((eq *keyboard-layout* :qwerty)
(setf *keyboard-layout* :dvorak)
(message "^7* Selected keyboard layout:^2* Dvorak")
(run-shell-command "xmodmap ~/.Xmodmap && setxkbmap dvorak"))
((eq *keyboard-layout* :dvorak)
(setf *keyboard-layout* :qwerty)
(message "^7* Selected keyboard layout:^3* Qwerty")
(run-shell-command "xmodmap ~/.Xmodmap && setxkbmap us"))))

(define-key *root-map* (kbd "F12") "toggle-keyboard-layout")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;   Some mousey stuff    ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(setf *mouse-focus-policy* :click) ;; :click, :ignore, :sloppy

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Astro info and calculations ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;   Some Startup progies   ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defcommand firefox () ()
"run firefox"
(run-or-raise "firefox" '(:class "Firefox")))

(defcommand dolphin () ()
"run firefox"
(run-or-raise "dolphin" '(:class "dolphin")))

(defcommand amarok () ()
"run firefox"
(run-or-raise "amarok" '(:class "Amarok")))

(defcommand pidgin () ()
"run firefox"
(run-or-raise "pidgin" '(:class "Pidgin")))

(defcommand Urxvt () ()
"run an urxvt instance"
(run-or-raise "xterm -name Urxvt" '(:instance "Urxvt")))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;  Window placement rules  ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; Clear rules
(clear-window-placement-rules)

(define-frame-preference "Main"
;; frame raise lock (lock AND raise == jumpto)
(0 t   t :class "Urxvt"))

(define-frame-preference "media"
;; frame raise lock (lock AND raise == jumpto)
(0 t   t :class "dolphin"))

(define-frame-preference "media"
;; frame raise lock (lock AND raise == jumpto)
(0 t   t :class "Amarok"))

(define-frame-preference "www"
;; frame raise lock (lock AND raise == jumpto)
(0 t   t :class "Firefox"))

(define-frame-preference "chat"
;; frame raise lock (lock AND raise == jumpto)
(0 t   t :class "Pidgin"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;   Random Background   ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;(defvar *background-image-path* "/mnt/mercury/Images/EyeStrain")
;(defun select-random-background-image ()
;  "Select a random image"
;  (let ((file-list (directory (concatenate 'string *background-image-path* "*.jpg")))
;        (*random-state* (make-random-state t)))
;    (namestring (nth (random (length file-list)) file-list))))
;
;(run-shell-command (concatenate 'string "display -window root " (select-random-background-image)))

;;;;;;;;;;;;;;;;;;;;;;
;;;  Show me Info  ;;;
;;;;;;;;;;;;;;;;;;;;;;

(setf *debug-level* 10)

I will also post some calculations to be placed in it for quick reference(probably bind it in a command or sth). E.g. calculating how fast does a comet or an asteroid move using a formula like this: 2 * pi * sqrt(2/r – (1-e)/q) AU/year, maybe formulas to convert right ascension and declination to altitude and azimuth and a way to easily find my current longitude and latitude.

Written by aperturefever

May 10, 2010 at 10:55 am

Musca/dzen2 tips and tricks – Part 1

leave a comment »

So you decided to give musca a go. Here are some stuff i use in my setup. I hope someone out there finds these useful.

One thing that musca lacks is a toolbar, but as the author suggests, dzen2 is a nice alternative. And guess what, he’s right.
dzen2 is so customizable that you ‘re to able to do nice magic with it. For example:

Why open a terminal to find your disk space or waste useful resources to have it displayed on conky?
Add sth like that in your .musca_start and you ll be able to call a new command named dfh to watch your disk space status.

alias dfh exec (echo Disk Usage; df -h ; sleep 4) | dzen2 -l 17 -fg white -bg grey10 -w 400 -fn '-*-dina-medium-r-normal-*-*-*-*-*-*-*-*-*' -e 'onstart=uncollapse' 

Weather conditions are vital for astro-sessions so having some extra info is practical too
e.g. for Greece using the weatherget application i have sth like this:

alias weatherget exec (echo Weather Report; weatherget -s GRXX0004 --metric ; sleep 4) | dzen2 -l 17 -fg white -bg grey10 -w 400 -fn '-*-dina-medium-r-normal-*-*-*-*-*-*-*-*-*' -e 'onstart=uncollapse'

At the time setting rules is not ready in musca. But guess what! Musca is so groovy that you can actually “emulate” such configuration. Example.. I want to have gimp start in stacked mode or in a preconfigured tiled layout.

alias g1mp exec gimp
hook on ^g1mp stack on

or
if gimpfoo is a layout that suits your tastes for gimp window placement

hook on ^g1mp load gimpfoo

So when pressing Mod+m and typing g1mp you’ll have gimp in stacked mode 😀

to be continued! 😀

Written by aperturefever

June 8, 2009 at 7:23 pm

Musca – A new tiling window manager

with 6 comments

Searching for something in freshmeat a couple of days ago, i stumbled upon a small tiling window manager named Musca. You’ll say “What? Another one? For what reason?”. Hey! Why not? Well we all know that the 3 kings are ratpoison, dwm and ion. All features that were first introduced by them made tiling window management what it is today. Now take all the features that you actually liked in all of them and implement them in something new. The result is Musca. Musca is a tiling window manager that is written from scratch in C and has many features including:

  • Extremely small (binary is 97Kb and zipped package 37Kb), light and elegant
  • Simple configuration via config.h (Yes it needs recompiling)
  • Manual window tiling, that means no restrictions on layout setups
  • Group management support, that means no pesky tagging but actual groups
  • Simple mouse tasking, following click to focus philosophy
  • Frame management is followed by color indication so you actually know in what mode your frames are.(ie the catch-all mode that forces all windows opened in a specific frame is green)
  • Musca has multiscreen support out of the box and can manage groups to screens automatically
  • Uses dmenu as requirement for windows,groups and wm management
  • No obstructive status bars, panels, and such but you can use one if you like (e.g. trayer,dzen2 etc)
  • It is named after a star constellation…Yes that’s a plus. 😀
  • A nice feature called unmanaged_windows ( remember remember 😀 ). That let’s you make musca ignore windows and not assign them in frames. 😉

I really like Musca. Its light, small and configurable. Its still in devel state but its very usable and i have put aside stumpwm for now.  I had all my key bindings configured in seconds and Musca’s engine/group management philosophy was like second nature since, i use ratpoison and stumpwm. 🙂

Musca is actively developed and created by Sean Pringle. His website can be found here where he hosts his projects and other fun stuff.

UPDATE: New version of Musca, as of 9th March, is out with a *TON* of features that simplifies a lot of stuff including

  • floating support (via stack Musca command)
  • Added new commands!
  • Layout saving..thats means ENDLESS CAPABILITIES!!
  • Musca now has an external command interface for client management
  • Now you can undo layouts 😀 No more accidental layout windows
  • External startup configuration file to configure your window manager
  • Its getting better and better each day!! 😀

UPDATE:  The post is a bit old of course. Musca is more mature now and has even more features 😀

A pic of musca running on my Slackware 12.2 Laptop

2009-03-09-190658_1280x800_scrot1

Written by aperturefever

March 7, 2009 at 11:53 am