diff --git a/.gitignore b/.gitignore index 693ec296..f09b3033 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.cache /.vscode +/result config.h maomao maomao.o diff --git a/README.md b/README.md index 4cc3fb3f..20376dfd 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# +# Master-Stack Layout @@ -18,7 +18,7 @@ https://github.com/user-attachments/assets/c9bf9415-fad1-4400-bcdc-3ad2d76de85a # Maomaowm -This project is developed based on `dwl(0.5)` , +This project is developed based on `dwl(0.5)` , adding many operation that supported in hyprland and a hyprland-like keybinds, niri-like scroll layout and sway-like scratchpad. See below for more features. @@ -34,10 +34,10 @@ See below for more features. # window open rules ## options -- appid: type-string if match it or title, the rule match -- title: type-string if match it or appid, the rule match +- appid: type-string if match it or title, the rule match +- title: type-string if match it or appid, the rule match - tags: type-num(1-9) which tags to open the window -- isfloating: type-num(0 or 1) +- isfloating: type-num(0 or 1) - isfullscreen: type-num(0 or 1) - scroller_proportion: type-float(0.1-1.0) - animation_type : type-string(zoom,slide) @@ -66,7 +66,7 @@ yay -S rofi foot xdg-desktop-portal-wlr swaybg waybar wl-clip-persist cliphist w ``` -# install +# install # wlroots(0.17) ``` git clone -b 0.17.4 https://gitlab.freedesktop.org/wlroots/wlroots.git @@ -99,10 +99,70 @@ like `MAOMAOCONFIG=/home/xxx/maomao` - the fallback config path is in `/etc/maomao/config.conf`, you can find the default config here +# NixOS+Home-manager +```nix +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-parts.url = "github:hercules-ci/flake-parts"; + maomaowm.url = "github:DreamMaoMao/maomaowm"; + + }; + outputs = + inputs@{ self, flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + debug = true; + systems = [ "x86_64-linux" ]; + flake = { + nixosConfigurations = { + hostname = inputs.nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + backupFileExtension = "backup"; + users."username".imports = + [ + ( + { ... }: + { + wayland.windowManager.maomaowm = { + enable = true; + settings = '' + # see config.in + ''; + autostart_sh = '' + # see autostart.sh + ''; + }; + } + ) + ] + ++ [ + # Add maomaowm hm module + inputs.maomaowm.hmModules.maomaowm + ]; + }; + } + ]; + }; + }; + }; + }; +} +``` + + # my dotfile [maomao-config](https://github.com/DreamMaoMao/dotfile/tree/main/maomao) -# thanks for some refer repo +# thanks for some refer repo - https://github.com/dqrk0jeste/owl - for basal window animaition - https://github.com/djpohly/dwl - for basal dwl feature diff --git a/config.conf b/config.in similarity index 100% rename from config.conf rename to config.in diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..620452fb --- /dev/null +++ b/flake.lock @@ -0,0 +1,79 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1738453229, + "narHash": "sha256-7H9XgNiGLKN1G1CgRh0vUL4AheZSYzPm+zmZ7vxbJdo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "32ea77a06711b758da0ad9bd6a844c5740a87abd", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1740019556, + "narHash": "sha256-vn285HxnnlHLWnv59Og7muqECNMS33mWLM14soFIv2g=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "dad564433178067be1fbdfcce23b546254b6d641", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1738452942, + "narHash": "sha256-vJzFZGaCpnmo7I6i416HaBLpC+hvcURh/BQwROcGIp8=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/072a6db25e947df2f31aab9eccd0ab75d5b2da11.tar.gz" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1739829690, + "narHash": "sha256-mL1szCeIsjh6Khn3nH2cYtwO5YXG6gBiTw1A30iGeDU=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "3d0579f5cc93436052d94b73925b48973a104204", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..99654423 --- /dev/null +++ b/flake.nix @@ -0,0 +1,50 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + treefmt-nix = { + url = "github:numtide/treefmt-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + { + flake-parts, + treefmt-nix, + ... + }@inputs: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.flake-parts.flakeModules.easyOverlay + ]; + + flake.hmModules.maomaowm = import ./nix/hm-modules.nix; + + perSystem = + { + config, + pkgs, + ... + }: + let + inherit (pkgs) + callPackage + ; + maomaowm = callPackage ./nix { }; + treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; + in + { + packages.default = maomaowm; + overlayAttrs = { + inherit (config.packages) maomaowm; + }; + packages = { + inherit maomaowm; + }; + + formatter = treefmtEval.config.build.wrapper; + }; + systems = [ "x86_64-linux" ]; + }; +} diff --git a/meson.build b/meson.build index eeec9188..c2286095 100644 --- a/meson.build +++ b/meson.build @@ -1,38 +1,13 @@ -project('maomao', ['c', 'cpp'], - version : '0.1.5' -) +project('maomao', ['c', 'cpp'], version: '0.1.5') subdir('protocols') -# fs = import('fs') -# -# # 获取用户的主目录 -# home_dir = run_command('sh', '-c', 'echo $HOME', check: true).stdout().strip() -# config_dir = join_paths(home_dir, '.config', 'maomao') -# -# # 如果目标目录不存在,则创建它 -# if not fs.is_dir(config_dir) -# run_command('mkdir', '-p', config_dir, check: true) -# endif -# -# # 拷贝 config.conf -# config_file = join_paths(config_dir, 'config.conf') -# if not fs.exists(config_file) -# run_command('cp', 'config.conf', config_file, check: true) -# endif -# -# # 拷贝 autostart.sh -# autostart_file = join_paths(config_dir, 'autostart.sh') -# if not fs.exists(autostart_file) -# run_command('cp', 'autostart.sh', autostart_file, check: true) -# endif - cc = meson.get_compiler('c') libm = cc.find_library('m') -xcb = dependency('xcb', required : get_option('xwayland')) -xlibs = dependency('xcb-icccm', required : get_option('xwayland')) +xcb = dependency('xcb', required: get_option('xwayland')) +xlibs = dependency('xcb-icccm', required: get_option('xwayland')) wayland_server_dep = dependency('wayland-server') -wlroots_dep = dependency('wlroots', version : ['>=0.17.0', '<0.18.0']) +wlroots_dep = dependency('wlroots', version: ['>=0.17.0', '<0.18.0']) xkbcommon_dep = dependency('xkbcommon') libinput_dep = dependency('libinput') libwayland_client_dep = dependency('wayland-client') @@ -42,19 +17,20 @@ c_args = [ '-Wno-unused-function', '-DWLR_USE_UNSTABLE', '-D_POSIX_C_SOURCE=200809L', - '-DVERSION="@0@"'.format(meson.project_version()) + '-DVERSION="@0@"'.format(meson.project_version()), ] if xcb.found() and xlibs.found() c_args += '-DXWAYLAND' c_args += '-DIM' - endif +endif -executable('maomao', +executable( + 'maomao', 'maomao.c', 'util.c', wayland_sources, - dependencies : [ + dependencies: [ libm, xcb, xlibs, @@ -64,12 +40,22 @@ executable('maomao', libinput_dep, libwayland_client_dep, ], - install : true, - c_args : c_args + install: true, + c_args: c_args, ) +sysconfdir = get_option('sysconfdir') prefix = get_option('prefix') -desktop_install_dir = join_paths(prefix, 'share/wayland-sessions') -install_data('maomao.desktop', install_dir : desktop_install_dir) -install_data('config.conf', install_dir : '/etc/maomao') +config = configuration_data() +config.set('sysconfdir', sysconfdir) +config.set('prefix', prefix) +configure_file( + configuration: config, + input: 'config.in', + output: 'config.conf', + install_dir: join_paths(sysconfdir, 'maomao'), +) + +desktop_install_dir = join_paths(prefix, 'share/wayland-sessions') +install_data('maomao.desktop', install_dir: desktop_install_dir) diff --git a/nix/default.nix b/nix/default.nix new file mode 100644 index 00000000..8cca30b1 --- /dev/null +++ b/nix/default.nix @@ -0,0 +1,60 @@ +{ + lib, + libX11, + libinput, + libxcb, + libxkbcommon, + pixman, + pkg-config, + stdenv, + wayland, + wayland-protocols, + wayland-scanner, + wlroots_0_17, + xcbutilwm, + xwayland, + enableXWayland ? true, + meson, + ninja, +}: +let + pname = "maomaowm"; +in +stdenv.mkDerivation { + inherit pname; + version = "nightly"; + + src = ../.; + + nativeBuildInputs = [ + meson + ninja + pkg-config + wayland-scanner + ]; + + buildInputs = + [ + libinput + libxcb + libxkbcommon + pixman + wayland + wayland-protocols + wlroots_0_17 + ] + ++ lib.optionals enableXWayland [ + libX11 + xcbutilwm + xwayland + ]; + + meta = { + mainProgram = "maomao"; + description = "A streamlined but feature-rich Wayland compositor"; + homepage = "https://github.com/DreamMaoMao/maomaowm"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ ]; + platforms = lib.platforms.unix; + }; +} diff --git a/nix/hm-modules.nix b/nix/hm-modules.nix new file mode 100644 index 00000000..05c5e996 --- /dev/null +++ b/nix/hm-modules.nix @@ -0,0 +1,43 @@ +{ + lib, + config, + pkgs, + ... +}: + +let + maomaowm = pkgs.callPackage ./. { }; +in +{ + options = { + wayland.windowManager.maomaowm = { + enable = lib.mkOption { + type = lib.types.bool; + default = false; + }; + + settings = lib.mkOption { + type = lib.types.str; + default = ""; + }; + + autostart_sh = lib.mkOption { + type = lib.types.str; + default = ""; + }; + }; + }; + + config = lib.mkIf config.programs.maomaowm.enable { + home.packages = [ maomaowm ]; + + xdg.configFile = { + "maomaowm/config.conf" = { + text = config.programs.maomaowm.settings; + }; + "maomaowm/autostart.sh" = { + text = config.programs.maomaowm.settings; + }; + }; + }; +} diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 00000000..e61ce2d8 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,8 @@ +{ ... }: + +{ + projectRootFile = "flake.nix"; + programs = { + nixfmt.enable = true; + }; +}