-
Notifications
You must be signed in to change notification settings - Fork 2
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
Use Lua for configuration #42
Conversation
I've been using this config for over a month now and am happy with it. Let's release v2.0! The final changes today were just expanding the X keysyms added to the scope of the rwm Lua module. I wanted to bind some scripts to Mod+F4 and Mod+F5 and decided to go all in, generating as many symbols as I could. Users can always manually include the values in Lua by referencing the header on their system, but this is a much better start than what I had before. |
* replace topbar with bool * showbar bool * add a toml config file for a few basic options * more fields on config and make some bools * move fonts into config, reset default to 10 like dwm * take fontcount from fonts.len() directly * loop over fonts directly * load tags from config * switch config from toml to fig * working on colors * finish colors * update to fig with int and float * document get_colors * experimenting with dmenucmd and key handling in fig for dmenucmd, I think I'm just going to drop the dmenumon thing and add that manually as an argument. I need to go ahead and move spawn to use Rust command stuff too I'm going to have to make Arg an enum too, I think. it's just not really clear how to start passing around termcmd and dmenucmd Args that I get from fig. the current setup really depends on them being pointers that I can reference in the key definitions. any Key that takes an Arg.v is potentially a problem, but hopefully I can handle it by introducing multiple enum variants, one for each actual type the *void points to * convert Arg to an enum * make key_handlers rust fns for unwinding * log some args * fix incorrect types for setlayout and view * add layout index variant for Arg * replace MODKEY | ShiftMask with S_MOD * reorder and replace Mod + Ctrl + Shift too * Arg::V doesn't need to be void anymore * don't make Arg Copy * use rust strings and Command::spawn for spawn * move KEYS to CONFIG * make keys a vec * go through get_keys * work on loading keys from config * move key module to its own file * successfully load keys from a Fig file * add systray config options * add xembed #defines * add atoms * add Systray struct * add most of the code, minus remaining systray functions * impl updatesystrayicongeom * impl updatesystrayiconstate * impl wintosystrayicon * impl systraytomon * const -> static to prevent constant comparison error lint * impl updatesystray * handle clippy * make SYSTRAYONLEFT a bool * make SHOWSYSTRAY a bool * make SYSTRAYPINNINGFAILFIRST a bool * use new try_into impl * tidy imports * remove some pubs to see what needs to be loaded still * add Pertag and allocate one when creating a Monitor * update focusstack and setlayout * update togglebar, setmfact, and toggleview * update view * actually capture the chained assignment semantics * realize that I had two separate view functions, clippy for mem::swap * fix off-by-one for pertag * make isfullscreen bool * Implement window swallowing (#24) * update Rule struct, add st example * update Client * make isfloating bool * impl swallow, add XCON * impl unswallow * progress on swallowing with horrifying process management * finish swallowing? * delete unused xcon * add rule to example.fig * use rules from config * move other config options to CONFIG * import CONFIG everywhere instead of config::CONFIG * break buttons and layouts, last two field for CONFIG * load buttons and layouts from config * rename fields for clippy * simplify float and bool * simplify str_list and make sure it works * add fullscreen toggle from my dwm config * Add scratchpad patch (#25) * work on scratchpad * finish scratchpad * fix width -> height * try another found approach currently it always spawns a new scratchpad instead of toggling * take scratchpadname from config * allow binding togglescratch as it turns out, scratchpadcmd doesn't even need to be a field on Config. the user can just use it directly in their config file, and it gets called like any other function. the title of the spawned window just needs to match `scratchpadname` for everything to work properly * make sure cstring lives long enough I thought I was being clever keeping it in the match, but after checking the docs again (and crashing my window manager) I see that it's *my* responsibility to ensure the string lives long enough for the pointer to be valid * use normal string comparison I was getting really weird crashes/freezes with the other code, hopefully this resolves the issue * Revert "use normal string comparison" This reverts commit 459e7fc. * Revert "make sure cstring lives long enough" This reverts commit 260bd61. * really fix scratchpad (I hope) this seems less hacky and also actually selects the window * Merge master into `fig` and new lints (#32) * Implement the pertag patch for dwm (#23) * add Pertag and allocate one when creating a Monitor * update focusstack and setlayout * update togglebar, setmfact, and toggleview * update view * actually capture the chained assignment semantics * realize that I had two separate view functions, clippy for mem::swap * fix off-by-one this was clear in the patch, but I just didn't include the +1. symptom was a crash when trying to access tag 9 * make isfullscreen bool * Implement window swallowing (#24) * update Rule struct, add st example * update Client * make isfloating bool * impl swallow, add XCON * impl unswallow * progress on swallowing with horrifying process management * finish swallowing? * delete unused xcon * Add scratchpad patch (#25) * work on scratchpad * finish scratchpad * fix width -> height * try another found approach currently it always spawns a new scratchpad instead of toggling * fix duplicate pertag * fix duplicate scratchtag code * move fig to git dep for CI * handle newly-denied references to static mut https://doc.rust-lang.org/nightly/edition-guide/rust-2024/static-mut-references.html * clean up some unused imports and initial value * add xcb to fix sxiv window swallowing * add recipe for testing with xephyr, already catching an underflow * convert to i32 first to avoid underflow despite h and usedfont->h being unsigned, C allows the result to be negative I only caught this by running the debug build in xephyr, in release I guess something reasonable was happening automatically (probably the same as C) * fix imports for non-linux code * try to get clippy to catch this * Add part of the stacker patch (#33) * add pushstack * obey clippy * add better docs * add pushstack to example config * Use Xvfb for automated tests (#37) * test buttonpress * wait for xephyr to start * install xephyr * start events module * try starting x * /usr/bin/X not found * Only console users are allowed to run the X server * need sudo * forgot sudo echo doesn't work * revert sudo stuff, try -ac * use xvfb not xephyr for automated tests * install libxcb * try a different one * print xcb connection error * specify display for xcb too * delete unused benches * use a labeled block to avoid clippy * try_wait after kill to handle clippy * bring back linux cfg for xcon stuff * xquartz might have xvfb * try lowercase xvfb on mac * more debugging on mac * both xvfb and Xvfb are shown in which but PATH isn't updating * move tests to their own file * clippy on tests too * Start moving global state into a `State` struct, starting with `Cursor`s (#39) * move state into State struct TODO fix drop for Cur * clippy fix * fix segfault by restoring cur_free * use drw on Cur, moving back toward Drop * go back to Drop, segfault is fixed * delete CURSOR comment * handle clippy * plumb State with BH through everything * move atoms into State * make sure rwm exits successfully in xephyr * move DPY into state * move SW into state and finally have to pass &mut State everywhere * move all cleanup code into `cleanup` * missing state for macos * move DRW into state * hold a Drw not *mut Drw * add notes on drw::free * switch to Vec<Fnt> * state.SELMON * lowercase selmon * delete leftover drw comment * state.MONS * lowercase mons * state.STEXT * lowercase stext * use &raw instead of addr_of * move state to its own module and file * state.scheme * use Vecs of colors * add newtype ClrScheme for nicer indexing * make Monitor hold Pertag, not *mut Pertag * mac should also have Xvfb * make rect take &mut Drw * make invert bool * use refs * allow clippy fix when dirty * more refs * font_getexts never used h * clean up some more unused unsafe * make charexists bool * utf8decode was only called with clen = UTF_SIZ * Delete UTF-8 decoding, switch to String (#40) * make rect take &mut Drw * make invert bool * use refs * allow clippy fix when dirty * more refs * font_getexts never used h * clean up some more unused unsafe * make charexists bool * utf8decode was only called with clen = UTF_SIZ * mostly working, but title is always `broken` in xephyr * initialize client name to avoid precondition violation * remove size argument to gettextprop * update screen size in xephyr * debugging missing emojis in xephyr * fix emojis by actually setting utf8codepoint * fix some characters in title * char::from is a little nicer, then give up for now * state.sh * state.root and state.screen * state.lrpad * clean up some lrpad arithmetic * move almost all static mut into state * move xerrorlib where it's used and document its necessity * own systray * fix mac xcon issues * Use Lua for configuration (#42) * derive deserialize for config, with some intermediates for fn ptrs * add insta, load a Config from lua * ok_or * move CONFIG init to Config::load_home * allow unused for now * move config to lib and CONFIG to state * clippy fix * lowercase config * delete fig, use lua, check Key loading * custom Debug impl for Key for reproducible snapshots * update dmenucmd and test buttons * add layouts * install lua * ubuntu requires specifying lua5.4 * also install liblua5.4 * rename main_ to core * start generating tag keys * finish the default config * move docs to config.lua * take defaults entirely from lua * update config path * don't load config twice * use previously-defined scratchpad name * make way more keys available in the default config * run clippy with nightly * fix new operator precedence lint * include xf86 keys too
This replaces the custom Fig language config file with a Lua config based on mlua. mlua comes with very nice deserialization support, so this removes a lot of code from rwm and also removes the dependency on fig.
This PR also moved the global
CONFIG
to a field onState
, which caused a huge module reorganization to move most of the submodules previously inmain.rs
tolib.rs
.TODOS
main_
module, probably tocore
I think it probably makes sense to remove the
Default
impl forConfig
and all of the associated statics. I've been inspired by ghostty to make the default, empty config useful, and Lua helps a lot with that. With the defaultrwm
table inconfig.lua
, user configs can look like this:Just overriding a small subset of fields instead of requiring a full config.
This will also allow for programmatic config generation like
TAGKEYS
from dwm. Instead of having to write out all of theview
,toggleview
,tag
, andtoggletag
bindings forXK_1
-XK_9
, for example, you can use a Lua loop to append them.I also think it's a good time to move away from silently replacing a broken config with defaults (as is implied by deleting the
Default
code), and instead print an error right away if this happens. It might also be time to pull inclap
and add a flag for just checking the config to help with debugging.