From 4988fb203452a8e62c88e9c42311183c5ce2bd85 Mon Sep 17 00:00:00 2001 From: amy Date: Sun, 23 Jan 2022 19:33:14 +0100 Subject: [PATCH] activate dm and configue correct greeter for lightdm --- src/functions/desktops.rs | 59 +++++++++++++++++++++++++++++++++++++++ src/internal/files.rs | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/functions/desktops.rs b/src/functions/desktops.rs index 1aeb7d6..43328a2 100755 --- a/src/functions/desktops.rs +++ b/src/functions/desktops.rs @@ -1,3 +1,4 @@ +use crate::internal::exec::*; use crate::internal::*; pub fn choose_pkgs(desktop_setup: &str) { @@ -11,6 +12,14 @@ pub fn choose_pkgs(desktop_setup: &str) { "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings", ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); } "gnome" => { install(vec![ @@ -20,6 +29,7 @@ pub fn choose_pkgs(desktop_setup: &str) { "chrome-gnome-shell", "gdm", ]); + enable_dm("gdm"); } "kde" => { install(vec![ @@ -30,6 +40,7 @@ pub fn choose_pkgs(desktop_setup: &str) { "kde-applications", "sddm", ]); + enable_dm("sddm"); } "budgie" => { install(vec![ @@ -40,6 +51,14 @@ pub fn choose_pkgs(desktop_setup: &str) { "lightdm-gtk-greeter", "lightdm-gtk-greeter-settings", ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); } "cinnamon" => { install(vec![ @@ -51,6 +70,14 @@ pub fn choose_pkgs(desktop_setup: &str) { "metacity", "gnome-shell", ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); } "mate" => { install(vec![ @@ -61,6 +88,14 @@ pub fn choose_pkgs(desktop_setup: &str) { "lightdm-gtk-greeter-settings", "mate-extra", ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); } "xfce" => { install(vec![ @@ -71,6 +106,14 @@ pub fn choose_pkgs(desktop_setup: &str) { "lightdm-gtk-greeter-settings", "xfce4-goodies", ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); } "enlightenment" => { install(vec![ @@ -81,6 +124,14 @@ pub fn choose_pkgs(desktop_setup: &str) { "lightdm-gtk-greeter-settings", "terminology", ]); + files_eval( + files::append_file( + "/mnt/etc/lightdm/lightdm.conf", + "[SeatDefaults]\ngreeter-session=lightdm-gtk-greeter\n", + ), + "Add lightdm greeter", + ); + enable_dm("lightdm"); } _ => { @@ -88,3 +139,11 @@ pub fn choose_pkgs(desktop_setup: &str) { } } } + +fn enable_dm(dm: &str) { + log(format!("Enabling {}", dm)); + exec_eval( + exec_chroot("systemctl", vec![String::from("enable"), String::from(dm)]), + format!("Enable {}", dm).as_str(), + ); +} diff --git a/src/internal/files.rs b/src/internal/files.rs index 1584ae5..fc0bd17 100755 --- a/src/internal/files.rs +++ b/src/internal/files.rs @@ -17,7 +17,7 @@ pub fn create_file(path: &str) { pub fn append_file(path: &str, content: &str) -> std::io::Result<()> { log(format!( "[ \x1b[2;1;32mOK\x1b[0m ] Append '{}' to file {}", - content.replace("\n", ""), + content.trim_end(), path )); let mut file = OpenOptions::new().append(true).open(path)?;