Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] launch application windows in vtm desktop through command line #544

Closed
Fan-iX opened this issue Jan 16, 2024 · 17 comments
Closed
Assignees
Labels
enhancement New feature or request scripting engine UX User Experience

Comments

@Fan-iX
Copy link

Fan-iX commented Jan 16, 2024

For now, clicking on the taskbar seems to be the only way to launch a new application window on the vtm desktop.

Is it possible to start up new app windows from the command line? For example, run vtm -w vtm -r term vim ~/.bashrc in bash will launch a new window with ~/.bashrc opened in vim.

In this way, I can startup multiple text editors in separate windows from one shell, and edit files without blocking the original shell (just like notepad .\mytext.txt in windows). With the help of some helper scripts, I can also accomplish some useful features, like double-click to open/preview a file in a new window.

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 16, 2024

Thanks for the great idea. I'll add this option.

@o-sdn-o o-sdn-o added enhancement New feature or request UX User Experience scripting engine labels Jan 16, 2024
@o-sdn-o o-sdn-o self-assigned this Jan 17, 2024
@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 17, 2024

I'll try to use Application Scripting Runtime from #393 without external interpreters for now.

vtm monitor (vtm -m) or server in interactive mode (vtm -s) will read their input line by line and execute it.

List of commands

vtm.run("class", "param"={}, "user"={}, coor={}, size={})
vtm.exit()
vtm.shutdown()
vtm.users.disconnect("user")
vtm.users.list()
vtm.apps.list()
vtm.taskbar.menu.item.list()
vtm.taskbar.menu.swap("a_id", "b_id")
vtm.taskbar.menu.add.after("prev id", "xml config")
vtm.taskbar.menu.add.before("next id", "xml config")
vtm.taskbar.menu.remove("id")
vtm.taskbar.menu.run("id", "user"={}, coor={}, size={})
vtm.taskbar.menu.selected.get("user"={})
vtm.taskbar.menu.selected.set("id", "user"={})
vtm.config.get()
...

Usage

Redirected input:

printf "vtm.run(term, \"vim ~/.bashrc\")" | vtm -m
printf "vtm.run(headless, mc)\nvtm.run(headless, top)" | vtm -m

Interactively:

prompt:~# vtm -m
  os: Terminal type: VT
  os: Color mode: VT truecolor
  os: Mouse mode: Win32 Console API
 vtm: v0.9.55
main: Waiting for server...
 tty: Reading thread started 1648
main: No server connected
main: Connected
      10736:  tty: Console title changed to [sdn@megasus:0]

vtm.run(term, "vim ~/.bashrc")
...

o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 17, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 19, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 19, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 20, 2024

It seems to me that there is no need to use the vtm -m monitor cli option in the case of input redirection. This makes usage easier:

echo "vtm.run(dtvt, 'vtm -r')" | vtm
echo "vtm.exit()" | vtm

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 20, 2024

It remains to add synchronization of environment vars and the current directory.

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 20, 2024

The syntax needs to be changed, since too many parameters are expected for vtm functions.

o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 20, 2024
@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 20, 2024

I want to make the new syntax the same as in <menu\item ...> in settings.xml:

vtm.run(label="cmd" type=dtvt title="Command Prompt" footer="test footer" notes=" Windows Command Prompt " cmd="$0 -r term" hidden=no fgc=whitedk bgc=0x00000000 winsize=80,25 wincoor=10,5 winform=undefined)
echo "vtm.run(type=dtvt cmd='vtm -r')" | vtm
echo "vtm.run(type=dtvt cmd='$0 -r')" | vtm
echo "vtm.dtvt($0 -r)" | vtm
echo "vtm.dtvt($0 -r vim ~/.bashrc)" | vtm

o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 21, 2024
@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 21, 2024

I decided not to use $0 in this context:

echo "vtm.dtvt($0 -r)" | vtm

echo "vtm.run(type=dtvt cmd='vtm -r')" | vtm
echo "vtm.dtvt(vtm -r)" | vtm
echo "vtm.dtvt(vtm -r vim ~/.bashrc)" | vtm

o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 21, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 21, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 21, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 22, 2024
@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 22, 2024

I think you can test this feature. 😉

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 22, 2024

I added a new option - the 'cfg=' tag - with it you can set the configuration in xml-format for dtvt-apps:

echo "vtm.run(type=dtvt cmd='vtm -p p' cfg='<config><menu item*><item id=Term type=dtvt fgc=0xFFffff00 bgc=0xFFff0000 cmd=\'vtm -r\'/></menu><client><background tile=\'\' bgc=whitedk fgc=0 /></client></config>')" | vtm

@Fan-iX
Copy link
Author

Fan-iX commented Jan 22, 2024

Can I set id in the vtm.run command to categorize app windows in the task bar? In v0.9.56 All window started from command line are arranged under a new category in the taskbar titled the cmd of the first window launched, and clicking this taskbar item will startup new window using that cmd. I think windows launched without id can be displayed separately in the taskbar.

By the way, vtm.dtvt(bash) (bash can be any other executable file under $PATH) will launch a blank window that could not be closed by the taskbar ×.

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 22, 2024

Can I set id in the vtm.run command to categorize app windows in the task bar?

In the current implementation, the 'id=' tag is completely ignored, it is replaced by the entire command expression, i.e. 'id=vtm.run(...)'. I need to figure out how to integrate it into the existing menu configuration. A possible way is to take an existing menu item by id and launch a derived instance based on it.

By the way, vtm.dtvt(bash) (bash can be any other executable file under $PATH) will launch a blank window that could not be closed by the taskbar ×.

The executable file does not support DirectVT, and then something goes wrong there. I'll fix this bug and make it closeable. Thanks for testing.

o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 23, 2024
@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 23, 2024

Can I set id in the vtm.run command to categorize app windows in the task bar?

I have implemented the following logic to use the 'id' tag.

If a menu item configuration with the specified 'id' already exists and it was created at desktop startup, then the launched window instance will inherit the existing configuration. Otherwise, it will be overwritten before starting a new window instance while preserving the existing windows in the group.

Now you can set id in the vtm.run command to categorize app windows in the task bar.

o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 24, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 24, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 24, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 24, 2024
o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 24, 2024
@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 24, 2024

Adding splitters to the taskbar menu does not work yet.

o-sdn-o added a commit to o-sdn-o/vtm that referenced this issue Jan 24, 2024
@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 24, 2024

Run vtm desktop with custom menu from bash:

vtm -d; printf "vtm.del()\nvtm.set(splitter id=s2 label=Group1)\nvtm.set(id=mc cmd=mc)\nvtm.set(splitter id=s1 label=Group2)\nvtm.set(id=htop cmd=htop)\nvtm.selected(mc)" | vtm; vtm

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 24, 2024

Another syntax (need to implement --script <body> option) to run vtm desktop with custom menu from bash:

vtm --script "vtm.del()\nvtm.set(splitter id=s2 label=Group1)\nvtm.set(id=mc cmd=mc)\nvtm.set(splitter id=s1 label=Group2)\nvtm.set(id=htop cmd=htop)\nvtm.selected(mc)"

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Jan 27, 2024

It is necessary to add the ability to invoke several expressions separated by punctuation (. , ; / spc tab lf etc). One expression per line is not convenient.

vtm.run(); vtm.run()

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Feb 17, 2024

I think that at this stage the added functionality is enough. We will return to this issue later when we fully implement integration with external scripting engines.

@o-sdn-o o-sdn-o closed this as completed Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scripting engine UX User Experience
Projects
None yet
Development

No branches or pull requests

2 participants