parent
ef19ab8b3f
commit
83baf7b419
|
@ -3,7 +3,7 @@ name = "servicepoint-cli"
|
||||||
description = "A command line interface for the ServicePoint display."
|
description = "A command line interface for the ServicePoint display."
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.78.0"
|
rust-version = "1.80.0"
|
||||||
publish = true
|
publish = true
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
|
64
README.md
64
README.md
|
@ -31,13 +31,75 @@ cd servicepoint-cli
|
||||||
cargo run -- <args>
|
cargo run -- <args>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage: servicepoint-cli [OPTIONS] <COMMAND>
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
reset-everything [aliases: r]
|
||||||
|
pixels [aliases: p]
|
||||||
|
brightness [aliases: b]
|
||||||
|
stream [aliases: s]
|
||||||
|
help Print this message or the help of the given subcommand(s)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-d, --destination <DESTINATION> ip:port of the servicepoint display [default: 127.0.0.1:2342]
|
||||||
|
-t, --transport <TRANSPORT> protocol to use for communication with display [default: udp] [possible values: udp, web-socket, fake]
|
||||||
|
-v, --verbose verbose logging
|
||||||
|
-h, --help Print help
|
||||||
|
-V, --version Print version
|
||||||
|
```
|
||||||
|
|
||||||
|
### Stream
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage: servicepoint-cli stream <COMMAND>
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
stdin
|
||||||
|
screen
|
||||||
|
help Print this message or the help of the given subcommand(s)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Print help
|
||||||
|
```
|
||||||
|
|
||||||
|
### Brightness
|
||||||
|
|
||||||
|
```
|
||||||
|
Usage: servicepoint-cli brightness <COMMAND>
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
reset [aliases: r]
|
||||||
|
set [aliases: s]
|
||||||
|
min
|
||||||
|
max
|
||||||
|
help Print this message or the help of the given subcommand(s)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Print help
|
||||||
|
```
|
||||||
|
|
||||||
|
### Pixels
|
||||||
|
```
|
||||||
|
Usage: servicepoint-cli pixels <COMMAND>
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
reset [aliases: r]
|
||||||
|
help Print this message or the help of the given subcommand(s)
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-h, --help Print help
|
||||||
|
```
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
If you have ideas on how to improve the code, add features or improve documentation feel free to open a pull request.
|
If you have ideas on how to improve the code, add features or improve documentation feel free to open a pull request.
|
||||||
|
|
||||||
You think you found a bug? Please open an issue.
|
You think you found a bug? Please open an issue.
|
||||||
|
|
||||||
Submissions on Forgejo are preferred, but you can also use GitHub.
|
Submissions on [Forgejo](https://git.berlin.ccc.de/servicepoint/servicepoint-cli) are preferred, but you can also use [GitHub](https://github.com/kaesaecracker/servicepoint-cli).
|
||||||
|
|
||||||
All creatures welcome.
|
All creatures welcome.
|
||||||
|
|
||||||
|
|
24
src/cli.rs
24
src/cli.rs
|
@ -38,14 +38,11 @@ pub enum Mode {
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
brightness_command: BrightnessCommand,
|
brightness_command: BrightnessCommand,
|
||||||
},
|
},
|
||||||
StreamStdin {
|
#[command(visible_alias = "s")]
|
||||||
#[arg(long, short, default_value_t = false)]
|
Stream {
|
||||||
slow: bool,
|
#[clap(subcommand)]
|
||||||
},
|
stream_command: StreamCommand,
|
||||||
StreamScreen {
|
}
|
||||||
#[command(flatten)]
|
|
||||||
options: StreamScreenOptions,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(clap::Parser, std::fmt::Debug)]
|
#[derive(clap::Parser, std::fmt::Debug)]
|
||||||
|
@ -73,3 +70,14 @@ pub enum Protocol {
|
||||||
Fake,
|
Fake,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(clap::Parser, std::fmt::Debug)]
|
||||||
|
pub enum StreamCommand {
|
||||||
|
Stdin {
|
||||||
|
#[arg(long, short, default_value_t = false)]
|
||||||
|
slow: bool,
|
||||||
|
},
|
||||||
|
Screen {
|
||||||
|
#[command(flatten)]
|
||||||
|
options: StreamScreenOptions,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::cli::{BrightnessCommand, Mode, PixelCommand};
|
use crate::cli::{BrightnessCommand, Mode, PixelCommand, StreamCommand};
|
||||||
use crate::stream_stdin::stream_stdin;
|
use crate::stream_stdin::stream_stdin;
|
||||||
use crate::stream_window::stream_window;
|
use crate::stream_window::stream_window;
|
||||||
use log::info;
|
use log::info;
|
||||||
|
@ -12,8 +12,10 @@ pub fn execute_mode(mode: Mode, connection: Connection) {
|
||||||
}
|
}
|
||||||
Mode::Pixels { pixel_command } => pixels(&connection, pixel_command),
|
Mode::Pixels { pixel_command } => pixels(&connection, pixel_command),
|
||||||
Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),
|
Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),
|
||||||
Mode::StreamStdin { slow } => stream_stdin(&connection, slow),
|
Mode::Stream { stream_command } => match stream_command {
|
||||||
Mode::StreamScreen { options } => stream_window(&connection, options),
|
StreamCommand::Stdin { slow } => stream_stdin(&connection, slow),
|
||||||
|
StreamCommand::Screen { options } => stream_window(&connection, options),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ use image::{
|
||||||
imageops::{dither, resize, BiLevel, FilterType},
|
imageops::{dither, resize, BiLevel, FilterType},
|
||||||
DynamicImage, ImageBuffer, Rgb, Rgba,
|
DynamicImage, ImageBuffer, Rgb, Rgba,
|
||||||
};
|
};
|
||||||
use log::{debug, error, warn};
|
use log::{error, warn};
|
||||||
use scap::{
|
use scap::{
|
||||||
capturer::{Capturer, Options},
|
capturer::{Capturer, Options},
|
||||||
frame::convert_bgra_to_rgb,
|
frame::convert_bgra_to_rgb,
|
||||||
|
@ -11,13 +11,12 @@ use scap::{
|
||||||
use servicepoint::{
|
use servicepoint::{
|
||||||
Bitmap, Command, CompressionCode, Connection, Origin, FRAME_PACING, PIXEL_HEIGHT, PIXEL_WIDTH,
|
Bitmap, Command, CompressionCode, Connection, Origin, FRAME_PACING, PIXEL_HEIGHT, PIXEL_WIDTH,
|
||||||
};
|
};
|
||||||
use std::ops::Div;
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
#[derive(clap::Parser, std::fmt::Debug, Clone)]
|
#[derive(clap::Parser, std::fmt::Debug, Clone)]
|
||||||
pub struct StreamScreenOptions {
|
pub struct StreamScreenOptions {
|
||||||
#[arg(long, short, default_value_t = true)]
|
#[arg(long, short, default_value_t = false)]
|
||||||
pub dither: bool,
|
pub no_dither: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stream_window(connection: &Connection, options: StreamScreenOptions) {
|
pub fn stream_window(connection: &Connection, options: StreamScreenOptions) {
|
||||||
|
@ -38,7 +37,7 @@ pub fn stream_window(connection: &Connection, options: StreamScreenOptions) {
|
||||||
FilterType::Nearest,
|
FilterType::Nearest,
|
||||||
);
|
);
|
||||||
|
|
||||||
if options.dither {
|
if !options.no_dither {
|
||||||
dither(&mut frame, &BiLevel);
|
dither(&mut frame, &BiLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,9 +70,7 @@ fn start_capture() -> Option<Capturer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut capturer = Capturer::build(Options {
|
let mut capturer = Capturer::build(Options {
|
||||||
fps: FRAME_PACING
|
fps: FRAME_PACING.div_duration_f32(Duration::from_secs(1)) as u32,
|
||||||
.div_duration_f32(Duration::from_secs(1))
|
|
||||||
.div(2f32) as u32,
|
|
||||||
target: None,
|
target: None,
|
||||||
show_cursor: true,
|
show_cursor: true,
|
||||||
show_highlight: true,
|
show_highlight: true,
|
||||||
|
|
Loading…
Reference in a new issue