mirror of https://github.com/fairyglade/ly.git
Consolidate xsetup.sh & wsetup.sh into one file
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
parent
c7f70ac78f
commit
6fbbb4eff0
|
@ -269,11 +269,8 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
|
||||||
|
|
||||||
try patch_map.put("$CONFIG_DIRECTORY", config_directory);
|
try patch_map.put("$CONFIG_DIRECTORY", config_directory);
|
||||||
|
|
||||||
const patched_xsetup = try patchFile(allocator, "res/xsetup.sh", patch_map);
|
const patched_setup = try patchFile(allocator, "res/setup.sh", patch_map);
|
||||||
const patched_wsetup = try patchFile(allocator, "res/wsetup.sh", patch_map);
|
try installText(patched_setup, config_dir, ly_config_directory, "setup.sh", .{ .mode = 0o755 });
|
||||||
|
|
||||||
try installText(patched_xsetup, config_dir, ly_config_directory, "xsetup.sh", .{ .mode = 0o755 });
|
|
||||||
try installText(patched_wsetup, config_dir, ly_config_directory, "wsetup.sh", .{ .mode = 0o755 });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +314,7 @@ fn install_ly(allocator: std.mem.Allocator, install_config: bool) !void {
|
||||||
pub fn uninstallall(step: *std.Build.Step, _: ProgressNode) !void {
|
pub fn uninstallall(step: *std.Build.Step, _: ProgressNode) !void {
|
||||||
const allocator = step.owner.allocator;
|
const allocator = step.owner.allocator;
|
||||||
|
|
||||||
try deleteTree(allocator, config_directory, "/ly", "ly data directory not found");
|
try deleteTree(allocator, config_directory, "/ly", "ly config directory not found");
|
||||||
|
|
||||||
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin/", executable_name });
|
const exe_path = try std.fs.path.join(allocator, &[_][]const u8{ dest_directory, prefix_directory, "/bin/", executable_name });
|
||||||
var success = true;
|
var success = true;
|
||||||
|
|
|
@ -149,8 +149,8 @@ numlock = false
|
||||||
# Service name (set to ly to use the provided pam config file)
|
# Service name (set to ly to use the provided pam config file)
|
||||||
service_name = ly
|
service_name = ly
|
||||||
|
|
||||||
# Wayland setup command
|
# Setup command
|
||||||
wayland_cmd = $CONFIG_DIRECTORY/ly/wsetup.sh
|
setup_cmd = $CONFIG_DIRECTORY/ly/setup.sh
|
||||||
|
|
||||||
# Wayland desktop environments
|
# Wayland desktop environments
|
||||||
waylandsessions = $PREFIX_DIRECTORY/share/wayland-sessions
|
waylandsessions = $PREFIX_DIRECTORY/share/wayland-sessions
|
||||||
|
@ -162,9 +162,6 @@ xinitrc = ~/.xinitrc
|
||||||
# Xorg server command
|
# Xorg server command
|
||||||
x_cmd = $PREFIX_DIRECTORY/bin/X
|
x_cmd = $PREFIX_DIRECTORY/bin/X
|
||||||
|
|
||||||
# Xorg setup command
|
|
||||||
x_cmd_setup = $CONFIG_DIRECTORY/ly/xsetup.sh
|
|
||||||
|
|
||||||
# Xorg xauthority edition tool
|
# Xorg xauthority edition tool
|
||||||
xauth_cmd = $PREFIX_DIRECTORY/bin/xauth
|
xauth_cmd = $PREFIX_DIRECTORY/bin/xauth
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,107 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Shell environment setup after login
|
||||||
|
# Copyright (C) 2015-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
|
||||||
|
|
||||||
|
# This file is extracted from kde-workspace (kdm/kfrontend/genkdmconf.c)
|
||||||
|
# Copyright (C) 2001-2005 Oswald Buddenhagen <ossi@kde.org>
|
||||||
|
|
||||||
|
# Copyright (C) 2024 The Fairy Glade
|
||||||
|
# This work is free. You can redistribute it and/or modify it under the
|
||||||
|
# terms of the Do What The Fuck You Want To Public License, Version 2,
|
||||||
|
# as published by Sam Hocevar. See the LICENSE file for more details.
|
||||||
|
|
||||||
|
# Note that the respective logout scripts are not sourced.
|
||||||
|
case $SHELL in
|
||||||
|
*/bash)
|
||||||
|
[ -z "$BASH" ] && exec $SHELL "$0" "$@"
|
||||||
|
set +o posix
|
||||||
|
[ -f "$CONFIG_DIRECTORY"/profile ] && . "$CONFIG_DIRECTORY"/profile
|
||||||
|
if [ -f "$HOME"/.bash_profile ]; then
|
||||||
|
. "$HOME"/.bash_profile
|
||||||
|
elif [ -f "$HOME"/.bash_login ]; then
|
||||||
|
. "$HOME"/.bash_login
|
||||||
|
elif [ -f "$HOME"/.profile ]; then
|
||||||
|
. "$HOME"/.profile
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*/zsh)
|
||||||
|
[ -z "$ZSH_NAME" ] && exec $SHELL "$0" "$@"
|
||||||
|
[ -d "$CONFIG_DIRECTORY"/zsh ] && zdir="$CONFIG_DIRECTORY"/zsh || zdir="$CONFIG_DIRECTORY"
|
||||||
|
zhome=${ZDOTDIR:-"$HOME"}
|
||||||
|
# zshenv is always sourced automatically.
|
||||||
|
[ -f "$zdir"/zprofile ] && . "$zdir"/zprofile
|
||||||
|
[ -f "$zhome"/.zprofile ] && . "$zhome"/.zprofile
|
||||||
|
[ -f "$zdir"/zlogin ] && . "$zdir"/zlogin
|
||||||
|
[ -f "$zhome"/.zlogin ] && . "$zhome"/.zlogin
|
||||||
|
emulate -R sh
|
||||||
|
;;
|
||||||
|
*/csh|*/tcsh)
|
||||||
|
# [t]cshrc is always sourced automatically.
|
||||||
|
# Note that sourcing csh.login after .cshrc is non-standard.
|
||||||
|
sess_tmp=$(mktemp /tmp/sess-env-XXXXXX)
|
||||||
|
$SHELL -c "if (-f $CONFIG_DIRECTORY/csh.login) source $CONFIG_DIRECTORY/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $sess_tmp"
|
||||||
|
. "$sess_tmp"
|
||||||
|
rm -f "$sess_tmp"
|
||||||
|
;;
|
||||||
|
*/fish)
|
||||||
|
[ -f "$CONFIG_DIRECTORY"/profile ] && . "$CONFIG_DIRECTORY"/profile
|
||||||
|
[ -f "$HOME"/.profile ] && . "$HOME"/.profile
|
||||||
|
sess_tmp=$(mktemp /tmp/sess-env-XXXXXX)
|
||||||
|
$SHELL --login -c "/bin/sh -c 'export -p' > $sess_tmp"
|
||||||
|
. "$sess_tmp"
|
||||||
|
rm -f "$sess_tmp"
|
||||||
|
;;
|
||||||
|
*) # Plain sh, ksh, and anything we do not know.
|
||||||
|
[ -f "$CONFIG_DIRECTORY"/profile ] && . "$CONFIG_DIRECTORY"/profile
|
||||||
|
[ -f "$HOME"/.profile ] && . "$HOME"/.profile
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ "$XDG_SESSION_TYPE" = "x11" ]; then
|
||||||
|
[ -f "$CONFIG_DIRECTORY"/xprofile ] && . "$CONFIG_DIRECTORY"/xprofile
|
||||||
|
[ -f "$HOME"/.xprofile ] && . "$HOME"/.xprofile
|
||||||
|
|
||||||
|
# run all system xinitrc shell scripts.
|
||||||
|
if [ -d "$CONFIG_DIRECTORY"/X11/xinit/xinitrc.d ]; then
|
||||||
|
for i in "$CONFIG_DIRECTORY"/X11/xinit/xinitrc.d/* ; do
|
||||||
|
if [ -x "$i" ]; then
|
||||||
|
. "$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load Xsession scripts
|
||||||
|
# OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
|
||||||
|
# by the scripts to work
|
||||||
|
xsessionddir="$CONFIG_DIRECTORY"/X11/Xsession.d
|
||||||
|
export OPTIONFILE="$CONFIG_DIRECTORY"/X11/Xsession.options
|
||||||
|
export USERXSESSION="$HOME"/.xsession
|
||||||
|
export USERXSESSIONRC="$HOME"/.xsessionrc
|
||||||
|
export ALTUSERXSESSION="$HOME"/.Xsession
|
||||||
|
|
||||||
|
if [ -d "$xsessionddir" ]; then
|
||||||
|
for i in $(ls "$xsessionddir"); do
|
||||||
|
script="$xsessionddir/$i"
|
||||||
|
echo "Loading X session script $script"
|
||||||
|
if [ -r "$script" ] && [ -f "$script" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
|
||||||
|
. "$script"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "$CONFIG_DIRECTORY"/X11/Xresources ]; then
|
||||||
|
for i in "$CONFIG_DIRECTORY"/X11/Xresources/*; do
|
||||||
|
[ -f "$i" ] && xrdb -merge "$i"
|
||||||
|
done
|
||||||
|
elif [ -f "$CONFIG_DIRECTORY"/X11/Xresources ]; then
|
||||||
|
xrdb -merge "$CONFIG_DIRECTORY"/X11/Xresources
|
||||||
|
fi
|
||||||
|
[ -f "$HOME"/.Xresources ] && xrdb -merge "$HOME"/.Xresources
|
||||||
|
[ -f "$XDG_CONFIG_HOME"/X11/Xresources ] && xrdb -merge "$XDG_CONFIG_HOME"/X11/Xresources
|
||||||
|
|
||||||
|
if [ -f "$USERXSESSION" ]; then
|
||||||
|
. "$USERXSESSION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
|
@ -156,7 +156,7 @@ fn startSession(
|
||||||
std.posix.chdirZ(pwd.pw_dir.?) catch return error.ChangeDirectoryFailed;
|
std.posix.chdirZ(pwd.pw_dir.?) catch return error.ChangeDirectoryFailed;
|
||||||
|
|
||||||
switch (current_environment.display_server) {
|
switch (current_environment.display_server) {
|
||||||
.wayland => try executeWaylandCmd(pwd.pw_shell.?, config.wayland_cmd, current_environment.cmd),
|
.wayland => try executeWaylandCmd(pwd.pw_shell.?, config.setup_cmd, current_environment.cmd),
|
||||||
.shell => try executeShellCmd(pwd.pw_shell.?),
|
.shell => try executeShellCmd(pwd.pw_shell.?),
|
||||||
.xinitrc, .x11 => if (build_options.enable_x11_support) {
|
.xinitrc, .x11 => if (build_options.enable_x11_support) {
|
||||||
var vt_buf: [5]u8 = undefined;
|
var vt_buf: [5]u8 = undefined;
|
||||||
|
@ -377,9 +377,9 @@ fn executeShellCmd(shell: [*:0]const u8) !void {
|
||||||
return std.posix.execveZ(shell, &args, std.c.environ);
|
return std.posix.execveZ(shell, &args, std.c.environ);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn executeWaylandCmd(shell: [*:0]const u8, wayland_cmd: []const u8, desktop_cmd: []const u8) !void {
|
fn executeWaylandCmd(shell: [*:0]const u8, setup_cmd: []const u8, desktop_cmd: []const u8) !void {
|
||||||
var cmd_buffer: [1024]u8 = undefined;
|
var cmd_buffer: [1024]u8 = undefined;
|
||||||
const cmd_str = try std.fmt.bufPrintZ(&cmd_buffer, "{s} {s}", .{ wayland_cmd, desktop_cmd });
|
const cmd_str = try std.fmt.bufPrintZ(&cmd_buffer, "{s} {s}", .{ setup_cmd, desktop_cmd });
|
||||||
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||||
return std.posix.execveZ(shell, &args, std.c.environ);
|
return std.posix.execveZ(shell, &args, std.c.environ);
|
||||||
}
|
}
|
||||||
|
@ -416,7 +416,7 @@ fn executeX11Cmd(shell: [*:0]const u8, pw_dir: [*:0]const u8, config: Config, de
|
||||||
xorg_pid = try std.posix.fork();
|
xorg_pid = try std.posix.fork();
|
||||||
if (xorg_pid == 0) {
|
if (xorg_pid == 0) {
|
||||||
var cmd_buffer: [1024]u8 = undefined;
|
var cmd_buffer: [1024]u8 = undefined;
|
||||||
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} {s}", .{ config.x_cmd_setup, desktop_cmd }) catch std.process.exit(1);
|
const cmd_str = std.fmt.bufPrintZ(&cmd_buffer, "{s} {s}", .{ config.setup_cmd, desktop_cmd }) catch std.process.exit(1);
|
||||||
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
const args = [_:null]?[*:0]const u8{ shell, "-c", cmd_str };
|
||||||
std.posix.execveZ(shell, &args, std.c.environ) catch {};
|
std.posix.execveZ(shell, &args, std.c.environ) catch {};
|
||||||
std.process.exit(1);
|
std.process.exit(1);
|
||||||
|
|
|
@ -36,6 +36,7 @@ restart_cmd: []const u8 = "/sbin/shutdown -r now",
|
||||||
restart_key: []const u8 = "F2",
|
restart_key: []const u8 = "F2",
|
||||||
save: bool = true,
|
save: bool = true,
|
||||||
service_name: [:0]const u8 = "ly",
|
service_name: [:0]const u8 = "ly",
|
||||||
|
setup_cmd: []const u8 = build_options.config_directory ++ "/ly/setup.sh",
|
||||||
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,
|
||||||
|
@ -43,11 +44,9 @@ sleep_key: []const u8 = "F3",
|
||||||
tty: u8 = build_options.tty,
|
tty: u8 = build_options.tty,
|
||||||
vi_mode: bool = false,
|
vi_mode: bool = false,
|
||||||
vi_default_mode: ViMode = .normal,
|
vi_default_mode: ViMode = .normal,
|
||||||
wayland_cmd: []const u8 = build_options.config_directory ++ "/ly/wsetup.sh",
|
|
||||||
waylandsessions: []const u8 = build_options.prefix_directory ++ "/share/wayland-sessions",
|
waylandsessions: []const u8 = build_options.prefix_directory ++ "/share/wayland-sessions",
|
||||||
x_cmd: []const u8 = build_options.prefix_directory ++ "/bin/X",
|
x_cmd: []const u8 = build_options.prefix_directory ++ "/bin/X",
|
||||||
xinitrc: ?[]const u8 = "~/.xinitrc",
|
xinitrc: ?[]const u8 = "~/.xinitrc",
|
||||||
x_cmd_setup: []const u8 = build_options.config_directory ++ "/ly/xsetup.sh",
|
|
||||||
xauth_cmd: []const u8 = build_options.prefix_directory ++ "/bin/xauth",
|
xauth_cmd: []const u8 = build_options.prefix_directory ++ "/bin/xauth",
|
||||||
xsessions: []const u8 = build_options.prefix_directory ++ "/share/xsessions",
|
xsessions: []const u8 = build_options.prefix_directory ++ "/share/xsessions",
|
||||||
brightness_down_key: []const u8 = "F5",
|
brightness_down_key: []const u8 = "F5",
|
||||||
|
|
|
@ -76,7 +76,9 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie
|
||||||
std.mem.eql(u8, field.key, "max_password_len") or
|
std.mem.eql(u8, field.key, "max_password_len") or
|
||||||
std.mem.eql(u8, field.key, "mcookie_cmd") or
|
std.mem.eql(u8, field.key, "mcookie_cmd") or
|
||||||
std.mem.eql(u8, field.key, "term_reset_cmd") or
|
std.mem.eql(u8, field.key, "term_reset_cmd") or
|
||||||
std.mem.eql(u8, field.key, "term_restore_cursor_cmd"))
|
std.mem.eql(u8, field.key, "term_restore_cursor_cmd") or
|
||||||
|
std.mem.eql(u8, field.key, "x_cmd_setup") or
|
||||||
|
std.mem.eql(u8, field.key, "wayland_cmd"))
|
||||||
{
|
{
|
||||||
// The options don't exist anymore
|
// The options don't exist anymore
|
||||||
mapped_config_fields = true;
|
mapped_config_fields = true;
|
||||||
|
|
Loading…
Reference in New Issue