mirror of
https://github.com/ebeem/guile-swayer.git
synced 2024-12-25 21:59:00 +01:00
49 lines
1.4 KiB
Scheme
Executable file
49 lines
1.4 KiB
Scheme
Executable file
#!/usr/bin/guile
|
|
!#
|
|
|
|
(add-to-load-path
|
|
(dirname (or (current-filename)
|
|
(string-append (getenv "HOME") "/.config/sway/init.scm"))))
|
|
|
|
(use-modules (oop goops)
|
|
(srfi srfi-18)
|
|
(modules workspace-groups)
|
|
(modules workspace-grid)
|
|
(swayipc connection)
|
|
(swayipc records)
|
|
(swayipc info)
|
|
(swayipc events)
|
|
(swayipc dispatcher))
|
|
|
|
|
|
;; 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)
|
|
|
|
(add-hook! sway-workspace-hook workspace-changed)
|
|
(start-event-listener-thread)
|
|
(thread-join! LISTENER-THREAD)
|