Skip to content

Commit

Permalink
Merge pull request #13 from smudge/gnome-support
Browse files Browse the repository at this point in the history
[v0.2.0] Basic Linux support! (GNOME/GSettings only)
  • Loading branch information
smudge committed Jun 22, 2020
2 parents 7f546fb + 91d31e7 commit 30997b3
Show file tree
Hide file tree
Showing 12 changed files with 356 additions and 22 deletions.
198 changes: 197 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nightlight"
version = "0.1.1"
version = "0.2.0"
authors = ["smudge <nathan@ngriffith.com>"]
edition = "2018"
categories = ["command-line-utilities", "os::macos-apis"]
Expand All @@ -10,6 +10,11 @@ readme = "README.md"
license = "MIT"

[dependencies]
time = "0.2.10"

[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2"
objc-foundation = "0.1.1"
time = "0.2.10"

[target.'cfg(target_os = "linux")'.dependencies]
gio = "0.8.1"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ nightlight schedule off
In addition to a CLI, `nightlight` can be pulled-in as a dependency for other Rust crates:

```
nightlight = "0.1.1"
nightlight = "0.2.0"
```

Here's an example `fn` that toggles Night Shift off,
Expand Down
9 changes: 6 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
fn main()
{
println!("cargo:rustc-link-search=framework={}", "/System/Library/PrivateFrameworks");
fn main() {
#[cfg(target_os = "macos")]
println!(
"cargo:rustc-link-search=framework={}",
"/System/Library/PrivateFrameworks"
);
}
14 changes: 8 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
mod ffi;
#[cfg_attr(target_os = "linux", path = "linux/mod.rs")]
#[cfg_attr(target_os = "macos", path = "macos/mod.rs")]
mod os;
mod schedule;
mod status;

pub use schedule::{Schedule, Time};
pub use status::Status;

pub struct NightLight {
client: ffi::CBBlueLightClient,
client: os::Client,
}

impl NightLight {
pub fn new() -> NightLight {
NightLight {
client: ffi::CBBlueLightClient::new(),
client: os::Client::new(),
}
}

Expand Down Expand Up @@ -46,8 +48,8 @@ impl NightLight {
}

pub fn get_schedule(&self) -> Result<Schedule, String> {
let status = self.client.status()?;
NightLight::schedule(status.mode(), status.from_time(), status.to_time())
let (from_time, to_time) = self.client.get_schedule()?;
NightLight::schedule(self.client.get_mode()?, from_time, to_time)
}

pub fn set_temp(&self, temp: i32) -> Result<(), String> {
Expand All @@ -63,7 +65,7 @@ impl NightLight {
}

pub fn status(&self) -> Result<Status, String> {
Ok(match self.client.status()?.enabled() {
Ok(match self.client.get_enabled()? {
true => Status::On,
false => Status::Off,
})
Expand Down
19 changes: 19 additions & 0 deletions src/linux/locale.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use std::sync::Arc;

pub struct Locale {
is_24_hr: bool,
}

impl Locale {
pub fn initialize() -> Result<(), String> {
Ok(())
}

pub fn current() -> Arc<Locale> {
Arc::new(Locale { is_24_hr: true })
}

pub fn is_24_hr(&self) -> bool {
true
}
}
Loading

0 comments on commit 30997b3

Please sign in to comment.