-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.stumpwmrc
executable file
·161 lines (139 loc) · 6.17 KB
/
.stumpwmrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
; -*- Mode: Lisp; Mode: StumpWM; -*-
; .stumpwmrc
(in-package :stumpwm)
(setq *startup-message* nil)
(setq *startup-mode-line* t)
(loop for file in '("battery" "notifications")
do (load (make-pathname :name file :type "lisp" :directory
'(:relative ".stumpwm.d" "contrib"))))
; --- process management ----------------------------------------
(defun ps-exists (ps)
(let ((f "ps -ef | grep ~S | grep -v -e grep -e stumpish | wc -l"))
(< 0 (parse-integer (run-shell-command (format nil f ps) t)))))
(defun start-uniq-command-ps (command &key options (background t))
(unless (ps-exists command)
(run-shell-command
(concat command " " options " " (when background "&")))))
(defun kill-ps-command (command)
(format nil "kill -TERM `ps -ef | grep ~S | grep -v grep | awk '{print $2}'`"
command))
(defun kill-ps (command)
(run-shell-command (kill-ps-command command)))
; --- stumpwm command definitions -------------------------------
(defmacro def-run-or-raise-command (cmd prop)
(let ((cmd-str (string-downcase (symbol-name cmd))))
`(defcommand ,cmd () ()
(run-or-raise ,cmd-str ,prop))))
(def-run-or-raise-command gnome-terminal '(:class "Gnome-terminal"))
;(def-run-or-raise-command mlterm '(:class "mlterm"))
;(def-run-or-raise-command urxvt '(:class "URxvt"))
(def-run-or-raise-command firefox '(:class "Firefox"))
(def-run-or-raise-command soffice '(:class "soffice"))
(def-run-or-raise-command virtualbox '(:class "VirtualBox"))
(defcommand ps-kill (ps) ((:rest "Process to kill: "))
(kill-ps ps))
(defcommand emacs () ()
(run-or-raise "emacs" '(:class "Emacs")))
(defcommand nm-applet () ()
(start-uniq-command-ps "nm-applet" :options "--sm-disable"))
(defcommand show-battery () ()
(echo-string (current-screen) (run-shell-command "acpi" t)))
(defcommand uptime () ()
(echo-string (current-screen) (run-shell-command "uptime" t)))
(defcommand gnome-panel () ()
(if (ps-exists "gnome-panel")
(progn (kill-ps "gnome-panel")
(sleep 0.3)
(when *startup-mode-line*
(run-shell-command "stumpish mode-line")))
(progn (when (head-mode-line (current-head))
(mode-line))
(run-shell-command "gnome-panel"))))
; --- run commands ---------------------------------------
(run-shell-command "xsetroot -solid black")
(run-shell-command "/opt/atokx3/sample/iiimf_status_hide")
(nm-applet)
(start-uniq-command-ps "gnome-settings-daemon")
(start-uniq-command-ps "gnome-power-manager")
(start-uniq-command-ps "gnome-valume-manager")
(start-uniq-command-ps "update-notifier")
(run-shell-command "~/src/backup/alert.sh")
(emacs)
; --- sudo command definitions --------------------------------
(define-stumpwm-type :password (input prompt)
(let ((history *input-history*)
(arg (argument-pop input))
(fn (symbol-function 'draw-input-bucket)))
(unless arg
(unwind-protect
(setf (symbol-function 'draw-input-bucket)
(lambda (screen prompt input &optional errorp)
(let ((i (copy-structure input)))
(setf (input-line-string i)
(make-string (length (input-line-string i))
:initial-element #\*))
(funcall fn screen prompt i)))
arg (read-one-line (current-screen) prompt))
(setf (symbol-function 'draw-input-bucket) fn
*input-history* history))
arg)))
(defmacro define-sudo-command (name command &key output)
(let ((cmd (gensym)))
`(defcommand ,name (password) ((:password "sudo password: "))
(let ((,cmd (concat "echo '" password "' | sudo -S " ,command)))
,(if output
`(run-prog-collect-output *shell-program* "-c" ,cmd)
`(run-prog *shell-program* :args (list "-c" ,cmd) :wait nil))))))
(define-sudo-command eon
(concat "pon em"
(when (ps-exists "nm-applet")
(concat "&& sudo " (kill-ps-command "nm-applet"))))
:output t)
(define-sudo-command eoff "poff em" :output t)
(define-sudo-command reboot "reboot")
(define-sudo-command shutdown "shutdown -h now")
(define-sudo-command backup "~/src/backup/backup.sh")
(define-sudo-command apache-start "/etc/init.d/apache2 start")
(define-sudo-command apache-stop "/etc/init.d/apache2 stop")
; --- key bindings -----------------------------------------------
(set-prefix-key (kbd "C-,"))
(define-key *root-map* (kbd "s") "colon exec firefox http://")
(define-key *root-map* (kbd "*") "show-battery")
(define-key *root-map* (kbd "w") "windowlist")
(define-key *root-map* (kbd "c") "gnome-terminal")
(define-key *root-map* (kbd "e") "emacs")
(define-key *root-map* (kbd "b") "firefox")
(define-key *root-map* (kbd "C-o") "soffice")
(define-key *root-map* (kbd "v") "virtualbox")
(define-key *root-map* (kbd "P") "gnome-panel")
(define-key *root-map* (kbd "m") "mode-line")
(define-key *root-map* (kbd "N") '*notifications-map*)
(define-key *root-map* (kbd "u") "uptime")
; emacs style
(define-key *root-map* (kbd "0") "remove")
(define-key *root-map* (kbd "1") "only")
(define-key *root-map* (kbd "2") "vsplit")
(define-key *root-map* (kbd "3") "hsplit")
(define-key *input-map* (kbd "C-m") 'input-submit)
(define-key *input-map* (kbd "C-h") 'input-delete-backward-char)
(define-key *input-map* (kbd "M-p") 'input-history-back)
(define-key *input-map* (kbd "M-n") 'input-history-forward)
(define-key *input-map* (kbd "C-i") 'input-complete-forward)
(define-key *resize-map* (kbd "C-m") "exit-iresize")
; --- mode line -------------------------------------------------
(setf *mode-line-screen-position* :top)
(setf *mode-line-frame-position* :top)
(setf *mode-line-border-width* 1)
(setf *mode-line-pad-x* 6)
(setf *mode-line-pad-y* 0)
(setf *mode-line-background-color* "black")
(setf *mode-line-foreground-color* "wheat")
(setf *mode-line-border-color* "dark grey")
(setf *screen-mode-line-format*
(list "^03%N^n "
'(:eval (run-shell-command
"LANG=c; date '+%m/%d(%a)_%H:%M'|tr -d [:cntrl:]" t))
" | %b | %g"))
(when (and *startup-mode-line*
(not (head-mode-line (current-head))))
(mode-line))