tdakhran / razer-ctl

A tray icon for controlling Razer Blade 16
MIT License
14 stars 3 forks source link

Enable efficiency mode for razer-tray #8

Closed jacobgelling closed 3 months ago

jacobgelling commented 4 months ago

This PR enables efficiency mode for razer-tray.

It marks the process as low priority and consumes less power, perfect for a tray app running in the background.

Effect can be seen in task manager: image

tdakhran commented 3 months ago

Thanks for your contribution! Efficiency mode is a great fit for this application. Windows-specific things break compilation for Linux.

❯ cargo build --release
...
= note: /usr/sbin/ld: /tmp/razer-ctl/target/release/deps/razer_tray-cf05d932771d07d6.razer_tray.d705ed2d400c0810-cgu.00.rcgu.o: in function `razer_tray::main':
          razer_tray.d705ed2d400c0810-cgu.00:(.text._ZN10razer_tray4main17h542f386bec55afb4E+0x4372): undefined reference to `GetCurrentProcess'
          /usr/sbin/ld: razer_tray.d705ed2d400c0810-cgu.00:(.text._ZN10razer_tray4main17h542f386bec55afb4E+0x4383): undefined reference to `SetPriorityClass'
          /usr/sbin/ld: razer_tray.d705ed2d400c0810-cgu.00:(.text._ZN10razer_tray4main17h542f386bec55afb4E+0x438d): undefined reference to `GetLastError'
          /usr/sbin/ld: razer_tray.d705ed2d400c0810-cgu.00:(.text._ZN10razer_tray4main17h542f386bec55afb4E+0x43bc): undefined reference to `SetProcessInformation'
          /usr/sbin/ld: razer_tray.d705ed2d400c0810-cgu.00:(.text._ZN10razer_tray4main17h542f386bec55afb4E+0x43c6): undefined reference to `GetLastError'

I need to work on adding a bit of CI to catch such things. For now, let's guard windows specific things under Conditional Compilation.

jacobgelling commented 3 months ago

@tdakhran I've added the conditional compilation flags and conditional windows crate dependency.

tdakhran commented 3 months ago

Thanks! Build for Linux still fails

❯ cargo build --release
   Compiling razer-tray v0.6.0 (/tmp/razer-ctl/razer-tray)
error[E0425]: cannot find function `efficiency_mode` in this scope
   --> razer-tray/src/main.rs:626:9
    |
626 |         efficiency_mode();
    |         ^^^^^^^^^^^^^^^ not found in this scope

It should be something like to completely disable the code

    #[cfg(target_os = "windows")]
    efficiency_mode();

I merged #1 and this got automatically closed. And I can't reopen it again. @jacobgelling could you please resubmit the PR? You have contributor access and can create PR directly in this repo.

tdakhran commented 3 months ago

I reopened https://github.com/tdakhran/razer-ctl/tree/tarek/feat/support_razer_blade_14_2023, but I can't retarget this PR to https://github.com/tdakhran/razer-ctl/tree/main