Create the cmus related flgas, and add the innterval flag
This commit is contained in:
parent
0cba238b82
commit
278f0f2bbd
1 changed files with 31 additions and 4 deletions
|
@ -1,16 +1,17 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
const NOTIFICATION_TIMEOUT: &str = "5";
|
const NOTIFICATION_TIMEOUT: u8 = 5;
|
||||||
const NOTIFICATION_BODY: &str = "<b>Playing:</b> {title} from {album} \n\n <b>Artist:</b> {artist} - {year}";
|
const NOTIFICATION_BODY: &str = "<b>Playing:</b> {title} from {album} \n\n <b>Artist:</b> {artist} - {year}";
|
||||||
const NOTIFICATION_SUMMARY: &str = "{artist} - {title}";
|
const NOTIFICATION_SUMMARY: &str = "{artist} - {title}";
|
||||||
const NOTIFICATION_APP_NAME: &str = "C* Music Player";
|
const NOTIFICATION_APP_NAME: &str = "C* Music Player";
|
||||||
const DEFAULT_MAX_DEPTH: &str = "3";
|
const DEFAULT_MAX_DEPTH: u8 = 3;
|
||||||
|
const DEFAULT_INTERVAL_TIME: u32 = 1000; // 1000 ms
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(author, about, version, long_about = None)]
|
#[command(author, about, version, long_about = None)]
|
||||||
pub struct Arguments {
|
pub struct Arguments {
|
||||||
/// The notification timeout, in seconds
|
/// The notification timeout, in seconds
|
||||||
#[arg(short, long, default_value = NOTIFICATION_TIMEOUT)]
|
#[arg(short, long, default_value_t = NOTIFICATION_TIMEOUT)]
|
||||||
pub timeout: u8,
|
pub timeout: u8,
|
||||||
/// Make the notification persistent, i.e. not disappear after a timeout (you can dismiss it manually)
|
/// Make the notification persistent, i.e. not disappear after a timeout (you can dismiss it manually)
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
|
@ -54,7 +55,7 @@ pub struct Arguments {
|
||||||
/// if the files are not found in the track's directory, or the directory specified by the `--cover-path`
|
/// if the files are not found in the track's directory, or the directory specified by the `--cover-path`
|
||||||
/// or `--lyrics-path`* options, the program will search in the parent directory,
|
/// or `--lyrics-path`* options, the program will search in the parent directory,
|
||||||
/// and so on, until the maximum depth is reached.
|
/// and so on, until the maximum depth is reached.
|
||||||
#[arg(short, long, default_value = DEFAULT_MAX_DEPTH)]
|
#[arg(short, long, default_value_t = DEFAULT_MAX_DEPTH)]
|
||||||
pub depth: u8,
|
pub depth: u8,
|
||||||
/// The name of the app to use for the notification.
|
/// The name of the app to use for the notification.
|
||||||
#[arg(short, long, default_value = NOTIFICATION_APP_NAME)]
|
#[arg(short, long, default_value = NOTIFICATION_APP_NAME)]
|
||||||
|
@ -69,6 +70,7 @@ pub struct Arguments {
|
||||||
pub summary: String,
|
pub summary: String,
|
||||||
#[cfg(feature = "lyrics")]
|
#[cfg(feature = "lyrics")]
|
||||||
/// The body of the notification.
|
/// The body of the notification.
|
||||||
|
///
|
||||||
/// you can use the placeholder "{artist}" and "{album}" and "{title}" and "{track_number}" and
|
/// you can use the placeholder "{artist}" and "{album}" and "{title}" and "{track_number}" and
|
||||||
/// "{disc_number}" and "{year}" and "{genre}" in the body, they will be replaced with the corresponding metadata.
|
/// "{disc_number}" and "{year}" and "{genre}" in the body, they will be replaced with the corresponding metadata.
|
||||||
/// but if the metadata is not available, the placeholder will be replaced with an empty string.
|
/// but if the metadata is not available, the placeholder will be replaced with an empty string.
|
||||||
|
@ -88,6 +90,7 @@ pub struct Arguments {
|
||||||
pub body: String,
|
pub body: String,
|
||||||
#[cfg(not(feature = "lyrics"))]
|
#[cfg(not(feature = "lyrics"))]
|
||||||
/// The body of the notification.
|
/// The body of the notification.
|
||||||
|
///
|
||||||
/// you can use the placeholder "{artist}" and "{album}" and "{title}" and "{track_number}" and
|
/// you can use the placeholder "{artist}" and "{album}" and "{title}" and "{track_number}" and
|
||||||
/// "{disc_number}" and "{year}" and "{genre}" in the body, they will be replaced with the corresponding metadata.
|
/// "{disc_number}" and "{year}" and "{genre}" in the body, they will be replaced with the corresponding metadata.
|
||||||
/// but if the metadata is not available, the placeholder will be replaced with an empty string.
|
/// but if the metadata is not available, the placeholder will be replaced with an empty string.
|
||||||
|
@ -101,4 +104,28 @@ pub struct Arguments {
|
||||||
/// Also you can use the simple html markup, if your notification server supports it.
|
/// Also you can use the simple html markup, if your notification server supports it.
|
||||||
#[arg(default_value = NOTIFICATION_BODY)]
|
#[arg(default_value = NOTIFICATION_BODY)]
|
||||||
pub body: String,
|
pub body: String,
|
||||||
|
/// The cmus-remote binary path, if not given, the program will search for it in the PATH environment variable.
|
||||||
|
///
|
||||||
|
/// if you're using a custom package format like flatpak, or snap, you can give it the full run command (without any arguments),
|
||||||
|
/// e.g. "flatpak run io.github.cmus.cmus", "snap run cmus"
|
||||||
|
#[arg(short = 'b', long = "cmus-remote-bin", default_value = None)]
|
||||||
|
pub cmus_remote_bin_path: Option<String>,
|
||||||
|
/// The cmus socket address, if not given, the program will use the default socket address, which is "$XDG_RUNTIME_DIR/cmus-socket".
|
||||||
|
#[arg(short = 'k', long = "cmus-socket", default_value = None)]
|
||||||
|
pub cmus_socket_address: Option<String>,
|
||||||
|
/// The cmus socket password, if any.
|
||||||
|
#[arg(short = 'x', long = "socket-password", default_value = None)]
|
||||||
|
pub cmus_socket_password: Option<String>,
|
||||||
|
/// The interval to request the cmus status, in milliseconds.
|
||||||
|
///
|
||||||
|
/// if you set it to 0, the program will only request the cmus status once and wait for the track duration time to make another request.
|
||||||
|
/// e.g. if the track duration is 3 minutes, the program will request the cmus status once, and wait for 3 minutes to make another request,
|
||||||
|
/// and if the track changes to another track with 5 minutes duration, the program will request the cmus status once, and wait for 5 minutes to make another request at so on.
|
||||||
|
///
|
||||||
|
/// this is useful if you have a potato computer, and you don't want to waste your CPU and battery,
|
||||||
|
/// but it will make the notification a little bit stupid, if you change the track manually, the notification will not update until the track duration time is reached.
|
||||||
|
///
|
||||||
|
/// but I recommend 1s, it's not too fast, and not too slow, and it will not waste your CPU and battery.
|
||||||
|
#[arg(short = 'r', long, default_value_t = DEFAULT_INTERVAL_TIME)]
|
||||||
|
pub interval: u32,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue