Created
December 15, 2009 16:59
-
-
Save bavardage/257085 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; kiloseconds.lisp -- Bring Kiloseconds to StumpWM | |
;;; | |
;;; Copyright 2009 Ben Duffield | |
;;; | |
;;; This module is free software; you can redistribute it and/or modify | |
;;; it under the terms of the GNU General Public License as published by | |
;;; the Free Software Foundation; either version 2, or (at your option) | |
;;; any later version. | |
;;; | |
;;; This module is distributed in the hope that it will be useful, | |
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
;;; GNU General Public License for more details. | |
;;; | |
;;; You should have received a copy of the GNU General Public License | |
;;; along with this software; see the file COPYING. If not, write to | |
;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330, | |
;;; Boston, MA 02111-1307 USA | |
;;; USAGE: | |
;;; | |
;;; Put: | |
;;; | |
;;; (load "/path/to/kiloseconds.lisp") | |
;;; | |
;;; In your ~/.stumpwmrc | |
;;; | |
;;; Then you can use "%k" in your mode line format, and call/bind the | |
;;; command ks | |
;;; | |
(in-package :stumpwm) | |
(export '(kiloseconds | |
time-kiloseconds | |
ks)) | |
;; Install formatter | |
(pushnew '(#\k fmt-time-kiloseconds) *screen-mode-line-formatters* :test 'equal) | |
;; ...and the rest | |
(defun kiloseconds () | |
"Returns the number of kiloseconds since the start of the day" | |
(multiple-value-bind (seconds minutes hours) | |
(get-decoded-time) | |
(/ (+ seconds | |
(* minutes 60) | |
(* hours 3600)) | |
1000.0))) | |
(defun time-kiloseconds () | |
"Returns the time in kiloseconds" | |
(format nil "~3$ ks" (kiloseconds))) | |
(defun fmt-time-kiloseconds (ml) | |
(declare (ignore ml)) | |
(time-kiloseconds)) | |
(defcommand ks () () | |
"Displays the time in kiloseconds" | |
(echo (time-kiloseconds))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment