diff --git a/doc/riverctl.1.scd b/doc/riverctl.1.scd index 6a8332a..ece7eee 100644 --- a/doc/riverctl.1.scd +++ b/doc/riverctl.1.scd @@ -230,13 +230,13 @@ A complete list may be found in _/usr/include/linux/input-event-codes.h_ *attach-mode* *top*|*bottom* Configure where new views should attach to the view stack. -*background-color* _#RRGGBB_|_#RRGGBBAA_ +*background-color* _0xRRGGBB_|_0xRRGGBBAA_ Set the background color. -*border-color-focused* _#RRGGBB_|_#RRGGBBAA_ +*border-color-focused* _0xRRGGBB_|_0xRRGGBBAA_ Set the border color of focused views. -*border-color-unfocused* _#RRGGBB_|_#RRGGBBAA_ +*border-color-unfocused* _0xRRGGBB_|_0xRRGGBBAA_ Set the border color of unfocused views. *border-width* _pixels_ diff --git a/example/init b/example/init index a00a5b1..5c7fa16 100755 --- a/example/init +++ b/example/init @@ -140,6 +140,11 @@ do riverctl map $mode None XF86MonBrightnessDown spawn 'light -U 5' done +# Set background and border color +riverctl background-color 0x002b36 +riverctl border-color-focused 0x93a1a1 +riverctl border-color-unfocused 0x586e75 + # Set repeat rate riverctl set-repeat 50 300 diff --git a/river/Config.zig b/river/Config.zig index 63fef65..0ee14b4 100644 --- a/river/Config.zig +++ b/river/Config.zig @@ -48,7 +48,7 @@ border_width: u32 = 2, border_color_focused: [4]f32 = [_]f32{ 0.57647059, 0.63137255, 0.63137255, 1.0 }, // Solarized base1 /// Color of border of unfocused window in RGBA -border_color_unfocused: [4]f32 = [_]f32{ 0.34509804, 0.43137255, 0.45882353, 1.0 }, // Solarized base0 +border_color_unfocused: [4]f32 = [_]f32{ 0.34509804, 0.43137255, 0.45882353, 1.0 }, // Solarized base01 /// Map of keymap mode name to mode id mode_to_id: std.StringHashMap(usize), diff --git a/river/command.zig b/river/command.zig index 47413ee..c67f15b 100644 --- a/river/command.zig +++ b/river/command.zig @@ -144,7 +144,7 @@ pub fn errToMsg(err: Error) [:0]const u8 { Error.InvalidDirection => "invalid direction. Must be 'next' or 'previous'", Error.InvalidPhysicalDirection => "invalid direction. Must be 'up', 'down', 'left' or 'right'", Error.InvalidOrientation => "invalid orientation. Must be 'horizontal', or 'vertical'", - Error.InvalidRgba => "invalid color format, must be #RRGGBB or #RRGGBBAA", + Error.InvalidRgba => "invalid color format, must be hexadecimal 0xRRGGBB or 0xRRGGBBAA", Error.InvalidValue => "invalid value", Error.OutOfMemory => "out of memory", Error.Other => unreachable, diff --git a/river/command/config.zig b/river/command/config.zig index 00a3494..9161c7d 100644 --- a/river/command/config.zig +++ b/river/command/config.zig @@ -16,6 +16,7 @@ // along with this program. If not, see . const std = @import("std"); +const fmt = std.fmt; const server = &@import("../main.zig").server; @@ -32,7 +33,7 @@ pub fn borderWidth( if (args.len < 2) return Error.NotEnoughArguments; if (args.len > 2) return Error.TooManyArguments; - server.config.border_width = try std.fmt.parseInt(u32, args[1], 10); + server.config.border_width = try fmt.parseInt(u32, args[1], 10); server.root.arrangeAll(); server.root.startTransaction(); } @@ -94,14 +95,15 @@ pub fn setCursorWarp( return Error.UnknownOption; } -/// Parse a color in the format #RRGGBB or #RRGGBBAA +/// Parse a color in the format 0xRRGGBB or 0xRRGGBBAA fn parseRgba(string: []const u8) ![4]f32 { - if ((string.len != 7 and string.len != 9) or string[0] != '#') return error.InvalidRgba; + if (string.len != 8 and string.len != 10) return error.InvalidRgba; + if (string[0] != '0' or string[1] != 'x') return error.InvalidRgba; - const r = try std.fmt.parseInt(u8, string[1..3], 16); - const g = try std.fmt.parseInt(u8, string[3..5], 16); - const b = try std.fmt.parseInt(u8, string[5..7], 16); - const a = if (string.len == 9) try std.fmt.parseInt(u8, string[7..9], 16) else 255; + const r = try fmt.parseInt(u8, string[2..4], 16); + const g = try fmt.parseInt(u8, string[4..6], 16); + const b = try fmt.parseInt(u8, string[6..8], 16); + const a = if (string.len == 10) try fmt.parseInt(u8, string[8..10], 16) else 255; return [4]f32{ @intToFloat(f32, r) / 255.0,