Format rust files

This commit is contained in:
Arash Hatami 2021-10-01 22:48:04 +03:30
parent 18b1646cd4
commit 2894a5ab7b
No known key found for this signature in database
GPG Key ID: 7DF90CA27C515736
5 changed files with 38 additions and 16 deletions

View File

@ -153,7 +153,10 @@ fn patch(path: PathBuf) -> PathBuf {
{
if _tmp == "/root" {
if let Ok(output) = std::process::Command::new("whoami").output() {
let user = String::from_utf8_lossy(&output.stdout).to_string().trim().to_owned();
let user = String::from_utf8_lossy(&output.stdout)
.to_string()
.trim()
.to_owned();
if user != "root" {
return format!("/home/{}", user).into();
}

View File

@ -417,7 +417,7 @@ pub fn fix_login_wayland() {
"sed",
"-i",
"s/#WaylandEnable=false/WaylandEnable=false/g",
&file
&file,
])
.output()
{
@ -435,20 +435,22 @@ pub fn fix_login_wayland() {
pub fn current_is_wayland() -> bool {
let dtype = get_display_server();
return "wayland" == dtype && unsafe{UNMODIFIED};
return "wayland" == dtype && unsafe { UNMODIFIED };
}
pub fn modify_default_login() -> String {
let dsession = std::env::var("DESKTOP_SESSION").unwrap();
let user_name = std::env::var("USERNAME").unwrap();
if let Ok(Some(x)) = run_cmds("ls /usr/share/* | grep ${DESKTOP_SESSION}-xorg.desktop".to_owned()) {
if let Ok(Some(x)) =
run_cmds("ls /usr/share/* | grep ${DESKTOP_SESSION}-xorg.desktop".to_owned())
{
if x.trim_end().to_string() != "" {
match std::process::Command::new("pkexec")
.args(vec![
"sed",
"-i",
&format!("s/={0}$/={0}-xorg/g", &dsession),
&format!("/var/lib/AccountsService/users/{}", &user_name)
&format!("/var/lib/AccountsService/users/{}", &user_name),
])
.output()
{
@ -458,7 +460,9 @@ pub fn modify_default_login() -> String {
log::error!("modify_default_login failed: {}", x);
return "Fix failed! Please re-login with X server manually".to_owned();
} else {
unsafe {UNMODIFIED = false;}
unsafe {
UNMODIFIED = false;
}
return "".to_owned();
}
}
@ -467,14 +471,16 @@ pub fn modify_default_login() -> String {
return "Fix failed! Please re-login with X server manually".to_owned();
}
}
} else if let Ok(Some(z)) = run_cmds("ls /usr/share/* | grep ${DESKTOP_SESSION:0:-8}.desktop".to_owned()) {
} else if let Ok(Some(z)) =
run_cmds("ls /usr/share/* | grep ${DESKTOP_SESSION:0:-8}.desktop".to_owned())
{
if z.trim_end().to_string() != "" {
match std::process::Command::new("pkexec")
.args(vec![
"sed",
"-i",
&format!("s/={}$/={}/g", &dsession, &dsession[..dsession.len()-8]),
&format!("/var/lib/AccountsService/users/{}", &user_name)
&format!("s/={}$/={}/g", &dsession, &dsession[..dsession.len() - 8]),
&format!("/var/lib/AccountsService/users/{}", &user_name),
])
.output()
{
@ -484,7 +490,9 @@ pub fn modify_default_login() -> String {
log::error!("modify_default_login failed: {}", x);
return "Fix failed! Please re-login with X server manually".to_owned();
} else {
unsafe {UNMODIFIED = false;}
unsafe {
UNMODIFIED = false;
}
return "".to_owned();
}
}

View File

@ -145,7 +145,13 @@ pub fn get_cursor_data(hcursor: u64) -> ResultType<CursorData> {
if do_outline {
let mut outline = Vec::new();
outline.resize(((width + 2) * (height + 2) * 4) as _, 0);
drawOutline(outline.as_mut_ptr(), cbits.as_ptr(), width, height, outline.len() as _);
drawOutline(
outline.as_mut_ptr(),
cbits.as_ptr(),
width,
height,
outline.len() as _,
);
cbits = outline;
width += 2;
height += 2;
@ -393,8 +399,14 @@ extern "C" {
fn LaunchProcessWin(cmd: *const u16, session_id: DWORD, as_user: BOOL) -> HANDLE;
fn selectInputDesktop() -> BOOL;
fn inputDesktopSelected() -> BOOL;
fn handleMask(out: *mut u8, mask: *const u8, width: i32, height: i32, bmWidthBytes: i32, bmHeight: i32)
-> i32;
fn handleMask(
out: *mut u8,
mask: *const u8,
width: i32,
height: i32,
bmWidthBytes: i32,
bmHeight: i32,
) -> i32;
fn drawOutline(out: *mut u8, in_: *const u8, width: i32, height: i32, out_size: i32);
fn get_di_bits(out: *mut u8, dc: HDC, hbmColor: HBITMAP, width: i32, height: i32) -> i32;
fn blank_screen(v: BOOL);

View File

@ -99,7 +99,6 @@ fn run(sp: GenericService) -> ResultType<()> {
*SWITCH.lock().unwrap() = false;
sp.send(msg_out);
}
let mut crc = (0, 0);
let start = time::Instant::now();
let mut last_sent = time::Instant::now();