[feature request] launch application windows in vtm desktop through command line
Fan-iX opened this issue ยท 17 comments
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.
Thanks for the great idea. I'll add this option.
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")
...
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
It remains to add synchronization of environment vars and the current directory.
The syntax needs to be changed, since too many parameters are expected for vtm functions.
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
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
I think you can test this feature. ๐
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
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 ร
.
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.
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.
Adding splitters to the taskbar menu does not work yet.
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
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)"
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()
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.