Skip to content

Commit

Permalink
Merge pull request #152 from JakeRoggenbuck/no-anim
Browse files Browse the repository at this point in the history
Add flag to manually disable animation, systemctl
  • Loading branch information
JakeRoggenbuck authored Jan 29, 2022
2 parents e3480ed + a787952 commit fffebbf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub struct Daemon {
pub charge: i8,
pub logger: logger::Logger,
pub config: Config,
pub no_animation: bool,
}

fn make_gov_powersave(cpu: &mut CPU) -> Result<(), Error> {
Expand Down Expand Up @@ -61,7 +62,7 @@ fn print_battery_status() {
}
}

fn print_turbo_status(cores: usize) {
fn print_turbo_status(cores: usize, no_animation: bool) {
match check_turbo_enabled() {
Ok(turbo) => {
let enabled_message = if turbo { "yes" } else { "no" };
Expand All @@ -73,7 +74,9 @@ fn print_turbo_status(cores: usize) {
style::Reset
);

print_turbo_animation(turbo, cores)
if !no_animation {
print_turbo_animation(turbo, cores);
}
}
Err(e) => eprintln!("Could not check turbo\n{:?}", e),
}
Expand Down Expand Up @@ -254,7 +257,7 @@ impl Checker for Daemon {
print_battery_status();

// Shows if turbo is enabled with an amazing turbo animation
print_turbo_status(cores);
print_turbo_status(cores, self.no_animation);

// Tells user how to stop
println!("\nctrl+c to stop running\n\n");
Expand Down Expand Up @@ -301,6 +304,7 @@ pub fn daemon_init(
delay: u64,
mut edit: bool,
config: Config,
no_animation: bool,
) -> Result<Daemon, Error> {
let started_as_edit: bool = edit;
let mut forced_reason: String = String::new();
Expand Down Expand Up @@ -354,6 +358,7 @@ pub fn daemon_init(
logs: Vec::<logger::Log>::new(),
},
config,
no_animation,
};

// Make a cpu struct for each cpu listed
Expand Down
21 changes: 18 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ enum Command {
/// Milliseconds between update
#[structopt(short, long, default_value = "1000")]
delay: u64,

/// No animations, for systemctl updating issue
#[structopt(short, long)]
no_animation: bool,
},

/// Monitor each cpu, it's min, max, and current speed, along with the governor
Expand All @@ -131,6 +135,10 @@ enum Command {
/// Milliseconds between update
#[structopt(short, long, default_value = "1000")]
delay: u64,

/// No animations, for systemctl updating issue
#[structopt(short, long)]
no_animation: bool,
},
}

Expand Down Expand Up @@ -212,7 +220,7 @@ fn main() {

// Everything starting with "set"
Command::Set { set } => match set {
SetType::Gov { value } => match daemon_init(true, 0, false, config) {
SetType::Gov { value } => match daemon_init(true, 0, false, config, true) {
Ok(mut d) => match d.set_govs(value.clone()) {
Ok(_) => {}
Err(e) => eprint!("Could not set gov, {:?}", e),
Expand All @@ -222,7 +230,11 @@ fn main() {
},

// Run command
Command::Run { quiet, delay } => match daemon_init(!quiet, delay, true, config) {
Command::Run {
quiet,
delay,
no_animation,
} => match daemon_init(!quiet, delay, true, config, no_animation) {
Ok(d) => {
main_daemon = d;
main_daemon.run().unwrap_err();
Expand All @@ -231,7 +243,10 @@ fn main() {
},

// Monitor command
Command::Monitor { delay } => match daemon_init(true, delay, false, config) {
Command::Monitor {
delay,
no_animation,
} => match daemon_init(true, delay, false, config, no_animation) {
Ok(d) => {
main_daemon = d;
main_daemon.run().unwrap_err();
Expand Down

0 comments on commit fffebbf

Please sign in to comment.