GithubHelp home page GithubHelp logo

vtm panel about vtm HOT 37 CLOSED

Vosjedev avatar Vosjedev commented on July 29, 2024
vtm panel

from vtm.

Comments (37)

Vosjedev avatar Vosjedev commented on July 29, 2024 1

I don't have anything to add, I agree with your edits. Thanks for merging!

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024 1

Then I'l go and add color support later. I am currently working on other stuff.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

Currently this has the issue that when using it, the panel resets the escape code, which leads to vtm sometimes drawing the panel background color instead of the default color, and the terminal is really gliched. I made a video of it:

2023-06-12.09-52-48.mp4

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

here is the code (also in the github repo)

#!/bin/python3
from time import sleep
import datetime,os,pwd,socket,colorama,subprocess,psutil

colorama.init()

vtmversion=subprocess.check_output(['vtm', '--version']).decode()[0:-1]
while True:
    cols,lines=os.get_terminal_size()

    bat=psutil.sensors_battery()
    batinfo=f"{str(bat.percent).split('.')[0]}%"
    if bat.power_plugged:
        batinfo=f"Charging, {batinfo}"
    else:
        batinfo=f"battery:  {batinfo}"

    now=datetime.datetime.now()
    date=f"{now.day}-{now.month}-{now.year} {now.hour}:{now.minute}:{now.second}"
    date=str(now).split('.')[0]

    left=f"{date} | {pwd.getpwuid(os.getuid()).pw_name}@{socket.gethostname()} | {lines}x{cols}"
    right=f"{batinfo} | {vtmversion}"
    seperator=" "*int(cols-len(left)-len(right))
    print(f"\033[0;37;40m\033[0;0H"+left+seperator+right,end='',flush=True)
    sleep(0.5)

the colorama is for translating the escape codes.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I made it check the vtm version, because originaly it was at the bottom, covering the vtm version at the bottom right.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

Very good. Let's try to integrate your panel as much as possible into vtm.

In my setup, I can't repro the issue with bg color glitches. Could you please share your ~/.bashrc section containing the PS1 color prompt definition. I have a suspicion that this behavior is related to this.

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I am not using bash, I am using a shell called xonsh because of the python/shell combi. I dont know how the coloring works, because you can insert {color} in the $PROMPT variable and it makes the color for you. It uses prompt_toolkit.

But I think this issue is there when I am using bash as well... Will verify in a second

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I can verify bash also has the issue.
Oh, and the only modification made to my .bashrc was an alias from cl to clear, and a change to PATH.

The colorprompt section is identical to your example.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

Sorry for the slow replies, I've been diving into extending the win32-input-mode protocol and this will take some time.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

No problem, I will try some things. Maybe I'l try to look into including it in vtm natively (that would require me learning whatever C variant you are using, but that would be fun to try).

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I am planning to add an extra section to the user's viewport to bind an external panel like yours there. This is a one cell high (adjustable value) and full screen width section located at the very top of the vtm viewport.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

Would panels give the info to vtm, and vtm draws it? Or do they have to draw by thereselfs on a space held emty by vtm?

I would suggest the first, as it stops this type of issues.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

vtm will output whatever your panel prints to the console.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

What's the progress here? Where are you currently working on?

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I dived into implementing full keyboard support. It is necessary to uniquely identify the pressed buttons in order to use them inside the vtm. This must be implemented for correct remote work on heterogeneous systems. For example, in a Windows-Linux remote connection scenario, keyboard input occurs with errors.

Without keyboard input working correctly, it's not worth talking about remote use via directvt.

I also found that vtm is used on Android. Keyboard control is very lacking there, because instead of a mouse there is only a touch interface.

It also requires prebuild binaries for ARM architecture, including 32-bit ones, and since vtm cannot be built on a 32-bit host, the compiler needs more than 4 gigs of RAM. I have to build such assemblies too. There were a number of issues when compiling to 32-bit architecture.

I'll be able to work on the vtm panel after I finish keyboard support, it will take some time.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

Along the way, I make keyboard events available from outside using the vt-input-mode (former win32-input-mode) #400 protocol.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I also found that vtm is used on Android.

Yes, it is available in the termux repos. I installed it. Single clickes work, but dragging only moves the mouse, without sending a click. I cant verify it is not getting a click, because I cant open debug mode, my tablet is to old to support the ๐Ÿž.

It also requires prebuild binaries for ARM architecture, including 32-bit ones, and since vtm cannot be built on a 32-bit host, the compiler needs more than 4 gigs of RAM. I have to build such assemblies too. There were a number of issues when compiling to 32-bit architecture.

Vtm is compiled for android in the termux repo. I guess compiling works for android... but on both my android devices uname -m returns aarch64, so I guess they both are 64bit arm. Also, I once was able to run vtm on my armv7l (that is 32bit arm) raspberrypi. I just deleted it to update it, then found out I could not recompile because of outdated gcc.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I'm currently doing builds for ARM 32-bit and ARM 64-bit. For Windows, this turned out to be easy, now I'm doing it for Linux.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

Vtm is compiled for android in the termux repo.

All static-linked vtm builds for Linux will work on Android, as it is based on the Linux kernel.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

yes I know, but what I mean, could you use the termux binary on arm linux?

It is possible responses are slow next week, I am on holydays to Spain.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I haven't tested this (run Android/termux binaries on Linux), I don't have ARM devices within reach yet, and I'll test it on QEMU a bit later.

Have a nice vacation!

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I don't have ARM devices within reach yet

I am thinking about buying a pinetab 2, but I don't know if I can get it in europe yet. Pine64's site is not very clear on that...

Have a nice vacation!

Thank you!

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I am going to revisit my panel, but first I have to chatch up on release notes: still on v0.9.9q!

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

So how would I hook my panel into VTM? Are there any docs yet? Otherwise I could write a small one while trying it out.

Edit: Already trying to figure it out based on the commits.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I figured it out! Now I am going to put more stuff in the panel, then I will write a quick doc, you can then decide if you want to include it somewhere.

Also, I would suggest not having any scrollback on the panel : ) . It currently has one, and this means that the panel will just fill the scrollback, or I would have to use a \r at the end, which instantly makes the panel incompatible with
macos (and I guess other os's using \r as newline).

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

To hide any scrollbars, the application running in the panel simply needs to switch to the alternate buffer using the following vt-sequence:

# Altbuf
printf "\e[?1049h"

# Normal scrollback
printf "\e[?1049l"

Thank you very much for doing this! ๐Ÿ‘

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I guess I wrote a very detailed doc including code snippets instead. It uses examples in python3, but there's a bash adaptation at the bottom for the people that don't understand python (assuming everyone understands either python or bash :D ).
panelDocs.md

The doc

The panel

In release v0.9.9v a slot for panels was introduced.

settings

The following lines where added to the example settings.xml:

    <panel> <!-- Desktop info panel. -->
        <cmd = ""/> <!-- Command-line to activate. -->
        <cwd = ""/> <!-- Working directory. -->
        <height = 1 /> <!-- Desktop space reserved on top. -->
    </panel>

Here you can set what command provides the lines to display in the panel.

making a script for the panel

For this script I will be using python3, but I guess you can adapt this to your favorite language. A bash version will be below, to help if you don't understand python.

First set the path to your script in settings.xml bt changing the config/panel/cmd tag to contain the path.
Then make your script at that location, and we can start.

First, the concept.
The panel works by running your command in a small terminal at the top. This means you will have a scrollbar. To prevent that, (and thus to save a little amount of memory,) print the following escape code to the screen: \e[[?1049h.

This means our script now looks like this:

#!/usr/bin/env python3
# my custom panel

print("\033[?1049h") # remove scrollback

If you print data, that data will push the previous data off-screen. The script has to run in a loop to make sure the data gets updated. So, add a loop which collects data and prints that.

#!/usr/bin/env python3
# my custom panel
from time import sleep # import sleep() function

print("\033[?1049h") # remove scrollback
while True: # loop infinitly
    data='My data' # collect data
    print(data) # print data
    sleep(1) # wait 1 second before looping back to the start

This will print My data to the panel every 1 second.

I guess we now want to print some actual data. Lets print the time.
In python, we get that from datetime.datetime.now(). datetime.datetime.now() returns the time in this format: YYYY-MM-DD HH:MM:SS.SSSSSS. We don't want the date or nanoseconds, so lets split those off: datetime.datetime.now().split(' ')[1].split('.')[0] returns HH:MM:SS. perfect.
Now lets put that in the script:

#!/usr/bin/env python3
# my custom panel
from time import sleep # import sleep() function
import datetime

print("\033[?1049h") # remove scrollback
while True: # loop infinitly
    time=datetime.datetime.now().split(' ')[1].split('.')[0] # get current time
    print(time) # print data: the time
    sleep(1) # wait 1 second before looping back to the start

This will print the current time to the panel, and you can see it update every second.

You probably want to add more data, and that is possible. Just collect more data, and add the variables to the print() function.
Here I added a date and the text Hello world!, and I seperated them all by |:

#!/usr/bin/env python3
# my custom panel
from time import sleep # import sleep() function
import datetime

print("\033[?1049h") # remove scrollback
while True: # loop infinitly
    time=datetime.datetime.now().split(' ')[1].split('.')[0] # get current time
    date=datetime.datetime.now().split(' ')[0]
    print(time,'|',date,'|','Hello world!') # print data: time | date | Hello world!
    sleep(1) # wait 1 second before looping back to the start

A full script to base your own panel on can be found here.

A bash adaptation of the script we just created in python (so people that don't 'speak' python know what's going on):

#!/usr/bin/env bash
# my custom panel

echo -e "\e[?1049h" # remove scrollback

while true; do
    time="$(date +%X)" # get time (in local format)
    date="$(date +%x)" # get date (in local format)
    echo "$time | $date | Hello world!" # print data: time | date | Hello world!
    sleep 1
done

Written by vosjedev


If you would like anything changed, that's no problem. Just change it or ask me to change it.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

If you donโ€™t mind, Iโ€™ll open a pull request (or you can open it yourself) and weโ€™ll make edits there.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I edited the panel.md text a little and added a link to it from readme.md.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I will merge your draft to the main and wait for your addition edits if you wish (your pull request).

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I agree with closing. Note I linked this issue from the repo as status tracker for the panel I am maintaining. If you want I can move that over to there.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I can't translate the last sentence ๐Ÿ˜…. Perhaps we need to cross-link this, add links to doc/panel.md and the like.

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

Ah, sorry, I meant:

I am currently asking people to go to this issue for announcements etc for my script.
If you want, I can make an issue in my own repo for announcements etc.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I have added a cross-reference to your vtm panel repository in the doc/panel.md subsection App-based Dashboard.

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

I've corrected the text a little. This text was slightly mismatched. I didn't notice that the link was already there in the text ๐Ÿ˜….

from vtm.

Vosjedev avatar Vosjedev commented on July 29, 2024

I guess I will have to redo some things on my panel anyways to make it a bit more userfriendly (add stuff like colors and a config).
Does the vtm terminal translate color escape sequences (\e[48;2;0;0;0m-like) to windows api calls on windows automatically?

from vtm.

o-sdn-o avatar o-sdn-o commented on July 29, 2024

Does the vtm terminal translate color escape sequences (\e[48;2;0;0;0m-like) to windows api calls on windows automatically?

Yes, it is supported by vtm. vtm renders everything (vt sequences, etc) onto its internal canvas, and then prints the final canvas using the Windows Console API (or some better way for the console it's running on).

from vtm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.