summaryrefslogtreecommitdiffstats
path: root/.emacs.d
diff options
context:
space:
mode:
authorAmin Bandali <bandali@kelar.org>2024-04-01 15:21:11 -0400
committerAmin Bandali <bandali@kelar.org>2024-04-01 15:21:11 -0400
commit22a270eba9568af1394a46429f1a379200496cf9 (patch)
tree03a1de7c3719fa58c1c6c3fbefe77a94014592e1 /.emacs.d
parent1d18d65c2b6260f6e58d1cdf974ccb13d59cbf9d (diff)
downloadconfigs-22a270eba9568af1394a46429f1a379200496cf9.tar.gz
configs-22a270eba9568af1394a46429f1a379200496cf9.tar.xz
configs-22a270eba9568af1394a46429f1a379200496cf9.zip
Break pulse volume code out of bar and into its own script
In part so that it could easily be used in Emacs as well. Also rename pacify-pulseaudio to b-pacify (as in PAcify).
Diffstat (limited to '.emacs.d')
-rw-r--r--.emacs.d/init.el113
1 files changed, 10 insertions, 103 deletions
diff --git a/.emacs.d/init.el b/.emacs.d/init.el
index 9286e0c..f4bb031 100644
--- a/.emacs.d/init.el
+++ b/.emacs.d/init.el
@@ -219,66 +219,16 @@ plain variables. This means that `setopt' will execute any
(setopt battery-mode-line-format " [%b%p%% %t]")
(display-battery-mode))
-(progn ; display system volume in mode-line
- (defvar b/volume-level 0)
- (defvar b/volume-mute nil)
- (defvar b/volume-level-mic 0)
- (defvar b/volume-mute-mic nil)
-
- (defun b/volume-get (&optional use-default-source)
- "Get the default sink volume and mute state.
-If USE-DEFAULT-SOURCE is non-nill, use the default source (e.g. a
-microphone) instead of the default sink."
- (pcase (split-string ; expecting: <mute> <volume> (e.g. true 15)
- (string-trim
- (shell-command-to-string
- (mapconcat
- #'identity
- `("pamixer"
- ,(when use-default-source "--default-source")
- "--get-volume"
- "--get-mute")
- " "))))
- (`(,m ,v)
- (let ((mute (string= "true" m))
- (volume (string-to-number v)))
- `(,mute ,volume)))))
-
- (defun b/volume-update ()
- "Update system sound volume as displayed in mode-line."
- (let ((changed))
- (pcase (b/volume-get)
- (`(,mute ,volume)
- (unless (eq mute b/volume-mute)
- (setq b/volume-mute mute
- changed t))
- (unless (= volume b/volume-level)
- (setq b/volume-level volume
- changed t))))
- (pcase (b/volume-get 'mic)
- (`(,mute ,volume)
- (unless (eq mute b/volume-mute-mic)
- (setq b/volume-mute-mic mute
- changed t))
- (unless (= volume b/volume-level-mic)
- (setq b/volume-level-mic volume
- changed t))))
- (when changed
- (force-mode-line-update))))
-
- (defvar b/volume-timer (run-at-time nil 5 #'b/volume-update))
-
- (setq-default
+(progn ; display system volume and mute states in mode-line
+ (defsubst b/pavols ()
+ "Get volume and mute state of default pulseaudio sink and source."
+ ;; <sink_volume><sink_unmuted>,<source_volume><source_unmuted>
+ ;; e.g. 46+,89-
+ (string-trim (shell-command-to-string "b-pavols")))
+ (setopt
mode-line-format
- (append
- mode-line-format
- '((:eval
- (format
- " [%s%%%%%s %s%%%%%s]"
- (number-to-string b/volume-level)
- (if b/volume-mute "-" "+")
- (number-to-string b/volume-level-mic)
- (if b/volume-mute-mic "-" "+")))))))
+ `(,@mode-line-format
+ (:eval (format " [%s]" (b/pavols))))))
;; (with-eval-after-load 'fringe
;; ;; smaller fringe
@@ -502,42 +452,6 @@ for all frames."
(completing-read "Find recent file: " recentf-list)))
(b/keymap-global-set "C-c f r" #'b/recentf-open))
-;; (define-key minibuffer-local-completion-map
-;; "\t" #'minibuffer-force-complete)
-
-;; (with-eval-after-load 'icomplete
-
-;; (setq icomplete-on-del-error-function #'abort-recursive-edit)
-
-;; (defun b/icomplete-fido-backward-updir ()
-;; "Delete char before or go up directory, like `ido-mode'."
-;; (interactive)
-;; (if (and (eq (char-before) ?/)
-;; (eq (icomplete--category) 'file))
-;; (save-excursion
-;; (goto-char (1- (point)))
-;; (when (search-backward "/" (point-min) t)
-;; (delete-region (1+ (point)) (point-max))))
-;; (condition-case nil
-;; (call-interactively #'delete-backward-char)
-;; (error
-;; (when icomplete-on-del-error-function
-;; (funcall icomplete-on-del-error-function))))))
-
-;; (define-key icomplete-fido-mode-map
-;; (kbd "DEL") #'b/icomplete-fido-backward-updir))
-
-;; (fido-mode 1)
-;; (defun b/icomplete--fido-mode-setup ()
-;; "Customizations to `fido-mode''s minibuffer."
-;; (when (and icomplete-mode (icomplete-simple-completing-p))
-;; (setq-local
-;; ;; icomplete-compute-delay 0.1
-;; ;; icomplete-hide-common-prefix t
-;; icomplete-separator " ยท "
-;; completion-styles '(basic substring partial-completion flex))))
-;; (add-hook 'minibuffer-setup-hook #'b/icomplete--fido-mode-setup 1)
-
(with-eval-after-load 'eshell
(setopt
eshell-hist-ignoredups t
@@ -702,13 +616,6 @@ for all frames."
(b/keymap-set m "b" #'help-go-back)
(b/keymap-set m "f" #'help-go-forward)))
-(with-eval-after-load 'tramp
- (setopt tramp-auto-save-directory (b/emacs.d "tramp-auto-save/"))
- (add-to-list 'tramp-default-proxies-alist '(nil "\\`root\\'" "/ssh:%h:"))
- (add-to-list 'tramp-default-proxies-alist '("localhost" nil nil))
- (add-to-list 'tramp-default-proxies-alist
- (list (regexp-quote (system-name)) nil nil)))
-
(with-eval-after-load 'doc-view
(b/keymap-set doc-view-mode-map "M-RET" #'image-previous-line))
@@ -1121,7 +1028,7 @@ for all frames."
(setopt
message-elide-ellipsis "[...]\n"
- message-citation-line-format "%N writes:\n"
+ message-citation-line-format "%N wrote:\n"
message-citation-line-function
#'message-insert-formatted-citation-line
message-confirm-send t