Do stuff in already open applications rather than in new instances #4

Open
opened 2024-06-27 18:14:11 -06:00 by sashakoshka · 2 comments
Owner

When an application program is launched, Nasin should be able to figure out if it is already running, and if so, send messages to it. This mainly applies to applications that satisfy ApplicationURLOpener, but it could also apply to applications that you might have multiple windows of in general (like a calculator). For the second case, we likely will need another API, likely a NewWindow behavior of Application.

To accomplish this, Nasin needs to be able to parse command line args. Since a GUI application doesn't really require a super slick and convenient CLI interface, flag will work just fine here.

The only problem is how to allow A) the application to parse cli args and B) allow nasin to parse cli args, while being able to do B without A, and being able to do B while the configuration for A is not yet defined. We cannot solve this by parsing the arguments twice because the parsing depends on the configuration of A.

When an application program is launched, Nasin should be able to figure out if it is already running, and if so, send messages to it. This mainly applies to applications that satisfy ApplicationURLOpener, but it could also apply to applications that you might have multiple windows of in general (like a calculator). For the second case, we likely will need another API, likely a NewWindow behavior of Application. To accomplish this, Nasin needs to be able to parse command line args. Since a GUI application doesn't really require a super slick and convenient CLI interface, flag will work just fine here. The only problem is how to allow A) the application to parse cli args and B) allow nasin to parse cli args, while being able to do B without A, and being able to do B while the configuration for A is not yet defined. We cannot solve this by parsing the arguments twice because the parsing depends on the configuration of A.
Author
Owner

This could be done over dbus, however that is not cross platform. Perhaps pid files could be utilized.

This *could* be done over dbus, however that is not cross platform. Perhaps pid files could be utilized.
Author
Owner

The clear solution here is to create another Application interface with an extra AddFlags method that Nasin can check for:

type ApplicationFlagAdder struct {
        Application
        AddFlags(*flag.FlagSet)
}

AddFlags, if it exists, will be called before Init, and it will add flags to the default flag set that Nasin uses.

The clear solution here is to create another Application interface with an extra AddFlags method that Nasin can check for: ```go type ApplicationFlagAdder struct { Application AddFlags(*flag.FlagSet) } ``` AddFlags, if it exists, will be called before Init, and it will add flags to the default flag set that Nasin uses.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: tomo/nasin#4
No description provided.