add hard reset
Some checks failed
Rust / build (pull_request) Failing after 2m10s

This commit is contained in:
Vinzenz Schroeter 2025-05-04 14:35:59 +02:00
parent 044583141c
commit 6a5af6b4f4
3 changed files with 36 additions and 19 deletions

View file

@ -33,11 +33,11 @@ cargo run -- <args>
## Usage
```
```text
Usage: servicepoint-cli [OPTIONS] <COMMAND>
Commands:
reset-everything Reset both pixels and brightness [aliases: r]
reset Reset both pixels and brightness [aliases: r]
pixels Commands for manipulating pixels [aliases: p]
brightness Commands for manipulating the brightness [aliases: b]
text Commands for sending text to the screen [aliases: t]
@ -53,7 +53,7 @@ Options:
### Pixels
```
```text
Commands for manipulating pixels
Usage: servicepoint-cli pixels <COMMAND>
@ -68,7 +68,7 @@ Commands:
#### Image
```
```text
Send an image file (e.g. jpeg or png) to the display.
Usage: servicepoint-cli pixels image [OPTIONS] <FILE_NAME>
@ -87,7 +87,7 @@ Options:
#### Screen
```
```text
Stream the default screen capture source to the display. On Linux Wayland, this pops up a screen or window chooser, but it also may directly start streaming your main screen.
Usage: servicepoint-cli pixels screen [OPTIONS]
@ -104,7 +104,7 @@ Options:
### Brightness
```
```text
Commands for manipulating the brightness
Usage: servicepoint-cli brightness <COMMAND>
@ -117,18 +117,18 @@ Commands:
### Text
```
```text
Commands for sending text to the screen
Usage: servicepoint-cli text <COMMAND>
Commands:
stdin Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`
stdin Pipe text to the display, example: `journalctl | servicepoint-cli text stdin`
```
#### Stdin
```
```text
Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`
Usage: servicepoint-cli stream stdin [OPTIONS]
@ -137,6 +137,16 @@ Options:
-s, --slow Wait for a short amount of time before sending the next line
```
### Reset
```text
Reset both pixels and brightness
Usage: servicepoint-cli reset [OPTIONS]
Options:
-f, --force hard reset screen
```
## Contributing

View file

@ -29,7 +29,10 @@ pub struct Cli {
#[derive(clap::Parser, std::fmt::Debug)]
pub enum Mode {
#[command(visible_alias = "r", about = "Reset both pixels and brightness")]
ResetEverything,
Reset {
#[arg(short, long, help = "hard reset screen")]
force: bool,
},
#[command(visible_alias = "p")]
Pixels {
#[clap(subcommand)]
@ -114,7 +117,7 @@ pub enum TransportType {
#[clap(about = "Commands for sending text to the screen")]
pub enum TextCommand {
#[command(
about = "Pipe text to the display, example: `journalctl | servicepoint-cli stream stdin`"
about = "Pipe text to the display, example: `journalctl | servicepoint-cli text stdin`"
)]
Stdin {
#[arg(

View file

@ -7,7 +7,7 @@ use crate::{
};
use clap::Parser;
use log::debug;
use servicepoint::{Brightness, UdpSocketExt};
use servicepoint::{Brightness, HardResetCommand, UdpSocketExt};
mod brightness;
mod cli;
@ -32,10 +32,14 @@ fn main() {
pub fn execute_mode(mode: Mode, connection: Transport) {
match mode {
Mode::ResetEverything => {
Mode::Reset { force } => {
if force {
connection.send_command(HardResetCommand).unwrap()
} else {
brightness_set(&connection, Brightness::MAX);
pixels_off(&connection);
}
}
Mode::Pixels { pixel_command } => pixels(&connection, pixel_command),
Mode::Brightness { brightness_command } => brightness(&connection, brightness_command),
Mode::Text { text_command } => text(&connection, text_command),