add toggle command

parent 45dd72ed
...@@ -20,6 +20,7 @@ ximper-shell-panel list-modules ...@@ -20,6 +20,7 @@ ximper-shell-panel list-modules
ximper-shell-panel list-modules -o json ximper-shell-panel list-modules -o json
ximper-shell-panel start ximper-shell-panel start
ximper-shell-panel stop ximper-shell-panel stop
ximper-shell-panel toggle
ximper-shell-panel restart ximper-shell-panel restart
``` ```
......
...@@ -53,6 +53,11 @@ func main() { ...@@ -53,6 +53,11 @@ func main() {
Action: stopCommand, Action: stopCommand,
}, },
{ {
Name: "toggle",
Usage: "Start the panel if stopped, stop it if running",
Action: toggleCommand,
},
{
Name: "restart", Name: "restart",
Usage: "Restart the panel", Usage: "Restart the panel",
Action: restartCommand, Action: restartCommand,
...@@ -130,6 +135,10 @@ func stopCommand(ctx context.Context, cmd *cli.Command) error { ...@@ -130,6 +135,10 @@ func stopCommand(ctx context.Context, cmd *cli.Command) error {
return StopWaybar() return StopWaybar()
} }
func toggleCommand(ctx context.Context, cmd *cli.Command) error {
return ToggleWaybar()
}
func restartCommand(ctx context.Context, cmd *cli.Command) error { func restartCommand(ctx context.Context, cmd *cli.Command) error {
return RestartWaybar() return RestartWaybar()
} }
...@@ -50,6 +50,13 @@ func StopWaybar() error { ...@@ -50,6 +50,13 @@ func StopWaybar() error {
return stopWaybar() return stopWaybar()
} }
func ToggleWaybar() error {
if PanelIsRunning() {
return StopWaybar()
}
return StartWaybar()
}
func RestartWaybar() error { func RestartWaybar() error {
if err := StopWaybar(); err != nil { if err := StopWaybar(); err != nil {
return err 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