Compare commits

...

No commits in common. "4f0ad04376fb6a3f4003be7064d1af4ba6374ef1" and "c040555f01cf1988c1153ae790d2dfa9e20679e1" have entirely different histories.

6 changed files with 1 additions and 161 deletions

45
.vscode/launch.json vendored
View File

@ -1,45 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable 'rustbook'",
"cargo": {
"args": [
"build",
"--bin=rustbook",
"--package=rustbook"
],
"filter": {
"name": "rustbook",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
},
{
"type": "lldb",
"request": "launch",
"name": "Debug unit tests in executable 'rustbook'",
"cargo": {
"args": [
"test",
"--no-run",
"--bin=rustbook",
"--package=rustbook"
],
"filter": {
"name": "rustbook",
"kind": "bin"
}
},
"args": [],
"cwd": "${workspaceFolder}"
}
]
}

57
.vscode/tasks.json vendored
View File

@ -1,57 +0,0 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Cargo build (debug)",
"type": "process",
"command": "cargo",
"args": ["build"],
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Cargo build (release)",
"type": "process",
"command": "cargo",
"args": ["build", "--release"],
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Cargo clean",
"type": "process",
"command": "cargo",
"args": ["clean"],
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Cargo doc",
"type": "process",
"command": "cargo",
"args": ["doc"],
"problemMatcher": [
"$rustc"
],
"group": {
"kind": "build",
"isDefault": true
}
},
]
}

View File

@ -1,9 +0,0 @@
[package]
name = "rustbook"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
linux_battery = { git = "https://git.blackfinn.de/rust/linux_battery.git" }

View File

@ -1,17 +1,3 @@
# batman # batman
Simple linux battery monitor. Simple linux battery monitor
## Build
### debug
```shell
cargo build
```
### release
```shell
cargo build --release
```

View File

@ -1,3 +0,0 @@
1624598988 Unknown 98 %
1624598990 Unknown 98 %
1624598992 Unknown 98 %

View File

@ -1,32 +0,0 @@
use linux_battery::Battery;
use std::fs::OpenOptions;
use std::io::Write;
use std::time::{Duration, SystemTime};
use std::thread::sleep;
fn main() {
let mut battery = Battery::new("BAT0");
let mut log_file = OpenOptions::new()
.create(true)
.append(true)
.open("batman.log")
.expect("can't open log file");
loop {
let sys_time = SystemTime::now();
match sys_time.duration_since(SystemTime::UNIX_EPOCH) {
Ok(n) => {
let mut log_entry = format!("{}\t{}", n.as_secs(), battery.state());
match battery.capacity() {
Some(cap) => log_entry = format!("{}\t{} %", log_entry, cap),
None => {},
}
log_entry = format!("{}\r\n", log_entry);
log_file.write_all(log_entry.as_bytes()).expect("write to file failed");
},
Err(_) => {},
}
sleep(Duration::new(2, 0));
}
}