parent
							
								
									ef19ab8b3f
								
							
						
					
					
						commit
						83baf7b419
					
				
					 5 changed files with 90 additions and 21 deletions
				
			
		|  | @ -3,7 +3,7 @@ name = "servicepoint-cli" | |||
| description = "A command line interface for the ServicePoint display." | ||||
| version = "0.1.0" | ||||
| edition = "2021" | ||||
| rust-version = "1.78.0" | ||||
| rust-version = "1.80.0" | ||||
| publish = true | ||||
| resolver = "2" | ||||
| readme = "README.md" | ||||
|  |  | |||
							
								
								
									
										64
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										64
									
								
								README.md
									
										
									
									
									
								
							|  | @ -31,13 +31,75 @@ cd servicepoint-cli | |||
| 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 | ||||
| 
 | ||||
| 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. | ||||
| 
 | ||||
| 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. | ||||
| 
 | ||||
|  |  | |||
							
								
								
									
										24
									
								
								src/cli.rs
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								src/cli.rs
									
										
									
									
									
								
							|  | @ -38,14 +38,11 @@ pub enum Mode { | |||
|         #[clap(subcommand)] | ||||
|         brightness_command: BrightnessCommand, | ||||
|     }, | ||||
|     StreamStdin { | ||||
|         #[arg(long, short, default_value_t = false)] | ||||
|         slow: bool, | ||||
|     }, | ||||
|     StreamScreen { | ||||
|         #[command(flatten)] | ||||
|         options: StreamScreenOptions, | ||||
|     }, | ||||
|     #[command(visible_alias = "s")] | ||||
|     Stream { | ||||
|         #[clap(subcommand)] | ||||
|         stream_command: StreamCommand, | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[derive(clap::Parser, std::fmt::Debug)] | ||||
|  | @ -73,3 +70,14 @@ pub enum Protocol { | |||
|     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_window::stream_window; | ||||
| use log::info; | ||||
|  | @ -12,8 +12,10 @@ pub fn execute_mode(mode: Mode, connection: Connection) { | |||
|         } | ||||
|         Mode::Pixels { pixel_command } => pixels(&connection, pixel_command), | ||||
|         Mode::Brightness { brightness_command } => brightness(&connection, brightness_command), | ||||
|         Mode::StreamStdin { slow } => stream_stdin(&connection, slow), | ||||
|         Mode::StreamScreen { options } => stream_window(&connection, options), | ||||
|         Mode::Stream { stream_command } => match stream_command { | ||||
|             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}, | ||||
|     DynamicImage, ImageBuffer, Rgb, Rgba, | ||||
| }; | ||||
| use log::{debug, error, warn}; | ||||
| use log::{error, warn}; | ||||
| use scap::{ | ||||
|     capturer::{Capturer, Options}, | ||||
|     frame::convert_bgra_to_rgb, | ||||
|  | @ -11,13 +11,12 @@ use scap::{ | |||
| use servicepoint::{ | ||||
|     Bitmap, Command, CompressionCode, Connection, Origin, FRAME_PACING, PIXEL_HEIGHT, PIXEL_WIDTH, | ||||
| }; | ||||
| use std::ops::Div; | ||||
| use std::time::Duration; | ||||
| 
 | ||||
| #[derive(clap::Parser, std::fmt::Debug, Clone)] | ||||
| pub struct StreamScreenOptions { | ||||
|     #[arg(long, short, default_value_t = true)] | ||||
|     pub dither: bool, | ||||
|     #[arg(long, short, default_value_t = false)] | ||||
|     pub no_dither: bool, | ||||
| } | ||||
| 
 | ||||
| pub fn stream_window(connection: &Connection, options: StreamScreenOptions) { | ||||
|  | @ -38,7 +37,7 @@ pub fn stream_window(connection: &Connection, options: StreamScreenOptions) { | |||
|             FilterType::Nearest, | ||||
|         ); | ||||
| 
 | ||||
|         if options.dither { | ||||
|         if !options.no_dither { | ||||
|             dither(&mut frame, &BiLevel); | ||||
|         } | ||||
| 
 | ||||
|  | @ -71,9 +70,7 @@ fn start_capture() -> Option<Capturer> { | |||
|     } | ||||
| 
 | ||||
|     let mut capturer = Capturer::build(Options { | ||||
|         fps: FRAME_PACING | ||||
|             .div_duration_f32(Duration::from_secs(1)) | ||||
|             .div(2f32) as u32, | ||||
|         fps: FRAME_PACING.div_duration_f32(Duration::from_secs(1)) as u32, | ||||
|         target: None, | ||||
|         show_cursor: true, | ||||
|         show_highlight: true, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Vinzenz Schroeter
						Vinzenz Schroeter