config: minor config changes

This commit is contained in:
Mitchell Hashimoto
2025-01-05 12:35:41 -08:00
parent 0ae8d9ed42
commit bb83a14d7a
2 changed files with 13 additions and 11 deletions

View File

@ -403,7 +403,7 @@ pub fn syncAppearance(self: *Window, config: *const configpkg.Config) !void {
const blurred = switch (config.@"background-blur-radius") { const blurred = switch (config.@"background-blur-radius") {
.false => false, .false => false,
.true => true, .true => true,
.value => |v| v > 0, .radius => |v| v > 0,
}; };
try wl.setBlur(blurred); try wl.setBlur(blurred);
} }

View File

@ -5666,7 +5666,7 @@ pub const AutoUpdate = enum {
pub const BackgroundBlur = union(enum) { pub const BackgroundBlur = union(enum) {
false, false,
true, true,
value: u8, radius: u8,
pub fn parseCLI(self: *BackgroundBlur, input: ?[]const u8) !void { pub fn parseCLI(self: *BackgroundBlur, input: ?[]const u8) !void {
const input_ = input orelse { const input_ = input orelse {
@ -5675,19 +5675,21 @@ pub const BackgroundBlur = union(enum) {
return; return;
}; };
if (cli.args.parseBool(input_)) |b| { self.* = if (cli.args.parseBool(input_)) |b|
self.* = if (b) .true else .false; if (b) .true else .false
} else |_| { else |_|
const value = std.fmt.parseInt(u8, input_, 0) catch return error.InvalidValue; .{ .radius = std.fmt.parseInt(
self.* = .{ .value = value }; u8,
} input_,
0,
) catch return error.InvalidValue };
} }
pub fn cval(self: BackgroundBlur) u8 { pub fn cval(self: BackgroundBlur) u8 {
return switch (self) { return switch (self) {
.false => 0, .false => 0,
.true => 20, .true => 20,
.value => |v| v, .radius => |v| v,
}; };
} }
@ -5698,7 +5700,7 @@ pub const BackgroundBlur = union(enum) {
switch (self) { switch (self) {
.false => try formatter.formatEntry(bool, false), .false => try formatter.formatEntry(bool, false),
.true => try formatter.formatEntry(bool, true), .true => try formatter.formatEntry(bool, true),
.value => |v| try formatter.formatEntry(u8, v), .radius => |v| try formatter.formatEntry(u8, v),
} }
} }
@ -5716,7 +5718,7 @@ pub const BackgroundBlur = union(enum) {
try testing.expectEqual(.false, v); try testing.expectEqual(.false, v);
try v.parseCLI("42"); try v.parseCLI("42");
try testing.expectEqual(42, v.value); try testing.expectEqual(42, v.radius);
try testing.expectError(error.InvalidValue, v.parseCLI("")); try testing.expectError(error.InvalidValue, v.parseCLI(""));
try testing.expectError(error.InvalidValue, v.parseCLI("aaaa")); try testing.expectError(error.InvalidValue, v.parseCLI("aaaa"));