Hy Interop for Qtile #2720
-
|
I would love to configure Qtile in Hy (Python is too weak--I want macros and symbols). I am not a deep Python user so I am unfamiliar with loading and some of the terminology. Hopefully I am still understandable. I've tried various things, but I still can't figure out how I can get this to work. For context, Qtile loads a configuration file and somehow uses the global variables in that configuration file to configure the Qtile instance. This unfortunately puts it into annoying middle ground between being a library and being a program. So far, I've been making my config file a python file that imports Hy and then my init.hy configuration file:
While I can see that the things in the Hy file are running (e.g. if I put a Does anyone have any ideas of how I can get this to work cleanly? I would generally be looking for a way to evaluate the Hy code in the context of the python config file being run. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
As a note, obviously one can compile to python using the hy cli, but given that Hy aims for interop with Python I assume this should be possible in a much cleaner way. I will also say that one can edit the Qtile executable to import hy (mentioned by @fgui in their config at https://github.com/fgui/config_qtile_hy_e/), but again I would hope for a non-invasive way to do this. |
Beta Was this translation helpful? Give feedback.
-
|
Using the following inside the Qtile configuration (e.g. # Import hy so you can load hy modules
import hy
# Import everything from the hy module contaning the configuration into the
# current "namespace" (idk the term that python uses).
from init import *
# Imports from init.hyI feared that config reloading might not work correctly like this (due to the way modules generally work as eval once code), but Qtile's restart at least seems to handle this. I will leave this question open for a while just incase someone else who has more Python knowledge wants to chime in or until I do more extensive testing. |
Beta Was this translation helpful? Give feedback.
Using the following inside the Qtile configuration (e.g.
config.pyor whatever you pass with the-cflag) works properly as far as I can tell (I haven't done anything complicated yet in this configuration though, so I can't say that it won't run into problems).I feared that config reloading might not work correctly like this (due to the way modules generally work as eval once code), but Qtile's restart at least seems to handle this.
I will leave this question open for a…