GlazeWM 开源项目教程
1. 项目的目录结构及介绍
GlazeWM 项目的目录结构如下:
glazewm/
├── .github/
│ └── workflows/
├── assets/
│ └── icons/
├── src/
│ ├── Commands/
│ ├── Config/
│ ├── Containers/
│ ├── Handlers/
│ ├── Services/
│ ├── Utils/
│ ├── GlazeWM.csproj
│ ├── Program.cs
│ └── Startup.cs
├── .gitignore
├── LICENSE
├── README.md
└── glazewm.sln
目录结构介绍
- .github/workflows/: 包含 GitHub Actions 的工作流配置文件。
- assets/icons/: 存放项目所需的图标文件。
- src/: 项目的源代码目录。
- Commands/: 包含各种命令的实现。
- Config/: 包含配置相关的文件。
- Containers/: 包含窗口管理器的容器组件。
- Handlers/: 包含事件处理程序。
- Services/: 包含各种服务类。
- Utils/: 包含实用工具类。
- GlazeWM.csproj: 项目的 C# 项目文件。
- Program.cs: 程序的入口点。
- Startup.cs: 启动配置文件。
- .gitignore: Git 忽略文件配置。
- LICENSE: 项目的许可证文件。
- README.md: 项目的说明文档。
- glazewm.sln: 项目的解决方案文件。
2. 项目的启动文件介绍
项目的启动文件是 src/Program.cs
。这个文件包含了程序的入口点,负责初始化和启动 GlazeWM 窗口管理器。
Program.cs 文件内容概览
using System;
using System.Threading.Tasks;
using GlazeWM.Infrastructure.Common;
using GlazeWM.Infrastructure.Common.Commands;
using GlazeWM.Infrastructure.WindowsApi;
using GlazeWM.Domain.UserConfigs;
using GlazeWM.Domain.Workspaces;
using GlazeWM.Domain.Windows;
using GlazeWM.Infrastructure.Bussing;
using GlazeWM.Infrastructure.Serialization;
using GlazeWM.Infrastructure.Utils;
using GlazeWM.App.Bootstrap;
using GlazeWM.App.Commands;
using GlazeWM.App.Services;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace GlazeWM
{
public class Program
{
public static async Task Main(string[] args)
{
var host = CreateHostBuilder(args).Build();
await host.RunAsync();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((context, services) =>
{
services.AddSingleton<Bus>();
services.AddSingleton<CommandHandlerService>();
services.AddSingleton<UserConfigService>();
services.AddSingleton<WorkspaceService>();
services.AddSingleton<WindowService>();
services.AddSingleton<AppBootstrapper>();
services.AddSingleton<AppService>();
services.AddSingleton<JsonService>();
services.AddSingleton<WindowsEventService>();
services.AddSingleton<WindowManagerService>();
services.AddSingleton<YamlService>();
services.AddSingleton<AppCommands>();
services.AddSingleton<AppHandlers>();
services.AddSingleton<AppServices>();
services.AddSingleton<AppUtils>();
})
.ConfigureAppConfiguration((context, config) =>
{
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
})
.UseWindowsService();
}
}
3. 项目的配置文件介绍
项目的配置文件主要位于 src/Config/
目录下。这些文件定义了窗口管理器的各种配置,包括布局、快捷键、主题等。
配置文件示例
# config.yaml
general:
theme: default
workspaces:
- name: "1"
layout: "tiling"
- name: "2"
layout: "floating"