mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Test and create /etc/X11/xorg.conf.d/ if not exist
This commit is contained in:
@@ -5,6 +5,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Changed
|
||||||
|
- Test and create /etc/X11/xorg.conf.d/ if it doesn't exist
|
||||||
|
|
||||||
|
# [3.1.0] - 2021-03-10
|
||||||
|
### Changed
|
||||||
|
- Add missing nvidia module nvidia_uvm to gfx ctrl list
|
||||||
|
|
||||||
# [3.1.0] - 2021-03-09
|
# [3.1.0] - 2021-03-09
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ use ctrl_gfx::error::GfxError;
|
|||||||
use ctrl_gfx::*;
|
use ctrl_gfx::*;
|
||||||
use log::{error, info, warn};
|
use log::{error, info, warn};
|
||||||
use rog_types::gfx_vendors::GfxVendors;
|
use rog_types::gfx_vendors::GfxVendors;
|
||||||
use std::io::Write;
|
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use std::{io::Write, ops::Add, path::Path};
|
||||||
use std::{sync::Arc, sync::Mutex};
|
use std::{sync::Arc, sync::Mutex};
|
||||||
use sysfs_class::{PciDevice, SysClass};
|
use sysfs_class::{PciDevice, SysClass};
|
||||||
use system::{GraphicsDevice, PciBus};
|
use system::{GraphicsDevice, PciBus};
|
||||||
@@ -210,13 +210,18 @@ impl CtrlGraphics {
|
|||||||
[PRIMARY_GPU_BEGIN, PRIMARY_GPU_END].concat()
|
[PRIMARY_GPU_BEGIN, PRIMARY_GPU_END].concat()
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Writing {}", PRIMARY_GPU_XORG_PATH);
|
if !Path::new(XORG_PATH).exists() {
|
||||||
|
std::fs::create_dir(XORG_PATH).map_err(|err| GfxError::Write(XORG_PATH.into(), err))?;
|
||||||
|
}
|
||||||
|
|
||||||
|
let file = XORG_PATH.to_string().add(XORG_FILE);
|
||||||
|
info!("Writing {}", file);
|
||||||
let mut file = std::fs::OpenOptions::new()
|
let mut file = std::fs::OpenOptions::new()
|
||||||
.create(true)
|
.create(true)
|
||||||
.truncate(true)
|
.truncate(true)
|
||||||
.write(true)
|
.write(true)
|
||||||
.open(PRIMARY_GPU_XORG_PATH)
|
.open(&file)
|
||||||
.map_err(|err| GfxError::Write(PRIMARY_GPU_XORG_PATH.into(), err))?;
|
.map_err(|err| GfxError::Write(file, err))?;
|
||||||
|
|
||||||
file.write_all(&text)
|
file.write_all(&text)
|
||||||
.and_then(|_| file.sync_all())
|
.and_then(|_| file.sync_all())
|
||||||
@@ -270,16 +275,18 @@ impl CtrlGraphics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn do_display_manager_action(action: &str) -> Result<(), RogError> {
|
fn do_display_manager_action(action: &str) -> Result<(), RogError> {
|
||||||
let service = "display-manager.service";
|
|
||||||
let mut cmd = Command::new("systemctl");
|
let mut cmd = Command::new("systemctl");
|
||||||
cmd.arg(action);
|
cmd.arg(action);
|
||||||
cmd.arg(service);
|
cmd.arg(DISPLAY_MANAGER);
|
||||||
|
|
||||||
let status = cmd
|
let status = cmd
|
||||||
.status()
|
.status()
|
||||||
.map_err(|err| GfxError::Command(format!("{:?}", cmd), err))?;
|
.map_err(|err| GfxError::Command(format!("{:?}", cmd), err))?;
|
||||||
if !status.success() {
|
if !status.success() {
|
||||||
let msg = format!("systemctl {} {} failed: {:?}", action, service, status);
|
let msg = format!(
|
||||||
|
"systemctl {} {} failed: {:?}",
|
||||||
|
action, DISPLAY_MANAGER, status
|
||||||
|
);
|
||||||
error!("{}", msg);
|
error!("{}", msg);
|
||||||
return Err(GfxError::DisplayManager(msg).into());
|
return Err(GfxError::DisplayManager(msg).into());
|
||||||
}
|
}
|
||||||
@@ -287,10 +294,9 @@ impl CtrlGraphics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn wait_display_manager_inactive() -> Result<(), RogError> {
|
fn wait_display_manager_inactive() -> Result<(), RogError> {
|
||||||
let service = "display-manager.service";
|
|
||||||
let mut cmd = Command::new("systemctl");
|
let mut cmd = Command::new("systemctl");
|
||||||
cmd.arg("is-active");
|
cmd.arg("is-active");
|
||||||
cmd.arg(service);
|
cmd.arg(DISPLAY_MANAGER);
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
@@ -318,18 +324,16 @@ impl CtrlGraphics {
|
|||||||
.rescan()
|
.rescan()
|
||||||
.map_err(|err| GfxError::Bus("bus rescan error".into(), err))?;
|
.map_err(|err| GfxError::Bus("bus rescan error".into(), err))?;
|
||||||
|
|
||||||
let drivers = vec!["nvidia_drm", "nvidia_uvm", "nvidia_modeset", "nvidia"]; // i2c_nvidia_gpu?
|
|
||||||
|
|
||||||
match vendor {
|
match vendor {
|
||||||
GfxVendors::Nvidia | GfxVendors::Hybrid | GfxVendors::Compute => {
|
GfxVendors::Nvidia | GfxVendors::Hybrid | GfxVendors::Compute => {
|
||||||
for driver in drivers {
|
for driver in NVIDIA_DRIVERS.iter() {
|
||||||
Self::do_driver_action(driver, "modprobe")?;
|
Self::do_driver_action(driver, "modprobe")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: compute mode, needs different setup
|
// TODO: compute mode, needs different setup
|
||||||
// GfxVendors::Compute => {}
|
// GfxVendors::Compute => {}
|
||||||
GfxVendors::Integrated => {
|
GfxVendors::Integrated => {
|
||||||
for driver in drivers {
|
for driver in NVIDIA_DRIVERS.iter() {
|
||||||
Self::do_driver_action(driver, "rmmod")?;
|
Self::do_driver_action(driver, "rmmod")?;
|
||||||
}
|
}
|
||||||
self.unbind_remove_nvidia()?;
|
self.unbind_remove_nvidia()?;
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ pub mod gfx;
|
|||||||
|
|
||||||
pub mod system;
|
pub mod system;
|
||||||
|
|
||||||
|
const NVIDIA_DRIVERS: [&str; 4] = ["nvidia_drm", "nvidia_uvm", "nvidia_modeset", "nvidia"];
|
||||||
|
|
||||||
|
const DISPLAY_MANAGER: &str = "display-manager.service";
|
||||||
|
|
||||||
const MODPROBE_PATH: &str = "/etc/modprobe.d/asusd.conf";
|
const MODPROBE_PATH: &str = "/etc/modprobe.d/asusd.conf";
|
||||||
|
|
||||||
static MODPROBE_BASE: &[u8] = br#"# Automatically generated by asusd
|
static MODPROBE_BASE: &[u8] = br#"# Automatically generated by asusd
|
||||||
@@ -15,7 +19,8 @@ options nvidia NVreg_DynamicPowerManagement=0x02
|
|||||||
options nvidia-drm modeset=1
|
options nvidia-drm modeset=1
|
||||||
"#;
|
"#;
|
||||||
|
|
||||||
const PRIMARY_GPU_XORG_PATH: &str = "/etc/X11/xorg.conf.d/90-nvidia-primary.conf";
|
const XORG_FILE: &str = "90-nvidia-primary.conf";
|
||||||
|
const XORG_PATH: &str = "/etc/X11/xorg.conf.d/";
|
||||||
|
|
||||||
static PRIMARY_GPU_BEGIN: &[u8] = br#"# Automatically generated by asusd
|
static PRIMARY_GPU_BEGIN: &[u8] = br#"# Automatically generated by asusd
|
||||||
Section "OutputClass"
|
Section "OutputClass"
|
||||||
|
|||||||
Reference in New Issue
Block a user