5
Cargo.lock
generated
5
Cargo.lock
generated
@@ -1357,9 +1357,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.110"
|
||||
version = "0.2.112"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b58a4469763e4e3a906c4ed786e1c70512d16aa88f84dded826da42640fc6a1c"
|
||||
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
|
||||
|
||||
[[package]]
|
||||
name = "libdbus-sys"
|
||||
@@ -1731,6 +1731,7 @@ dependencies = [
|
||||
"futures 0.3.18",
|
||||
"ioctl-rs",
|
||||
"lazy_static 1.4.0",
|
||||
"libc",
|
||||
"librespot-core",
|
||||
"librespot-playback",
|
||||
"librespot-protocol",
|
||||
|
||||
@@ -46,6 +46,7 @@ regex = "1"
|
||||
ioctl-rs = { version = "0.2", optional = true }
|
||||
serde_cbor = "0.11.2"
|
||||
pancurses = { version = "0.17.0", features = ["win32"] }
|
||||
libc = "0.2.111"
|
||||
|
||||
[dependencies.rspotify]
|
||||
version = "0.11.3"
|
||||
|
||||
23
README.md
23
README.md
@@ -259,18 +259,19 @@ time with <kbd>Escape</kbd>.
|
||||
|
||||
The following commands are supported:
|
||||
|
||||
| Command | Action |
|
||||
| :--------------------------------- | :--------------------------------------------------------------- |
|
||||
| `quit` | Quit `ncspot`. |
|
||||
| `logout` | Remove any cached credentials from disk and quit `ncspot`. |
|
||||
| `toggle` | Toggle playback. |
|
||||
| `stop` | Stop playback. |
|
||||
| `previous` | Play previous track. |
|
||||
| `next` | Play next track. |
|
||||
| `clear` | Clear playlist. |
|
||||
| `share <item>` | Copies a sharable URL of the item to the system clipboard. |
|
||||
| `newplaylist <name>` | Create new playlist with name `<name>`. |
|
||||
| Command | Action |
|
||||
|---|---|
|
||||
| `quit` | Quit `ncspot`. |
|
||||
| `logout` | Remove any cached credentials from disk and quit `ncspot`. |
|
||||
| `toggle` | Toggle playback. |
|
||||
| `stop` | Stop playback. |
|
||||
| `previous` | Play previous track. |
|
||||
| `next` | Play next track. |
|
||||
| `clear` | Clear playlist. |
|
||||
| `share <item>` | Copies a sharable URL of the item to the system clipboard. |
|
||||
| `newplaylist <name>` | Create new playlist with name `<name>`. |
|
||||
| `sort <sort_key> <sort_direction>` | Sort a playlist by `<sort_key>` in direction `<sort_direction>`. |
|
||||
| `exec <cmd>` | Executes a command in the system shell. Be aware that command output is printed to the terminal, so redirection to `/dev/null` e.g. by appending `2> /dev/null` may be necessary. |
|
||||
|
||||
Supported `<item>` are:
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ pub enum Command {
|
||||
Logout,
|
||||
ShowRecommendations(TargetMode),
|
||||
Redraw,
|
||||
Execute(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for Command {
|
||||
@@ -191,7 +192,7 @@ impl fmt::Display for Command {
|
||||
Command::Jump(mode) => match mode {
|
||||
JumpMode::Previous => "jumpprevious".to_string(),
|
||||
JumpMode::Next => "jumpnext".to_string(),
|
||||
JumpMode::Query(term) => format!("jump {}", term).to_string(),
|
||||
JumpMode::Query(term) => String::from(format!("jump {}", term)),
|
||||
},
|
||||
Command::Help => "help".to_string(),
|
||||
Command::ReloadConfig => "reload".to_string(),
|
||||
@@ -201,6 +202,7 @@ impl fmt::Display for Command {
|
||||
Command::Logout => "logout".to_string(),
|
||||
Command::ShowRecommendations(mode) => format!("similar {}", mode),
|
||||
Command::Redraw => "redraw".to_string(),
|
||||
Command::Execute(cmd) => format!("exec {}", cmd),
|
||||
};
|
||||
// escape the command separator
|
||||
let repr = repr.replace(";", ";;");
|
||||
@@ -471,6 +473,7 @@ pub fn parse(input: &str) -> Option<Vec<Command>> {
|
||||
.map(Command::ShowRecommendations),
|
||||
"noop" => Some(Command::Noop),
|
||||
"redraw" => Some(Command::Redraw),
|
||||
"exec" => Some(Command::Execute(args.join(" "))),
|
||||
_ => None,
|
||||
};
|
||||
commands.push(command?);
|
||||
|
||||
@@ -253,6 +253,13 @@ impl CommandManager {
|
||||
s.quit();
|
||||
Ok(None)
|
||||
}
|
||||
Command::Execute(cmd) => {
|
||||
log::info!("Executing command: {}", cmd);
|
||||
let cmd = std::ffi::CString::new(cmd.clone()).unwrap();
|
||||
let result = unsafe { libc::system(cmd.as_ptr()) };
|
||||
log::info!("Exit code: {}", result);
|
||||
Ok(None)
|
||||
}
|
||||
Command::Jump(_)
|
||||
| Command::Move(_, _)
|
||||
| Command::Shift(_, _)
|
||||
|
||||
Reference in New Issue
Block a user