rename project to guile-swayer

This commit is contained in:
Almarhoon Ibraheem 2024-06-26 19:01:58 +03:00
parent c686dd7a0e
commit 5d24a2dfd7
4 changed files with 77 additions and 46 deletions

View file

@ -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=. |
| 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

View file

@ -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)

View file

@ -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

View file

@ -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")