stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] Xmodmap keys


From: Sébastien Vauban
Subject: [STUMP] Xmodmap keys
Date: Wed, 24 Jun 2009 16:34:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.94 (gnu/linux)

Hello,

I am using StumpWM for a couple (more than 2) of months now, with a lot of
delight.

Though, (too) often, I experience the following problem: my `Super_L' key
(code 133) becomes "inactive" (as if I wasn't pressing on it). Horrible when
it happens, as this is my prefix key... My sole solution, in that case, is to
`Alt-Shift-F6' (other terminal), `ps' the X process, and kill it. Results:
I loose every unsaved change, and all applications die the hard way...

Sometimes, it's only my `Caps Lock' key that gets "undefined" (message I see
when in Emacs). Still a trouble, as I use it to switch between French and
British keyboards...

I DON'T SAY that it's StumpWM's fault for these, but I'd like to have hints on
how to debug or avoid this? Any help will be greatly appreciated... as this
renders my system very difficult to use (happening more than once per day)...

FYI, my current `.stumpwmrc' (I've snipped out parts that I really considere
as harmless -- not to bother anyone trying to read it):

--8<---------------cut here---------------start------------->8---
;; .stumpwmrc

(in-package :stumpwm)

(message "Loading rc!")

(run-shell-command "rm .xsession-errors")


;;; --[ Binding Keys

;; launch Emacs
(defcommand emacs () ()  ;! redefining emacs command
  "Start Emacs or switch to it, if it is already running."
  (run-or-raise "emacs" '(:class "Emacs")))

;; launch Web browser
(defcommand firefox () ()
  "Start Firefox or switch to it, if it is already running."
  (run-or-raise "firefox" '(:class "Firefox")))
(define-key *root-map* (kbd "f") "firefox")

;; push the window in the adjacent frame
(define-key *root-map* (kbd "C-Up") "move-window up")
(define-key *root-map* (kbd "C-Left") "move-window left")
(define-key *root-map* (kbd "C-Down") "move-window down")
(define-key *root-map* (kbd "C-Right") "move-window right")


;; --[ Custom Shortcuts

;; keyboard layout (see section "Prefix Key" for keycode 133)
(defvar *keyboard-layout* :qwerty-gb)
(run-shell-command "setxkbmap gb && xmodmap -e 'keycode 133 = F20' -e 'clear 
Lock' -e 'keycode 66 = F19'")

(defcommand toggle-keyboard-layout () ()
  "docstring"
  (ecase *keyboard-layout*
    (:qwerty-gb
     (setf *keyboard-layout* :azerty-fr)
     (run-shell-command "setxkbmap fr && xmodmap -e 'keycode 133 = F20' -e 
'clear Lock' -e 'keycode 66 = F19'")
     (message "Selected keyboard layout: France")
     (run-shell-command "xset led 3"))
    (:azerty-fr
     (setf *keyboard-layout* :qwerty-gb)
     (run-shell-command "setxkbmap gb && xmodmap -e 'keycode 133 = F20' -e 
'clear Lock' -e 'keycode 66 = F19'")
     (message "Selected keyboard layout: United Kingdom")
     (run-shell-command "xset -led 3"))))

(define-key *top-map* (kbd "F19") "toggle-keyboard-layout")


;; --[ Mode-line

;; what will be displayed on the modeline (sort of taskbar) for each screen
;; FIXME `run-shell-command' in mode-line could be the source of StumpWM crashes
(setf *screen-mode-line-format*
      (list '(:eval (run-shell-command "date '+%a %F %R' | tr -d [:cntrl:]" t))
            " - %I - "
            '(:eval (run-shell-command "ifconfig | grep inet | awk '{print $2}' 
| head -1 | tr -d [:cntrl:]" t))
            " [^B%n^b] %W"))

;; turn on the modeline
(if (not (head-mode-line (current-head)))
    (toggle-mode-line (current-screen) (current-head)))


;; --[ Groups

;; create the other groups
(run-commands "gnewbg Other")


;;--[ Interacting With Unix

;; shell program used by `run-shell-command' (`sh' by default, which is *not*
;; `bash')
(setq *shell-program* (stumpwm::getenv "SHELL"))  ; `getenv' is not exported

;; system tray
;; TODO Check if it exists
(run-shell-command "which stalonetray && stalonetray")

;; other programs in the system tray
(run-shell-command "gnome-power-manager")
(run-shell-command "nm-applet --sm-disable")  ; network manager
;; TODO Check if it exists
(run-shell-command "which mail-notification && mail-notification --sm-disable")

(run-shell-command "update-manager")

;; TODO Check if it exists
(run-shell-command "which log-event-notify && log-event-notify")


;; ----[ Debugging StumpWM

;; turn on debugging (look at `.xsession-errors')
(setf stumpwm::*debug-level* 10)  ; get rid of debug by setting level to 0


;; --[ Hooks

;; display the key sequence 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)


;; --[ Prefix Key

;; same as `keycode 133 = F20' in `~/.Xmodmap', `133' (TO BE CHECKED WITH
;; `xev') being the left "Windows" key, aka `Super_L'
(run-shell-command "xmodmap -e 'keycode 133 = F20'" t)

;; change the prefix key
(set-prefix-key (kbd "F20"))

;;; .stumpwmrc ends here
--8<---------------cut here---------------end--------------->8---

Best regards,
  Seb

PS- I am using VirtualBox quite often. Don't know if (but don't think that) it
    could explain problems...

-- 
Sébastien Vauban





reply via email to

[Prev in Thread] Current Thread [Next in Thread]