From 5d24a2dfd77df9238b2f11f17368e66f1475f0de Mon Sep 17 00:00:00 2001 From: Almarhoon Ibraheem Date: Wed, 26 Jun 2024 19:01:58 +0300 Subject: [PATCH] rename project to guile-swayer --- README.org | 24 ++++---- examples/playground/example.scm | 93 ++++++++++++++++++++---------- examples/stumpwm-inspired/config | 2 +- examples/stumpwm-inspired/init.scm | 4 +- 4 files changed, 77 insertions(+), 46 deletions(-) diff --git a/README.org b/README.org index 45710d8..c0defc0 100644 --- a/README.org +++ b/README.org @@ -1,7 +1,7 @@ #+STARTUP: inlineimages #+OPTIONS: toc:3 ^:nil -** SWAYIPC +** Guile Swayer I am an =Emacs= user and previously used =StumpWM=, an =X11= window manager written in =Common Lisp=. I believe window managers should be scriptable because the level of workflow customization required by users often exceeds what can be achieved with simple configuration parameters (see my workflow below for a clearer understanding of why this is the case). Unfortunately, =Sway/i3= lacks a straightforward programmable interface for customization. This project provides complete control over =Sway/i3= using =Guile=! @@ -96,7 +96,7 @@ You can assign keybindings that execute Guile code! Obviously, running shell com *** Subscribe to Events -Certain scenarios necessitate subscribing to events. One example from my =workflow= described below requires this capability. With =swayipc=, you have the ability to listen for events and execute actions in response. +Certain scenarios necessitate subscribing to events. One example from my =workflow= described below requires this capability. With =guile-swayer=, you have the ability to listen for events and execute actions in response. #+begin_src scheme ;; subscribe to events @@ -133,15 +133,15 @@ It's important to know where you clone the repo as you will have to reference it **** Root Directory -|------------+-----------------------------------------------------------------| -| File | Description | -|------------+-----------------------------------------------------------------| -| examples | Examples of configurations the you can refer to for inspiration | -| modules | Directory containing modules for extending Sway using =swayipc=. | -| sjson | A patched version of =guile-json= (temporarily). | -| swayipc | Directory containing the core code for =swayipc=. | -| README.org | This readme file | -|------------+-----------------------------------------------------------------| +|------------+---------------------------------------------------------------------| +| File | Description | +|------------+---------------------------------------------------------------------| +| examples | Examples of configurations the you can refer to for inspiration | +| modules | Directory containing modules for extending Sway using =guile-swayer=. | +| sjson | A patched version of =guile-json= (temporarily). | +| swayipc | Directory containing the core code for =swayipc=. | +| README.org | This readme file | +|------------+---------------------------------------------------------------------| **** swayipc Directory |------------+-----------------------------------------------------------------------------| @@ -178,7 +178,7 @@ exec_always "pkill -f '.*guile.*sway/init.scm'" exec_always "sleep 0.5 && ~/.config/sway/init.scm" #+end_src -2- I plan to publish a module for =swayipc=, it's currently not hosted anywhere. You'll need to add the module to your =load path=. Additionally, =swayipc= includes another patched Guile library called =guile-json=, which is embedded for now. In the future, this will be included as a separate dependency rather than embedded. +2- I plan to publish a module for =guile-swayer=, it's currently not hosted anywhere. You'll need to add the module to your =load path=. Additionally, =swayipc= includes another patched Guile library called =guile-json=, which is embedded for now. In the future, this will be included as a separate dependency rather than embedded. #+begin_src scheme (add-to-load-path diff --git a/examples/playground/example.scm b/examples/playground/example.scm index ebe3d1a..ee7ff20 100755 --- a/examples/playground/example.scm +++ b/examples/playground/example.scm @@ -13,7 +13,7 @@ (add-to-load-path path)) ;; you can simply uncomment the above section and hardcode the path as below -;; (add-to-load-path "/home/YOUR_USER_HERE/git/swayipc") +;; (add-to-load-path "/home/YOUR_USER_HERE/git/guile-swayer") ;; if you would like to be relative to home, do as below ;; (string-append (getenv "HOME") "/.config/sway/init.scm") @@ -22,41 +22,72 @@ (srfi srfi-18) (modules workspace-groups) (modules workspace-grid) - (swayipc connection) - (swayipc records) - (swayipc info) - (swayipc events) - (swayipc dispatcher)) + (ice-9 pretty-print) + (swayipc)) -;; get focused workspace from a list of workspaces -(define (focused-workspace-name workspaces) - (cond - ((null? workspaces) #f) - ((equal? #t (sway-workspace-focused (car workspaces))) - (sway-workspace-name (car workspaces))) - (else (focused-workspace-name (cdr workspaces))))) - -(format #t "output record from function #sway-get-workspaces:\n ~a\n" - (sway-get-workspaces)) - -(format #t "current focused workspace is [~a]\n" - (focused-workspace-name (sway-get-workspaces))) - -;; assign simple keybindings -;; refer to the module modules/general.scm for easier interface -(sway-bindsym "Mod4+t" "exec alacritty") - -;; subscribe to events -(define (workspace-changed workspace-event) - (let* ((current-tree (sway-workspace-event-current workspace-event)) - (workspace (sway-tree-name current-tree))) - - (format #t "workspace changed to ~a!\n" workspace))) - ;; subscribe to all events (sway-subscribe-all) +(define (workspace-changed event) + (display "workspace-changed\n") + (pretty-print event)) + (add-hook! sway-workspace-hook workspace-changed) + +(define (output-changed event) + (display "output-changed\n") + (pretty-print event)) + +(add-hook! sway-output-hook output-changed) + +(define (mode-changed event) + (display "mode-changed\n") + (pretty-print event)) + +(add-hook! sway-mode-hook mode-changed) + +(define (window-changed event) + (display "window-changed\n") + (pretty-print event)) + +(add-hook! sway-window-hook window-changed) + +(define (binding-changed event) + (display "binding-changed\n") + (pretty-print event)) + +(add-hook! sway-binding-hook binding-changed) + +(define (bar-config-changed event) + (display "bar-config-changed\n") + (pretty-print event)) + +(add-hook! sway-bar-config-hook bar-config-changed) + +(define (shutdown-changed event) + (display "shutdown-changed\n") + (pretty-print event)) + +(add-hook! sway-shutdown-hook shutdown-changed) + +(define (tick-changed event) + (display "tick-changed\n") + (pretty-print event)) + +(add-hook! sway-tick-hook tick-changed) + +(define (bar-state-update-changed event) + (display "bar-state-update-changed\n") + (pretty-print event)) + +(add-hook! sway-bar-state-update-hook bar-state-update-changed) + +(define (input-changed event) + (display "input-changed\n") + (pretty-print event)) + +(add-hook! sway-input-hook input-changed) + (sway-start-event-listener-thread) (thread-join! SWAY-LISTENER-THREAD) diff --git a/examples/stumpwm-inspired/config b/examples/stumpwm-inspired/config index 1c7a8b7..e6f71f0 100644 --- a/examples/stumpwm-inspired/config +++ b/examples/stumpwm-inspired/config @@ -1,6 +1,6 @@ include /etc/sway/config.d/* -# good idea to kill all current guile swayipc instances first +# good idea to kill all current guile guile-swayer instances first exec_always "pkill -f '.*guile.*sway/init.scm'" # then run a fresh instance diff --git a/examples/stumpwm-inspired/init.scm b/examples/stumpwm-inspired/init.scm index 4a93236..5c79cca 100755 --- a/examples/stumpwm-inspired/init.scm +++ b/examples/stumpwm-inspired/init.scm @@ -3,7 +3,7 @@ ;; assuming your are running from a path relative to swaypic & modules ;; you can hardcode the load path here if that assumption isn't valid. -;; you have to add to load path the directory the contains modules and swayipc +;; you have to add to load path the directory the contains modules and guile-swayer ;; these 2 directories exist in the root directory of the repostiry and are ;; supposed to be 2 parent levels away from this init file. (let ((path (dirname @@ -13,7 +13,7 @@ (add-to-load-path path)) ;; you can simply uncomment the above section and hardcode the path as below -;; (add-to-load-path "/home/YOUR_USER_HERE/git/swayipc") +;; (add-to-load-path "/home/YOUR_USER_HERE/git/guile-swayer") ;; if you would like to be relative to home, do as below ;; (string-append (getenv "HOME") "/.config/sway/init.scm")