@@ -29,9 +29,7 @@ use glib::{clone, Object};
29
29
use std:: cell:: RefMut ;
30
30
31
31
// Modules
32
- use crate :: { provider, settingswindow, APP_ID } ;
33
- use provider:: Provider ;
34
- use settingswindow:: SettingsWindow ;
32
+ use crate :: { APP_ID , provider:: Provider , settingswindow:: SettingsWindow } ;
35
33
36
34
// GObject wrapper for Property
37
35
glib:: wrapper! {
@@ -243,15 +241,6 @@ impl MainWindow {
243
241
* have a single globally accessible action instead, we call add_action on our application instead.
244
242
*/
245
243
fn setup_actions ( & self ) {
246
- /*
247
- let action_close = SimpleAction::new("close", None);
248
- action_close.connect_activate(clone!(@weak self as window => move |_, _| {
249
- window.close();
250
- }));
251
- self.add_action(&action_close);
252
- actions.add_action(&action_close);
253
- */
254
-
255
244
// Create action from key "open_nvidia_settings" and add to action group "win"
256
245
let open_nvidia_settings: SimpleAction = SimpleAction :: new ( "open_nvidia_settings" , None ) ;
257
246
open_nvidia_settings. connect_activate ( clone ! ( @weak self as window => move |_, _| {
@@ -311,70 +300,6 @@ impl MainWindow {
311
300
self . add_action ( & open_nvidia_settings) ;
312
301
313
302
/*
314
- // Create action from key "subprocess" and add to action group "win"
315
- let subprocess: SimpleAction = SimpleAction::new("subprocess", None);
316
- subprocess.connect_activate(clone!(@weak self as window => move |_, _| {
317
- match subprocess::exec_communicate(
318
- &[
319
- OsStr::new("nvidia-settings"),
320
- OsStr::new("-q"),
321
- OsStr::new("GpuUUID"),
322
- OsStr::new("-t"),
323
- ],
324
- None::<&gio::Cancellable>,
325
- ) {
326
- Ok(return_val) => match return_val {
327
- (None, None) => println!("no stdout or stderr, something went really wrong..."),
328
- (None, Some(stderr_buffer)) => match std::str::from_utf8(&stderr_buffer) {
329
- Ok(stderr_buffer_contents) => {
330
- println!("Process failed with error: {}", stderr_buffer_contents)
331
- }
332
- Err(err) => panic!("{}", err),
333
- },
334
- (Some(stdout_buffer), None) => match std::str::from_utf8(&stdout_buffer) {
335
- Ok(stdout_buffer_contents) => {
336
- println!("Process suceeded, returning: `{}`", stdout_buffer_contents)
337
- }
338
- Err(err) => panic!("{}", err),
339
- },
340
- (Some(stdout_buffer), Some(stderr_buffer)) => {
341
- match std::str::from_utf8(&stdout_buffer) {
342
- Ok(stdout_buffer_contents) => match std::str::from_utf8(&stderr_buffer) {
343
- Ok(stderr_buffer_contents) => println!(
344
- "Process suceeded, returning: `{}` but with error: `{}`",
345
- stdout_buffer_contents, stderr_buffer_contents
346
- ),
347
- Err(err) => panic!("{}", err),
348
- },
349
- Err(err) => panic!("{}", err),
350
- }
351
- }
352
- },
353
- Err(err) => println!("something went wrong: {}", err),
354
- };
355
- }));
356
- self.add_action(&subprocess);
357
-
358
- // Create action from key "processor" and add to action group "win"
359
- let processor: SimpleAction = SimpleAction::new("processor", None);
360
- processor.connect_activate(clone!(@weak self as window => move |_, _| {
361
- let p: Processor = Processor::new("nvidia-settings", "-q GpuUUID -t");
362
-
363
- //NOTE: Leaving this here for future use..
364
- //p.set_property("base-call", "nvidia-settings");
365
- //p.set_property("call", "nvidia-settings");
366
- //p.set_property("tail-call", "t");
367
-
368
- match p.process() {
369
- Ok(output) => match output {
370
- Some(valid_output) => println!("Process suceeded, returning: `{}`", valid_output),
371
- None => println!("Process encountered an unknown error.."),
372
- },
373
- Err(err) => println!("Process encountered an error, returning: `{}`", err),
374
- }
375
- }));
376
- self.add_action(&processor);
377
-
378
303
// Create action from key "formatter_and_property" and add to action group "win"
379
304
let formatter_and_property: SimpleAction =
380
305
SimpleAction::new("formatter_and_property", None);
@@ -597,58 +522,6 @@ impl MainWindow {
597
522
}
598
523
}));
599
524
self.add_action(&formatter_and_property);
600
-
601
- // Create action from key "providers" and add to action group "win"
602
- let providers: SimpleAction = SimpleAction::new("providers", None);
603
- providers.connect_activate(clone!(@weak self as window => move |_, _| {
604
- let _gpu_count: i32 = 1;
605
-
606
- // SETTINGS
607
- let _settings_prov: Provider = Provider::new(|| {
608
- vec![
609
- Property::new(&Processor::new("nvidia-settings", "-q GpuUUID -t"), "utilization.gpu", "", &Formatter::new(), &1),
610
- Property::new(&Processor::new("nvidia-settings", "-q GpuUUID -t"), "temperature.gpu", "", &Formatter::new(), &1),
611
- Property::new(&Processor::new("nvidia-settings", "-q GpuUUID -t"), "memory.used,memory.total", "", &Formatter::new(), &1),
612
- Property::new(&Processor::new("nvidia-settings", "-q GpuUUID -t"), "fan.speed", "", &Formatter::new(), &1),
613
- ]
614
- }, 0);
615
-
616
- // SMI
617
- let _smi_prov: Provider = Provider::new(|| {
618
- vec![
619
- Property::new(&Processor::new("nvidia-smi", "--query-gpu=gpu_name --format=csv,noheader"), "utilization.gpu", "", &Formatter::new(), &1),
620
- Property::new(&Processor::new("nvidia-smi", "--query-gpu=gpu_name --format=csv,noheader"), "temperature.gpu", "", &Formatter::new(), &1),
621
- Property::new(&Processor::new("nvidia-smi", "--query-gpu=gpu_name --format=csv,noheader"), "memory.used,memory.total", "", &Formatter::new(), &1),
622
- Property::new(&Processor::new("nvidia-smi", "--query-gpu=gpu_name --format=csv,noheader"), "fan.speed", "", &Formatter::new(), &1),
623
- Property::new(&Processor::new("nvidia-smi", "--query-gpu=gpu_name --format=csv,noheader"), "power.draw", "", &Formatter::new(), &1),
624
- ]
625
- }, 1);
626
-
627
- // SETTINGS & SMI
628
- let _both_prov: Provider = Provider::new(|| {
629
- vec![
630
- Property::new(&Processor::new("nvidia-settings", "-q GpuUUID -t"), "utilization.gpu", "", &Formatter::new(), &1),
631
- Property::new(&Processor::new("nvidia-settings", "-q GpuUUID -t"), "temperature.gpu", "", &Formatter::new(), &1),
632
- Property::new(&Processor::new("nvidia-settings", "-q GpuUUID -t"), "memory.used,memory.total", "", &Formatter::new(), &1),
633
- Property::new(&Processor::new("nvidia-settings", "-q GpuUUID -t"), "fan.speed", "", &Formatter::new(), &1),
634
- Property::new(&Processor::new("nvidia-smi", "--query-gpu=gpu_name --format=csv,noheader"), "power.draw", "", &Formatter::new(), &1),
635
- ]
636
- }, 2);
637
-
638
- // OPTIMUS
639
- let _optimus_prov: Provider = Provider::new(|| {
640
- vec![
641
- Property::new(&Processor::new("optirun", "nvidia-smi --query-gpu=gpu_name --format=csv,noheader"), "utilization.gpu", "", &Formatter::new(), &1),
642
- Property::new(&Processor::new("optirun", "nvidia-smi --query-gpu=gpu_name --format=csv,noheader"), "temperature.gpu", "", &Formatter::new(), &1),
643
- Property::new(&Processor::new("optirun", "nvidia-smi --query-gpu=gpu_name --format=csv,noheader"), "memory.used,memory.total", "", &Formatter::new(), &1),
644
- Property::new(&Processor::new("optirun", "nvidia-smi --query-gpu=gpu_name --format=csv,noheader"), "fan.speed", "", &Formatter::new(), &1),
645
- Property::new(&Processor::new("optirun", "nvidia-smi --query-gpu=gpu_name --format=csv,noheader"), "power.draw", "", &Formatter::new(), &1),
646
- ]
647
- }, 3);
648
- }));
649
- self.add_action(&providers);
650
-
651
- //self.emit_activate_focus()
652
525
*/
653
526
654
527
let open_app_settings: SimpleAction = SimpleAction :: new ( "open_app_settings" , None ) ;
0 commit comments