commands: Adding "disconnect" command to force socket shutdown (#1057)
* commands: Adding "disconnect" command to force socket shutdown * Rename to `reconnect` * Add documentation to README Related to: #628 #1033 --------- Co-authored-by: Henrik Friedrichsen <henrik@affekt.org>
This commit is contained in:
@@ -326,6 +326,7 @@ Note: \<FOO\> - mandatory arg; [BAR] - optional arg
|
|||||||
| `exec` \<CMD\> | Execute a command in the system shell.<br/>\* Command output is printed to the terminal, so redirection (`2> /dev/null`) may be necessary. |
|
| `exec` \<CMD\> | Execute a command in the system shell.<br/>\* Command output is printed to the terminal, so redirection (`2> /dev/null`) may be necessary. |
|
||||||
| `noop` | Do nothing. Useful for disabling default keybindings. See [custom keybindings](#custom-keybindings). |
|
| `noop` | Do nothing. Useful for disabling default keybindings. See [custom keybindings](#custom-keybindings). |
|
||||||
| `reload` | Reload the configuration from disk. See [Configuration](#configuration). |
|
| `reload` | Reload the configuration from disk. See [Configuration](#configuration). |
|
||||||
|
| `reconnect` | Reconnect to Spotify (useful when session has expired or connection was lost |
|
||||||
|
|
||||||
## Remote control (IPC)
|
## Remote control (IPC)
|
||||||
|
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ pub enum Command {
|
|||||||
ShowRecommendations(TargetMode),
|
ShowRecommendations(TargetMode),
|
||||||
Redraw,
|
Redraw,
|
||||||
Execute(String),
|
Execute(String),
|
||||||
|
Reconnect,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Command {
|
impl fmt::Display for Command {
|
||||||
@@ -216,6 +217,7 @@ impl fmt::Display for Command {
|
|||||||
| Command::ReloadConfig
|
| Command::ReloadConfig
|
||||||
| Command::Noop
|
| Command::Noop
|
||||||
| Command::Logout
|
| Command::Logout
|
||||||
|
| Command::Reconnect
|
||||||
| Command::Redraw => vec![],
|
| Command::Redraw => vec![],
|
||||||
};
|
};
|
||||||
repr_tokens.append(&mut extras_args);
|
repr_tokens.append(&mut extras_args);
|
||||||
@@ -266,6 +268,7 @@ impl Command {
|
|||||||
Command::ShowRecommendations(_) => "similar",
|
Command::ShowRecommendations(_) => "similar",
|
||||||
Command::Redraw => "redraw",
|
Command::Redraw => "redraw",
|
||||||
Command::Execute(_) => "exec",
|
Command::Execute(_) => "exec",
|
||||||
|
Command::Reconnect => "reconnect",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -721,6 +724,7 @@ pub fn parse(input: &str) -> Result<Vec<Command>, CommandParseError> {
|
|||||||
}
|
}
|
||||||
"redraw" => Command::Redraw,
|
"redraw" => Command::Redraw,
|
||||||
"exec" => Command::Execute(args.join(" ")),
|
"exec" => Command::Execute(args.join(" ")),
|
||||||
|
"reconnect" => Command::Reconnect,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(NoSuchCommand {
|
return Err(NoSuchCommand {
|
||||||
cmd: command.into(),
|
cmd: command.into(),
|
||||||
|
|||||||
@@ -269,6 +269,10 @@ impl CommandManager {
|
|||||||
log::info!("Exit code: {}", result);
|
log::info!("Exit code: {}", result);
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
|
Command::Reconnect => {
|
||||||
|
self.spotify.shutdown();
|
||||||
|
Ok(None)
|
||||||
|
}
|
||||||
|
|
||||||
Command::Queue
|
Command::Queue
|
||||||
| Command::PlayNext
|
| Command::PlayNext
|
||||||
|
|||||||
Reference in New Issue
Block a user