mirror of https://github.com/fairyglade/ly.git
Remove options superseded by corner customisation
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
7eae544418
commit
954e90b3bd
|
|
@ -155,7 +155,7 @@ colormix_col3 = 0x20000000
|
||||||
|
|
||||||
# Screen corners customization
|
# Screen corners customization
|
||||||
# Keywords:
|
# Keywords:
|
||||||
# keys -> Power management keys (shutdown, restart, etc.)
|
# keys -> Power management, brightness control & toggle password keys
|
||||||
# clock -> Clock (format defined by 'clock' option)
|
# clock -> Clock (format defined by 'clock' option)
|
||||||
# tty -> Active TTY number
|
# tty -> Active TTY number
|
||||||
# battery -> Battery percentage
|
# battery -> Battery percentage
|
||||||
|
|
@ -179,7 +179,7 @@ corner_bottom_right = labels
|
||||||
corner_top_left = keys
|
corner_top_left = keys
|
||||||
|
|
||||||
# Top right
|
# Top right
|
||||||
corner_top_right = clock tty
|
corner_top_right = clock
|
||||||
|
|
||||||
# For custom binds: the horizontal limit in characters for each
|
# For custom binds: the horizontal limit in characters for each
|
||||||
# line of custom binds before moving on to the next.
|
# line of custom binds before moving on to the next.
|
||||||
|
|
@ -285,15 +285,6 @@ hibernate_key = F4
|
||||||
# Remove main box borders
|
# Remove main box borders
|
||||||
hide_borders = false
|
hide_borders = false
|
||||||
|
|
||||||
# Remove power management command hints
|
|
||||||
hide_key_hints = false
|
|
||||||
|
|
||||||
# Remove keyboard lock states from the top right corner
|
|
||||||
hide_keyboard_locks = false
|
|
||||||
|
|
||||||
# Remove version number from the top left corner
|
|
||||||
hide_version_string = false
|
|
||||||
|
|
||||||
# Command executed when no input is detected for a certain time
|
# Command executed when no input is detected for a certain time
|
||||||
# If null, no command will be executed
|
# If null, no command will be executed
|
||||||
inactivity_cmd = null
|
inactivity_cmd = null
|
||||||
|
|
@ -379,11 +370,6 @@ shell = true
|
||||||
# Specifies the key combination used for showing the password
|
# Specifies the key combination used for showing the password
|
||||||
show_password_key = F7
|
show_password_key = F7
|
||||||
|
|
||||||
# Display the active TTY number (e.g. tty3) to the right of the clock in the top right corner
|
|
||||||
# If the clock is disabled, the TTY label occupies the top right corner on its own
|
|
||||||
# If false, the TTY number will not be shown
|
|
||||||
show_tty = false
|
|
||||||
|
|
||||||
# Command executed when pressing shutdown_key
|
# Command executed when pressing shutdown_key
|
||||||
shutdown_cmd = /sbin/shutdown $PLATFORM_SHUTDOWN_ARG now
|
shutdown_cmd = /sbin/shutdown $PLATFORM_SHUTDOWN_ARG now
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ colormix_col3: u32 = 0x20000000,
|
||||||
corner_bottom_left: []const u8 = "version",
|
corner_bottom_left: []const u8 = "version",
|
||||||
corner_bottom_right: []const u8 = "labels",
|
corner_bottom_right: []const u8 = "labels",
|
||||||
corner_top_left: []const u8 = "keys",
|
corner_top_left: []const u8 = "keys",
|
||||||
corner_top_right: []const u8 = "clock tty",
|
corner_top_right: []const u8 = "clock",
|
||||||
custom_bind_width: ?u32 = null,
|
custom_bind_width: ?u32 = null,
|
||||||
custom_sessions: []const u8 = build_options.config_directory ++ "/ly/custom-sessions",
|
custom_sessions: []const u8 = build_options.config_directory ++ "/ly/custom-sessions",
|
||||||
default_input: Input = .login,
|
default_input: Input = .login,
|
||||||
|
|
@ -67,9 +67,6 @@ gameoflife_initial_density: f32 = 0.4,
|
||||||
hibernate_cmd: ?[]const u8 = null,
|
hibernate_cmd: ?[]const u8 = null,
|
||||||
hibernate_key: []const u8 = "F4",
|
hibernate_key: []const u8 = "F4",
|
||||||
hide_borders: bool = false,
|
hide_borders: bool = false,
|
||||||
hide_key_hints: bool = false,
|
|
||||||
hide_keyboard_locks: bool = false,
|
|
||||||
hide_version_string: bool = false,
|
|
||||||
inactivity_cmd: ?[]const u8 = null,
|
inactivity_cmd: ?[]const u8 = null,
|
||||||
inactivity_delay: u16 = 0,
|
inactivity_delay: u16 = 0,
|
||||||
initial_info_text: ?[]const u8 = null,
|
initial_info_text: ?[]const u8 = null,
|
||||||
|
|
@ -92,7 +89,6 @@ session_log: ?[]const u8 = "ly-session.log",
|
||||||
setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh",
|
setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh",
|
||||||
shell: bool = true,
|
shell: bool = true,
|
||||||
show_password_key: []const u8 = "F7",
|
show_password_key: []const u8 = "F7",
|
||||||
show_tty: bool = false,
|
|
||||||
shutdown_cmd: []const u8 = "/sbin/shutdown -a now",
|
shutdown_cmd: []const u8 = "/sbin/shutdown -a now",
|
||||||
shutdown_key: []const u8 = "F1",
|
shutdown_key: []const u8 = "F1",
|
||||||
sleep_cmd: ?[]const u8 = null,
|
sleep_cmd: ?[]const u8 = null,
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,11 @@ const removed_properties = [_][]const u8{
|
||||||
"wayland_cmd",
|
"wayland_cmd",
|
||||||
"console_dev",
|
"console_dev",
|
||||||
"load",
|
"load",
|
||||||
|
// Migrating these isn't worth the effort so just say we removed them
|
||||||
|
"hide_key_hints",
|
||||||
|
"hide_keyboard_locks",
|
||||||
|
"hide_version_string",
|
||||||
|
"show_tty",
|
||||||
};
|
};
|
||||||
|
|
||||||
pub var auto_eight_colors: bool = true;
|
pub var auto_eight_colors: bool = true;
|
||||||
|
|
|
||||||
93
src/main.zig
93
src/main.zig
|
|
@ -103,6 +103,13 @@ const UiState = struct {
|
||||||
password_label: Label,
|
password_label: Label,
|
||||||
version_label: Label,
|
version_label: Label,
|
||||||
bigclock_label: BigLabel,
|
bigclock_label: BigLabel,
|
||||||
|
show_tty: bool,
|
||||||
|
hide_key_hints: bool,
|
||||||
|
hide_numlock: bool,
|
||||||
|
hide_capslock: bool,
|
||||||
|
hide_version_string: bool,
|
||||||
|
hide_labels: bool,
|
||||||
|
hide_binds: bool,
|
||||||
box: Box,
|
box: Box,
|
||||||
info_line: InfoLine,
|
info_line: InfoLine,
|
||||||
animate: bool,
|
animate: bool,
|
||||||
|
|
@ -433,6 +440,14 @@ pub fn main(init: std.process.Init) !void {
|
||||||
};
|
};
|
||||||
std.posix.sigaction(std.posix.SIG.TERM, &act, null);
|
std.posix.sigaction(std.posix.SIG.TERM, &act, null);
|
||||||
|
|
||||||
|
state.show_tty = cornersContain(state, "tty");
|
||||||
|
state.hide_key_hints = !cornersContain(state, "keys");
|
||||||
|
state.hide_numlock = !cornersContain(state, "numlock");
|
||||||
|
state.hide_capslock = !cornersContain(state, "capslock");
|
||||||
|
state.hide_version_string = !cornersContain(state, "version");
|
||||||
|
state.hide_labels = !cornersContain(state, "labels") and !cornersContain(state, "lbl:");
|
||||||
|
state.hide_binds = !cornersContain(state, "binds") and !cornersContain(state, "cmd:");
|
||||||
|
|
||||||
// Initialize components
|
// Initialize components
|
||||||
state.shutdown_label = Label.init(
|
state.shutdown_label = Label.init(
|
||||||
"",
|
"",
|
||||||
|
|
@ -504,7 +519,7 @@ pub fn main(init: std.process.Init) !void {
|
||||||
);
|
);
|
||||||
defer state.brightness_up_label.deinit();
|
defer state.brightness_up_label.deinit();
|
||||||
|
|
||||||
if (!state.config.hide_key_hints) {
|
if (!state.hide_key_hints) {
|
||||||
try state.shutdown_label.setTextAlloc(
|
try state.shutdown_label.setTextAlloc(
|
||||||
state.allocator,
|
state.allocator,
|
||||||
"{s} {s}",
|
"{s} {s}",
|
||||||
|
|
@ -1052,7 +1067,7 @@ pub fn main(init: std.process.Init) !void {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.config.show_tty) {
|
if (state.show_tty) {
|
||||||
try state.tty_label.setTextBuf(&state.tty_buf, "tty{d}", .{state.active_tty});
|
try state.tty_label.setTextBuf(&state.tty_buf, "tty{d}", .{state.active_tty});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1226,34 +1241,35 @@ pub fn main(init: std.process.Init) !void {
|
||||||
|
|
||||||
state.custom_binds = .empty;
|
state.custom_binds = .empty;
|
||||||
defer state.custom_binds.deinit(state.allocator);
|
defer state.custom_binds.deinit(state.allocator);
|
||||||
|
|
||||||
state.custom_info = .empty;
|
|
||||||
defer state.custom_info.deinit(state.allocator);
|
|
||||||
|
|
||||||
var lblIter = custom.labels.iterator();
|
|
||||||
// NOTE: Because widgets have a pointer to the underlying Label, we have to ensure
|
|
||||||
// that the ArrayList doesn't allocate more memory than what we ensured. Otherwise
|
|
||||||
// the pointer to the Label becomes invalid.
|
|
||||||
try state.custom_info.ensureTotalCapacity(state.allocator, @intCast(custom.labels.count()));
|
|
||||||
while (lblIter.next()) |i| {
|
|
||||||
try state.custom_info.append(state.allocator, .{
|
|
||||||
.info = i.value_ptr.*,
|
|
||||||
.lbl = .init("", null, state.buffer.fg, state.buffer.bg, updateCustomInfo, null),
|
|
||||||
});
|
|
||||||
var latest = &state.custom_info.items[state.custom_info.items.len - 1];
|
|
||||||
latest.info.id = latest.lbl.widget().id;
|
|
||||||
latest.info.counter = 1;
|
|
||||||
}
|
|
||||||
defer for (state.custom_info.items) |*item| {
|
|
||||||
item.lbl.deinit();
|
|
||||||
};
|
|
||||||
|
|
||||||
var iter = custom.binds.iterator();
|
|
||||||
defer for (state.custom_binds.items) |*i| {
|
defer for (state.custom_binds.items) |*i| {
|
||||||
i.lbl.deinit();
|
i.lbl.deinit();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!state.config.hide_key_hints) {
|
state.custom_info = .empty;
|
||||||
|
defer state.custom_info.deinit(state.allocator);
|
||||||
|
defer for (state.custom_info.items) |*item| {
|
||||||
|
item.lbl.deinit();
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!state.hide_labels) {
|
||||||
|
var lblIter = custom.labels.iterator();
|
||||||
|
// NOTE: Because widgets have a pointer to the underlying Label, we have to ensure
|
||||||
|
// that the ArrayList doesn't allocate more memory than what we ensured. Otherwise
|
||||||
|
// the pointer to the Label becomes invalid.
|
||||||
|
try state.custom_info.ensureTotalCapacity(state.allocator, @intCast(custom.labels.count()));
|
||||||
|
while (lblIter.next()) |i| {
|
||||||
|
try state.custom_info.append(state.allocator, .{
|
||||||
|
.info = i.value_ptr.*,
|
||||||
|
.lbl = .init("", null, state.buffer.fg, state.buffer.bg, updateCustomInfo, null),
|
||||||
|
});
|
||||||
|
var latest = &state.custom_info.items[state.custom_info.items.len - 1];
|
||||||
|
latest.info.id = latest.lbl.widget().id;
|
||||||
|
latest.info.counter = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!state.hide_binds) {
|
||||||
|
var iter = custom.binds.iterator();
|
||||||
while (iter.next()) |i| {
|
while (iter.next()) |i| {
|
||||||
var concat = try std.mem.concat(state.allocator, u8, &[_][]const u8{ i.key_ptr.*, " ", i.value_ptr.name });
|
var concat = try std.mem.concat(state.allocator, u8, &[_][]const u8{ i.key_ptr.*, " ", i.value_ptr.name });
|
||||||
inline for (@typeInfo(Lang).@"struct".fields) |lang_key| {
|
inline for (@typeInfo(Lang).@"struct".fields) |lang_key| {
|
||||||
|
|
@ -1276,6 +1292,8 @@ pub fn main(init: std.process.Init) !void {
|
||||||
});
|
});
|
||||||
state.custom_binds.items[state.custom_binds.items.len - 1].lbl.allocator = state.allocator;
|
state.custom_binds.items[state.custom_binds.items.len - 1].lbl.allocator = state.allocator;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!state.hide_key_hints) {
|
||||||
try layer2.append(state.allocator, state.shutdown_label.widget());
|
try layer2.append(state.allocator, state.shutdown_label.widget());
|
||||||
try layer2.append(state.allocator, state.restart_label.widget());
|
try layer2.append(state.allocator, state.restart_label.widget());
|
||||||
if (state.config.sleep_cmd != null) {
|
if (state.config.sleep_cmd != null) {
|
||||||
|
|
@ -1298,14 +1316,16 @@ pub fn main(init: std.process.Init) !void {
|
||||||
if (state.config.clock != null) {
|
if (state.config.clock != null) {
|
||||||
try layer2.append(state.allocator, state.clock_label.widget());
|
try layer2.append(state.allocator, state.clock_label.widget());
|
||||||
}
|
}
|
||||||
if (state.config.show_tty) {
|
if (state.show_tty) {
|
||||||
try layer2.append(state.allocator, state.tty_label.widget());
|
try layer2.append(state.allocator, state.tty_label.widget());
|
||||||
}
|
}
|
||||||
if (state.config.bigclock != .none) {
|
if (state.config.bigclock != .none) {
|
||||||
try layer2.append(state.allocator, state.bigclock_label.widget());
|
try layer2.append(state.allocator, state.bigclock_label.widget());
|
||||||
}
|
}
|
||||||
if (!state.config.hide_keyboard_locks) {
|
if (!state.hide_numlock) {
|
||||||
try layer2.append(state.allocator, state.numlock_label.widget());
|
try layer2.append(state.allocator, state.numlock_label.widget());
|
||||||
|
}
|
||||||
|
if (!state.hide_capslock) {
|
||||||
try layer2.append(state.allocator, state.capslock_label.widget());
|
try layer2.append(state.allocator, state.capslock_label.widget());
|
||||||
}
|
}
|
||||||
try layer2.append(state.allocator, state.box.widget());
|
try layer2.append(state.allocator, state.box.widget());
|
||||||
|
|
@ -1316,7 +1336,7 @@ pub fn main(init: std.process.Init) !void {
|
||||||
try layer2.append(state.allocator, login_widget);
|
try layer2.append(state.allocator, login_widget);
|
||||||
try layer2.append(state.allocator, state.password_label.widget());
|
try layer2.append(state.allocator, state.password_label.widget());
|
||||||
try layer2.append(state.allocator, state.password_widget);
|
try layer2.append(state.allocator, state.password_widget);
|
||||||
if (!state.config.hide_version_string) {
|
if (!state.hide_version_string) {
|
||||||
try layer2.append(state.allocator, state.version_label.widget());
|
try layer2.append(state.allocator, state.version_label.widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1408,6 +1428,15 @@ pub fn main(init: std.process.Init) !void {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn cornersContain(state: UiState, text: []const u8) bool {
|
||||||
|
const top_left = std.mem.containsAtLeast(u8, state.config.corner_top_left, 1, text);
|
||||||
|
const top_right = std.mem.containsAtLeast(u8, state.config.corner_top_right, 1, text);
|
||||||
|
const bottom_left = std.mem.containsAtLeast(u8, state.config.corner_bottom_left, 1, text);
|
||||||
|
const bottom_right = std.mem.containsAtLeast(u8, state.config.corner_bottom_right, 1, text);
|
||||||
|
|
||||||
|
return top_left or top_right or bottom_left or bottom_right;
|
||||||
|
}
|
||||||
|
|
||||||
fn maxWidths(labels: [][]const u8) usize {
|
fn maxWidths(labels: [][]const u8) usize {
|
||||||
var max_width: usize = 0;
|
var max_width: usize = 0;
|
||||||
|
|
||||||
|
|
@ -2078,8 +2107,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu
|
||||||
const base_x = state.edge_margin.x;
|
const base_x = state.edge_margin.x;
|
||||||
|
|
||||||
if (std.mem.eql(u8, item, "keys")) {
|
if (std.mem.eql(u8, item, "keys")) {
|
||||||
if (state.config.hide_key_hints) return false;
|
|
||||||
|
|
||||||
var local_x = current_x.*;
|
var local_x = current_x.*;
|
||||||
var local_y = current_y;
|
var local_y = current_y;
|
||||||
|
|
||||||
|
|
@ -2127,7 +2154,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (std.mem.eql(u8, item, "tty")) {
|
} else if (std.mem.eql(u8, item, "tty")) {
|
||||||
if (!state.config.show_tty) return false;
|
|
||||||
const width = TerminalBuffer.strWidth(state.tty_label.text);
|
const width = TerminalBuffer.strWidth(state.tty_label.text);
|
||||||
if (is_left) {
|
if (is_left) {
|
||||||
state.tty_label.positionXY(Position.init(current_x.*, current_y));
|
state.tty_label.positionXY(Position.init(current_x.*, current_y));
|
||||||
|
|
@ -2149,7 +2175,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (std.mem.eql(u8, item, "version")) {
|
} else if (std.mem.eql(u8, item, "version")) {
|
||||||
if (state.config.hide_version_string) return false;
|
|
||||||
const width = TerminalBuffer.strWidth(state.version_label.text);
|
const width = TerminalBuffer.strWidth(state.version_label.text);
|
||||||
if (is_left) {
|
if (is_left) {
|
||||||
state.version_label.positionXY(Position.init(current_x.*, current_y));
|
state.version_label.positionXY(Position.init(current_x.*, current_y));
|
||||||
|
|
@ -2160,7 +2185,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (std.mem.eql(u8, item, "numlock")) {
|
} else if (std.mem.eql(u8, item, "numlock")) {
|
||||||
if (state.config.hide_keyboard_locks) return false;
|
|
||||||
const width = TerminalBuffer.strWidth(state.lang.numlock);
|
const width = TerminalBuffer.strWidth(state.lang.numlock);
|
||||||
if (is_left) {
|
if (is_left) {
|
||||||
state.numlock_label.positionXY(Position.init(current_x.*, current_y));
|
state.numlock_label.positionXY(Position.init(current_x.*, current_y));
|
||||||
|
|
@ -2171,7 +2195,6 @@ fn positionSingleWidget(state: *UiState, item: []const u8, current_x: *usize, cu
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (std.mem.eql(u8, item, "capslock")) {
|
} else if (std.mem.eql(u8, item, "capslock")) {
|
||||||
if (state.config.hide_keyboard_locks) return false;
|
|
||||||
const width = TerminalBuffer.strWidth(state.lang.capslock);
|
const width = TerminalBuffer.strWidth(state.lang.capslock);
|
||||||
if (is_left) {
|
if (is_left) {
|
||||||
state.capslock_label.positionXY(Position.init(current_x.*, current_y));
|
state.capslock_label.positionXY(Position.init(current_x.*, current_y));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue