From 5718c83892fe4989712d362ecf653fb7926d7985 Mon Sep 17 00:00:00 2001 From: jao Date: Sat, 27 Aug 2022 03:28:52 +0100 Subject: sway init code recovered --- init.el | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/init.el b/init.el index 302d40e..41a1fed 100644 --- a/init.el +++ b/init.el @@ -443,7 +443,54 @@ (add-hook 'after-init-hook #'jao-xmonad-enable t)) ;;;; sway -(defvar jao-sway-enabled nil) +(defun jao-swaymsg (msg) + (shell-command (format "swaymsg '%s' >/dev/null" msg))) + +(defmacro jao-def-swaymsg (name msg) + `(defun ,(intern (format "jao-sway-%s" name)) () + (interactive) + (jao-swaymsg ,msg))) +(jao-def-swaymsg firefox "[app_id=firefox] focus") + +(defvar jao-sway-enabled + (and (eq window-system 'pgtk) (not jao-xmonad-enabled))) + +(defun jao-sway-set-wallpaper (f) + (jao-swaymsg (format "output * bg %s fill" f)) + (make-symbolic-link f "~/.wallpaper.sway" t)) + +(defun jao-sway-run-or-focus (cmd &optional ws) + (if (jao-shell-running-p "firefox") + (jao-swaymsg (format "[app_id=%s] focus" cmd)) + (jao-swaymsg (format "workspace %s" (or ws 2))) + (start-process-shell-command cmd nil cmd))) + +(defun jao-sway-run-or-focus-tidal () + (interactive) + (if (jao-shell-running-p "tidal-hifi") + (jao-swaymsg "[app_id=tidal-hifi] scratchpad show") + (start-process-shell-command "tidal-hifi" nil "tidal-hifi &") + (jao-sway-run-or-focus-tidal))) + +(defun jao-sway-run-or-focus-firefox () + (interactive) + (jao-sway-run-or-focus "firefox")) + +(defun jao-sway-enable () + (setq jao-browse-doc-use-emacs-p t) + (setq jao-wallpaper-random-wake nil) + (jao-trisect) + (jao-set-transparency 85) + (jao-themes-setup) + (xmobar-mode) + (global-set-key (kbd "s-f") #'jao-sway-run-or-focus-firefox) + (defalias 'jao-streaming-list #'jao-sway-run-or-focus-tidal) + (message "Welcome to sway")) + +(when jao-sway-enabled + (defalias 'x-change-window-property #'ignore) + (add-hook 'after-init-hook #'jao-sway-enable)) + ;;;; wallpaper (defvar jao-wallpaper-dir "~/.wallpapers/") -- cgit v1.2.3