summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2022-08-27 03:28:52 +0100
committerjao <jao@gnu.org>2022-08-27 03:28:52 +0100
commit5718c83892fe4989712d362ecf653fb7926d7985 (patch)
treedc89315608ee445d3fb7b404c35816142c2a47a6
parent87ea96e50e2552cd94638b973167e9afc911d371 (diff)
downloadelibs-5718c83892fe4989712d362ecf653fb7926d7985.tar.gz
elibs-5718c83892fe4989712d362ecf653fb7926d7985.tar.bz2
sway init code recovered
-rw-r--r--init.el49
1 files changed, 48 insertions, 1 deletions
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/")