diff --git a/src/alga/cli_app.py b/src/alga/cli_app.py index d931e45..f9cf215 100644 --- a/src/alga/cli_app.py +++ b/src/alga/cli_app.py @@ -12,6 +12,13 @@ app = Typer(no_args_is_help=True, help="Apps installed on the TV") +@app.command() +def close(app_id: Annotated[str, Argument()]) -> None: + """Close the provided app""" + + client.request("ssap://system.launcher/close", {"id": app_id}) + + @app.command() def current() -> None: """Get the current app""" @@ -23,10 +30,14 @@ def current() -> None: @app.command() -def close(app_id: Annotated[str, Argument()]) -> None: - """Close the provided app""" +def info(app_id: str) -> None: + """Show info about specific app""" - client.request("ssap://system.launcher/close", {"id": app_id}) + response = client.request( + "ssap://com.webos.applicationManager/getAppInfo", {"id": app_id} + ) + + print(response["appInfo"]) @app.command() @@ -61,14 +72,3 @@ def list() -> None: console = Console() console.print(table) - - -@app.command() -def info(app_id: str) -> None: - """Show info about specific app""" - - response = client.request( - "ssap://com.webos.applicationManager/getAppInfo", {"id": app_id} - ) - - print(response["appInfo"]) diff --git a/src/alga/cli_channel.py b/src/alga/cli_channel.py index 275c629..a2d45bb 100644 --- a/src/alga/cli_channel.py +++ b/src/alga/cli_channel.py @@ -21,13 +21,6 @@ def current() -> None: ) -@app.command() -def up() -> None: - """Change channel up""" - - client.request("ssap://tv/channelUp") - - @app.command() def down() -> None: """Change channel down""" @@ -35,22 +28,6 @@ def down() -> None: client.request("ssap://tv/channelDown") -@app.command() -def set(value: Annotated[str, Argument()]) -> None: - """Change to specific channel""" - - if value.isnumeric(): - # If a channel number is provided, we look up the channel ID as some models require it. - response = client.request("ssap://tv/getChannelList") - - for channel in response["channelList"]: - if channel["channelNumber"] == value: - value = channel["channelId"] - break - - client.request("ssap://tv/openChannel", {"channelId": value}) - - @app.command() def list() -> None: """List available channels""" @@ -80,3 +57,26 @@ def list() -> None: console = Console() console.print(table) + + +@app.command() +def set(value: Annotated[str, Argument()]) -> None: + """Change to specific channel""" + + if value.isnumeric(): + # If a channel number is provided, we look up the channel ID as some models require it. + response = client.request("ssap://tv/getChannelList") + + for channel in response["channelList"]: + if channel["channelNumber"] == value: + value = channel["channelId"] + break + + client.request("ssap://tv/openChannel", {"channelId": value}) + + +@app.command() +def up() -> None: + """Change channel up""" + + client.request("ssap://tv/channelUp") diff --git a/src/alga/cli_input.py b/src/alga/cli_input.py index 848acf1..66d6b5c 100644 --- a/src/alga/cli_input.py +++ b/src/alga/cli_input.py @@ -10,13 +10,6 @@ app = Typer(no_args_is_help=True, help="HDMI and similar inputs") -@app.command() -def set(value: Annotated[str, Argument()]) -> None: - """Switch to given input""" - - client.request("ssap://tv/switchInput", {"inputId": value}) - - @app.command() def list() -> None: """List available inputs""" @@ -36,3 +29,10 @@ def list() -> None: console = Console() console.print(table) + + +@app.command() +def set(value: Annotated[str, Argument()]) -> None: + """Switch to given input""" + + client.request("ssap://tv/switchInput", {"inputId": value}) diff --git a/src/alga/cli_media.py b/src/alga/cli_media.py index 67d5852..e09379d 100644 --- a/src/alga/cli_media.py +++ b/src/alga/cli_media.py @@ -7,10 +7,10 @@ @app.command() -def play() -> None: - """Play media""" +def fast_forward() -> None: + """Fast forward media""" - client.request("ssap://media.controls/play") + client.request("ssap://media.controls/fastForward") @app.command() @@ -21,21 +21,21 @@ def pause() -> None: @app.command() -def stop() -> None: - """Stop media""" +def play() -> None: + """Play media""" - client.request("ssap://media.controls/stop") + client.request("ssap://media.controls/play") @app.command() -def fast_forward() -> None: - """Fast forward media""" +def rewind() -> None: + """Rewind media""" - client.request("ssap://media.controls/fastForward") + client.request("ssap://media.controls/rewind") @app.command() -def rewind() -> None: - """Rewind media""" +def stop() -> None: + """Stop media""" - client.request("ssap://media.controls/rewind") + client.request("ssap://media.controls/stop") diff --git a/src/alga/cli_volume.py b/src/alga/cli_volume.py index f34df03..d397775 100644 --- a/src/alga/cli_volume.py +++ b/src/alga/cli_volume.py @@ -9,13 +9,6 @@ app = Typer(no_args_is_help=True, help="Audio volume") -@app.command() -def up() -> None: - """Turn volume up""" - - client.request("ssap://audio/volumeUp") - - @app.command() def down() -> None: """Turn volume down""" @@ -23,13 +16,6 @@ def down() -> None: client.request("ssap://audio/volumeDown") -@app.command() -def set(value: Annotated[int, Argument()]) -> None: - """Set volume to specific amount""" - - client.request("ssap://audio/setVolume", {"volume": value}) - - @app.command() def get() -> None: """Get current volume""" @@ -47,8 +33,22 @@ def mute() -> None: client.request("ssap://audio/setMute", {"mute": True}) +@app.command() +def set(value: Annotated[int, Argument()]) -> None: + """Set volume to specific amount""" + + client.request("ssap://audio/setVolume", {"volume": value}) + + @app.command() def unmute() -> None: """Unmute audio""" client.request("ssap://audio/setMute", {"mute": False}) + + +@app.command() +def up() -> None: + """Turn volume up""" + + client.request("ssap://audio/volumeUp") diff --git a/usage.md b/usage.md index c10a496..237ad6f 100644 --- a/usage.md +++ b/usage.md @@ -15,15 +15,15 @@ $ alga [OPTIONS] COMMAND [ARGS]... **Commands**: * `adhoc`: Send raw request to the TV +* `setup`: Pair a new TV +* `version`: Print Alga version * `app`: Apps installed on the TV * `channel`: TV channels * `input`: HDMI and similar inputs * `media`: Control the playing media * `power`: Turn TV (or screen) on and off * `remote`: Remote control button presses -* `setup`: Pair a new TV * `sound-output`: Audio output device -* `version`: Print Alga version * `volume`: Audio volume ## `alga adhoc` @@ -45,6 +45,38 @@ $ alga adhoc [OPTIONS] PATH [DATA] * `--help`: Show this message and exit. +## `alga setup` + +Pair a new TV + +**Usage**: + +```console +$ alga setup [OPTIONS] [HOSTNAME] +``` + +**Arguments**: + +* `[HOSTNAME]`: [default: lgwebostv] + +**Options**: + +* `--help`: Show this message and exit. + +## `alga version` + +Print Alga version + +**Usage**: + +```console +$ alga version [OPTIONS] +``` + +**Options**: + +* `--help`: Show this message and exit. + ## `alga app` Apps installed on the TV @@ -502,24 +534,6 @@ $ alga remote send [OPTIONS] BUTTON * `--help`: Show this message and exit. -## `alga setup` - -Pair a new TV - -**Usage**: - -```console -$ alga setup [OPTIONS] [HOSTNAME] -``` - -**Arguments**: - -* `[HOSTNAME]`: [default: lgwebostv] - -**Options**: - -* `--help`: Show this message and exit. - ## `alga sound-output` Audio output device @@ -571,20 +585,6 @@ $ alga sound-output set [OPTIONS] VALUE * `--help`: Show this message and exit. -## `alga version` - -Print Alga version - -**Usage**: - -```console -$ alga version [OPTIONS] -``` - -**Options**: - -* `--help`: Show this message and exit. - ## `alga volume` Audio volume