-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved half the shit to the notifier (renamed to proxy), turns out you…
… can't do much from a windows service
- Loading branch information
Showing
20 changed files
with
124 additions
and
134 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/display/refresh_rate_mode.rs → ...er_proxy/src/display/refresh_rate_mode.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash)] | ||
pub enum PowerConfigSelection { | ||
Wired, | ||
Battery, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash)] | ||
pub enum ProxyCommand { | ||
ChangePowerConfig(PowerConfigSelection), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use autopower_shared::{ | ||
logging::Logger, | ||
pipe::{Pipe, Server, PIPE_NAME}, | ||
proxy_command::ProxyCommand, | ||
stream::Write, | ||
}; | ||
|
||
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; | ||
|
||
const LOGGER: Logger = Logger::new("notifications", "autopower"); | ||
|
||
pub struct Proxy { | ||
pipe: Pipe<Server, Write>, | ||
} | ||
|
||
impl Proxy { | ||
pub fn create() -> Result<Self> { | ||
LOGGER.debug("Creating pipe..."); | ||
let pipe = Pipe::create_server(PIPE_NAME)?; | ||
LOGGER.debug("Created pipe, waiting for connection..."); | ||
pipe.connect()?; | ||
Ok(Proxy { pipe }) | ||
} | ||
pub fn send_command(&mut self, command: ProxyCommand) -> Result<()> { | ||
LOGGER.debug(format!("Sent command:\n{:?}", command)); | ||
self.pipe.write_as(command)?; | ||
Ok(()) | ||
} | ||
|
||
pub fn terminate(&mut self) -> Result<()> { | ||
LOGGER.debug("Terminating proxy..."); | ||
self.pipe.close() | ||
} | ||
} |
Oops, something went wrong.