diff --git a/init.el b/init.el index db6e03e..e68ba67 100644 --- a/init.el +++ b/init.el @@ -526,9 +526,9 @@ hydra-ispell/body hydra-toggle/body hydra-zoom/body - hydra-rectangle/body)) - -(use-package db-emacsclient) + hydra-rectangle/body + db/two-monitors-xrandr + db/one-monitor-xrandr)) (use-package hydra :commands (defhydra)) @@ -581,6 +581,10 @@ db/find-parent-task db/ensure-running-clock db/save-current-org-task-to-file + db/org-clock-out + db/org-clock-in-break-task + db/org-clock-in-home-task + db/org-clock-in-work-task endless/org-ispell db/update-org-agenda-files db/org-agenda-list-deadlines diff --git a/site-lisp/db-emacsclient.el b/site-lisp/db-emacsclient.el deleted file mode 100644 index cf19535..0000000 --- a/site-lisp/db-emacsclient.el +++ /dev/null @@ -1,61 +0,0 @@ -;;; db-emacsclient.el --- Execute functions called from emacsclient -*- lexical-binding: t -*- - -;;; Commentary: -;; -;; - -;;; Code: - -(defvar db/emacsclient-map (make-sparse-keymap) - "Keymap used for keys called from emacsclient.") - -(defun db/emacsclient-key (key) - "Run command associated with `KEY' in `db/emacsclient-map'." - (let ((function (lookup-key db/emacsclient-map key))) - (when function (apply function nil)))) - -(define-key db/emacsclient-map "w" - (lambda () - (interactive) - (clock-in-task-by-id org-working-task-id) - ;;; FIXME: duplicate code - (call-process "xrandr" nil nil nil - "--output" "HDMI-3" "--primary" "--right-of" "LVDS-1" "--auto") - (call-process "xkbcomp" nil nil nil - "-I" "$HOME/.local/share/xkb/" - "~/.local/share/xkb/keymap/xkbtest $DISPLAY"))) - -(define-key db/emacsclient-map "2" - (lambda () - (call-process "xrandr" nil nil nil - "--output" "HDMI-3" "--primary" "--right-of" "LVDS-1" "--auto") - (call-process "xkbcomp" nil nil nil - "-I" "$HOME/.local/share/xkb/" - "~/.local/share/xkb/keymap/xkbtest $DISPLAY"))) - -(define-key db/emacsclient-map "o" - #'org-clock-out) - -(define-key db/emacsclient-map "b" - (lambda () - (interactive) - (clock-in-task-by-id org-break-task-id))) - -(define-key db/emacsclient-map "h" - (lambda () - (interactive) - (clock-in-task-by-id org-home-task-id) - ;;; FIXME: duplicate code - (call-process "xrandr" nil nil nil - "--output" "HDMI-3" "--off"))) - -(define-key db/emacsclient-map "1" - (lambda () - (call-process "xrandr" nil nil nil - "--output" "HDMI-3" "--off"))) - -;;; - -(provide 'db-emacsclient) - -;;; db-emacsclient.el ends here diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index e64f086..08a3751 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -302,6 +302,22 @@ In ~%s~: (insert "No running clock") (insert org-clock-heading))))) +(defun db/org-clock-out () + "Clock out current clock." + (org-clock-out)) + +(defun db/org-clock-in-break-task () + "Clock into default break task as given by `org-break-task-id’." + (db/clock-in-task-by-id org-break-task-id)) + +(defun db/org-clock-in-home-task () + "Clock into default home task as given by `org-home-task-id’." + (db/clock-in-task-by-id org-home-task-id)) + +(defun db/org-clock-in-work-task () + "Clock into default work task as given by `org-work-task-id’." + (db/clock-in-task-by-id org-working-task-id)) + ;;; Fixes diff --git a/site-lisp/db-utils.el b/site-lisp/db-utils.el index 0452ee9..8b60b53 100644 --- a/site-lisp/db-utils.el +++ b/site-lisp/db-utils.el @@ -495,6 +495,19 @@ _h_ _l_ _o_k _y_ank ("e" rectangle-exchange-point-and-mark nil) ("o" nil nil)) + +;;; Wrappers for external applications + +(defun db/two-monitors-xrandr () + "Activate second monitor using xrandr." + (call-process "xrandr" nil nil nil + "--output" "HDMI-3" "--primary" "--right-of" "LVDS-1" "--auto")) + +(defun db/one-monitor-xrandr () + "Deactivate all additional monitors." + (call-process "xrandr" nil nil nil + "--output" "HDMI-3" "--off")) + ;;; End