From 924ac9ccf8f4dbd9d082a36176d8ead7c047d4e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Mon, 10 Jan 2022 21:38:37 +0100 Subject: [PATCH] add lupan-wm and lupan-clock and use them if available --- .gitignore | 2 + lupan-clock/Makefile | 2 + lupan-clock/lupan-clock.c | 44 +++ lupan-wm/Cargo.lock | 794 ++++++++++++++++++++++++++++++++++++++ lupan-wm/Cargo.toml | 9 + lupan-wm/src/main.rs | 145 +++++++ xsession/.xsession | 27 +- 7 files changed, 1018 insertions(+), 5 deletions(-) create mode 100644 lupan-clock/Makefile create mode 100644 lupan-clock/lupan-clock.c create mode 100644 lupan-wm/Cargo.lock create mode 100644 lupan-wm/Cargo.toml create mode 100644 lupan-wm/src/main.rs diff --git a/.gitignore b/.gitignore index 71aca1e..72278bf 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,7 @@ bspwm/.config/bspwm/themes/theme.sh shell/.config/zsh/plugins/zsh-autosuggestions shell/.config/zsh/plugins/zsh-syntax-highlighting qtile/.config/qtile/theme.txt +lupan-clock/lupan-clock +lupan-wm/target *~ __pycache__ diff --git a/lupan-clock/Makefile b/lupan-clock/Makefile new file mode 100644 index 0000000..73c40be --- /dev/null +++ b/lupan-clock/Makefile @@ -0,0 +1,2 @@ +lupan-clock: lupan-clock.c + ${CC} -o $@ $< -lX11 -Wall diff --git a/lupan-clock/lupan-clock.c b/lupan-clock/lupan-clock.c new file mode 100644 index 0000000..8b41793 --- /dev/null +++ b/lupan-clock/lupan-clock.c @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include + +static void die(const char *errstr); + +void die(const char *errstr) { + fputs(errstr, stderr); + exit(EXIT_FAILURE); +} + +void show(Display *dpy, int root, struct tm *tm) +{ + char s[6]; + strftime(s, sizeof(s), "%H:%M", tm); + XStoreName(dpy, root, s); + XSync(dpy, True); +} + +int main() { + Display *dpy; + int root, h, m, init = 60; + time_t t; + struct tm *tm; + + if (!(dpy = XOpenDisplay(NULL))) + die("lupan-clock: cannot open display\n"); + root = DefaultRootWindow(dpy); + while (1) { + t = time(NULL); + tm = localtime(&t); + if (tm->tm_hour != h || tm->tm_min != m || init > 0) { + show(dpy, root, tm); + h = tm->tm_hour; + m = tm->tm_min; + init = (init > 0) ? init - 1 : 0; + } + sleep(1); + } + return 1; +} diff --git a/lupan-wm/Cargo.lock b/lupan-wm/Cargo.lock new file mode 100644 index 0000000..842acdc --- /dev/null +++ b/lupan-wm/Cargo.lock @@ -0,0 +1,794 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "anyhow" +version = "1.0.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "cairo-rs" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5c0f2e047e8ca53d0ff249c54ae047931d7a6ebe05d00af73e0ffeb6e34bdb8" +dependencies = [ + "bitflags", + "cairo-sys-rs", + "glib", + "glib-sys", + "gobject-sys", + "libc", + "thiserror", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ed2639b9ad5f1d6efa76de95558e11339e7318426d84ac4890b86c03e828ca7" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "cc" +version = "1.0.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time", + "winapi", +] + +[[package]] +name = "clap" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f34b09b9ee8c7c7b400fe2f8df39cafc9538b03d6ba7f4ae13e4cb90bfbb7d" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "indexmap", + "lazy_static", + "os_str_bytes", + "strsim", + "termcolor", + "textwrap", +] + +[[package]] +name = "clap_derive" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a0645a430ec9136d2d701e54a95d557de12649a9dd7109ced3187e648ac824" +dependencies = [ + "heck 0.4.0", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "futures-channel" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba3dda0b6588335f360afc675d0564c17a77a2bda81ca178a4b6081bd86c7f0b" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0c8ff0461b82559810cdccfde3215c3f373807f5e5232b71479bff7bb2583d7" + +[[package]] +name = "futures-executor" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29d6d2ff5bb10fb95c85b8ce46538a2e5f5e7fdc755623a7d4529ab8a4ed9d2a" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-macro" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbd947adfffb0efc70599b3ddcf7b5597bb5fa9e245eb99f62b3a5f7bb8bd3c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-task" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ee7c6485c30167ce4dfb83ac568a849fe53274c831081476ee13e0dce1aad72" + +[[package]] +name = "futures-util" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5cf40b47a271f77a8b1bec03ca09044d99d2372c0de244e66430761127164" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "glib" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c685013b7515e668f1b57a165b009d4d28cb139a8a989bbd699c10dad29d0c5" +dependencies = [ + "bitflags", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "glib-macros", + "glib-sys", + "gobject-sys", + "libc", + "once_cell", +] + +[[package]] +name = "glib-macros" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41486a26d1366a8032b160b59065a59fb528530a46a49f627e7048fb8c064039" +dependencies = [ + "anyhow", + "heck 0.3.3", + "itertools", + "proc-macro-crate", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "glib-sys" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7e9b997a66e9a23d073f2b1abb4dbfc3925e0b8952f67efd8d9b6e168e4cdc1" +dependencies = [ + "libc", + "system-deps", +] + +[[package]] +name = "gobject-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "952133b60c318a62bf82ee75b93acc7e84028a093e06b9e27981c2b6fe68218c" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "indexmap" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "itertools" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" +dependencies = [ + "either", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" + +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lupan-wm" +version = "0.1.0" +dependencies = [ + "clap", + "penrose", + "simplelog", +] + +[[package]] +name = "memchr" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" + +[[package]] +name = "nix" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa9b4819da1bc61c0ea48b63b7bc8604064dd43013e7cc325df098d49cd7c18a" +dependencies = [ + "bitflags", + "cc", + "cfg-if", + "libc", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" + +[[package]] +name = "os_str_bytes" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" +dependencies = [ + "memchr", +] + +[[package]] +name = "pango" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9937068580bebd8ced19975938573803273ccbcbd598c58d4906efd4ac87c438" +dependencies = [ + "bitflags", + "glib", + "glib-sys", + "gobject-sys", + "libc", + "once_cell", + "pango-sys", +] + +[[package]] +name = "pango-sys" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d2650c8b62d116c020abd0cea26a4ed96526afda89b1c4ea567131fdefc890" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "pangocairo" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5ae67a05a5e023f09f64e9a71c845274d4b82dedee237b70425811885e883" +dependencies = [ + "bitflags", + "cairo-rs", + "cairo-sys-rs", + "glib", + "glib-sys", + "gobject-sys", + "libc", + "pango", + "pango-sys", + "pangocairo-sys", +] + +[[package]] +name = "pangocairo-sys" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94ccc97f698c2f0233b84e5ca676893a1e676785b60eec700b9c0e6dcd0feb98" +dependencies = [ + "cairo-sys-rs", + "glib-sys", + "libc", + "pango-sys", + "system-deps", +] + +[[package]] +name = "penrose" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c99eba539000844e97310340f43654453286c81da95639436d9a41f738fdab06" +dependencies = [ + "bitflags", + "cairo-rs", + "cairo-sys-rs", + "nix", + "pango", + "pangocairo", + "penrose_keysyms", + "penrose_proc", + "strum 0.20.0", + "strum_macros 0.20.1", + "thiserror", + "tracing", + "xcb", +] + +[[package]] +name = "penrose_keysyms" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a574df0fe3d7e0bb1fd297dd722d8aea8ea33a734d862451509814062bec2d6" +dependencies = [ + "strum 0.20.0", + "strum_macros 0.20.1", +] + +[[package]] +name = "penrose_proc" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a4e9438e0d3ed63bbd08fd0838bb35d94ef298f6705144b27608a5a22f1ebb9" +dependencies = [ + "penrose_keysyms", + "proc-macro2", + "quote", + "rustversion", + "strum 0.20.0", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "392a54546fda6b7cc663379d0e6ce8b324cf88aecc5a499838e1be9781bdce2e" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustversion" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2cc38e8fa666e2de3c4aba7edeb5ffc5246c1c2ed0e3d17e560aeeba736b23f" + +[[package]] +name = "serde" +version = "1.0.132" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008" + +[[package]] +name = "simplelog" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b2736f58087298a448859961d3f4a0850b832e72619d75adc69da7993c2cd3c" +dependencies = [ + "chrono", + "log", + "termcolor", +] + +[[package]] +name = "slab" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57bd81eb48f4c437cadc685403cad539345bf703d78e63707418431cecd4522b" + +[[package]] +name = "strum" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7318c509b5ba57f18533982607f24070a55d353e90d4cae30c467cdb2ad5ac5c" +dependencies = [ + "strum_macros 0.20.1", +] + +[[package]] +name = "strum_macros" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "strum_macros" +version = "0.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8bc6b87a5112aeeab1f4a9f7ab634fe6cbefc4850006df31267f4cfb9e3149" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "syn" +version = "1.0.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ecb2e6da8ee5eb9a61068762a32fa9619cc591ceb055b3687f4cd4051ec2e06b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "system-deps" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3ecc17269a19353b3558b313bba738b25d82993e30d62a18406a24aba4649b" +dependencies = [ + "heck 0.3.3", + "pkg-config", + "strum 0.18.0", + "strum_macros 0.18.0", + "thiserror", + "toml", + "version-compare", +] + +[[package]] +name = "termcolor" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" + +[[package]] +name = "thiserror" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi", + "winapi", +] + +[[package]] +name = "toml" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +dependencies = [ + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4f480b8f81512e825f337ad51e94c1eb5d3bbdf2b363dcd01e2b19a9ffe3f8e" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "unicode-segmentation" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "version-compare" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d63556a25bae6ea31b52e640d7c41d1ab27faba4ccb600013837a3d0b3994ca1" + +[[package]] +name = "version_check" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" + +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "xcb" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62056f63138b39116f82a540c983cc11f1c90cd70b3d492a70c25eaa50bd22a6" +dependencies = [ + "libc", + "log", +] diff --git a/lupan-wm/Cargo.toml b/lupan-wm/Cargo.toml new file mode 100644 index 0000000..37012dd --- /dev/null +++ b/lupan-wm/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "lupan-wm" +version = "0.1.0" +edition = "2018" + +[dependencies] +clap = { version = "3.0.5", features = ["derive"] } +penrose = "0.2.1" +simplelog = "0.8" diff --git a/lupan-wm/src/main.rs b/lupan-wm/src/main.rs new file mode 100644 index 0000000..998eb0b --- /dev/null +++ b/lupan-wm/src/main.rs @@ -0,0 +1,145 @@ +#[macro_use] +extern crate penrose; + +use clap::Parser; + +use penrose::{ + contrib::{hooks::ManageExistingClients}, + core::{ + bindings::MouseEvent, config::Config, helpers::index_selectors, manager::WindowManager, + hooks::Hooks, + layout::{bottom_stack, side_stack, Layout, LayoutConf}, + }, + draw::{bar::dwm_bar, Color, TextStyle}, + logging_error_handler, + xcb::{new_xcb_backed_window_manager, XcbDraw, XcbConnection}, + Backward, Forward, Less, More, Result, Selector +}; + +use std::convert::{TryFrom, TryInto}; + +pub type Conn = XcbConnection; + +const EDITOR: &str = "emacsclient -c -n"; +const TERMINAL: &str = "alacritty"; +const SUSPEND: &str = "systemctl suspend"; + +const FONT: &str = "Iosevka Slab Light"; +const FONT_SIZE: i32 = 20; +const BAR_BG: &str = "#0c4a6e"; +const BAR_FG: &str = "#7dd3fc"; +const BAR_HIGHLIGHT: &str = "#0369a1"; +const BAR_EMPTY: &str = "#94a3b8"; +const FOCUSED_BORDER: &str = "#d97706"; +const UNFOCUSED_BORDER: &str = "#64748b"; + +#[derive(Parser, Debug)] +#[clap(about, version, author)] +struct Args { + /// Font name + #[clap(short, long, default_value_t = FONT.to_string())] + font: String, + + /// Font size + #[clap(short = 's', long, default_value_t = FONT_SIZE)] + font_size: i32, +} + +fn main() -> Result<()> { + let n_main = 1; + let ratio = 0.6; + let args = Args::parse(); + let rofi_theme_str = format!("* {{ text-color: {}; background-color: {}; blue: {}; font: \"{} {}\"; }}", + BAR_FG, BAR_BG, BAR_HIGHLIGHT, args.font, args.font_size); + let config = Config::default() + .builder() + .workspaces(vec!["1", "2", "3", "4", "5", "6", "7", "8", "9"]) + .bar_height((2 * args.font_size).try_into().unwrap()) + .border_px(4) + .focused_border(FOCUSED_BORDER)? + .unfocused_border(UNFOCUSED_BORDER)? + .layouts(vec![ + Layout::new("[side]", LayoutConf::default(), side_stack, n_main, ratio), + Layout::new("[botm]", LayoutConf::default(), bottom_stack, n_main, ratio), + ]) + .build() + .unwrap(); + + let key_bindings = gen_keybindings! { + // Program launchers + "M-e" => run_external!(EDITOR); + "M-space" => Box::new(move |_: &mut WindowManager<_>| spawn!( + "rofi", "-theme", "Pop-Dark", "-theme-str", &rofi_theme_str, "-kb-row-select", "Tab", "-kb-row-tab", "Alt-Tab", "-show", "run")); + "M-Return" => run_external!(TERMINAL); + "M-S-s" => run_external!(SUSPEND); + + // Exit Penrose (important to remember this one!) + "M-A-C-Escape" => run_internal!(exit); + + // Client management + "M-j" => run_internal!(cycle_client, Forward); + "M-k" => run_internal!(cycle_client, Backward); + "M-S-j" => run_internal!(drag_client, Forward); + "M-A-j" => run_internal!(rotate_clients, Forward); + "M-A-k" => run_internal!(rotate_clients, Backward); + "M-S-k" => run_internal!(drag_client, Backward); + "M-S-f" => run_internal!(toggle_client_fullscreen, &Selector::Focused); + "M-S-q" => run_internal!(kill_client); + + // Workspace management + "M-Tab" => run_internal!(toggle_workspace); + "M-period" => run_internal!(cycle_screen, Forward); + "M-comma" => run_internal!(cycle_screen, Backward); + "M-A-period" => run_internal!(cycle_workspace, Forward); + "M-A-comma" => run_internal!(cycle_workspace, Backward); + + // Layout management + "M-m" => run_internal!(cycle_layout, Forward); + "M-S-m" => run_internal!(cycle_layout, Backward); + "M-A-Up" => run_internal!(update_max_main, More); + "M-A-Down" => run_internal!(update_max_main, Less); + "M-A-Right" => run_internal!(update_main_ratio, More); + "M-A-Left" => run_internal!(update_main_ratio, Less); + "M-S-h" => run_internal!(update_max_main, More); + "M-S-l" => run_internal!(update_max_main, Less); + "M-l" => run_internal!(update_main_ratio, More); + "M-h" => run_internal!(update_main_ratio, Less); + + map: { "1", "2", "3", "4", "5", "6", "7", "8", "9" } to index_selectors(9) => { + "M-{}" => focus_workspace (REF); + "M-S-{}" => client_to_workspace (REF); + }; + }; + + let mouse_bindings = gen_mousebindings! { + Press Right + [Meta] => |wm: &mut WindowManager<_>, _: &MouseEvent| wm.cycle_workspace(Forward), + Press Left + [Meta] => |wm: &mut WindowManager<_>, _: &MouseEvent| wm.cycle_workspace(Backward), + Press Middle + [Meta] => |wm: &mut WindowManager<_>, _: &MouseEvent| wm.toggle_workspace(), + Press Left + [Ctrl] => |_wm: &mut WindowManager<_>, _: &MouseEvent| penrose::core::helpers::spawn(TERMINAL) + }; + + let bar = dwm_bar( + XcbDraw::new()?, + (2 * args.font_size).try_into().unwrap(), + &TextStyle { + font: args.font, + point_size: args.font_size, + fg: Color::try_from(BAR_FG)?, + bg: Some(Color::try_from(BAR_BG)?), + padding: (12.0, 12.0), + }, + Color::try_from(BAR_HIGHLIGHT)?, // highlight + Color::try_from(BAR_EMPTY)?, // empty_ws + config.workspaces().clone(), + )?; + + let hooks: Hooks = vec![ + ManageExistingClients::new(), + Box::new(bar), + ]; + + let mut wm = new_xcb_backed_window_manager(config, hooks, logging_error_handler())?; + wm.grab_keys_and_run(key_bindings, mouse_bindings)?; + + Ok(()) +} diff --git a/xsession/.xsession b/xsession/.xsession index 8a13282..c2284f7 100755 --- a/xsession/.xsession +++ b/xsession/.xsession @@ -6,7 +6,6 @@ fi xrandr --auto xrandr --output HDMI1 --right-of DP1 -xsetroot -solid '#94a3b8' xrdb -merge ~/.Xresources setxkbmap pl -option ctrl:nocaps xmodmap ~/.xmodmaprc @@ -23,14 +22,32 @@ emacsclient --eval nil -a '' & xsettingsd & -exec qtile start +if which lupan-wm > /dev/null; then + xsetroot -solid '#0ea5e9' + lupan-clock & + xsetroot -cursor_name left_ptr + exec lupan-wm -s 20 +fi + +xsetroot -solid '#94a3b8' + +if which qtile > /dev/null; then + exec qtile start +fi if which bspwm > /dev/null; then sxhkd & xsetroot -cursor_name left_ptr exec bspwm fi -exec /usr/bin/i3 -dwm-clock & -exec /usr/local/bin/dwm + +if which i3 > /dev/null; then + exec i3 +fi + +if which dwm > /dev/null; then + lupan-clock & + exec dwm +fi + exec xterm