mirror of
https://github.com/fairyglade/ly.git
synced 2026-08-07 05:32:02 +00:00
Remove shutdown_cmd & restart_cmd + sleep & hibernate
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -64,8 +64,6 @@ gameoflife_fg: u32 = 0x0000FF00,
|
||||
gameoflife_entropy_interval: usize = 10,
|
||||
gameoflife_frame_delay: usize = 6,
|
||||
gameoflife_initial_density: f32 = 0.4,
|
||||
hibernate_cmd: ?[]const u8 = null,
|
||||
hibernate_key: []const u8 = "F4",
|
||||
hide_borders: bool = false,
|
||||
inactivity_cmd: ?[]const u8 = null,
|
||||
inactivity_delay: u16 = 0,
|
||||
@@ -81,7 +79,6 @@ margin_box_h: u8 = 2,
|
||||
margin_box_v: u8 = 1,
|
||||
numlock: bool = false,
|
||||
path: ?[]const u8 = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
restart_cmd: []const u8 = "/sbin/shutdown -r now",
|
||||
restart_key: []const u8 = "F2",
|
||||
save: bool = true,
|
||||
service_name: [:0]const u8 = "ly",
|
||||
@@ -89,10 +86,7 @@ session_log: ?[]const u8 = "ly-session.log",
|
||||
setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh",
|
||||
shell: bool = true,
|
||||
show_password_key: []const u8 = "F7",
|
||||
shutdown_cmd: []const u8 = "/sbin/shutdown -a now",
|
||||
shutdown_key: []const u8 = "F1",
|
||||
sleep_cmd: ?[]const u8 = null,
|
||||
sleep_key: []const u8 = "F3",
|
||||
start_cmd: ?[]const u8 = null,
|
||||
text_in_center: bool = false,
|
||||
type_username: bool = false,
|
||||
|
||||
@@ -14,6 +14,7 @@ const IniParser = ly_core.IniParser;
|
||||
const ini = ly_core.ini;
|
||||
|
||||
const Config = @import("Config.zig");
|
||||
const Lang = @import("Lang.zig");
|
||||
const OldSave = @import("OldSave.zig");
|
||||
const SavedUsers = @import("SavedUsers.zig");
|
||||
const custom = @import("custom.zig");
|
||||
@@ -45,6 +46,8 @@ const removed_properties = [_][]const u8{
|
||||
"wayland_cmd",
|
||||
"console_dev",
|
||||
"load",
|
||||
"shutdown_cmd",
|
||||
"restart_cmd",
|
||||
// Migrating these isn't worth the effort so just say we removed them
|
||||
"hide_key_hints",
|
||||
"hide_keyboard_locks",
|
||||
@@ -56,6 +59,10 @@ pub var auto_eight_colors: bool = true;
|
||||
|
||||
pub var maybe_animate: ?bool = null;
|
||||
pub var maybe_save_file: ?[]const u8 = null;
|
||||
pub var maybe_sleep_key: ?[]const u8 = null;
|
||||
pub var maybe_sleep_cmd: ?[]const u8 = null;
|
||||
pub var maybe_hibernate_key: ?[]const u8 = null;
|
||||
pub var maybe_hibernate_cmd: ?[]const u8 = null;
|
||||
|
||||
pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniField {
|
||||
if (std.mem.eql(u8, field.key, "animate")) {
|
||||
@@ -129,7 +136,6 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie
|
||||
if (std.mem.eql(u8, field.key, "save_file")) {
|
||||
// The option doesn't exist anymore, but we save its value for migration later on
|
||||
maybe_save_file = temporary_allocator.dupe(u8, field.value) catch return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -168,6 +174,26 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie
|
||||
return mapped_field;
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, field.key, "sleep_key")) {
|
||||
maybe_sleep_key = temporary_allocator.dupe(u8, field.value) catch return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, field.key, "sleep_cmd")) {
|
||||
maybe_sleep_cmd = temporary_allocator.dupe(u8, field.value) catch return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, field.key, "hibernate_key")) {
|
||||
maybe_hibernate_key = temporary_allocator.dupe(u8, field.value) catch return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (std.mem.eql(u8, field.key, "hibernate_cmd")) {
|
||||
maybe_hibernate_cmd = temporary_allocator.dupe(u8, field.value) catch return null;
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: Dearest Melpert,
|
||||
// I pray this message finds you well, as daylight dwindles and the witching hour
|
||||
// approaches, I find it more and more imperative as time continues that I place
|
||||
@@ -228,7 +254,7 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie
|
||||
|
||||
// This is the stuff we only handle after reading the config.
|
||||
// For example, the "animate" field could come after "animation"
|
||||
pub fn lateConfigFieldHandler(config: *Config) void {
|
||||
pub fn lateConfigFieldHandler(config: *Config, lang: Lang) void {
|
||||
if (maybe_animate) |animate| {
|
||||
if (!animate) config.*.animation = .none;
|
||||
}
|
||||
@@ -257,6 +283,24 @@ pub fn lateConfigFieldHandler(config: *Config) void {
|
||||
if (!set_color_properties[7]) config.error_fg = Styling.BOLD | Color.ECOL_RED;
|
||||
if (!set_color_properties[8]) config.fg = Color.ECOL_WHITE;
|
||||
}
|
||||
|
||||
if (maybe_sleep_key) |key| {
|
||||
if (maybe_sleep_cmd) |cmd| {
|
||||
custom.binds.put(temporary_allocator, key, .{
|
||||
.name = temporary_allocator.dupe(u8, lang.sleep) catch "",
|
||||
.cmd = cmd,
|
||||
}) catch {};
|
||||
}
|
||||
}
|
||||
|
||||
if (maybe_hibernate_key) |key| {
|
||||
if (maybe_hibernate_cmd) |cmd| {
|
||||
custom.binds.put(temporary_allocator, key, .{
|
||||
.name = temporary_allocator.dupe(u8, lang.hibernate) catch "",
|
||||
.cmd = cmd,
|
||||
}) catch {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn tryMigrateIniSaveFile(allocator: std.mem.Allocator, io: std.Io, path: []const u8, saved_users: *SavedUsers, usernames: [][]const u8) !?IniParser(OldSave) {
|
||||
|
||||
Reference in New Issue
Block a user