set up color scheme on console shell

This commit is contained in:
Bruce Leidl 2019-09-26 22:49:01 -04:00
parent 2b69ce2c08
commit 23f5903e1f
4 changed files with 31 additions and 2 deletions

View File

@ -31,6 +31,8 @@ pub enum Error {
RebootFailed(io::Error), RebootFailed(io::Error),
OpenLogFailed(io::Error), OpenLogFailed(io::Error),
XAuthFail(io::Error), XAuthFail(io::Error),
WriteBashrc(io::Error),
NetworkConfigure(netlink::Error),
} }
impl fmt::Display for Error { impl fmt::Display for Error {
@ -67,6 +69,8 @@ impl fmt::Display for Error {
RebootFailed(err) => write!(f, "could not reboot system: {}", err), RebootFailed(err) => write!(f, "could not reboot system: {}", err),
OpenLogFailed(err) => write!(f, "failed to open log file: {}", err), OpenLogFailed(err) => write!(f, "failed to open log file: {}", err),
XAuthFail(err) => write!(f, "error creating .Xauthority file: {}", err), XAuthFail(err) => write!(f, "error creating .Xauthority file: {}", err),
WriteBashrc(err) => write!(f, "error writing bashrc file: {}", err),
NetworkConfigure(err) => write!(f, "error configuring network: {}", err),
} }
} }
} }

View File

@ -7,6 +7,21 @@ use std::{fs, process, io, env};
use crate::service::{Service, ServiceLaunch}; use crate::service::{Service, ServiceLaunch};
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::io::Read; use std::io::Read;
use std::net::Ipv4Addr;
use std::str::FromStr;
use crate::netlink::NetlinkSocket;
const BASHRC: &str = r#"
export PS1="airwolf > "
umask 022
shopt -s checkwinsize
alias ls='ls --color=auto'
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
"#;
pub struct InitServer { pub struct InitServer {
hostname: String, hostname: String,

View File

@ -22,6 +22,8 @@ const BASE_ENVIRONMENT: &[&str] = &[
const SHELL_ENVIRONMENT: &[&str] = &[ const SHELL_ENVIRONMENT: &[&str] = &[
"SHELL=/bin/bash", "SHELL=/bin/bash",
"PATH=/usr/bin:/usr/sbin",
"COLORTERM=truecolor",
"TERM=xterm-256color", "TERM=xterm-256color",
"GNOME_DESKTOP_SESSION_ID=this-is-deprecated", "GNOME_DESKTOP_SESSION_ID=this-is-deprecated",
"NO_AT_BRIDGE=1", "NO_AT_BRIDGE=1",
@ -32,6 +34,7 @@ const SHELL_ENVIRONMENT: &[&str] = &[
"DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus", "DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus",
]; ];
pub struct Service { pub struct Service {
name: String, name: String,
child: Child, child: Child,
@ -136,8 +139,8 @@ impl ServiceLaunch {
.root(root) .root(root)
.home(home) .home(home)
.env("HOME", home) .env("HOME", home)
.shell_environment() .shell_environment();
.arg("--login"); // .arg("--login");
match realm { match realm {
Some(name) => shell.env("REALM_NAME", name), Some(name) => shell.env("REALM_NAME", name),

View File

@ -105,6 +105,13 @@ impl VmConfig {
let _terminal_restore = TerminalRestore::save(); let _terminal_restore = TerminalRestore::save();
if let Some(scheme) = Base16Scheme::by_name("black-metal-immortal") {
let mut term = AnsiTerminal::new().unwrap();
if let Err(err) = term.apply_base16(scheme) {
warn!("Failed to set terminal color scheme: {}", err);
}
}
match Vm::open(self) { match Vm::open(self) {
Ok(vm) => if let Err(err) = vm.start() { Ok(vm) => if let Err(err) = vm.start() {
notify!("Error starting VM: {}", err); notify!("Error starting VM: {}", err);