Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to load a user config file #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tpine
Copy link

@tpine tpine commented Jan 16, 2024

This loads a config file first checking $XDG_CONFIG_HOME and if that does not exist falls back to .config/mahogany/init.lisp.

It is adapted from the function in stumpwm.

Copy link
Collaborator

@sdilts sdilts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Please see the suggested changes and comments.

lisp/main.lisp Outdated
(error (c) (values nil (format nil "~a" c) config-file))
(:no-error (&rest args) (declare (ignore args)) (values t nil config-file)))
(progn
(log-string :debug (format nil "Found config file at ~a" config-file))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log-string accepts format arguments, so you don't need the extra call to format.

Suggested change
(log-string :debug (format nil "Found config file at ~a" config-file))
(log-string :debug "Found config file at ~a" config-file)

This log statement would also make more sense to have above the catch-error if statement so it is always printed when the config file is found.

lisp/main.lisp Outdated
Comment on lines 69 to 89
(init-callback-struct output-callbacks (:struct hrt-output-callbacks)
(output-added handle-new-output)
(output-removed handle-output-removed)
(output-mode-changed output-mode-change-callback))
(init-callback-struct seat-callbacks (:struct hrt-seat-callbacks)
(button-event cursor-callback)
(wheel-event cursor-callback)
(keyboard-keypress-event keyboard-callback))
(init-view-callbacks view-callbacks)

(setf (mahogany-state-server *compositor-state*) server)
(log-string :debug "Initialized mahogany state")
(hrt-server-init server output-callbacks seat-callbacks view-callbacks 3)
(log-string :debug "Initialized heart state")
(unwind-protect
(hrt-server-start server)
(log-string :debug "Cleaning up...")
(server-stop *compositor-state*)
(hrt-server-finish server)
(server-state-reset *compositor-state*)
(log-string :debug "Shutdown reached."))))
(setf (mahogany-state-server *compositor-state*) server)
(log-string :debug "Initialized mahogany state")
(hrt-server-init server output-callbacks seat-callbacks view-callbacks 3)
(log-string :debug "Initialized heart state")
(unwind-protect
(hrt-server-start server)
(log-string :debug "Cleaning up...")
(server-stop *compositor-state*)
(hrt-server-finish server)
(server-state-reset *compositor-state*)
(log-string :debug "Shutdown reached."))))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't change the indentation and formatting of unrelated code, especially where the formatting is correct. If your editor thought this needed to be changed, check that cffi was loaded properly.

lisp/main.lisp Outdated
(if config-file
(if catch-errors
(handler-case (load config-file)
(error (c) (values nil (format nil "~a" c) config-file))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to returning the error, I would log the error at the :warn level just so it isn't silently ignored.

This loads a config file first checking $XDG_CONFIG_HOME and if that
does not exist falls back to .config/mahogany/init.lisp.

It is adapted from the function in stumpwm.
(values t nil config-file))))
(progn
(log-string :debug "Did not find config file")
(values t nil nil)))))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting of the above code is a little difficult to read in the website; specifically, the two progn blocks should be indented to line up under the test config-file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants