summaryrefslogtreecommitdiffhomepage
path: root/init.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-09-02 16:39:38 +0100
committerjao <jao@gnu.org>2022-09-02 16:39:38 +0100
commit6a64ae46206bfcb3fde1780126d59229793fa94c (patch)
tree41c63eed52a01366e4288d85c6f7c14875887b91 /init.el
parent6ce5f612c74f4ab3e64c6d372219b4ee45489104 (diff)
downloadelibs-6a64ae46206bfcb3fde1780126d59229793fa94c.tar.gz
elibs-6a64ae46206bfcb3fde1780126d59229793fa94c.tar.bz2
jao-shell improvements
Diffstat (limited to 'init.el')
-rw-r--r--init.el46
1 files changed, 20 insertions, 26 deletions
diff --git a/init.el b/init.el
index 770688c..ea860aa 100644
--- a/init.el
+++ b/init.el
@@ -167,12 +167,12 @@
(defun jao-bright-up ()
(interactive)
- (jao-shell-string "brightnessctl -q s 5%%+")
+ (jao-shell-exec "brightnessctl -q s 5%%+" t)
(jao-bright-show))
(defun jao-bright-down ()
(interactive)
- (jao-shell-string "brightnessctl -q s 5%%-")
+ (jao-shell-exec "brightnessctl -q s 5%%-" t)
(jao-bright-show))
;;;; keyboard
@@ -467,26 +467,24 @@
(when jao-wayland-enabled
(add-hook 'after-init-hook #'jao-wayland-enable))
-(defun jao-wayland-type (&rest args)
- (apply 'jao-shell-string "wtype" args))
+(defsubst jao-wayland-type (&rest args)
+ (apply #'jao-shell-exec* t "wtype" args))
;;;; river
(defvar jao-river-enabled (jao-shell-running-p "river"))
(defun jao-river-enabled-p () jao-river-enabled)
-(defun jao-river-to-ws (n)
+(defsubst jao-river-to-ws (n)
(jao-wayland-type "-M" "win" (format "%s" n)))
-(defun jao-river-window-list ()
- (let ((json-false nil)
- (json-null nil))
- (json-read-from-string (shell-command-to-string "lswt -j"))))
+(defsubst jao-river-window-list ()
+ (jao-shell-output "lswt -j" (lambda () (let ((json-false nil)) (json-read)))))
(defun jao-river-focused ()
(seq-some (lambda (w) (and (alist-get 'activated w) w))
(jao-river-window-list)))
-(defun jao-river-get-focused-title ()
+(defsubst jao-river-get-focused-title ()
(alist-get 'title (jao-river-focused)))
(defun jao-river-focus-window (title)
@@ -495,13 +493,14 @@
ws)))
(or (alist-get 'activated w)
(seq-some (lambda (_ignored)
- (jao-shell-string "riverctl focus-view next")
+ (jao-shell-exec "riverctl focus-view next" t)
(equal title (jao-river-get-focused-title)))
(and w ws)))))
(defun jao-river-zathura-to-org ()
(let ((title (jao-river-get-focused-title)))
(when (string-match-p "\\.pdf" title)
+ (message "%s" title)
(jao-notify title "Opening ORG counterpart"))
(jao-river-to-ws 1)
(jao-pdf-goto-zathura-org title t)))
@@ -526,8 +525,7 @@
(defun jao-river-restart-i3bar ()
(interactive)
- (when (jao-shell-running-p "i3bar-river")
- (jao-shell-string "killall i3bar-river"))
+ (jao-shell-kill-p "i3bar-river")
(jao-shell-exec "i3bar-river")
(sit-for 0.2)
(jao-tracking-set-log ""))
@@ -556,7 +554,7 @@
(let ((n (file-name-nondirectory file)))
(jao-swaymsg "workspace number 3")
(unless (= 0 (jao-swaymsg (format "[title=\"%s\"] focus" n)))
- (jao-shell-exec (jao-pdf-zathura-open-cmd file page "")))
+ (jao-shell-exec (jao-pdf-zathura-open-cmd file page)))
(when page (sit-for 0.2) (jao-wayland-type (format "%dg" page)))))
(defun jao-sway-set-wallpaper (f)
@@ -618,8 +616,8 @@
(interactive)
(let ((wid (jao-shell-string "xdotool getwindowfocus")))
(if (jao-screensaver-enabled)
- (jao-shell-string "xdg-screensaver suspend" wid)
- (jao-shell-string "xdg-screensaver resume" wid))
+ (jao-shell-exec* "xdg-screensaver" "suspend" wid)
+ (jao-shell-exec* "xdg-screensaver" wid))
(jao-notify (format "Using '%s'"
(jao-shell-string "xdotool getwindownames" wid))
(format "Screensaver %s"
@@ -1869,11 +1867,11 @@
(if (string-blank-p id)
(progn
(when jao-xmonad-enabled
- (jao-shell-exec "xdotool set_destktop 2"))
- (jao-shell-string (jao-pdf-zathura-open-cmd file page " &")))
+ (jao-shell-exec "xdotool set_destktop 2" t))
+ (jao-shell-exec (jao-pdf-zathura-open-cmd file page) t))
(let* ((page (if page (format " && xdotool type %dg" page) ""))
(cmd (format "xdotool windowactivate %s%s" id page)))
- (jao-shell-string cmd)))))
+ (jao-shell-exec cmd t)))))
(defun jao-x11-zathura-goto-org (&optional title no-ask)
(let ((title (or title (jao-shell-string "xdotool"
@@ -2804,9 +2802,7 @@
(defun jao-toggle-nm-applet ()
(interactive)
- (if (jao-shell-running-p "nm-applet")
- (jao-shell-string "killall nm-applet")
- (jao-nm-applet)))
+ (or (jao-shell-kill-p "nm-applet") (jao-nm-applet)))
;;;; enwc
(use-package enwc
@@ -3069,7 +3065,7 @@
(string-to-number level)))))
(defun jao-mixer-set (dev v)
- (jao-shell-string "amixer sset" dev v)
+ (jao-shell-exec* t "amixer" "sset" dev v)
(jao-mixer-get-level dev))
(defun jao-mixer-master-toggle ()
@@ -3096,9 +3092,7 @@
(defun jao-toggle-audio-applet ()
(interactive)
- (if (string-empty-p (jao-shell-string "pidof pasystray"))
- (jao-audio-applet)
- (jao-shell-string "killall pasystray")))
+ (or (jao-shell-kill-p "paystray") (jao-audio-applet)))
(global-set-key (kbd "<f4>") #'jao-toggle-audio-applet)