add toggle command

parent 45dd72ed
......@@ -20,6 +20,7 @@ ximper-shell-panel list-modules
ximper-shell-panel list-modules -o json
ximper-shell-panel start
ximper-shell-panel stop
ximper-shell-panel toggle
ximper-shell-panel restart
```
......
......@@ -53,6 +53,11 @@ func main() {
Action: stopCommand,
},
{
Name: "toggle",
Usage: "Start the panel if stopped, stop it if running",
Action: toggleCommand,
},
{
Name: "restart",
Usage: "Restart the panel",
Action: restartCommand,
......@@ -130,6 +135,10 @@ func stopCommand(ctx context.Context, cmd *cli.Command) error {
return StopWaybar()
}
func toggleCommand(ctx context.Context, cmd *cli.Command) error {
return ToggleWaybar()
}
func restartCommand(ctx context.Context, cmd *cli.Command) error {
return RestartWaybar()
}
......@@ -50,6 +50,13 @@ func StopWaybar() error {
return stopWaybar()
}
func ToggleWaybar() error {
if PanelIsRunning() {
return StopWaybar()
}
return StartWaybar()
}
func RestartWaybar() error {
if err := StopWaybar(); err != nil {
return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment