mirror of
https://github.com/fairyglade/ly.git
synced 2026-02-04 08:24:55 +00:00
Check for session file name in autologin (closes #895)
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -14,6 +14,7 @@ pub const DesktopEntry = struct {
|
|||||||
pub const Entry = struct { @"Desktop Entry": DesktopEntry = .{} };
|
pub const Entry = struct { @"Desktop Entry": DesktopEntry = .{} };
|
||||||
|
|
||||||
entry_ini: ?Ini(Entry) = null,
|
entry_ini: ?Ini(Entry) = null,
|
||||||
|
file_name: []const u8 = "",
|
||||||
name: []const u8 = "",
|
name: []const u8 = "",
|
||||||
xdg_session_desktop: ?[]const u8 = null,
|
xdg_session_desktop: ?[]const u8 = null,
|
||||||
xdg_session_desktop_owned: bool = false,
|
xdg_session_desktop_owned: bool = false,
|
||||||
|
|||||||
@@ -1251,6 +1251,7 @@ fn crawl(session: *Session, lang: Lang, path: []const u8, display_server: Displa
|
|||||||
});
|
});
|
||||||
errdefer entry_ini.deinit();
|
errdefer entry_ini.deinit();
|
||||||
|
|
||||||
|
const file_name = std.fs.path.stem(item.name);
|
||||||
const entry = entry_ini.data.@"Desktop Entry";
|
const entry = entry_ini.data.@"Desktop Entry";
|
||||||
var maybe_xdg_session_desktop: ?[]const u8 = null;
|
var maybe_xdg_session_desktop: ?[]const u8 = null;
|
||||||
var maybe_xdg_desktop_names: ?[]const u8 = null;
|
var maybe_xdg_desktop_names: ?[]const u8 = null;
|
||||||
@@ -1268,15 +1269,15 @@ fn crawl(session: *Session, lang: Lang, path: []const u8, display_server: Displa
|
|||||||
} else if (display_server != .custom) {
|
} else if (display_server != .custom) {
|
||||||
// If DesktopNames is empty, and this isn't a custom session entry,
|
// If DesktopNames is empty, and this isn't a custom session entry,
|
||||||
// we'll take the name of the session file
|
// we'll take the name of the session file
|
||||||
const stem = std.fs.path.stem(item.name);
|
if (file_name.len > 0) {
|
||||||
if (stem.len > 0) {
|
maybe_xdg_session_desktop = try session.label.allocator.dupe(u8, file_name);
|
||||||
maybe_xdg_session_desktop = try session.label.allocator.dupe(u8, stem);
|
|
||||||
xdg_session_desktop_owned = true;
|
xdg_session_desktop_owned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try session.addEnvironment(.{
|
try session.addEnvironment(.{
|
||||||
.entry_ini = entry_ini,
|
.entry_ini = entry_ini,
|
||||||
|
.file_name = std.fs.path.stem(item.name),
|
||||||
.name = entry.Name,
|
.name = entry.Name,
|
||||||
.xdg_session_desktop = maybe_xdg_session_desktop,
|
.xdg_session_desktop = maybe_xdg_session_desktop,
|
||||||
.xdg_session_desktop_owned = xdg_session_desktop_owned,
|
.xdg_session_desktop_owned = xdg_session_desktop_owned,
|
||||||
@@ -1310,6 +1311,7 @@ fn findSessionByName(session: *Session, name: []const u8) ?usize {
|
|||||||
if (std.ascii.eqlIgnoreCase(session_desktop_name, name)) return i;
|
if (std.ascii.eqlIgnoreCase(session_desktop_name, name)) return i;
|
||||||
}
|
}
|
||||||
if (std.ascii.eqlIgnoreCase(env.environment.name, name)) return i;
|
if (std.ascii.eqlIgnoreCase(env.environment.name, name)) return i;
|
||||||
|
if (std.ascii.eqlIgnoreCase(env.environment.file_name, name)) return i;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user